4 * SourceForge Generic Tracker facility
6 * SourceForge: Breaking Down the Barriers to Open Source Development
7 * Copyright 1999-2001 (c) VA Linux Systems
8 * http://sourceforge.net
15 require_once $gfcommon.'tracker/ArtifactType.class.php';
16 require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
17 require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
19 class ArtifactTypeHtml extends ArtifactType {
22 * ArtifactType() - constructor
24 * @param $Group object
25 * @param $artifact_type_id - the id # assigned to this artifact type in the db
27 function ArtifactTypeHtml(&$Group,$artifact_type_id=false, $arr=false) {
28 return $this->ArtifactType($Group,$artifact_type_id,$arr);
31 function header($params) {
32 global $HTML, $sys_use_tracker;
33 if (!$sys_use_tracker) {
36 $group_id= $this->Group->getID();
38 //required by new site_project_header
39 $params['group']=$group_id;
40 $params['toptab']='tracker';
41 $params['tabtext']=$this->getName();
43 site_project_header($params);
48 $labels[] = $this->getName().': '._('Browse');
49 $links[] = '/tracker/?func=browse&group_id='.$group_id.'&atid='. $this->getID();
50 $labels[] = _('Download .csv');
51 $links[] = '/tracker/?func=downloadcsv&group_id='.$group_id.'&atid='. $this->getID();
52 if ($this->allowsAnon() || session_loggedin()) {
53 $labels[] = _('Submit New');
54 $links[] = '/tracker/?func=add&group_id='.$group_id.'&atid='. $this->getID();
57 if (session_loggedin()) {
58 $labels[] = _('Reporting');
59 $links[] = '/tracker/reporting/?group_id='.$group_id.'&atid='. $this->getID();
60 if ($this->isMonitoring()) {
61 $labels[] = _('Stop Monitor');
63 $labels[] = _('Monitor');
65 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor';
67 if ($this->userIsAdmin()) {
68 $labels[] = _('Admin');
69 $links[] = '/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID();
73 echo $HTML->subMenu($labels,$links);
76 function footer($params) {
77 site_project_footer($params);
80 function adminHeader($params) {
82 echo $this->header($params);
83 $group_id= $this->Group->getID();
85 $links_arr[]='/tracker/admin/?group_id='.$group_id;
86 $title_arr[]=_('New Tracker');
88 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&update_type=1';
89 $title_arr[]=_('Update Settings');
91 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_extrafield=1';
92 $title_arr[]=_('Manage Custom Fields');
94 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&clone_tracker=1';
95 $title_arr[]=_('Clone Tracker');
97 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_canned=1';
98 $title_arr[]=_('Add Canned Responses');
100 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&delete=1';
101 $title_arr[]=_('Delete');
103 echo $HTML->printSubMenu($title_arr,$links_arr);
106 function adminFooter($params) {
107 echo $this->footer($params);
110 function renderExtraFields($selected=array(),$show_100=false,$text_100='none',$show_any=false,$text_any='Any',$filter='',$status_show_100=false,$mode='') {
111 $efarr = $this->getExtraFields($filter);
112 //each two columns, we'll reset this and start a new row
113 //TODO - add code for "display only" such as mod-limited and detail.php pages
114 $template = $this->getRenderHTML($filter);
115 if ($mode=='QUERY') {
116 $keys=array_keys($efarr);
117 for ($k=0; $k<count($keys); $k++) {
119 $efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_MULTISELECT;
122 $keys=array_keys($efarr);
123 for ($k=0; $k<count($keys); $k++) {
126 if (!isset($selected[$efarr[$i]['extra_field_id']]))
127 $selected[$efarr[$i]['extra_field_id']] = '';
129 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
130 $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100,$show_any,$text_any);
132 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
134 $str = $this->renderCheckbox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100);
136 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
138 $str = $this->renderRadio($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100,$show_any,$text_any);
140 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT) {
142 $str = $this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
144 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
146 $str = $this->renderTextArea($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
148 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
150 $str = $this->renderMultiSelectBox ($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100);
152 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
154 $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$status_show_100,$text_100,$show_any,$text_any);
157 $template = str_replace('<!--'.$efarr[$i]['field_name'].'-->',$str,$template);
159 if($template != NULL){
167 * @return string HTML template.
169 function getRenderHTML($filter='') {
170 return (($this->data_array['custom_renderer']) ? $this->data_array['custom_renderer'] : $this->generateRenderHTML($filter) );
176 * @return string HTML template.
178 function generateRenderHTML($filter='') {
179 $efarr =& $this->getExtraFields($filter);
180 //each two columns, we'll reset this and start a new row
183 <!-- Start Extra Fields Rendering -->
184 <!-- COLUMN NAMES MUST BE PRESERVED EXACTLY, INCLUDING CASE! -->
188 $keys=array_keys($efarr);
190 for ($k=0; $k<$count; $k++) {
193 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
196 <td width="50%" valign="top"><strong>'.$efarr[$i]['field_name'].':<br /></strong><!--'.$efarr[$i]['field_name'].'--></td>';
198 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
201 <td width="50%" valign="top"><strong>'.$efarr[$i]['field_name'].':<br /></strong><!--'.$efarr[$i]['field_name'].'--></td>';
203 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
206 <td width="50%" valign="top"><strong>'.$efarr[$i]['field_name'].':<br /></strong><!--'.$efarr[$i]['field_name'].'--></td>';
208 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT) {
210 //text fields might be really wide, so need a row to themselves.
211 if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
221 <td width="'.(50*$colspan).'%" colspan="'.$colspan.'" valign="top"><strong>'.$efarr[$i]['field_name'].'</strong>:<br /><!--'.$efarr[$i]['field_name'].'--></td>';
223 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
225 //text areas might be really wide, so need a row to themselves.
226 if (($col_count == 1) && ($efarr[$i]['attribute2'] > 30)) {
236 <td width="'.(50*$colspan).'%" colspan="'.$colspan.'" valign="top"><strong>'.$efarr[$i]['field_name'].'</strong>:<br /><!--'.$efarr[$i]['field_name'].'--></td>';
238 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
241 <td width="50%" valign="top"><strong>'.$efarr[$i]['field_name'].'</strong>:<br /><!--'.$efarr[$i]['field_name'].'--></td>';
243 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
246 <td width="50%" valign="top"><strong>'.$efarr[$i]['field_name'].'</strong>:<br /><!--'.$efarr[$i]['field_name'].'--></td>';
250 //we've done two columns - if there are more to do, start a new row
251 if (($col_count == 2) && ($k != $count-1)) {
258 if ($col_count == 1) {
264 <!-- End Extra Fields Rendering -->';
269 * renderSelect - this function builds pop up
272 * @param int The ID of this field.
273 * @param string The item that should be checked
274 * @param string Whether to show the '100 row'
275 * @param string What to call the '100 row'
276 * @return box and choices
278 function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any') {
279 if ($text_100 == 'none'){
282 $arr =& $this->getExtraFieldElements($extra_field_id);
283 for ($i=0; $i<count($arr); $i++) {
284 $keys[$i]=$arr[$i]['element_id'];
285 $vals[$i]=$arr[$i]['element_name'];
287 return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any);
291 * renderRadio - this function builds radio buttons.
293 * @param int The ID of this field.
294 * @param string The item that should be checked
295 * @param string Whether to show the '100 row'
296 * @param string What to call the '100 row'
297 * @return radio buttons
299 function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any') {
300 $arr =& $this->getExtraFieldElements($extra_field_id);
301 for ($i=0; $i<count($arr); $i++) {
302 $keys[$i]=$arr[$i]['element_id'];
303 $vals[$i]=$arr[$i]['element_name'];
305 return html_build_radio_buttons_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any);
309 * renderCheckbox - this function builds checkboxes.
311 * @param int The ID of this field.
312 * @param array The items that should be checked
313 * @param string Whether to show the '100 row'
314 * @param string What to call the '100 row'
315 * @return radio buttons
317 function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
318 if ($text_100 == 'none'){
321 if (!$checked || !is_array($checked)) {
324 $arr =& $this->getExtraFieldElements($extra_field_id);
327 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="100" '.
328 ((in_array(100,$checked)) ? 'CHECKED' : '').'/>'.$text_100.'<br />';
330 for ($i=0; $i<count($arr); $i++) {
332 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="'.$arr[$i]['element_id'].'" '.
333 ((in_array($arr[$i]['element_id'],$checked)) ? 'CHECKED' : '').'/> '.$arr[$i]['element_name'].'<br />';
339 * renderMultiSelectBox - this function builds checkboxes.
341 * @param int The ID of this field.
342 * @param array The items that should be checked
343 * @param string Whether to show the '100 row'
344 * @param string What to call the '100 row'
345 * @return radio multiselectbox
347 function renderMultiSelectBox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
348 $arr =& $this->getExtraFieldElements($extra_field_id);
352 if (!is_array($checked)) {
353 $checked = explode(',',$checked);
357 $arr =& $this->getExtraFieldElements($extra_field_id);
358 for ($i=0; $i<count($arr); $i++) {
359 $keys[]=$arr[$i]['element_id'];
360 $vals[]=$arr[$i]['element_name'];
362 return html_build_multiple_select_box_from_arrays($keys,$vals,"extra_fields[$extra_field_id][]",$checked,15,$show_100,$text_100);
366 * renderTextField - this function builds a text field.
368 * @param int The ID of this field.
369 * @param string The data for this field.
370 * @return text area and data.
372 function renderTextField ($extra_field_id,$contents,$size,$maxlength) {
374 <input type="text" name="extra_fields['.$extra_field_id.']" value="'.$contents.'" size="'.$size.'" maxlength="'.$maxlength.'"/>';
378 * renderTextArea - this function builds a text area.
380 * @param int The ID of this field.
381 * @param string The data for this field.
382 * @return text area and data.
384 function renderTextArea ($extra_field_id,$contents,$rows,$cols) {
386 <textarea name="extra_fields['.$extra_field_id.']" rows="'.$rows.'" cols="'.$cols.'">'.$contents.'</textarea>';
389 function technicianBox ($name='assigned_to[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
390 if ($text_100=='none'){
391 $text_100=_('Nobody');
393 $result = $this->getTechnicians();
394 // this was a bad hack to allow you to mass-update to unassigned, which is ID=100, which
395 // conflicted with the "No Change" ID of 100.
396 $ids =& util_result_column_to_array($result,0);
397 $names =& util_result_column_to_array($result,1);
398 if ($extra_id != '-1') {
400 $names[]=$extra_name;
404 if (!is_array($checked)) {
405 $checked = explode(',',$checked);
407 return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,15,$show_100,$text_100);
409 return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
413 function cannedResponseBox ($name='canned_response',$checked='xzxz') {
414 return html_build_select_box ($this->getCannedResponses(),$name,$checked);
418 * statusBox - show the statuses - automatically shows the "custom statuses" if they exist
422 function statusBox ($name='status_id',$checked='xzxz',$show_100=false,$text_100='none') {
423 if ($text_100=='none'){
426 return html_build_select_box($this->getStatuses(),$name,$checked,$show_100,$text_100);
433 // c-file-style: "bsd"