name = 'gmcrop'; $this->prefix = strtoupper($this->name); $this->tab = 'administration'; $this->version = '1.2.3'; $this->author = 'GreenMouseStudio.com'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Perfect Thumbnails'); $this->description = $this->l('Crop images instead of adding whitespace around them'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->getConfiguration(); } protected function getConfiguration() { $this->cropOrigin = Configuration::get($this->prefix.'_ORIGIN'); $this->backgroundColor = Configuration::get($this->prefix.'_BGCOLOR'); $imageTypesString = Configuration::get($this->prefix.'_CROPPEDTYPES'); $this->croppedImageTypes = explode(',', $imageTypesString); $this->cropBackground = (bool)Configuration::get($this->prefix.'_CROPBG'); $this->optimizeForBandwitdh = (bool)Configuration::get($this->prefix.'_BANDWIDTH'); $optimizedTypesString = Configuration::get($this->prefix.'_FITTEDTYPES'); $this->fittedImageTypes = explode(',', $optimizedTypesString); } public function install() { return parent::install() && Configuration::updateValue($this->prefix.'_ORIGIN', 4) && Configuration::updateValue($this->prefix.'_BGCOLOR', '#ffffff') && Configuration::updateValue($this->prefix.'_CROPPEDTYPES', 'home_default') && Configuration::updateValue($this->prefix.'_CROPBG', true) && Configuration::updateValue($this->prefix.'_FITTEDTYPES', 'thickbox_default') && $this->registerHook('displayBackOfficeHeader'); } public function uninstall() { Configuration::deleteByName($this->prefix.'_ORIGIN'); Configuration::deleteByName($this->prefix.'_BGCOLOR'); Configuration::deleteByName($this->prefix.'_CROPPEDTYPES'); Configuration::deleteByName($this->prefix.'_FITTEDTYPES'); Configuration::deleteByName($this->prefix.'_CROPBG'); return parent::uninstall(); } public function getContent() { $this->getConfiguration(); $output = ''; if (((bool) Tools::isSubmit($this->name.'submit')) == true) { $this->postProcess(); $output .= $this->displayConfirmation($this->l('Settings updated')); } $output .= $this->renderForm(); return $output; } protected function getImagesTypes() { $data = array(); $imagesTypes = ImageType::getImagesTypes(); foreach ($imagesTypes as $type) { $data[] = $type['name']; } return $data; } protected function renderTypesCheckboxes($name, $label, $selectedTypes) { $content = '