Annotation of FreeBSD/tinderbox/webui/module/modulePorts.php, revision 1.1.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/modulePorts.php,v 1.11 2007/06/09 22:09:12 marcus Exp $
28: #
29:
30: require_once 'module/module.php';
31:
32: class modulePorts extends module {
33:
34: function modulePorts() {
35: $this->module();
36: }
37:
38: function display_describe_port( $port_id ) {
39:
40: $ports = $this->TinderboxDS->getAllPortsByPortID( $port_id );
41:
42: if( is_array( $ports ) && count( $ports ) > 0 ) {
43: $this->template_assign( 'data', $this->get_list_data( '', $ports ) );
44: $this->template_assign( 'no_list', false );
45: } else {
46: $this->template_assign( 'no_list', true );
47: }
48:
49: foreach( $ports as $port ) {
50: $build = $this->TinderboxDS->getBuildById( $port->getBuildId() );
51: $ports_tree = $this->TinderboxDS->getPortsTreeForBuild( $build );
52: if( empty( $ports_tree_ids[$ports_tree->getId()] ) ) {
53: $ports_tree_ids[$ports_tree->getId()] = 1;
54:
55: list( $cvsweb, $cvsweb_querystr ) = explode( '?', $ports_tree->getCVSwebURL(), 2 );
56:
57: if ( $cvsweb_querystr ) {
58: $cvsweb = rtrim( $cvsweb, '/' );
59: $cvsweb_querystr = '?' . $cvsweb_querystr;
60: }
61:
62: $ports_trees_links[] = array( 'name' => $ports_tree->getName(), 'cvsweb' => $cvsweb, 'cvsweb_querystr' => $cvsweb_querystr );
63: }
64: }
65:
66: $this->template_assign( 'port_comment', $ports[0]->getComment() );
67: $this->template_assign( 'port_dir', $ports[0]->getDirectory() );
68: $this->template_assign( 'port_maintainer', $ports[0]->getMaintainer() );
69: $this->template_assign( 'port_name', $ports[0]->getName() );
70: $this->template_assign( 'ports_trees_links', $ports_trees_links );
71: $this->template_assign( 'local_time', prettyDatetime( date( 'Y-m-d H:i:s' ) ) );
72:
73: return $this->template_parse( 'describe_port.tpl' );
74: }
75:
76: function get_list_data( $build_name, $ports ) {
77: global $loguri;
78: global $errorloguri;
79: global $pkguri;
80:
81: if( empty( $build_name ) ) {
82: $different_builds = true;
83: } else {
84: $different_builds = false;
85: $build = $this->TinderboxDS->getBuildByName( $build_name );
86: $package_suffix = $this->TinderboxDS->getPackageSuffix( $build->getJailId() );
87: }
88:
89:
90: foreach( $ports as $port ) {
91: if( $different_builds == true ) {
92: $build = $this->TinderboxDS->getBuildById( $port->getBuildId() );
93: $package_suffix = $this->TinderboxDS->getPackageSuffix( $build->getJailId() );
94: $build_name = $build->getName();
95: }
96:
97: $port_id = $port->getId();
98: $port_last_built_version = $port->getLastBuiltVersion();
99: $port_logfilename = $port->getLogfileName();
100: $port_link_logfile = $loguri . '/' . $build_name . '/' . $port_logfilename;
101: $port_link_package = $pkguri . '/' . $build_name . '/All/' . $port_last_built_version . $package_suffix;
102: $port_last_run_duration = $port->getLastRunDuration();
103: $port_last_fail_reason = $port->getLastFailReason();
104:
105: switch( $port->getLastStatus() ) {
106: case 'SUCCESS':
107: $status_field_class = 'port_success';
108: $status_field_letter = ' ';
109: break;
110: case 'LEFTOVERS':
111: $status_field_class = 'port_leftovers';
112: $status_field_letter = 'L';
113: break;
114: case 'BROKEN':
115: $status_field_class = 'port_broken';
116: $status_field_letter = 'B';
117: $port_link_package = '';
118: break;
119: case 'FAIL':
120: $status_field_class = 'port_fail';
121: $status_field_letter = ' ';
122: $port_link_logfile = $errorloguri . '/' . $build_name . '/' . $port_logfilename;
123: $port_link_package = '';
124: break;
125: case 'DEPEND':
126: $status_field_class = 'port_depend';
127: $status_field_letter = ' ';
128: $port_link_logfile = '';
129: $port_link_package = '';
130: $port_last_fail_reason = $port->getLastFailedDep();
131: break;
132: case 'DUD':
133: $status_field_class = 'port_dud';
134: $status_field_letter = 'D';
135: $port_link_logfile = '';
136: $port_link_package = '';
137: break;
138: default:
139: $status_field_class = 'port_default';
140: $status_field_letter = ' ';
141: $port_link_logfile = '';
142: $port_link_package = '';
143: break;
144: }
145:
146: $data[] = array( 'build_name' => $build_name,
147: 'port_directory' => $port->getDirectory(),
148: 'port_maintainer' => prettyEmail( $port->getMaintainer() ).' ',
149: 'port_id' => $port_id,
150: 'port_last_built_version' => $port_last_built_version,
151: 'port_last_built' => prettyDatetime( $port->getLastBuilt() ),
152: 'port_last_successful_built' => prettyDatetime( $port->getLastSuccessfulBuilt() ),
153: 'port_last_fail_reason' => htmlentities( $port_last_fail_reason ),
154: 'port_last_run_duration' => $port_last_run_duration,
155: 'port_link_logfile' => $port_link_logfile,
156: 'port_link_package' => $port_link_package,
157: 'status_field_class' => $status_field_class,
158: 'status_field_letter' => $status_field_letter );
159: }
160: return $data;
161: }
162: }
163: ?>