/** * Override's BaseModel method to intercept calls for field 'idno'; uses the specified IDNumbering * plugin to generate HTML for idno. If no plugin is specified then the call is passed on to BaseModel::htmlFormElement() * Calls for fields other than idno are passed to BaseModel::htmlFormElement() */ public function htmlFormElement($ps_field, $ps_format = null, $pa_options = null) { if (!is_array($pa_options)) { $pa_options = array(); } foreach (array('name', 'form_name', 'request', 'field_errors', 'display_form_field_tips', 'no_tooltips', 'label', 'readonly') as $vs_key) { if (!isset($pa_options[$vs_key])) { $pa_options[$vs_key] = null; } } if (!$this->opo_idno_plugin_instance) { $this->loadIDNoPlugInInstance($pa_options); } if ($ps_field == $this->getProperty('ID_NUMBERING_ID_FIELD') && $this->opo_idno_plugin_instance && $pa_options['request']) { $vs_idno_fld = $this->getProperty('ID_NUMBERING_ID_FIELD'); if ($vn_parent_id = $this->get($this->getProperty('HIERARCHY_PARENT_ID_FLD'))) { $this->opo_idno_plugin_instance->isChild(true); } // if it has a parent_id then set the id numbering plugin using "child_only" numbering schemes (if defined) if (!$this->getPrimaryKey() && $vn_parent_id && $this->opo_idno_plugin_instance->isChild()) { $t_parent = $this->getAppDatamodel()->getInstanceByTableName($this->tableName(), false); if ($this->inTransaction()) { $t_parent->setTransaction($this->getTransaction()); } if ($t_parent->load($vn_parent_id)) { $this->set($vs_idno_fld, $x = $this->opo_idno_plugin_instance->makeTemplateFromValue($t_parent->get($vs_idno_fld), 1, true)); // chop off last serial element } } $this->opo_idno_plugin_instance->setValue($this->get($ps_field)); if (method_exists($this, "getTypeCode")) { $this->opo_idno_plugin_instance->setType($this->getTypeCode()); } $vs_element = $this->opo_idno_plugin_instance->htmlFormElement($ps_field, $va_errors, array_merge($pa_options, array('error_icon' => $pa_options['request']->getThemeUrlPath() . "/graphics/icons/warning_small.gif", 'progress_indicator' => $pa_options['request']->getThemeUrlPath() . "/graphics/icons/indicator.gif", 'show_errors' => $this->getPrimaryKey() ? true : false, 'context_id' => isset($pa_options['context_id']) ? $pa_options['context_id'] : null, 'table' => $this->tableName(), 'row_id' => $this->getPrimaryKey(), 'check_for_dupes' => true, 'search_url' => caSearchUrl($pa_options['request'], $this->tableName(), '')))); if (is_null($ps_format)) { if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) { $ps_format = $this->_CONFIG->get('bundle_element_error_display_format'); $va_field_errors = array(); foreach ($pa_options['field_errors'] as $o_e) { $va_field_errors[] = $o_e->getErrorDescription(); } $vs_errors = join('; ', $va_field_errors); } else { $ps_format = $this->_CONFIG->get('bundle_element_display_format'); $vs_errors = ''; } } if ($ps_format != '') { $ps_formatted_element = $ps_format; $ps_formatted_element = str_replace("^ELEMENT", $vs_element, $ps_formatted_element); $va_attr = $this->getFieldInfo($ps_field); foreach (array('DISPLAY_DESCRIPTION', 'DESCRIPTION', 'LABEL', 'DESCRIPTION') as $vs_key) { if (!isset($va_attr[$vs_key])) { $va_attr[$vs_key] = null; } } // TODO: should be in config file $pa_options["display_form_field_tips"] = true; if ($pa_options["display_form_field_tips"] || !isset($pa_options["display_form_field_tips"]) && $va_attr["DISPLAY_DESCRIPTION"] || !isset($pa_options["display_form_field_tips"]) && !isset($va_attr["DISPLAY_DESCRIPTION"]) && $vb_fl_display_form_field_tips) { if (preg_match("/\\^DESCRIPTION/", $ps_formatted_element)) { $ps_formatted_element = str_replace("^LABEL", isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"], $ps_formatted_element); $ps_formatted_element = str_replace("^DESCRIPTION", $va_attr["DESCRIPTION"], $ps_formatted_element); } else { // no explicit placement of description text, so... $vs_field_id = '_' . $this->tableName() . '_' . $this->getPrimaryKey() . '_' . $pa_options["name"] . '_' . $pa_options['form_name']; $ps_formatted_element = str_replace("^LABEL", '<span id="' . $vs_field_id . '">' . (isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"]) . '</span>', $ps_formatted_element); if (!$pa_options['no_tooltips']) { TooltipManager::add('#' . $vs_field_id, "<h3>" . (isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"]) . "</h3>" . $va_attr["DESCRIPTION"]); } } } else { $ps_formatted_element = str_replace("^LABEL", isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"], $ps_formatted_element); $ps_formatted_element = str_replace("^DESCRIPTION", "", $ps_formatted_element); } $ps_formatted_element = str_replace("^ERRORS", $vs_errors, $ps_formatted_element); $vs_element = $ps_formatted_element; } return $vs_element; } else { return parent::htmlFormElement($ps_field, $ps_format, $pa_options); } }
/** * */ public function htmlFormElement($ps_field, $ps_format = null, $pa_options = null) { if ($ps_field == 'list_id') { // Custom list drop-down $vs_format = $this->_CONFIG->get('form_element_display_format'); $t_list = new ca_lists(); $va_lists = caExtractValuesByUserLocale($t_list->getListOfLists()); $va_opts = array(); foreach ($va_lists as $vn_list_id => $va_list_info) { $va_opts[$va_list_info['name'] . ' (' . $va_list_info['list_code'] . ')'] = $vn_list_id; } ksort($va_opts); $vs_format = str_replace('^LABEL', $vs_field_label = $this->getFieldInfo('list_id', 'LABEL'), $vs_format); $vs_format = str_replace('^EXTRA', '', $vs_format); $vs_format = str_replace('^ELEMENT', caHTMLSelect($ps_field, $va_opts, array('id' => $ps_field), array('value' => $this->get('list_id'))), $vs_format); if (!isset($pa_options['no_tooltips']) || !$pa_options['no_tooltips']) { TooltipManager::add('#list_id', "<h3>{$vs_field_label}</h3>" . $this->getFieldInfo('list_id', 'DESCRIPTION'), $pa_options['tooltip_namespace']); } return $vs_format; } return parent::htmlFormElement($ps_field, $ps_format, $pa_options); }