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; }
/** * The "main" function * * The starting point of the TIP system. This must be called somewhere from * your index.php. */ public function go() { // Configure the locale $locale_module = $this->shared_modules['locale']; if (TIP::setLocaleId(TIP::getOption($locale_module, 'locale'))) { date_default_timezone_set(TIP::getOption($locale_module, 'timezone')); } // Executes the action if ($this->_request['module'] && $this->_request['action']) { if (is_null($module =& TIP_Type::getInstance($this->_request['module'], false))) { TIP::notifyError('module'); } else { if (isset($this->_request['id'])) { // Now the module is loaded: force id type casting $id_type = $module->getProperty('id_type'); isset($id_type) || ($id_type = 'integer'); settype($this->_request['id'], $id_type); $this->keys['ID'] = $this->_request['id']; } if (is_null($module->callAction($this->_request['action']))) { TIP::notifyError(is_null(TIP::getUserId()) ? 'reserved' : 'denied'); } } } elseif ($this->_request['module']) { TIP::notifyError('noaction'); } elseif ($this->_request['action']) { TIP::notifyError('nomodule'); } elseif (TIP_AHAH) { // AHAH request without module/action specified: perform a test $this->content = "<pre>\n" . TIP::toHtml(print_r($_SERVER, true)) . "\n</pre>\n"; } if (TIP_AHAH) { // AHAH request: output the page and return header('Content-Type: application/xml'); echo $this->content; return; } // Generates the page: body must be called before the head because // some head tags can be modified by body templates $body = $this->tagRun($this->body_template); echo str_replace('{locale}', TIP::getLocaleId('-'), $this->incipit); $this->run($this->head_template); echo $body . $this->explicit; $this->_session_started && HTTP_Session2::pause(); }
/** * Get the current locale, such as 'en_US' or 'it_IT' * * @param string $separator The optional glue to use between language * and territory parts * @return string The current locale */ public static function getLocaleId($separator = '_') { static $locale = null; if (is_null($locale)) { $shared_modules = TIP_Application::getGlobal('shared_modules'); $locale = TIP::getOption($shared_modules['locale'], 'locale'); } // Fallback to en_US, so ensure the locale is set anyway isset($locale) || ($locale = 'en_US'); return str_replace('_', $separator, $locale); }