/** * Méthode principale qui appelle les sous méthodes pour construire, * traiter et afficher le formulaire. * * @access public * @return void */ public function render($template = false) { if ($this->useSession) { $this->includeSessionRequirements(); } $this->session = Session::singleton(); SearchTools::ProlongDataInSession(); $this->auth(); $this->initialize(); if (!$this->parentForm && $this->action == GenericController::FEATURE_DELETE && in_array(GenericController::FEATURE_DELETE, $this->features)) { if (!isset($_REQUEST['confirm_delete'])) { Template::confirmDialog(I_DELETE_ITEMS, $_SERVER['REQUEST_URI'] . '&confirm_delete=1', $this->guessReturnURL()); exit; } $this->delete(); Tools::redirectTo($this->guessReturnURL()); exit(0); } $this->buildForm(); $this->onBeforeDisplay(); if ($this->action == GenericController::FEATURE_VIEW) { $this->form->freeze(); } else { if (isset($_POST['fromAddButton']) && $_POST['fromAddButton'] == '1' || isset($_POST['submitFlag']) && $this->form->validate()) { $values = $this->form->exportValues(); $ret = $this->form->process(array($this, 'handlePostData'), $values); // le script sort ici, car redirigé par la méthode onFinish() // à moins qu'on ait surchargé celle ci. } } if (!$this->parentForm) { $additionalContent = $this->additionalFormContent(); $smarty = $this->template; $smarty->assign('preContent', $this->preContent()); $smarty->assign('form', $this->form->toArray(true)); $smarty->assign('formTitle', empty($this->formTitle) ? ' ' : $this->formTitle); $template = !$template ? GENERIC_ADDEDIT_TEMPLATE : $template; $smarty->assign('additionalContent', $additionalContent); $smarty->assign('postContent', $this->postContent()); $content = $smarty->fetch($template); $method = $this->useAJAX ? 'ajaxPage' : 'page'; Template::$method($this->title, $content, $this->jsRequirements, array(), $this->htmlTemplate); } }