/** * */ public static function attributeHtmlFormElement($pa_element_info, $pa_options = null) { if (isset($pa_options['config']) && is_object($pa_options['config'])) { $o_config = $pa_options['config']; } else { $o_config = Configuration::load(); } $vn_width = 25; $vn_max_length = 255; $vs_element = Attribute::valueHTMLFormElement($pa_element_info['datatype'], $pa_element_info, $pa_options); $ps_format = isset($pa_options['format']) ? $pa_options['format'] : null; $vs_label = isset($pa_options['label']) ? $pa_options['label'] : ''; $vs_description = isset($pa_options['description']) ? $pa_options['description'] : ''; if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) { $ps_format = $o_config->get('form_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 { if (!$ps_format) { if ($vs_label) { $ps_format = $o_config->get('form_element_display_format'); } else { $ps_format = $o_config->get('form_element_display_format_without_label'); } } $vs_errors = ''; } $ps_formatted_element = str_replace("^LABEL", "<span class='_attribute_value_" . $pa_element_info['element_code'] . "'>{$vs_label}</span>", $ps_format); $ps_formatted_element = str_replace("^ELEMENT", $vs_element, $ps_formatted_element); $ps_formatted_element = str_replace("^DESCRIPTION", "", $ps_formatted_element); $ps_formatted_element = str_replace("^EXTRA", "", $ps_formatted_element); if ($vs_description) { // don't use TooltipManager to make sure the tooltip is also displayed when this element is added dynamically (via "add" button) //TooltipManager::add('#_attribute_value_'.$pa_element_info['element_code'], "<h3>".$vs_label."</h3>".$vs_description); $ps_formatted_element .= "\n" . caGetTooltipJS(array('._attribute_value_' . $pa_element_info['element_code'] => $vs_description)); } return $ps_formatted_element; }
/** * Returns HTML <script> block setting tooltips for response * * @param string $ps_namespace Optional namespace specifier; allows you to group tooltip code and output different tool tips at different times in the request cycle * @return string HTML <script> block setting up tooltips */ static function getLoadHTML($ps_namespace = 'default') { if (!$ps_namespace) { $ps_namespace = 'default'; } $vs_buf = ''; if (!is_array(TooltipManager::$opa_tooltips)) { TooltipManager::init(); } if (isset(TooltipManager::$opa_tooltips[$ps_namespace]) && is_array(TooltipManager::$opa_tooltips[$ps_namespace])) { $vs_class = isset(TooltipManager::$opa_namespace_classes[$ps_namespace]) && TooltipManager::$opa_namespace_classes[$ps_namespace] ? TooltipManager::$opa_namespace_classes[$ps_namespace] : "tooltipFormat"; $vs_buf .= caGetTooltipJS(TooltipManager::$opa_tooltips[$ps_namespace], $vs_class); } if (isset(TooltipManager::$opa_tooltip_functions[$ps_namespace]) && is_array(TooltipManager::$opa_tooltip_functions[$ps_namespace])) { $vs_buf .= "<script type='text/javascript'>\njQuery(document).ready(function() {\n"; foreach (TooltipManager::$opa_tooltip_functions[$ps_namespace] as $vs_id => $vs_code) { $vs_class = isset(TooltipManager::$opa_namespace_classes[$ps_namespace]) && TooltipManager::$opa_namespace_classes[$ps_namespace] ? TooltipManager::$opa_namespace_classes[$ps_namespace] : "tooltipFormat"; $vs_buf .= "jQuery('{$vs_id}').tooltip({ tooltipClass: '{$vs_class}', show: 150, hide: 150, items: '*', content: function() { {$vs_code}; }});\n"; } $vs_buf .= "});\n</script>\n"; } return $vs_buf; }