* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7769 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ 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->displayImagePreferences(); $this->displayRegenerate(); $this->displayMoveImages(); } 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 here.'); }elseif (Tools::getValue('submitMoveImages'.$this->table)) { if ($this->tabAccess['edit'] === '1') { if ($this->_moveImagesToNewFileSystem()) Tools::redirectAdmin($currentIndex.'&conf=25'.'&token='.$this->token); } else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); }elseif (Tools::getValue('submitImagePreferences')) { if ($this->tabAccess['edit'] === '1') { if ((int)Tools::getValue('PS_JPEG_QUALITY') < 0 || (int)Tools::getValue('PS_JPEG_QUALITY') > 100) $this->_errors[] = Tools::displayError('Incorrect value for JPEG image quality.'); elseif ((int)Tools::getValue('PS_PNG_QUALITY') < 0 || (int)Tools::getValue('PS_PNG_QUALITY') > 9) $this->_errors[] = Tools::displayError('Incorrect value for PNG image quality.'); elseif (!Configuration::updateValue('PS_IMAGE_QUALITY', Tools::getValue('PS_IMAGE_QUALITY')) || !Configuration::updateValue('PS_JPEG_QUALITY', Tools::getValue('PS_JPEG_QUALITY')) || !Configuration::updateValue('PS_PNG_QUALITY', Tools::getValue('PS_PNG_QUALITY'))) $this->_errors[] = Tools::displayError('Unknown error.'); else Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4'); } else $this->_errors[] = Tools::displayError('You do not have permission to edit 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(); if (!($obj = $this->loadObject(true))) return; 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'), 'stores' => $this->l('Stores') ); echo '