/** * Configure an attachment based element * * This code can be shared by every HTML_QuickForm_attachment based element. * * @param HTML_QuickForm_element &$element The element to configure * @param string $args The widget args * @return HTML_QuickForm_element The configured element */ private function &_configAttachment(&$element, $args) { // Common base path and uri $element->setBasePath(TIP::buildDataPath((string) $this->master)); $element->setBaseUrl(TIP::buildDataUri((string) $this->master)); // Unload the element data, if needed $unload_id = 'unload_' . $element->getName(); if ($this->action == TIP_FORM_ACTION_DELETE && TIP::getGet('process', 'int') == 1 || array_key_exists($unload_id, $_POST)) { $element->setState(QF_ATTACHMENT_TO_UNLOAD); } else { // Add the unload element $unload_label = $this->getLocale('label.' . $unload_id); $unload_element = $this->_form->createElement('checkbox', $unload_id, $unload_label, $unload_label, array('tabindex' => $this->_tabindex)); $element->setUnloadElement($unload_element); } return $element; }
/** * Wikize the field specified in $params * * The value of the field with $params id is parsed and rendered by the * Text_Wiki renderer according to the wiki rules defined in the * widget args of this field. */ protected function tagWiki($params) { $value = $this->getField($params); if (is_null($value)) { TIP::error("no field found ({$params})"); return null; } $fields =& $this->data->getFields(); if (!array_key_exists($params, $fields)) { // Field not found $this->data: it is probably a joined field $rules = null; } else { $field =& $fields[$params]; // Get the wiki rules if (array_key_exists('widget_args', $field)) { $rules = explode(',', $field['widget_args']); } elseif (array_key_exists('wiki_rules', $field)) { // DEPRECATED: now use widget args instead of "wiki_rules" option $rules = explode(',', $field['wiki_rules']); } else { $rules = null; } } $wiki_base = TIP::buildActionUri($this->id, 'view', '%s'); $renderer =& TIP_Renderer::getWiki($rules, null, $wiki_base); $renderer->setRenderConf('Xhtml', 'Image', 'base', TIP::buildDataUri($this->id) . '/'); $result = $renderer->transform($value); if (PEAR::isError($result)) { return 'ERROR: ' . $result->getMessage(); } return $result; }
/** * Build a relative URI: $params must be referred to the module data root */ protected function tagDataUri() { $pieces = func_get_args(); return TIP::buildDataUri($this->id, $pieces); }