/** * */ function caSearchLink($po_request, $ps_content, $ps_classname, $ps_table, $ps_search, $pa_other_params = null, $pa_attributes = null, $pa_options = null) { if (!($vs_url = caSearchUrl($po_request, $ps_table, $ps_search, false, $pa_other_params, $pa_options))) { return "<strong>Error: no url for search</strong>"; } $vs_tag = "<a href='" . $vs_url . "'"; if ($ps_classname) { $vs_tag .= " class='{$ps_classname}'"; } if (is_array($pa_attributes)) { $vs_tag .= _caHTMLMakeAttributeString($pa_attributes); } $vs_tag .= '>' . $ps_content . '</a>'; return $vs_tag; }
/** * 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); } }