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