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

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: #
        !            27: # $MCom: portstools/tinderbox/webui/module/moduleBuilds.php,v 1.6 2005/12/26 22:33:53 marcus Exp $
        !            28: #
        !            29: 
        !            30: require_once 'module/module.php';
        !            31: 
        !            32: class moduleBuilds extends module {
        !            33: 
        !            34:        function moduleBuilds() {
        !            35:                $this->module();
        !            36:        }
        !            37: 
        !            38:        function display_list_builds() {
        !            39:                global $pkgdir;
        !            40:                global $pkguri;
        !            41: 
        !            42:                $builds = $this->TinderboxDS->getAllBuilds();
        !            43: 
        !            44:                if( is_array( $builds ) && count( $builds ) > 0 ) {
        !            45:                        $data = $this->get_list_data( $builds );
        !            46:                        foreach( $data as $res )
        !            47:                                $sort[] = $res['name'];
        !            48:                        array_multisort( $sort, SORT_ASC, $data );
        !            49:                        $this->template_assign( 'data', $data );
        !            50:                        $this->template_assign( 'no_list', false );
        !            51:                } else {
        !            52:                        $this->template_assign( 'no_list', true );
        !            53:                }
        !            54: 
        !            55:                $this->template_assign( 'maintainers', $this->TinderboxDS->getAllMaintainers() );
        !            56:                return $this->template_parse( 'list_builds.tpl' );
        !            57:        }
        !            58: 
        !            59:        function get_list_data( $builds ) {
        !            60:                global $pkgdir;
        !            61:                global $pkguri;
        !            62: 
        !            63:                $i = 0;
        !            64:                foreach( $builds as $build ) {
        !            65:                        $status      = $build->getBuildStatus();
        !            66:                        $description = $build->getDescription();
        !            67:                        $name        = $build->getName();
        !            68: 
        !            69:                        $stats       = $this->TinderboxDS->getBuildStatsWithStatus( $build->getId() );
        !            70: 
        !            71:                        $results = array(
        !            72:                                "UNKNOWN"    => 0,
        !            73:                                "FAIL"       => 0,
        !            74:                                "LEFTOVERS"  => 0,
        !            75:                                "SUCCESS"    => 0,
        !            76:                        );
        !            77:                        foreach ($stats as $stat) {
        !            78:                                $results[$stat['last_status']] = $stat['c'];
        !            79:                        }
        !            80:                        foreach ($results as $k => $v) {
        !            81:                                if ($v == 0) $results[$k] = "-";
        !            82:                        }
        !            83: 
        !            84:                        switch( $status ) {
        !            85:                                case 'PORTBUILD':
        !            86:                                        $status_field_class = 'build_portbuild';
        !            87:                                        break;
        !            88:                                case 'PREPARE':
        !            89:                                        $status_field_class = 'build_prepare';
        !            90:                                        break;
        !            91:                                default:
        !            92:                                        $status_field_class = 'build_default';
        !            93:                                        break;
        !            94:                        }
        !            95: 
        !            96:                        $data[$i]['status_field_class'] = $status_field_class;
        !            97:                        $data[$i]['name'] = $name;
        !            98:                        $data[$i]['description'] = $description;
        !            99:                        if( is_dir( $pkgdir.'/'.$name ) ) {
        !           100:                                $data[$i]['packagedir'] = $pkguri.'/'.$name.'/';
        !           101:                        } else {
        !           102:                                $data[$i]['packagedir'] = false;
        !           103:                        }
        !           104:                        $data[$i]['results'] = $results;
        !           105:                        $i++;
        !           106:                }
        !           107: 
        !           108:                return $data;
        !           109: 
        !           110:        }
        !           111: 
        !           112:        function get_all_builds() {
        !           113:                $all_builds_raw = $this->TinderboxDS->getAllBuilds();
        !           114:                $all_builds = array();
        !           115:                foreach( $all_builds_raw as $build ) {
        !           116:                        $all_builds[] = array( 'build_id' => $build->getId(), 'build_name' => $build->getName() );
        !           117:                }
        !           118:                return $all_builds;
        !           119:        }
        !           120: }
        !           121: ?>