Files
redline.com.pl/modules/steasyvideo/controllers/admin/AdminStEasyVideoGalleryController.php
Jacek Pyziak eacf500d18 feat: Add YouTube video support and update admin templates
- Introduced a new YouTube tech integration in `youtube.min.js` for enhanced video playback.
- Created new admin template files for managing video settings, including `index.php` and `steasyvideo-pro.tpl`.
- Updated hook templates (`device_mode.tpl`, `forquickview.tpl`, `header.tpl`, `miniature.tpl`, `miniature_tb.tpl`, and predefined templates) to include video functionality.
- Implemented caching headers in several PHP files to improve performance.
- Ensured all new templates include proper licensing information and copyright notices.
2025-05-23 19:27:41 +02:00

422 lines
22 KiB
PHP

<?php
/**
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @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 AdminStEasyVideoGalleryController 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'].')');
}
$selector_desc = $this->contr == 'QUICKVIEW' ? $this->l('In most cases, selectors in quickview should start with .modal.quickview') : ($this->contr == 'DESKTOP' ? $this->l('In most cases, selectors start with .page-product:not(.modal-open) to avoid conflict with selectors in quickview window.') : '');
$play_icon_fields = $this->module->getButtonFiledsOptions('PLAY_ICON');
unset($play_icon_fields[$this->module->_prefix_st.'PLAY_ICON_BTN_HOVER_COLOR_'.$this->contr], $play_icon_fields[$this->module->_prefix_st.'PLAY_ICON_BTN_HOVER_BG_'.$this->contr]);
$this->fields_options = array(
'general' => array(
'title' => $this->l('General Settings'),
'icon' => 'icon-cogs',
'fields' => array(
$this->module->_prefix_st.'GALLERY_DISPLAY_'.$this->contr => array(
'type' => 'radio',
'title' => $this->l('How to display vidoes'),
'validation' => 'isUnsignedInt',
'choices' => array(
0 => $this->l('No'),
1 => $this->l('Buttons'),
2 => $this->l('Videos'),
3 => $this->l('Add videos to a slider'),
4 => $this->l('Add buttons to a thumbnail slider, videos show out when the buttons are clicked'),
5 => $this->l('Add videos to a slider, add buttons to a synchronized thumbnail slider'),
6 => $this->l('Videos, add buttons to a thumbnail slider.'),// panda transformer gallery image scrolling
7 => $this->l('A button on the first image, and a video icon on the first item of thumbnail slider'),
),
),
$this->module->_prefix_st.'GALLERY_VIDEO_SELECTOR_'.$this->contr => array(
'type' => 'text',
'title' => $this->l('Video selector'),
'validation' => 'isAnything',
'desc' => $selector_desc,
),
$this->module->_prefix_st.'GALLERY_VIDEO_APPEND_'.$this->contr => [
'title' => $this->l('How to add'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id',
'list' => $this->module::$_appends,
],
$this->module->_prefix_st.'GALLERY_VIDEO_POSITION_'.$this->contr => [
'type' => 'radio',
'cast' => 'intval',
'title' => $this->l('How to video player'),
'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.'GALLERY_BUTTON_SELECTOR_'.$this->contr => array(
'type' => 'text',
'title' => $this->l('Button selector'),
'validation' => 'isAnything',
'desc' => $selector_desc,
),
$this->module->_prefix_st.'GALLERY_BUTTON_APPEND_'.$this->contr => [
'title' => $this->l('How to add'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id',
'list' => $this->module::$_appends,
],
$this->module->_prefix_st.'GALLERY_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.'GALLERY_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.'GALLERY_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.'GALLERY_TYPE_'.$this->contr => array(
'type' => 'radio',
'title' => $this->l('Slider'),
'validation' => 'isUnsignedInt',
'choices' => array(
0 => $this->l('Use the predefined value.'),
1 => $this->l('Swiper'),
2 => $this->l('Slick slider'),
3 => $this->l('Owl carrousel 2'),
4 => $this->l('Owl carrousel 1'),
// 5 => $this->l('PrestaShop classic theme - Scrollbox'),
),
'desc' => $this->l('Select the first option if you are using one of these themes: Classic theme, Panda theme, Transformer theme and Warehouse theme.'),
),
$this->module->_prefix_st.'GALLERY_SLIDER_APPEND_'.$this->contr => [
'title' => $this->l('How to add'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id',
'list' => array(
0 => array(
'id' => 0,
'name' => '1',
),
1 => array(
'id' => 1,
'name' => '2',
),
2 => array(
'id' => 2,
'name' => '3',
),
100 => array(
'id' => 100,
'name' => 'End',
),
),
],
$this->module->_prefix_st.'GALLERY_SLIDER_SELECTOR_'.$this->contr => array(
'type' => 'text',
'title' => $this->l('Gallery selector'),
'validation' => 'isAnything',
'desc' => $this->l('Leave it empty to use the predefined value.').$selector_desc,
),
$this->module->_prefix_st.'GALLERY_THUMBNAIL_TYPE_'.$this->contr => array(
'type' => 'radio',
'title' => $this->l('Thumbnail slider'),
'validation' => 'isUnsignedInt',
'choices' => array(
0 => $this->l('Use the predefined value.'),
1 => $this->l('Swiper'),
2 => $this->l('Slick slider'),
3 => $this->l('Owl carrousel 2'),
4 => $this->l('Owl carrousel 1'),
5 => $this->l('PrestaShop classic theme - Scrollbox'),
),
'desc' => $this->l('Select the first option if you are using one of these themes: Classic theme, Panda theme, Transformer theme and Warehouse theme.'),
),
$this->module->_prefix_st.'GALLERY_THUMBNAIL_APPEND_'.$this->contr => [
'title' => $this->l('How to add'),
'cast' => 'intval',
'type' => 'select',
'identifier' => 'id',
'list' => array(
0 => array(
'id' => 0,
'name' => '1',
),
1 => array(
'id' => 1,
'name' => '2',
),
2 => array(
'id' => 2,
'name' => '3',
),
100 => array(
'id' => 100,
'name' => 'End',
),
),
],
$this->module->_prefix_st.'GALLERY_THUMBNAIL_SELECTOR_'.$this->contr => array(
'type' => 'text',
'title' => $this->l('Thumbnail selector'),
'validation' => 'isAnything',
'desc' => $this->l('Leave it empty to use the predefined value.').$selector_desc,
),
$this->module->_prefix_st.'GALLERY_THUMBNAIL_ITEM_SELECTOR_'.$this->contr => array(
'type' => 'text',
'title' => $this->l('Thumbnail item selector'),
'validation' => 'isAnything',
'desc' => $this->l('Leave it empty to use the predefined value.').$selector_desc,
),
$this->module->_prefix_st.'GALLERY_CLOSE_VIDEO_'.$this->contr => array(
'type' => 'radio',
'cast' => 'intval',
'title' => $this->l('Close video'),
'validation' => 'isUnsignedInt',
'choices' => array(
0 => $this->l('Default'),
1 => $this->l('When a thumbnail item is clicked.'),
2 => $this->l('When a thumbnail item is on hover.'),
),
),
$this->module->_prefix_st.'GALLERY_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.'GALLERY_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.'GALLERY_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.'GALLERY_BUTTON_IMAGE_TYPE_'.$this->contr => [
'title' => $this->l('Placeholder image for buttons'),
'validation' => 'isAnything',
'required' => false,
'type' => 'select',
'list' => $image_types_arr,
'identifier' => 'id',
],
),
'submit' => array('title' => $this->l('Save all')),
),
'player' => array(
'title' => $this->l('Player'),
'icon' => 'icon-cogs',
'fields' => array(
$this->module->_prefix_st.'GALLERY_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.'GALLERY_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.'GALLERY_LOOP_'.$this->contr => array(
'title' => $this->l('Loop'),
'validation' => 'isBool',
'type' => 'bool',
'is_bool' => true,
),
$this->module->_prefix_st.'GALLERY_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.'GALLERY_PLAYER_BG_'.$this->contr => [
'title' => $this->l('Color'),
'validation' => 'isColor',
'type' => 'color',
'size' => 5,
'name' => $this->module->_prefix_st.'GALLERY_PLAYER_BG_'.$this->contr,
],
$this->module->_prefix_st.'GALLERY_VIDEO_ZINDEX_'.$this->contr => [
'title' => $this->l('Z-index'),
'validation' => 'isUnsignedId',
'required' => false,
'cast' => 'intval',
'type' => 'text',
],
),
'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.'GALLERY_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.'GALLERY_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.'GALLERY_PLAY_BTN_OFFSET_Y_'.$this->contr => [
'title' => $this->l('Offset y'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('pixels'),
],
) + $this->module->getButtonFiledsOptions('GALLERY_PLAY', '_'.$this->contr) + array(
$this->module->_prefix_st.'GALLERY_PLAY_TEXT_COLOR_'.$this->contr => [
'title' => $this->l('Play" text color'),
'validation' => 'isColor',
'type' => 'color',
'size' => 5,
'name' => $this->module->_prefix_st.'GALLERY_PLAY_TEXT_COLOR_'.$this->contr,
],
$this->module->_prefix_st.'GALLERY_PLAY_TEXT_BG_'.$this->contr => [
'title' => $this->l('Play" text background'),
'validation' => 'isColor',
'type' => 'color',
'size' => 5,
'name' => $this->module->_prefix_st.'GALLERY_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.'GALLERY_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.'GALLERY_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.'GALLERY_CLOSE_BTN_OFFSET_Y_'.$this->contr => [
'title' => $this->l('Offset y'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('pixels'),
],
) + $this->module->getButtonFiledsOptions('GALLERY_CLOSE', '_'.$this->contr),
'submit' => array('title' => $this->l('Save all')),
),
'play_icon_style' => array(
'title' => $this->l('Play icon style'),
'icon' => 'icon-cogs',
'fields' => $play_icon_fields,
'submit' => array('title' => $this->l('Save all')),
),
);
}
public function postProcess()
{
parent::postProcess();
}
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addCss(_MODULE_DIR_.$this->module->name.'/views/css/admin.css');
$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin.js?108');
}
}