* @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; } include_once(dirname(__FILE__).'/classes/StEasyVideoClass.php'); include_once(dirname(__FILE__).'/classes/StEasyVideoYuyanClass.php'); include_once(dirname(__FILE__).'/classes/EasyVideoBase.php'); class StEasyVideo extends Module { private $_html = ''; public $fields_form; public $fields_value; private $spacer_size = '5'; public $_prefix_st = 'ST_EASY_VIDEO_'; public $validation_errors = array(); private static $video_position = array(); private static $_bo_menu = array( array( 'class_name' => 'AdminParentStEasyVideo', 'name' => 'Product videos', 'tab' => 'IMPROVE', 'active' => 1, 'icon' => 'play_arrow', ), array( 'class_name' => 'AdminStEasyVideoLieBiao', 'name' => 'Videos', 'tab' => 'AdminParentStEasyVideo', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoProduct', 'name' => 'Product', 'tab' => 'AdminStEasyVideoLieBiao', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoCategory', 'name' => 'Category', 'tab' => 'AdminStEasyVideoLieBiao', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoManufacturer', 'name' => 'Brand', 'tab' => 'AdminStEasyVideoLieBiao', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoPeiZhi', 'name' => 'Settings', 'tab' => 'AdminParentStEasyVideo', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoSetting', 'name' => 'General', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoMiniature', 'name' => 'Miniature', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoMiniatureMobile', 'name' => 'Miniature on Mobile', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoProductSetting', 'name' => 'Product Page', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoProductMobileSetting', 'name' => 'Product Page (Mobile)', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), array( 'class_name' => 'AdminStEasyVideoQuickViewSetting', 'name' => 'Quick View', 'tab' => 'AdminStEasyVideoPeiZhi', 'active' => 1, ), ); public static $_appends = array( 0 => array( 'id' => 0, 'name' => 'append', ), 1 => array( 'id' => 1, 'name' => 'before', ), 2 => array( 'id' => 2, 'name' => 'after', ), 3 => array( 'id' => 3, 'name' => 'prepend', ), 4 => array( 'id' => 4, 'name' => 'parent append', ), 5 => array( 'id' => 5, 'name' => 'parent before', ), 6 => array( 'id' => 6, 'name' => 'parent after', ), 7 => array( 'id' => 7, 'name' => 'parent prepend', ), 8 => array( 'id' => 8, 'name' => 'parent parent append', ), 9 => array( 'id' => 9, 'name' => 'parent parent before', ), 10 => array( 'id' => 10, 'name' => 'parent parent after', ), 11 => array( 'id' => 11, 'name' => 'parent parent prepend', ), 12 => array( 'id' => 12, 'name' => 'html', ), ); public function __construct() { $this->name = 'steasyvideo'; $this->tab = 'front_office_features'; $this->version = '1.2.3'; $this->author = 'ST THEMES'; $this->module_key = '29305c4dbfaf92c4baf89df2dff337db'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Easy product video module'); $this->description = $this->l('Using a fancy way to display self-hosted videos or youtube videos for products.'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); self::$video_position = array( 1 => array( 'id' => 1, 'name' => $this->l('Top left') ), 2 => array( 'id' => 2, 'name' => $this->l('Top center') ), 3 => array( 'id' => 3, 'name' => $this->l('Top right') ), 4 => array( 'id' => 4, 'name' => $this->l('Center left') ), /*5 => array( 'id' => 5, 'name' => $this->l('Center center') ),*/ 6 => array( 'id' => 6, 'name' => $this->l('Center right') ), 7 => array( 'id' => 7, 'name' => $this->l('Bottom left') ), 8 => array( 'id' => 8, 'name' => $this->l('Bottom center') ), 9 => array( 'id' => 9, 'name' => $this->l('Bottom right') ), ); } public function install() { if (!parent::install() || !$this->installDB() || !$this->installTab() // || !$this->registerHook('actionProductDelete') to do || !$this->registerHook('displayHeader') || !$this->registerHook('displayProductListReviews') || !$this->registerHook('displayAdminProductsExtra') || !$this->registerHook('displayProductAdditionalInfo') || !$this->registerHook('displayBeforeBodyClosingTag') || !Configuration::updateValue($this->_prefix_st.'THEME_NAME', '') || !Configuration::updateValue($this->_prefix_st.'PLAYER_SKIN', 1) || !Configuration::updateValue($this->_prefix_st.'CUSTOM_CSS', '') || !Configuration::updateValue($this->_prefix_st.'YOUTUBE_API', 0) || !Configuration::updateValue($this->_prefix_st.'VIMEO_API', 1) || !Configuration::updateValue($this->_prefix_st.'BREAKPOINT', 0) || !Configuration::updateValue($this->_prefix_st.'MAXIMUM_TRIES', 10) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_HOVER_ELEMENT', '') ) { return false; } $languages = Language::getLanguages(); $play_video_text = array(); foreach ($languages as $language) { $play_video_text[$language['id_lang']] = 'Play'; } Configuration::updateValue($this->_prefix_st.'PLAY_VIDEO_TEXT', $play_video_text, true); $res = true; foreach (EasyVideoBase::$device as $kl => $ku) { if (!Configuration::updateValue($this->_prefix_st.'GALLERY_DISPLAY_'.$ku, $ku == 'DESKTOP' ? 1 : 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_APPEND_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_APPEND_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_LAYOUT_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_HIDE_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'GALLERY_CLOSE_VIDEO_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_TYPE_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_THUMBNAIL_TYPE_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_SLIDER_APPEND_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_SLIDER_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_THUMBNAIL_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_THUMBNAIL_ITEM_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_THUMBNAIL_APPEND_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_TEMPLATE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_IMAGE_TYPE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_TEMPLATE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_BUTTON_IMAGE_TYPE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_AUTOPLAY_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'GALLERY_MUTED_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'GALLERY_LOOP_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'GALLERY_CONTROLS_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'GALLERY_VIDEO_ZINDEX_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_PLAY_BTN_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_PLAY_BTN_OFFSET_X_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_PLAY_BTN_OFFSET_Y_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_PLAY_TEXT_COLOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_PLAY_TEXT_BG_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'GALLERY_CLOSE_BTN_POSITION_'.$ku, 2) || !Configuration::updateValue($this->_prefix_st.'GALLERY_CLOSE_BTN_OFFSET_X_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'GALLERY_CLOSE_BTN_OFFSET_Y_'.$ku, 0) ) { $res &= false; } if(!$this->installBtn(['GALLERY_PLAY', 'PLAY_ICON', 'GALLERY_CLOSE'], '_'.$ku)) $res &= false; if($kl=='quickview') continue; if(!Configuration::updateValue($this->_prefix_st.'MINIATURE_DISPLAY_'.$ku, 2) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_SELECTOR_'.$ku, '.js-product-miniature') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_APPEND_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_SELECTOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_APPEND_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_LAYOUT_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_HIDE_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_AUTOPLAY_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_MUTED_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_LOOP_'.$ku, 1) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_CONTROLS_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_TEMPLATE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_IMAGE_TYPE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_TEMPLATE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_BUTTON_IMAGE_TYPE_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_VIDEO_ZINDEX_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_POINTER_EVENTS_NONE_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_PLAY_BTN_POSITION_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_X_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_Y_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_PLAY_TEXT_COLOR_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_PLAY_TEXT_BG_'.$ku, '') || !Configuration::updateValue($this->_prefix_st.'MINIATURE_CLOSE_BTN_POSITION_'.$ku, 2) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_X_'.$ku, 0) || !Configuration::updateValue($this->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_Y_'.$ku, 0)) $res &= false; if(!$this->installBtn(['MINIATURE_PLAY', 'MINIATURE_CLOSE'], '_'.$ku)) $res &= false; } if (!$res) { return false; } if(!$this->installBtn(['PLAYER_PLAY', 'PLAYER_CLOSE'])) return false; return true; } public function installBtn($keys, $surfix=''){ $res = true; foreach ($keys as $key) { if (!Configuration::updateValue($this->_prefix_st.$key.'_BTN_COLOR'.$surfix, '') || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_BG'.$surfix, '') || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_BG_OPACITY'.$surfix, 1) || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_HOVER_COLOR'.$surfix, '') || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_HOVER_BG'.$surfix, '') || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_SIZE'.$surfix, 0) || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_ICON_SIZE'.$surfix, 0) || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_BORDER_COLOR'.$surfix, '') || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_BORDER_SIZE'.$surfix, 0) || !Configuration::updateValue($this->_prefix_st.$key.'_BTN_BORDER_RADIUS'.$surfix, '') ) { $res &= false; } } return $res; } public function installTab() { $result = true; foreach (self::$_bo_menu as $v) { $tab = new Tab(); $tab->active = (int)$v['active']; $tab->class_name = $v['class_name']; $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = $v['name']; } $tab->id_parent = (int)Tab::getIdFromClassName($v['tab']); $tab->module = $this->name; if (isset($v['icon'])) { $tab->icon = $v['icon']; } $result &= $tab->add(); } return $result; } public function uninstallTab() { $result = true; foreach (self::$_bo_menu as $v) { $id_tab = (int)Tab::getIdFromClassName($v['class_name']); if ($id_tab) { $tab = new Tab($id_tab); $result &= $tab->delete(); } else { $result = true; } } return $result; } private function installDB() { $res = Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_easy_video` ( `id_st_easy_video` int(11) unsigned NOT NULL AUTO_INCREMENT, `url` varchar(255) DEFAULT NULL, `thumbnail` varchar(255) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `position` int(10) unsigned NOT NULL DEFAULT 0, `active` tinyint(1) unsigned NOT NULL DEFAULT 1, `online_thumbnail` tinyint(1) unsigned NOT NULL DEFAULT 1, `loop` tinyint(1) unsigned NOT NULL DEFAULT 2, `muted` tinyint(1) unsigned NOT NULL DEFAULT 2, `autoplay` tinyint(1) unsigned NOT NULL DEFAULT 2, `id_product` TEXT DEFAULT NULL, `id_category` int(10) unsigned NOT NULL DEFAULT 0, `sub_category` tinyint(1) unsigned NOT NULL DEFAULT 1, `id_manufacturer` int(10) unsigned NOT NULL DEFAULT 0, `location` tinyint(1) unsigned NOT NULL DEFAULT 0, `ratio` varchar(255) DEFAULT NULL, PRIMARY KEY (`id_st_easy_video`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;'); $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_easy_video_shop` ( `id_st_easy_video` int(10) NOT NULL, `id_shop` int(11) NOT NULL, PRIMARY KEY (`id_st_easy_video`,`id_shop`), KEY `id_shop` (`id_shop`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'st_easy_video_yuyan` ( `id_st_easy_video` INT UNSIGNED NOT NULL, `id_lang` int(10) unsigned NOT NULL, PRIMARY KEY (`id_st_easy_video`, `id_lang`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); return $res; } private function uninstallDB() { return Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'st_easy_video`,`'._DB_PREFIX_.'st_easy_video_shop`,`'._DB_PREFIX_.'st_easy_video_yuyan`'); } public function uninstall() { // $this->_clearCache('steasyvideo.tpl'); if (!parent::uninstall() || !$this->uninstallDB() || !$this->uninstallTab()) { return false; } return true; } public function getContent() { Tools::redirectAdmin($this->context->link->getAdminLink('AdminStEasyVideoProduct')); } public function getPredefinedTemplate($id){ if(!$id) return ''; $content = $this->fetch('module:steasyvideo/views/templates/hook/predefined/'.$id.'.tpl'); if ($content && _PS_MODE_DEV_) { $pattern = "/\<\!--\s+(.+?)\s+--\>/s"; $content = preg_replace_callback($pattern, function($matches){ if (isset($matches[1]) && (int)$matches[1]) { return ''; } }, $content); $content = trim($content); } return $content; } public function hookDisplayHeader($params) { $st_easy_video = array( 'miniature' => array( 'current' => [], ), 'gallery' => array( 'current' => [], ), 'theme_name' => EasyVideoBase::getThemeName(), 'maximum_tries' => (int)Configuration::get($this->_prefix_st.'MAXIMUM_TRIES'), 'play_video_text' => html_entity_decode(Configuration::get($this->_prefix_st.'PLAY_VIDEO_TEXT', $this->context->language->id)), 'get_videos_url' => $this->context->link->getModuleLink('steasyvideo', 'ajax'), ); foreach (EasyVideoBase::$device as $kl => $ku) { $miniature_selector = Configuration::get($this->_prefix_st.'MINIATURE_SELECTOR_'.$ku); if(!$miniature_selector) $miniature_selector = '.js-product-miniature'; $gallery_video_selector = Configuration::get($this->_prefix_st.'GALLERY_VIDEO_SELECTOR_'.$ku); $gallery_video_selector = $gallery_video_selector ?: EasyVideoBase::getSelector('gallery_video_selector', $kl); $gallery_button_selector = Configuration::get($this->_prefix_st.'GALLERY_BUTTON_SELECTOR_'.$ku); $gallery_button_selector = $gallery_button_selector ?: EasyVideoBase::getSelector('gallery_button_selector', $kl); $gallery_type = Configuration::get($this->_prefix_st.'GALLERY_TYPE_'.$ku); $gallery_type = $gallery_type ?: EasyVideoBase::getSelector('gallery_type', $kl, 0); $gallery_thumbnail_type = Configuration::get($this->_prefix_st.'GALLERY_THUMBNAIL_TYPE_'.$ku); $gallery_thumbnail_type = $gallery_thumbnail_type ?: EasyVideoBase::getSelector('gallery_thumbnail_type', $kl, 0); $gallery_slider_selector = Configuration::get($this->_prefix_st.'GALLERY_SLIDER_SELECTOR_'.$ku); $gallery_slider_selector = $gallery_slider_selector ?: EasyVideoBase::getSelector('gallery_slider_selector', $kl); $gallery_thumbnail_selector = Configuration::get($this->_prefix_st.'GALLERY_THUMBNAIL_SELECTOR_'.$ku); $gallery_thumbnail_selector = $gallery_thumbnail_selector ?: EasyVideoBase::getSelector('gallery_thumbnail_selector', $kl); $gallery_thumbnail_item_selector = Configuration::get($this->_prefix_st.'GALLERY_THUMBNAIL_ITEM_SELECTOR_'.$ku); $gallery_thumbnail_item_selector = $gallery_thumbnail_item_selector ?: EasyVideoBase::getSelector('gallery_thumbnail_item_selector', $kl); $st_easy_video['gallery'][$kl] = array( 'display' => (int)Configuration::get($this->_prefix_st.'GALLERY_DISPLAY_'.$ku), 'video_selector' => $gallery_video_selector, 'video_append' => (int)Configuration::get($this->_prefix_st.'GALLERY_VIDEO_APPEND_'.$ku), 'video_position' => (int)Configuration::get($this->_prefix_st.'GALLERY_VIDEO_POSITION_'.$ku), 'button_selector' => $gallery_button_selector, 'button_append' => (int)Configuration::get($this->_prefix_st.'GALLERY_BUTTON_APPEND_'.$ku), 'button_position' => (int)Configuration::get($this->_prefix_st.'GALLERY_BUTTON_POSITION_'.$ku), 'button_layout' => (int)Configuration::get($this->_prefix_st.'GALLERY_BUTTON_LAYOUT_'.$ku), 'button_hide' => (int)Configuration::get($this->_prefix_st.'GALLERY_BUTTON_HIDE_'.$ku), 'close_video' => (int)Configuration::get($this->_prefix_st.'GALLERY_CLOSE_VIDEO_'.$ku), 'type' => (int)$gallery_type, 'thumbnail_type' => (int)$gallery_thumbnail_type, 'slider_append' => (int)Configuration::get($this->_prefix_st.'GALLERY_SLIDER_APPEND_'.$ku), 'thumbnail_append' => (int)Configuration::get($this->_prefix_st.'GALLERY_THUMBNAIL_APPEND_'.$ku), 'slider_selector' => $gallery_slider_selector, 'thumbnail_selector' => $gallery_thumbnail_selector, 'thumbnail_item_selector' => $gallery_thumbnail_item_selector, 'has_custom_button_template' => Configuration::get($this->_prefix_st.'GALLERY_BUTTON_TEMPLATE_'.$ku) != '', 'has_custom_video_template' => Configuration::get($this->_prefix_st.'GALLERY_VIDEO_TEMPLATE_'.$ku) != '', 'player_settings' => array( 'autoplay' => (int)Configuration::get($this->_prefix_st.'GALLERY_AUTOPLAY_'.$ku), 'muted' => (int)Configuration::get($this->_prefix_st.'GALLERY_MUTED_'.$ku), 'loop' => (int)Configuration::get($this->_prefix_st.'GALLERY_LOOP_'.$ku), 'controls' => (int)Configuration::get($this->_prefix_st.'GALLERY_CONTROLS_'.$ku), ), ); if($kl=='quickview') continue; $miniature_video_selector = Configuration::get($this->_prefix_st.'MINIATURE_VIDEO_SELECTOR_'.$ku); $miniature_video_selector = $miniature_video_selector ?: EasyVideoBase::getSelector('miniature_video_selector', $kl); $miniature_button_selector = Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_SELECTOR_'.$ku); $miniature_button_selector = $miniature_button_selector ?: EasyVideoBase::getSelector('miniature_button_selector', $kl); $st_easy_video['miniature'][$kl] = array( 'display' => (int)Configuration::get($this->_prefix_st.'MINIATURE_DISPLAY_'.$ku), 'selector' => $miniature_selector, 'video_selector' => $miniature_video_selector, 'video_append' => (int)Configuration::get($this->_prefix_st.'MINIATURE_VIDEO_APPEND_'.$ku), 'video_position' => (int)Configuration::get($this->_prefix_st.'MINIATURE_VIDEO_POSITION_'.$ku), 'button_selector' => $miniature_button_selector, 'button_append' => (int)Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_APPEND_'.$ku), 'button_position' => (int)Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_POSITION_'.$ku), 'button_layout' => (int)Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_LAYOUT_'.$ku), 'button_hide' => (int)Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_HIDE_'.$ku), 'video_template' => Configuration::get($this->_prefix_st.'MINIATURE_VIDEO_TEMPLATE_'.$ku), 'button_template' => Configuration::get($this->_prefix_st.'MINIATURE_BUTTON_TEMPLATE_'.$ku), 'player_settings' => array( 'autoplay' => (int)Configuration::get($this->_prefix_st.'MINIATURE_AUTOPLAY_'.$ku), 'muted' => (int)Configuration::get($this->_prefix_st.'MINIATURE_MUTED_'.$ku), 'loop' => (int)Configuration::get($this->_prefix_st.'MINIATURE_LOOP_'.$ku), 'controls' => (int)Configuration::get($this->_prefix_st.'MINIATURE_CONTROLS_'.$ku), ), ); if($kl=='desktop') $st_easy_video['miniature']['desktop']['hover_element'] = Configuration::get($this->_prefix_st.'MINIATURE_HOVER_ELEMENT'); } if (method_exists($this->context->controller, 'getProduct')) { $product = $this->context->controller->getProduct(); $video_templates = []; $button_templates = []; foreach (EasyVideoBase::$device as $kl => $ku) { if($id = EasyVideoBase::getSelector('gallery_video_template', $kl)){ $video_templates[$id] = $this->getPredefinedTemplate($id); } if($id = EasyVideoBase::getSelector('gallery_button_template', $kl)){ $button_templates[$id] = $this->getPredefinedTemplate($id); } } if ($video_data = EasyVideoBase::getVideosByProduct($product->id, [0, 1], 0, $product->link_rewrite, $video_templates, $button_templates)) { $st_easy_video = array_merge($st_easy_video, ['id_product' => $product->id, 'videos' => $video_data]); } } Media::addJsDef(array('steasyvideo' => $st_easy_video)); $this->context->controller->addJS($this->_path.'views/js/front.js'); $this->context->controller->addCSS($this->_path.'views/css/front.css'); $this->context->controller->addJS($this->_path.'views/js/video.min.js'); $this->context->controller->addCSS($this->_path.'views/css/video-js.css'); if (!Configuration::get($this->_prefix_st.'YOUTUBE_API')) { $this->context->controller->addJS($this->_path.'views/js/youtube.min.js'); } if (!Configuration::get($this->_prefix_st.'VIMEO_API')) { $this->context->controller->addJS($this->_path.'views/js/videojs-vimeo.umd.js'); } if ($skin = Configuration::get($this->_prefix_st.'PLAYER_SKIN')) { $this->context->controller->addCSS($this->_path.'views/css/skin-'.$skin.'.css'); } $template_file = 'module:steasyvideo/views/templates/hook/header.tpl'; $css = ''; if (!$this->isCached($template_file, $this->getCacheId())) { $breakpoint = (int)Configuration::get($this->_prefix_st.'BREAKPOINT'); if ($breakpoint) { $css .= '@media (max-width: '.$breakpoint.'px){#st_easy_video_device_mode:after {content: \'mobile\';}}'; } if (($bg_color = Configuration::get($this->_prefix_st.'BG_COLOR')) && Validate::isColor($bg_color)) { $bg_opacity = Configuration::get($this->_prefix_st.'BG_OPACITY'); if (!$bg_opacity || $bg_opacity == 1) { $css .= '.video-js .vjs-control-bar,.video-js .vjs-menu-button .vjs-menu-content{background-color: '.$bg_color.'; }'; } else { $bg_color_arr = self::hex2rgb($bg_color); if (is_array($bg_color_arr)) { if ($bg_opacity < 0 || $bg_opacity > 1) { $bg_opacity = 0.5; } $css .= '.video-js .vjs-control-bar,.video-js .vjs-menu-button .vjs-menu-content{background-color: rgba('.$bg_color_arr[0].','.$bg_color_arr[1].','.$bg_color_arr[2].','.$bg_opacity.'); }'; } } } if ($control_color = Configuration::get($this->_prefix_st.'CONTROL_COLOR')) { $css .= '.video-js{color: '.$control_color.'; }'; } if ($control_size = Configuration::get($this->_prefix_st.'CONTROL_SIZE')) { $css .= '.video-js .vjs-control-bar{font-size: '.$control_size.'px; }'; } if (($progress_bar_color = Configuration::get($this->_prefix_st.'PROGRESS_BAR_COLOR')) && Validate::isColor($progress_bar_color)) { $progress_bar_opacity = Configuration::get($this->_prefix_st.'PROGRESS_BAR_OPACITY'); if (!$progress_bar_opacity || $progress_bar_opacity == 1) { $css .= '.video-js .vjs-slider, .video-js .vjs-load-progress{background-color: '.$progress_bar_color.'; }'; } else { $progress_bar_color_arr = self::hex2rgb($progress_bar_color); if (is_array($progress_bar_color_arr)) { if ($progress_bar_opacity < 0 || $progress_bar_opacity > 1) { $progress_bar_opacity = 0.5; } $css .= '.video-js .vjs-slider, .video-js .vjs-load-progress{background-color: rgba('.$progress_bar_color_arr[0].','.$progress_bar_color_arr[1].','.$progress_bar_color_arr[2].','.$progress_bar_opacity.'); }'; } } } if ($progress_bar_highlight_color = Configuration::get($this->_prefix_st.'PROGRESS_BAR_HIGHLIGHT_COLOR')) { $css .= '.video-js .vjs-volume-level,.video-js .vjs-play-progress,.video-js .vjs-slider-bar{background: '.$progress_bar_highlight_color.'; }'; } $css .= $this->generateBtnCss([ ['prefix'=>'PLAYER_PLAY', 'normal'=>'.video-js .vjs-big-play-button', 'hover'=>'.video-js:hover .vjs-big-play-button', 'surfix'=>''], ['prefix'=>'PLAYER_CLOSE', 'normal'=>'.st_easy_video_close .vjs-icon-placeholder', 'hover'=>'.st_easy_video_close:hover .vjs-icon-placeholder', 'surfix'=>''], ]); foreach (EasyVideoBase::$device as $kl => $ku) { if($kl=='mobile' && !$breakpoint) continue; if($kl=='mobile') $css .= '@media (max-width: '.$breakpoint.'px){'; $gallery_video_zindex = (int)Configuration::get($this->_prefix_st.'GALLERY_VIDEO_ZINDEX_'.$ku); $gallery_video_zindex = $gallery_video_zindex ?: EasyVideoBase::getSelector('gallery_video_zindex', '', 1); if ($gallery_video_zindex) { $css .= $this->generateGalleryPrefix('.st_easy_video_box.st_easy_video_box_absolute', $kl).'{z-index: '.$gallery_video_zindex.';}'; $css .= $this->generateGalleryPrefix('.st_easy_video_btn', $kl).'{z-index: '.($gallery_video_zindex + 1).';}'; } if ($bg_color = Configuration::get($this->_prefix_st.'GALLERY_PLAYER_BG_'.$ku)) { $css .= $this->generateGalleryPrefix('.st_easy_video_box_1, .st_easy_video_box_1 .st_easy_video', $kl).'{background: '.$bg_color.';}'; } if ($width = Configuration::get($this->_prefix_st.'GALLERY_PLAYER_WIDTH_'.$ku)) { $css .= $this->generateGalleryPrefix('.st_easy_video_box_1', $kl).'{max-width: '.$width.'px;}'; } $css .= $this->generateGalleryPrefix('.st_easy_video_play_1.st_easy_video_btn_absolute', $kl).'{ '.$this->generateBtnPositionCss((int)Configuration::get($this->_prefix_st.'GALLERY_PLAY_BTN_POSITION_'.$ku), (int)Configuration::get($this->_prefix_st.'GALLERY_PLAY_BTN_OFFSET_X_'.$ku), (int)Configuration::get($this->_prefix_st.'GALLERY_PLAY_BTN_OFFSET_Y_'.$ku)).' }'; if ($play_text_color = Configuration::get($this->_prefix_st.'GALLERY_PLAY_TEXT_COLOR_'.$ku)) { $css .= $this->generateGalleryPrefix('.st_easy_video_play_1 .st_play_video_text', $kl).'{color: '.$play_text_color.'; }'; } if ($play_text_bg = Configuration::get($this->_prefix_st.'GALLERY_PLAY_TEXT_BG_'.$ku)) { $css .= $this->generateGalleryPrefix('.st_easy_video_play_1 .st_play_video_text', $kl).'{background-color: '.$play_text_bg.';padding: 0 3px 1px;}'; } $css .= $this->generateGalleryPrefix('.st_easy_video_close_1.st_easy_video_btn_absolute', $kl).'{ '.$this->generateBtnPositionCss((int)Configuration::get($this->_prefix_st.'GALLERY_CLOSE_BTN_POSITION_'.$ku), (int)Configuration::get($this->_prefix_st.'GALLERY_CLOSE_BTN_OFFSET_X_'.$ku), (int)Configuration::get($this->_prefix_st.'GALLERY_CLOSE_BTN_OFFSET_Y_'.$ku)).' }'; $play_icon_btn_size = (int)Configuration::get($this->_prefix_st.'PLAY_ICON_BTN_SIZE_'.$ku); if (!$play_icon_btn_size) { $play_icon_btn_size = 36; } $css .= $this->generateGalleryPrefix('.st_easy_video_play_icon.st_easy_video_btn_absolute', $kl).'{ '.$this->generateBtnPositionCss(0, floor($play_icon_btn_size / 2), floor($play_icon_btn_size / 2)).' }'; $css .= $this->generateBtnCss([ ['prefix'=>'GALLERY_PLAY', 'normal'=>$this->generateGalleryPrefix('.st_easy_video_play_1 .vjs-icon-placeholder', $kl), 'hover'=>$this->generateGalleryPrefix('.st_easy_video_play_1:hover .vjs-icon-placeholder', $kl), 'surfix'=>'_'.$ku], ['prefix'=>'GALLERY_CLOSE', 'normal'=>$this->generateGalleryPrefix('.st_easy_video_close_1 .vjs-icon-placeholder', $kl), 'hover'=>$this->generateGalleryPrefix('.st_easy_video_close_1:hover .vjs-icon-placeholder', $kl), 'surfix'=>'_'.$ku], ['prefix'=>'PLAY_ICON', 'normal'=>$this->generateGalleryPrefix('.st_easy_video_play_icon .vjs-icon-placeholder', $kl), 'hover'=>$this->generateGalleryPrefix('.st_easy_video_play_icon:hover .vjs-icon-placeholder', $kl), 'surfix'=>'_'.$ku], ]); if($kl=='quickview') continue; $miniature_video_zindex = (int)Configuration::get($this->_prefix_st.'MINIATURE_VIDEO_ZINDEX_'.$ku); $miniature_video_zindex = $miniature_video_zindex ?: EasyVideoBase::getSelector('miniature_video_zindex', '', 1); $miniature_selector = Configuration::get($this->_prefix_st.'MINIATURE_SELECTOR_'.$ku); if(!$miniature_selector) $miniature_selector = '.js-product-miniature'; if ($miniature_video_zindex) { $css .= $miniature_selector.' .st_easy_video_box.st_easy_video_box_absolute{z-index: '.$miniature_video_zindex.';}'; $css .= $miniature_selector.' .st_easy_video_btn{z-index: '.($miniature_video_zindex + 1).';}'; } if (Configuration::get($this->_prefix_st.'MINIATURE_POINTER_EVENTS_NONE_'.$ku)) { $css .= '.st_easy_video_box_0{pointer-events: none;}'; } if ($bg_color = Configuration::get($this->_prefix_st.'MINIATURE_PLAYER_BG_'.$ku)) { $css .= '.st_easy_video_box_0, .st_easy_video_box_0 .st_easy_video{background: '.$bg_color.';}'; } if ($width = Configuration::get($this->_prefix_st.'MINIATURE_PLAYER_WIDTH_'.$ku)) { $css .= '.st_easy_video_box_0{max-width: '.$width.'px;}'; } $css .= '.st_easy_video_play_0.st_easy_video_btn_absolute{ '.$this->generateBtnPositionCss((int)Configuration::get($this->_prefix_st.'MINIATURE_PLAY_BTN_POSITION_'.$ku), (int)Configuration::get($this->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_X_'.$ku), (int)Configuration::get($this->_prefix_st.'MINIATURE_PLAY_BTN_OFFSET_Y_'.$ku)).' }'; if ($play_text_color = Configuration::get($this->_prefix_st.'MINIATURE_PLAY_TEXT_COLOR_'.$ku)) { $css .= '.st_easy_video_play_0 .st_play_video_text{color: '.$play_text_color.'; }'; } if ($play_text_bg = Configuration::get($this->_prefix_st.'MINIATURE_PLAY_TEXT_BG_'.$ku)) { $css .= '.st_easy_video_play_0 .st_play_video_text{background-color: '.$play_text_bg.';padding: 0 3px 1px;}'; } $css .= '.st_easy_video_close_0.st_easy_video_btn_absolute{ '.$this->generateBtnPositionCss((int)Configuration::get($this->_prefix_st.'MINIATURE_CLOSE_BTN_POSITION_'.$ku), (int)Configuration::get($this->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_X_'.$ku), (int)Configuration::get($this->_prefix_st.'MINIATURE_CLOSE_BTN_OFFSET_Y_'.$ku)).' }'; $css .= $this->generateBtnCss([ ['prefix'=>'MINIATURE_PLAY', 'normal'=>'.st_easy_video_play_0 .vjs-icon-placeholder', 'hover'=>'.st_easy_video_play_0:hover .vjs-icon-placeholder', 'surfix'=>'_'.$ku], ['prefix'=>'MINIATURE_CLOSE', 'normal'=>'.st_easy_video_close_0 .vjs-icon-placeholder', 'hover'=>'.st_easy_video_close_1:hover .vjs-icon-placeholder', 'surfix'=>'_'.$ku], ]); if($kl=='mobile') $css .= '}'; } if ($custom_css = Configuration::get($this->_prefix_st.'CUSTOM_CSS')) { $css .= html_entity_decode(str_replace('ยค', '\\', $custom_css)); } } $this->context->smarty->assign('st_easy_video_css', $css); return $this->fetch($template_file, $this->getCacheId()); } public function generateGalleryPrefix($selector, $device){ if($device=='quickview'){ $selectors = explode(',', $selector); $selectors = array_map(function($value){ return '.modal.quickview '.$value.', .stsb_side_panel_show[data-elementor-type="quickview"] '.$value; }, $selectors); $selector = implode(',', $selectors); } return $selector; } public function generateBtnPositionCss($position, $offset_x, $offset_y) { $css = ''; switch ($position) { case 1: $css .= 'top: ' . $offset_y . 'px;left: ' . $offset_x . 'px;right: auto; bottom: auto;'; break; case 2: $css .= 'top: ' . $offset_y . 'px;left: auto;right: ' . $offset_x . 'px; bottom: auto;'; break; case 3: $css .= 'top: auto;left: auto;right: ' . $offset_x . 'px; bottom: ' . $offset_y . 'px;'; break; case 4: $css .= 'top: auto;left: ' . $offset_x . 'px;right: auto; bottom: ' . $offset_y . 'px;'; break; default: $css .= 'margin-left: -'.$offset_x.'px;margin-top: -'.$offset_y.'px;'; $css .= 'top: 50%;left: 50%;right: auto; bottom: auto;'; break; } return $css; } public function generateBtnCss($btns) { $css = ''; foreach ($btns as $v) { if ($play_btn_color = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_COLOR'.$v['surfix'])) { $css .= $v['normal'].'{color: '.$play_btn_color.'; }'; } if (($play_btn_bg = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BG'.$v['surfix'])) && Validate::isColor($play_btn_bg)) { $play_btn_opacity = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BG_OPACITY'.$v['surfix']); if (!$play_btn_opacity || $play_btn_opacity == 1) { $css .= $v['normal'].'{background-color: '.$play_btn_bg.'; }'; } else { $play_btn_bg_arr = self::hex2rgb($play_btn_bg); if (is_array($play_btn_bg_arr)) { if ($play_btn_opacity < 0 || $play_btn_opacity > 1) { $play_btn_opacity = 0.5; } $css .= $v['normal'].'{background-color: rgba('.$play_btn_bg_arr[0].','.$play_btn_bg_arr[1].','.$play_btn_bg_arr[2].','.$play_btn_opacity.'); }'; } } } if ($btn_hover_color = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_HOVER_COLOR'.$v['surfix'])) { $css .= $v['hover'].'{color:'.$btn_hover_color.';}'; } if (($btn_hover_bg = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_HOVER_BG'.$v['surfix'])) && Validate::isColor($btn_hover_bg)) { $btn_bg_opacity = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BG_OPACITY'.$v['surfix']); if (!$btn_bg_opacity || $btn_bg_opacity == 1) { $css .= $v['hover'].'{background-color: '.$btn_hover_bg.'; border-color:'.$btn_hover_bg.';}'; } else { $btn_hover_bg_arr = self::hex2rgb($btn_hover_bg); if (is_array($btn_hover_bg_arr)) { if ($btn_bg_opacity < 0 || $btn_bg_opacity > 1) { $btn_bg_opacity = 0.5; } $css .= $v['hover'].'{background-color: rgba('.$btn_hover_bg_arr[0].','.$btn_hover_bg_arr[1].','.$btn_hover_bg_arr[2].','.$btn_bg_opacity.'); border-color:: rgba('.$btn_hover_bg_arr[0].','.$btn_hover_bg_arr[1].','.$btn_hover_bg_arr[2].','.$btn_bg_opacity.');}'; } } } $play_btn_border_size = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BORDER_SIZE'.$v['surfix']); if ($play_btn_border_size || $play_btn_border_size === 0 || $play_btn_border_size === '0') { $css .= $v['normal'].'{border-width: '.$play_btn_border_size.'px; }'; } $play_btn_size = (int)Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_SIZE'.$v['surfix']); if ($play_btn_size) { $css .= $v['normal'].'{width: '.$play_btn_size.'px;height: '.$play_btn_size.'px;line-height: '.($play_btn_size - 2 * (int)$play_btn_border_size).'px; }'; } else { $play_btn_size = 36; } if ($play_btn_icon_size = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_ICON_SIZE'.$v['surfix'])) { $css .= $v['normal'].'{font-size: '.$play_btn_icon_size.'px; }'; } if ($play_btn_border_color = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BORDER_COLOR'.$v['surfix'])) { $css .= $v['normal'].'{border-color: '.$play_btn_border_color.'; }'; }; $play_btn_border_radius = Configuration::get($this->_prefix_st.$v['prefix'].'_BTN_BORDER_RADIUS'.$v['surfix']); if ($play_btn_border_radius || $play_btn_border_radius === 0 || $play_btn_border_radius === '0') { $css .= $v['normal'].'{border-radius: '.$play_btn_border_radius.'px; }'; } } return $css; } public function getButtonFiledsOptions($key, $surfix='') { return array( $this->_prefix_st.$key.'_BTN_COLOR'.$surfix => [ 'title' => $this->l('Color'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->_prefix_st.$key.'_BTN_COLOR'.$surfix, ], $this->_prefix_st.$key.'_BTN_BG'.$surfix => [ 'title' => $this->l('Background'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->_prefix_st.$key.'_BTN_BG'.$surfix, ], $this->_prefix_st.$key.'_BTN_BG_OPACITY'.$surfix => [ 'title' => $this->l('Background opacity'), 'validation' => 'isFloat', 'cast' => 'floatval', 'type' => 'text', 'desc' => $this->l('From 0.0 (fully transparent) to 1.0 (fully opaque).'), ], $this->_prefix_st.$key.'_BTN_HOVER_COLOR'.$surfix => [ 'title' => $this->l('Hover color'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->_prefix_st.$key.'_BTN_HOVER_COLOR'.$surfix, ], $this->_prefix_st.$key.'_BTN_HOVER_BG'.$surfix => [ 'title' => $this->l('Hover background'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->_prefix_st.$key.'_BTN_HOVER_BG'.$surfix, ], $this->_prefix_st.$key.'_BTN_SIZE'.$surfix => [ 'title' => $this->l('Size'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], $this->_prefix_st.$key.'_BTN_ICON_SIZE'.$surfix => [ 'title' => $this->l('Play icon size'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('pixels'), ], $this->_prefix_st.$key.'_BTN_BORDER_COLOR'.$surfix => [ 'title' => $this->l('Border color'), 'validation' => 'isColor', 'type' => 'color', 'size' => 5, 'name' => $this->_prefix_st.$key.'_BTN_BORDER_COLOR'.$surfix, ], $this->_prefix_st.$key.'_BTN_BORDER_SIZE'.$surfix => [ 'title' => $this->l('Border size'), 'validation' => 'isAnything', 'type' => 'text', 'suffix' => $this->l('pixels'), ], $this->_prefix_st.$key.'_BTN_BORDER_RADIUS'.$surfix => [ 'title' => $this->l('Border radius'), 'validation' => 'isAnything', 'type' => 'text', 'suffix' => $this->l('pixels'), ], ); } public function hookDisplayProductAdditionalInfo($params) { if (!isset($params['product']) || Tools::getValue('action') != 'quickview') { return ''; } $product = $this->context->controller->getProduct(); if ($video_data = EasyVideoBase::getVideosByProduct($product)) { $this->context->smarty->assign(array( 'video_data' => $video_data, 'id_product' => $product->id, 'id_product_attribute' => (int) Tools::getValue('id_product_attribute'), )); return $this->fetch('module:steasyvideo/views/templates/hook/forquickview.tpl'); } return ''; } /*public function hookDisplayAfterBodyOpeningTag($params) { return $this->display(__FILE__,'views/templates/hook/device_mode.tpl', $this->getCacheId()); }*/ public function hookDisplayBeforeBodyClosingTag($params) { return $this->fetch('module:steasyvideo/views/templates/hook/device_mode.tpl', $this->getCacheId()); } public function hookDisplayAdminProductsExtra($params) { $id_product = $params['id_product']; $this->smarty->assign(array( 'tiaozhuan_url' => $this->context->link->getAdminLink('AdminStEasyVideoProduct', true).'&addst_easy_video&ref=product&id_product='.$id_product, )); return $this->display(__FILE__, 'views/templates/admin/steasyvideo-pro.tpl'); } public static function hex2rgb($hex) { $hex = str_replace("#", "", $hex); if (strlen($hex) == 3) { $r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1)); $g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1)); $b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1)); } else { $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); } $rgb = array($r, $g, $b); return $rgb; } /*public function hookActionProductDelete($params) { if (isset($params['id_product']) && $params['id_product']) StEasyVideoClass::deleteByProductId($params['id_product']); return; }*/ /*public function hookFilterProductSearch($params) { if(Configuration::get($this->_prefix_st.'MINIATURE')){ if(isset($params['searchVariables']) && isset($params['searchVariables']['products'])) { foreach ($params['searchVariables']['products'] as $key => $product) { $videos = StEasyVideoClass::getProVideos($product['id_product'], $this->context->language->id); if(!empty($videos)){ $video = array_shift($videos); $params['searchVariables']['products'][$key]['steasyvideoo'] = $video['url']; } } } } }*/ public function hookDisplayProductListReviews($params) { /*$miniature = (int)Configuration::get($this->_prefix_st.'MINIATURE'); if(!$miniature) return '';*/ if (!isset($params['product'])) { return ''; } if(defined('_TB_VERSION_')){ $this->context->smarty->assign('easy_video_product', [ 'id_product' => $params['product']['id_product'], 'id_manufacturer' => $params['product']['id_manufacturer'], 'link_rewrite' => $params['product']['link_rewrite'], ]); return $this->display(__FILE__, 'views/templates/hook/miniature_tb.tpl'); }else{ $this->context->smarty->assign('easy_video_product', [ 'id_product' => $params['product']->id_product, 'id_manufacturer' => $params['product']->id_manufacturer, 'link_rewrite' => $params['product']->link_rewrite, ]); return $this->display(__FILE__, 'views/templates/hook/miniature.tpl'); } } }