/** * 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(); }
/** * Render the form * * @param bool|null $valid Whether the form was validated * @return bool true if the renderer was performed, * false on errors */ public function render($valid) { $mode = $valid === false ? $this->invalid_render : $this->valid_render; if ($mode == TIP_FORM_RENDER_NOTHING) { return true; } elseif ($mode == TIP_FORM_RENDER_REDIRECT) { // Pass a notification message throught the session if ($valid === false) { $notify = array(TIP_SEVERITY_ERROR, $this->action_id); } elseif ($this->notify_done) { $notify = array(TIP_SEVERITY_INFO, 'done'); } isset($notify) && HTTP_Session2::set('notify', $notify); // Forcibly close the current session HTTP_Session2::pause(); // Perform the redirection HTTP::redirect($this->follower, true); } if ($this->_stage > 1) { foreach ($this->_trailing_elements as &$element) { // Update the tabindex property ++$this->_tabindex; $element->setAttribute('tabindex', $this->_tabindex); $this->_form->addElement($element); } } // Execute the prerender callbacks foreach ($this->_prerender as $field => $data) { call_user_func_array($data['callback'], $data['args']); } // Add buttons $this->_addButtons($valid); // Form template initialization $template =& TIP_Application::getSharedTemplate($this->form_template); if (is_null($template)) { TIP::error("form template not found ({$this->form_template})"); return false; } $this->_form->setRequiredNote($this->getLocale('label.requirednote')); // Some global keys $this->keys['ATTRIBUTES'] = $this->_form->getAttributes(true); // DEPRECATED: the tag {form(getRequiredNote)} must be used instead $this->keys['REQUIREDNOTE'] = $this->_form->getRequiredNote(); // Populate the array (if not yet done) if (is_null($this->_array)) { $renderer =& TIP_Renderer::getForm(); $this->_form->accept($renderer); $this->_array = $renderer->toArray(); } // Call the renderer if ($mode == TIP_FORM_RENDER_IN_PAGE) { $content =& TIP_Application::getGlobal('content'); ob_start(); $done = $template->run($this); $content .= ob_get_clean(); } else { $done = $template->run($this); } return $done; }