/** * Get the Text_Wiki renderer * * Singleton to get the Text_Wiki instance properly configured for the * TIP system. You can specify an array of rules to use in the $rules * array, or leave it undefined to use all the available rules. * * @param array|null $rules The array of rules to enable * @param string|null $toc_title TOC title or null to use a default value * @param string|null $wiki_base Base URI for wiki links * @return Text_Wiki The renderer */ public static function &getWiki($rules = null, $toc_title = null, $wiki_base = '') { static $renderer = null; static $all_rules = array('Prefilter', 'Delimiter', 'Code', 'Function', 'Html', 'Raw', 'Include', 'Embed', 'Anchor', 'Heading', 'Toc', 'Horiz', 'Break', 'Blockquote', 'List', 'Deflist', 'Table', 'Image', 'Phplookup', 'Center', 'Paragraph', 'Url', 'Freelink', 'Interwiki', 'Wikilink', 'Colortext', 'Strong', 'Bold', 'Emphasis', 'Italic', 'Underline', 'Tt', 'Superscript', 'Subscript', 'Revise', 'Tighten'); static $base_rules = array('Prefilter', 'Break', 'Paragraph', 'Tighten'); if (is_null($renderer)) { require_once 'Text/Wiki.php'; isset($toc_title) || ($toc_title = TIP::getLocale('index', 'wiki')); $renderer =& Text_Wiki::singleton('Default'); $renderer->disable = array(); $renderer->setFormatConf('Xhtml', 'charset', 'UTF-8'); /* According to the following comment: * http://php.net/manual/function.htmlentities.php#78509 * "There's no sane reason to use htmlentities() instead of htmlspecialchars()" */ $renderer->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS); $renderer->setRenderConf('Xhtml', 'url', array('target' => '', 'regexes' => array('|http://picasaweb\\.google\\.com/.*/photo/.*|' => array('TIP_Renderer', 'picasa2PhotoCallback'), '|http://picasaweb\\.google\\.com/.*/albumid/.*|' => array('TIP_Renderer', 'picasa2AlbumCallback')))); $renderer->setRenderConf('Xhtml', 'code', array('css' => 'programlisting')); $renderer->setRenderConf('Xhtml', 'toc', array('title' => '<p><strong>' . $toc_title . '</strong></p>', 'div_id' => 'idToc', 'use_ul' => true, 'collapse' => false)); $renderer->setRenderConf('Xhtml', 'freelink', array('pages' => null, 'view_url' => $wiki_base, 'new_text_pos' => null)); } if (is_array($rules)) { // Capitalize the $rules values $rules = array_map('ucfirst', array_map('strtolower', $rules)); // Join the forced rules $rules = array_merge($rules, $base_rules); // Get the real rules to apply $rules = array_intersect($all_rules, $rules); } else { $rules = $base_rules; } $renderer->rules = $rules; return $renderer; }
private function &_widgetLookup(&$field, $args) { $id = $field['id']; $label = $this->getLocale('label.' . $id); $info = TIP::getLocale('comment.' . $id, $this->locale_prefix); if (empty($args)) { // Try to get the lookup module from the $cfg array global $cfg; foreach ($cfg as $module_id => &$module_options) { if (@$module_options['master'] == $this->id && end($module_options['type']) == 'hierarchy') { $lookup_id = $module_id; break; } } } else { // Explicitely defined in the widget args $lookup_id = $args; } // On lookup module not found, build a default one // by appending '_hierarchy' to this module id isset($lookup_id) || ($lookup_id = $this->id . '_hierarchy'); ++$this->_tabindex; $element =& $this->_addElement('text', $id, array('size' => 8, 'maxlength' => 8)); $element->setInfo($info); if ($this->json) { // Add JSON params, if needed $params = array('sWidget' => 'lookup', 'sUriView' => TIP::buildActionUri($lookup_id, 'view')); if (!is_null(TIP::getOption($lookup_id, 'search_field'))) { // Enable search URI $params['sUriSearch'] = TIP::buildActionUri($lookup_id, 'search'); } $element->setComment(json_encode($params)); // Enable AHAH interactivity $element->setAttribute('class', 'ahah'); } return $element; }
/** * Called by the login form to validate user and password * @param array $row The data row * @return true|array true on success or an associative array in the * form array(field => error_message) */ public function _checkLogin($row) { $filter = $this->data->filter('user', $row['user']) . ' LIMIT 1'; if (is_null($view =& $this->startDataView($filter))) { TIP::notifyError('select'); return array('user' => TIP::getLocale('error.select', 'notify', null, false)); } if (is_null($this->_row = $view->current())) { $this->endView(); return array('user' => $this->getLocale('notfound')); } if ($this->_row['password'] != $row['password']) { $this->endView(); $this->_row = null; return array('password' => $this->getLocale('wrongpassword')); } return true; }
/** * Localized label * * $params is the id of the string to localize. If there are no dots, * the current module id and '.label.' are prepended to $params. * * Output a properly localized string. */ protected function tagLocalized($params) { if (strpos($params, '.') !== false) { list($prefix, $id) = explode('.', $params, 2); } else { $prefix = $this->locale_prefix; $id = 'label.' . $params; } return TIP::getLocale($id, $prefix); }
/** * Get the privilege description * * Expands to the specified privilege description, in the current locale. * In $params you must specify the privilege as 'module_id,privilege', * where privilege must be manager|admin|trusted|untrusted|none. */ protected function tagPrivilegeDescription($params) { global $cfg; list($module, $privilege) = explode(',', $params); $prefixes = array_reverse($cfg[$module]['type']); isset($cfg[$module]['locale_prefix']) && array_unshift($prefixes, $cfg[$module]['locale_prefix']); foreach ($prefixes as $prefix) { $description = TIP::getLocale($privilege, $prefix); if (!empty($description)) { return TIP::toHtml($description); } } TIP::warning("localized privilege description not found ({$params})"); return null; }