* @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminScenesControllerCore extends AdminController { public $bootstrap = true ; public function __construct() { $this->table = 'scene'; $this->className = 'Scene'; $this->lang = true; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->identifier = 'id_scene'; $this->fieldImageSettings = array( array('name' => 'image', 'dir' => 'scenes'), array('name' => 'thumb', 'dir' => 'scenes/thumbs') ); $this->fields_list = array( 'id_scene' => array( 'title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs' ), 'name' => array( 'title' => $this->l('Image Maps'), 'filter_key' => 'b!name' ), 'active' => array( 'title' => $this->l('Activated'), 'align' => 'center', 'class' => 'fixed-width-xs', 'active' => 'status', 'type' => 'bool', 'orderby' => false ) ); parent::__construct(); } protected function afterImageUpload() { /* Generate image with differents size */ if (!($obj = $this->loadObject(true))) return; if ($obj->id && (isset($_FILES['image']) || isset($_FILES['thumb']))) { $base_img_path = _PS_SCENE_IMG_DIR_.$obj->id.'.jpg'; $images_types = ImageType::getImagesTypes('scenes'); foreach ($images_types as $k => $image_type) { if ($image_type['name'] == 'm_scene_default') { if (isset($_FILES['thumb']) && !$_FILES['thumb']['error']) $base_thumb_path = _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'.jpg'; else $base_thumb_path = $base_img_path; ImageManager::resize( $base_thumb_path, _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']); } elseif (isset($_FILES['image']) AND isset($_FILES['image']['tmp_name']) AND !$_FILES['image']['error']) ImageManager::resize( $base_img_path, _PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']); } } return true; } public function renderForm() { $this->initFieldsForm(); if (!($obj = $this->loadObject(true))) return; $this->tpl_form_vars['products'] = $obj->getProducts(true, $this->context->language->id, false, $this->context); return parent::renderForm(); } public function initPageHeaderToolbar() { if (empty($this->display)) $this->page_header_toolbar_btn['new_scene'] = array( 'href' => self::$currentIndex.'&addscene&token='.$this->token, 'desc' => $this->l('Add new image map', null, null, false), 'icon' => 'process-icon-new' ); parent::initPageHeaderToolbar(); } public function initToolbar() { parent::initToolbar(); if (in_array($this->display, array('add', 'edit'))) $this->toolbar_btn = array_merge(array('save-and-stay' => array( 'short' => 'SaveAndStay', 'href' => '#', 'desc' => $this->l('Save and stay'), )), $this->toolbar_btn); } public function initFieldsForm() { $obj = $this->loadObject(true); $scene_image_types = ImageType::getImagesTypes('scenes'); $large_scene_image_type = null; $thumb_scene_image_type = null; foreach ($scene_image_types as $scene_image_type) { if ($scene_image_type['name'] == 'scene_default') $large_scene_image_type = $scene_image_type; if ($scene_image_type['name'] == 'm_scene_default') $thumb_scene_image_type = $scene_image_type; } $fields_form = array( 'legend' => array( 'title' => $this->l('Image Maps'), 'icon' => 'icon-picture', ), 'description' => '
'.$this->l('When a customer hovers over the image, a pop-up appears displaying a brief description of the product.').'
'.$this->l('The customer can then click to open the full product page.').'
'.$this->l('To achieve this, please define the \'mapping zone\' that, when hovered over, will display the pop-up.').'
'.$this->l('Left click with your mouse to draw the four-sided mapping zone, then release.').'
'.$this->l('Then begin typing the name of the associated product, and a list of products will appear.').'
'.$this->l('Click the appropriate product and then click OK. Repeat these steps for each mapping zone you wish to create.').'
'.$this->l('When you have finished mapping zones, click "Save Image Map."').'