From b97c07772c56da520bb657cf8f2fac29f73afad6 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 26 Jun 2008 11:18:57 -0400 Subject: [PATCH] construct_custom_fields() now uses the new template system --- includes/functions.php | 70 +++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 97d1435..7b1dc43 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -215,13 +215,12 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte // ################## Start construct_custom_fields ################## function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefault = false, $searchMode = false) { - global $bugsys; static $fields; if (!is_array($fields)) { $fields = array(); - $fields_fetch = $bugsys->db->query(" + $fields_fetch = BSApp::$db->query(" SELECT bugfield.*, MAX(permission.mask) AS mask FROM " . TABLE_PREFIX . "bugfield AS bugfield LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission @@ -265,47 +264,53 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau switch ($field['type']) { case 'input_text': - eval('$tempfield = "' . $bugsys->template->fetch('bugfield_input_text') . '";'); + $tpl = new BSTemplate('bugfield_input_text'); + $tpl->vars = array( + 'field' => $field, + 'value' => $value + ); + $tempfield = $tpl->evaluate()->getTemplate(); break; case 'input_checkbox': - $selected = ($value ? ' checked="checked"' : ''); - eval('$tempfield = "' . $bugsys->template->fetch('bugfield_input_checkbox') . '";'); + $tpl = new BSTemplate('bugfield_input_checkbox'); + $tpl->vars = array( + 'field' => $field, + 'searchMode' => $searchMode, + 'selected' => ($value ? ' checked="checked"' : '') + ); + $tempfield = $tpl->evaluate()->getTemplate(); break; case 'select_single': $selects = unserialize($field['selects']); $value = trim($value); - $options = ''; + $tpl = new BSTemplate('bugfield_select_single_option'); + $tpl->vars = array( + 'id' => -1, + 'select' => '', + 'selected' => ((!$field['usedefault'] && !trim($value)) ? ' selected="selected"' : '') + ); + $options = $tpl->evaluate()->getTemplate(); - $id = -1; - $select = ''; - if (!$field['usedefault'] AND !trim($value)) - { - $selected = ' selected="selected"'; - } - else + foreach ($selects as $id => $select) { - $selected = ''; + $tpl = new BSTemplate('bugfield_select_single_option'); + $tpl->vars = array( + 'id' => $id, + 'select' => stripslashes(trim($select)), + 'selected' => (($select == $value || ($field['usedefault'] && $id == 0)) ? ' selected="selected"' : '') + ); + $options .= $tpl->evaluate()->getTemplate(); } - eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); - foreach ($selects AS $id => $select) - { - $selected = ''; - $select = stripslashes(trim($select)); - if ($select == $value) - { - $selected = ' selected="selected"'; - } - else if ($field['usedefault'] AND $id == 0) - { - $selected = ' selected="selected"'; - } - eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); - } - eval('$tempfield = "' . $bugsys->template->fetch('bugfield_select_single') . '";'); + $tpl = new BSTemplate('bugfield_select_single'); + $tpl->vars = array( + 'field' => $field, + 'options' => $options + ); + $tempfield = $tpl->evaluate()->getTemplate(); break; } } @@ -342,7 +347,10 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau $value = ($value ? 'True' : 'False'); } $field['value'] = $value; - eval('$tempfield = "' . $bugsys->template->fetch('bugfield_static_text') . '";'); + + $tpl = new BSTemplate('bugfield_static_text'); + $tpl->vars = array('field' => $field); + $tempfield = $tpl->evaluate()->getTemplate(); } $fieldbits[] = $tempfield; } -- 2.43.5