/** * 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; } }
/** * GridActionRedirect::execute() * * @access public * @param object $objects * @param boolean $doRedirect * @return mixed */ public function execute($objects, $itemIds = array(), $doRedirect = true) { // Retourne exception si pas d'item selectionne $result = parent::execute($objects, $itemIds); if (Tools::isException($result)) { return $result; } if (false !== strpos($this->_URL, '%d')) { if (count($objects) == 1) { $target = sprintf($this->_URL, $objects[0]->getId()); } else { if (!$this->allowEmptySelection) { return new Exception(I_NEED_SINGLE_ITEM); } $target = $this->_URL; } } else { if (empty($objects)) { if ($this->transmitedArrayName && !$this->allowEmptySelection) { return new Exception(I_NEED_SELECT_ITEM); } $target = $this->_URL; } else { $padding = strpos($this->_URL, '?') === false ? '?' : '&'; $queryString = ''; foreach ($objects as $key => $object) { $object = $objects[$key]; if (method_exists($object, 'getId')) { $queryString .= $padding . $this->transmitedArrayName . "[]=" . $object->getId(); $padding = '&'; } } $target = $this->_URL . $queryString; } } $target = UrlTools::compliantURL($target, false); if ($doRedirect) { Tools::redirectTo($target); exit; } else { return $target; } }
/** * GridActionJS::__construct() * * @param array $params * @return void */ public function __construct($params = array()) { if (false == isset($params['Caption'])) { $params['Caption'] = A_VALIDATE; } if (false == isset($params['GlyphEnabled'])) { $params['GlyphEnabled'] = 'images/ok.gif'; } if (false == isset($params['GlyphDisabled'])) { $params['GlyphDisabled'] = 'images/ok_no.gif'; } // Les instructions js a executer if (!isset($params['jsActionArray'])) { $params['jsActionArray'] = 'alert(\'Error\')'; trigger_error("jsActionArray has not been defined. " . "(GridActionJS)", E_USER_NOTICE); } $this->jsActionArray = $params['jsActionArray']; // Par defaut ici $this->withTriggerAction = false; parent::__construct($params); }
/** * GridActionSeparator::__construct() * * @param array $params * @return void */ public function __construct($params = array()) { parent::__construct($params); }
/** * GridActionToggleProperty::execute() * Execute les actions togglePropertyOn/Off. * * @param array $objects * @return void */ public function execute($objects, $itemIds = array()) { $result = parent::execute($objects, $itemIds); if (Tools::isException($result)) { return $result; } $count = count($objects); $method = 'set' . $this->property; for ($i = 0; $i < $count; $i++) { $object = $objects[$i]; // ne pas planter si le setter n'existe pas if (method_exists($object, $method)) { if (isset($_POST['Grid_ToggleAction'])) { if ($_POST['Grid_ToggleAction'] == '1') { $object->{$method}($this->toggleOnValue); } else { $object->{$method}($this->toggleOffValue); } $object->save(); } } } // redirection pour rappeler le render() du grid Tools::redirectTo(!empty($this->returnURL) ? $this->returnURL : $_SERVER['REQUEST_URI']); }