* @copyright PrestaShop * @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0 * @version 1.3 * */ include_once(realpath(PS_ADMIN_DIR.'/../').'/classes/AdminTab.php'); class AdminImages extends AdminTab { private $start_time = 0; private $max_execution_time = 7200; public function __construct() { $this->table = 'image_type'; $this->className = 'ImageType'; $this->lang = false; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'id_image_type' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 140, 'size' => 16), 'width' => array('title' => $this->l('Width'), 'align' => 'right', 'suffix' => ' px', 'width' => 50, 'size' => 5), 'height' => array('title' => $this->l('Height'), 'align' => 'right', 'suffix' => ' px', 'width' => 50, 'size' => 5) ); parent::__construct(); } public function displayList() { parent::displayList(); $this->displayRegenerate(); } public function postProcess() { global $currentIndex; if (Tools::getValue('submitRegenerate'.$this->table)) { if ($this->tabAccess['edit'] === '1') { if ($this->_regenerateThumbnails(Tools::getValue('type'), Tools::getValue('erase'))) Tools::redirectAdmin($currentIndex.'&conf=9'.'&token='.$this->token); } else $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.'); } else parent::postProcess(); } protected function _childValidation() { if (!Tools::getValue('id_image_type') AND Validate::isImageTypeName($typeName = Tools::getValue('name')) AND ImageType::typeAlreadyExists($typeName)) $this->_errors[] = Tools::displayError('this name already exists'); } public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); $obj = $this->loadObject(true); echo $obj->id ? $this->displayWarning($this->l('After modification, do not forget to regenerate thumbnails')) : ''; echo '
'; } /** * Display form for thumbnails regeneration * * @global string $currentIndex Current URL in order to keep current Tab */ public function displayRegenerate() { global $currentIndex; $types = array( 'categories' => $this->l('Categories'), 'manufacturers' => $this->l('Manufacturers'), 'suppliers' => $this->l('Suppliers'), 'scenes' => $this->l('Scenes'), 'products' => $this->l('Products') ); echo '