Annotation of FreeBSD/tinderbox/webui/module/moduleBuilds.php, revision 1.1.1.1.2.2

1.1       as          1: <?php
                      2: #-
                      3: # Copyright (c) 2005 Oliver Lehmann <oliver@FreeBSD.org>
                      4: # All rights reserved.
                      5: #
                      6: # Redistribution and use in source and binary forms, with or without
                      7: # modification, are permitted provided that the following conditions
                      8: # are met:
                      9: # 1. Redistributions of source code must retain the above copyright
                     10: #    notice, this list of conditions and the following disclaimer
                     11: # 2. Redistributions in binary form must reproduce the above copyright
                     12: #    notice, this list of conditions and the following disclaimer in the
                     13: #    documentation and/or other materials provided with the distribution.
                     14: #
                     15: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     16: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     17: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     18: # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     19: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     21: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25: # SUCH DAMAGE.
                     26: #
1.1.1.1.2.2! as         27: # $Paefchen: FreeBSD/tinderbox/webui/module/moduleBuilds.php,v 1.1.1.1.2.1 2007/11/13 07:36:19 as Exp $
1.1       as         28: # $MCom: portstools/tinderbox/webui/module/moduleBuilds.php,v 1.6 2005/12/26 22:33:53 marcus Exp $
                     29: #
                     30: 
                     31: class moduleBuilds extends module {
                     32: 
1.1.1.1.2.1  as         33:        public function display_list_builds() {
1.1       as         34:                $builds = $this->TinderboxDS->getAllBuilds();
                     35: 
1.1.1.1.2.2! as         36:                if (is_array($builds) && count($builds) > 0) {
        !            37:                        $data = $this->get_list_data($builds);
        !            38:                        foreach ($data as $res)
1.1       as         39:                                $sort[] = $res['name'];
1.1.1.1.2.2! as         40:                        array_multisort($sort, SORT_ASC, $data);
        !            41:                        $this->template_assign('data', $data);
        !            42:                        $this->template_assign('no_list', false);
        !            43:                }
        !            44:                else {
        !            45:                        $this->template_assign('no_list', true);
1.1       as         46:                }
                     47: 
                     48:                $this->template_assign( 'maintainers', $this->TinderboxDS->getAllMaintainers() );
                     49:                return $this->template_parse( 'list_builds.tpl' );
                     50:        }
                     51: 
                     52:        function get_list_data( $builds ) {
                     53:                $i = 0;
                     54:                foreach( $builds as $build ) {
                     55:                        $status      = $build->getBuildStatus();
                     56:                        $description = $build->getDescription();
                     57:                        $name        = $build->getName();
                     58: 
                     59:                        $stats       = $this->TinderboxDS->getBuildStatsWithStatus( $build->getId() );
                     60: 
                     61:                        $results = array(
                     62:                                "UNKNOWN"    => 0,
                     63:                                "FAIL"       => 0,
                     64:                                "LEFTOVERS"  => 0,
                     65:                                "SUCCESS"    => 0,
                     66:                        );
                     67:                        foreach ($stats as $stat) {
                     68:                                $results[$stat['last_status']] = $stat['c'];
                     69:                        }
                     70:                        foreach ($results as $k => $v) {
                     71:                                if ($v == 0) $results[$k] = "-";
                     72:                        }
                     73: 
                     74:                        switch( $status ) {
                     75:                                case 'PORTBUILD':
                     76:                                        $status_field_class = 'build_portbuild';
                     77:                                        break;
                     78:                                case 'PREPARE':
                     79:                                        $status_field_class = 'build_prepare';
                     80:                                        break;
                     81:                                default:
                     82:                                        $status_field_class = 'build_default';
                     83:                                        break;
                     84:                        }
                     85: 
                     86:                        $data[$i]['status_field_class'] = $status_field_class;
                     87:                        $data[$i]['name'] = $name;
                     88:                        $data[$i]['description'] = $description;
1.1.1.1.2.2! as         89:                        printf (PKGDIR);
        !            90:                        if( is_dir( PKGDIR.'/'.$name ) ) {
        !            91:                                $data[$i]['packagedir'] = PKGURL.'/'.$name.'/';
1.1       as         92:                        } else {
                     93:                                $data[$i]['packagedir'] = false;
                     94:                        }
                     95:                        $data[$i]['results'] = $results;
                     96:                        $i++;
                     97:                }
                     98:                return $data;
                     99: 
                    100:        }
                    101: 
1.1.1.1.2.1  as        102:        public function get_all_builds() {
1.1       as        103:                $all_builds_raw = $this->TinderboxDS->getAllBuilds();
                    104:                $all_builds = array();
                    105:                foreach( $all_builds_raw as $build ) {
                    106:                        $all_builds[] = array( 'build_id' => $build->getId(), 'build_name' => $build->getName() );
                    107:                }
                    108:                return $all_builds;
                    109:        }
                    110: }
1.1.1.1.2.1  as        111: 
1.1       as        112: ?>