Example #1
0
 static function FieldInput(&$field, &$errors, $errortype = "ticket", $context = array())
 {
     $output = "";
     $id = $field['id'];
     $userid = 0;
     if (array_key_exists('userid', $context)) {
         $userid = $context['userid'];
     }
     $ticketid = 0;
     if (array_key_exists('ticketid', $context)) {
         $ticketid = $context['ticketid'];
     }
     // if its a per user field, try to load the value
     $current = $field['default'];
     if ($field['peruser'] && $errortype == "ticket") {
         $uservalues = FSFCF::GetUserValues($userid, $ticketid);
         if (array_key_exists($field['id'], $uservalues)) {
             $current = $uservalues[$field['id']]['value'];
         }
     }
     $current = JRequest::getVar("custom_{$id}", $current);
     if ($field['type'] == "text") {
         $aparams = FSFCF::GetValues($field);
         $text_max = $aparams['text_max'];
         $text_size = $aparams['text_size'];
         $output = "<input name='custom_{$id}' id='custom_{$id}' value=\"" . FSF_Helper::escape($current) . "\" maxlength='{$text_max}' size='{$text_size}'>\n";
     }
     if ($field['type'] == "radio") {
         $values = FSFCF::GetValues($field);
         $output = "";
         if (count($values) > 0) {
             foreach ($values as $value) {
                 $output .= "<input type='radio' id='custom_{$id}' name='custom_{$id}' value=\"" . FSF_Helper::escape($value) . "\"";
                 if ($value == $current) {
                     $output .= " checked";
                 }
                 $output .= ">{$value}<br>\n";
             }
         }
     }
     if ($field['type'] == "combo") {
         $values = FSFCF::GetValues($field);
         $output = "<select name='custom_{$id}' id='custom_{$id}'>\n";
         $output .= "<option value=''>" . JText::_("PLEASE_SELECT") . "</option>\n";
         if (count($values) > 0) {
             foreach ($values as $value) {
                 $output .= "<option value=\"" . FSF_Helper::escape($value) . "\"";
                 if ($value == $current) {
                     $output .= " selected";
                 }
                 $output .= ">{$value}</option>\n";
             }
         }
         $output .= "</select>";
     }
     if ($field['type'] == "area") {
         $aparams = FSFCF::GetValues($field);
         $area_width = $aparams['area_width'];
         $area_height = $aparams['area_height'];
         $output = "<textarea name='custom_{$id}' id='custom_{$id}' cols='{$area_width}' rows='{$area_height}' style='width:95%'>{$current}</textarea>\n";
     }
     if ($field['type'] == "checkbox") {
         $output = "<input type='checkbox' name='custom_{$id}' id='custom_{$id}'";
         if ($current == "on") {
             $output .= " checked";
         }
         $output .= ">\n";
     }
     if ($field['type'] == "plugin") {
         $aparams = FSFCF::GetValues($field);
         $plugin = FSFCF::get_plugin($aparams['plugin']);
         $output = $plugin->Input($current, $aparams['plugindata'], $context, $id);
     }
     $id = "custom_" . $field['id'];
     if (array_key_exists($id, $errors)) {
         if ($errortype == "ticket") {
             $output .= '<div class="fsf_ticket_error" id="error_subject">' . $errors[$id] . '</div>';
         } else {
             $output .= '</td><td class="fsf_must_have_field">' . $errors[$id];
         }
     }
     return $output;
 }