* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ if (!defined('_PS_VERSION_')) { exit; } class AdminStEasyVideoMiniatureBaseController extends ModuleAdminController { protected $contr = ''; public function __construct() { $this->bootstrap = true; parent::__construct(); $image_types_arr = array( array('id' => '','name' => $this->l('Use the predefined value.'),) ); $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $k => $imageType) { if (Tools::substr($imageType['name'], -3) == '_2x') { continue; } $image_types_arr[] = array('id' => $imageType['name'], 'name' => $imageType['name'].'('.$imageType['width'].'x'.$imageType['height'].')'); } $display_options = array( 0 => $this->l('No'), 1 => $this->l('Buttons'), 2 => $this->l('Video players'), 3 => $this->l('Play on hover'), 4 => $this->l('Show buttons, play on hover'), ); if($this->contr=='MOBILE') unset($display_options[3], $display_options[4]); $this->fields_options = array( 'general' => array( 'title' => $this->l('General Settings'), 'icon' => 'icon-cogs', 'fields' => array( $this->module->_prefix_st.'MINIATURE_DISPLAY_'.$this->contr => array( 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('How to display videos'), 'validation' => 'isUnsignedInt', 'choices' => $display_options, ), $this->module->_prefix_st.'MINIATURE_VIDEO_SELECTOR_'.$this->contr => array( 'type' => 'text', 'title' => $this->l('Video selector'), 'validation' => 'isAnything', 'desc' => $this->l('A slector inside the miniature.'), ), $this->module->_prefix_st.'MINIATURE_VIDEO_APPEND_'.$this->contr => [ 'title' => $this->l('How to add videos'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id', 'list' => $this->module::$_appends, ], $this->module->_prefix_st.'MINIATURE_VIDEO_POSITION_'.$this->contr => [ 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('How to display players'), 'validation' => 'isUnsignedInt', 'choices' => array( 0 => $this->l('Display on an element (Position: absolute)'), 1 => $this->l('Normal document flow (Position: static)'), ), ], $this->module->_prefix_st.'MINIATURE_BUTTON_SELECTOR_'.$this->contr => array( 'type' => 'text', 'title' => $this->l('Button selector'), 'validation' => 'isAnything', 'desc' => $this->l('A slector inside the miniature.'), ), $this->module->_prefix_st.'MINIATURE_BUTTON_APPEND_'.$this->contr => [ 'title' => $this->l('How to add buttons'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id', 'list' => $this->module::$_appends, ], $this->module->_prefix_st.'MINIATURE_BUTTON_POSITION_'.$this->contr => [ 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('How to display buttons'), 'validation' => 'isUnsignedInt', 'choices' => array( 0 => $this->l('Display on an element (Position: absolute)'), 1 => $this->l('Normal document flow (Position: static)'), ), ], $this->module->_prefix_st.'MINIATURE_BUTTON_LAYOUT_'.$this->contr => array( 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('Play button layout'), 'validation' => 'isUnsignedInt', 'choices' => array( 0 => $this->l('Icon'), 1 => $this->l('Text'), 2 => $this->l('Icon + text horizontally'), 3 => $this->l('Icon + text vertically'), ), ), $this->module->_prefix_st.'MINIATURE_BUTTON_HIDE_'.$this->contr => array( 'title' => $this->l('Hide the play button when videos start play'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, ), $this->module->_prefix_st.'MINIATURE_SELECTOR_'.$this->contr => array( 'type' => 'text', 'title' => $this->l('Miniature selector'), 'validation' => 'isAnything', 'desc' => $this->l('The default value .js-product-miniature works for amolst all sites'), ), $this->module->_prefix_st.'MINIATURE_VIDEO_TEMPLATE_'.$this->contr => [ 'title' => $this->l('Video template'), 'validation' => 'isAnything', 'type' => 'textarea', 'cols' => 30, 'rows' => 5, 'desc' => array( $this->l('They are four variables you can use: @placeholder_url@, @placeholder_width@, @placeholder_height@, and @thumbnail_url@.'), $this->l('Disable the "Use HTMLPurifier Library" setting on the "BO>Preferences>General" page, otherwise the value won\'t be saved.'), ), ], $this->module->_prefix_st.'MINIATURE_VIDEO_IMAGE_TYPE_'.$this->contr => [ 'title' => $this->l('Placeholder image for videos'), 'validation' => 'isAnything', 'required' => false, 'type' => 'select', 'list' => $image_types_arr, 'identifier' => 'id', ], $this->module->_prefix_st.'MINIATURE_BUTTON_TEMPLATE_'.$this->contr => [ 'title' => $this->l('Button template'), 'validation' => 'isAnything', 'type' => 'textarea', 'cols' => 30, 'rows' => 5, 'desc' => array( $this->l('They are four variables you can use: @placeholder_url@, @placeholder_width@, @placeholder_height@, and @thumbnail_url@.'), $this->l('Disable the "Use HTMLPurifier Library" setting on the "BO>Preferences>General" page, otherwise the value won\'t be saved.'), ), ], $this->module->_prefix_st.'MINIATURE_BUTTON_IMAGE_TYPE_'.$this->contr => [ 'title' => $this->l('Placeholder image for buttons'), 'validation' => 'isAnything', 'required' => false, 'type' => 'select', 'list' => $image_types_arr, 'identifier' => 'id', ], $this->module->_prefix_st.'MINIATURE_VIDEO_ZINDEX_'.$this->contr => [ 'title' => $this->l('Z-index:'), 'validation' => 'isUnsignedId', 'required' => false, 'cast' => 'intval', 'type' => 'text', ], $this->module->_prefix_st.'MINIATURE_POINTER_EVENTS_NONE_'.$this->contr => array( 'title' => $this->l('Link to the product page'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, 'desc' => $this->l('In most cases, clicking on the video goes to the product page without enabling this setting. But if that\'s not your case, then enable this setting may help.'), ), ), 'submit' => array('title' => $this->l('Save all')), ), 'player' => array( 'title' => $this->l('Player'), 'icon' => 'icon-cogs', 'fields' => array( $this->module->_prefix_st.'MINIATURE_AUTOPLAY_'.$this->contr => array( 'title' => $this->l('Autoplay'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, 'desc' => $this->l('When videos are displayed in video palyers'), ), $this->module->_prefix_st.'MINIATURE_MUTED_'.$this->contr => array( 'title' => $this->l('Muted'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, 'desc' => $this->l('Only muted videos can be autoplay'), ), $this->module->_prefix_st.'MINIATURE_LOOP_'.$this->contr => array( 'title' => $this->l('Loop'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, ), $this->module->_prefix_st.'MINIATURE_CONTROLS_'.$this->contr => array( 'title' => $this->l('Show controls'), 'validation' => 'isBool', 'type' => 'bool', 'is_bool' => true, ), ), 'submit' => array('title' => $this->l('Save all')), ), 'player_style' => array( 'title' => $this->l('Player style'), 'icon' => 'icon-cogs', 'fields' => array( $this->module->_prefix_st.'MINIATURE_PLAYER_BG_'.$this->contr => [ 'title' => $this->l('Color'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->module->_prefix_st.'MINIATURE_PLAYER_BG_'.$this->contr, ], ), 'submit' => array('title' => $this->l('Save all')), ), 'button_style' => array( 'title' => $this->l('Play button style'), 'icon' => 'icon-cogs', 'fields' => array( $this->module->_prefix_st.'MINIATURE_PLAY_BTN_POSITION_'.$this->contr => [ 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('Position'), 'validation' => 'isUnsignedInt', 'choices' => array( 0 => $this->l('Center'), 1 => $this->l('Top left'), 2 => $this->l('Top right'), 3 => $this->l('Bottom right'), 4 => $this->l('Bottom left'), ), ], $this->module->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_X_'.$this->contr => [ 'title' => $this->l('Offset x'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], $this->module->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_Y_'.$this->contr => [ 'title' => $this->l('Offset y'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], ) + $this->module->getButtonFiledsOptions('MINIATURE_PLAY', '_'.$this->contr) + array( $this->module->_prefix_st.'MINIATURE_PLAY_TEXT_COLOR_'.$this->contr => [ 'title' => $this->l('"Play" text color'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->module->_prefix_st.'MINIATURE_PLAY_TEXT_COLOR_'.$this->contr, ], $this->module->_prefix_st.'MINIATURE_PLAY_TEXT_BG_'.$this->contr => [ 'title' => $this->l('"Play" text background'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->module->_prefix_st.'MINIATURE_PLAY_TEXT_BG_'.$this->contr, ], ), 'submit' => array('title' => $this->l('Save all')), ), 'close_style' => array( 'title' => $this->l('Close button style'), 'icon' => 'icon-cogs', 'fields' => array( $this->module->_prefix_st.'MINIATURE_CLOSE_BTN_POSITION_'.$this->contr => [ 'type' => 'radio', 'cast' => 'intval', 'title' => $this->l('Position'), 'validation' => 'isUnsignedInt', 'choices' => array( 0 => $this->l('Center'), 1 => $this->l('Top left'), 2 => $this->l('Top right'), 3 => $this->l('Bottom right'), 4 => $this->l('Bottom left'), ), ], $this->module->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_X_'.$this->contr => [ 'title' => $this->l('Offset x'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], $this->module->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_Y_'.$this->contr => [ 'title' => $this->l('Offset y'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], ) + $this->module->getButtonFiledsOptions('MINIATURE_CLOSE', '_'.$this->contr), 'submit' => array('title' => $this->l('Save all')), ), ); } public function postProcess() { parent::postProcess(); } public function setMedia($isNewTheme = false) { parent::setMedia($isNewTheme); $this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin.js?108'); } }