Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * GridActionDelete::execute()
  *
  * @param  $objects
  * @return void
  */
 public function execute($objects, $itemIds = array())
 {
     // Retourne exception si pas d'item selectionne
     $result = parent::execute($objects, $itemIds);
     if (Tools::isException($result)) {
         return $result;
     }
     $okLink = $this->_entityType . 'Delete.php?';
     $cancelLink = '' != $this->returnURL ? $this->returnURL : $this->_entityType . 'List.php?' . $this->_query;
     $padding = '';
     foreach ($objects as $object) {
         if (method_exists($object, 'getId')) {
             $okLink .= $padding . $this->transmitedArrayName . "[]=" . $object->getId();
         }
         $padding = '&';
     }
     if ($this->_query != "") {
         $okLink .= '&' . $this->_query;
     }
     if (false === $this->gridInPopup) {
         Template::confirmDialog($this->confirmMessage, $okLink, $cancelLink);
         exit;
     } else {
         Template::confirmDialog($this->confirmMessage, $okLink, $cancelLink, BASE_POPUP_TEMPLATE);
         exit;
     }
 }