/** * 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; }