Annotation of FreeBSD/tinderbox/webui/module/moduleBuilds.php, revision 1.1.1.1.2.3
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.3! as 27: # $Paefchen: FreeBSD/tinderbox/webui/module/moduleBuilds.php,v 1.1.1.1.2.2 2007/11/15 15:31:35 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: if( is_dir( PKGDIR.'/'.$name ) ) {
90: $data[$i]['packagedir'] = PKGURL.'/'.$name.'/';
1.1 as 91: } else {
92: $data[$i]['packagedir'] = false;
93: }
94: $data[$i]['results'] = $results;
95: $i++;
96: }
97: return $data;
98:
99: }
100:
1.1.1.1.2.1 as 101: public function get_all_builds() {
1.1 as 102: $all_builds_raw = $this->TinderboxDS->getAllBuilds();
103: $all_builds = array();
104: foreach( $all_builds_raw as $build ) {
105: $all_builds[] = array( 'build_id' => $build->getId(), 'build_name' => $build->getName() );
106: }
107: return $all_builds;
108: }
109: }
1.1.1.1.2.1 as 110:
1.1 as 111: ?>