This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,97 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\View\AbstractView;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\Header\BlockHeader;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\Header\MenuItem;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\TopBarMain\BlockTopBarMain;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Forms\Button\BlockButtonSave;
use Nextend\SmartSlider3\Application\Admin\Layout\LayoutDefault;
use Nextend\SmartSlider3\Application\Admin\TraitAdminUrl;
use Nextend\SmartSlider3\Generator\GeneratorFactory;
abstract class AbstractViewSettings extends AbstractView {
use TraitAdminUrl;
protected $active = 'general';
/** @var LayoutDefault */
protected $layout;
/**
* @var BlockHeader
*/
protected $blockHeader;
public function display() {
$this->layout = new LayoutDefault($this);
$this->layout->addBreadcrumb(n2_('Settings'), 'ssi_16 ssi_16--cog', $this->getUrlSettingsDefault());
$this->displayTopBar();
$this->displayHeader();
}
protected function displayTopBar() {
$topBar = new BlockTopBarMain($this);
$buttonSave = new BlockButtonSave($this);
$buttonSave->addClass('n2_button--inactive');
$buttonSave->addClass('n2_settings_save');
$topBar->addPrimaryBlock($buttonSave);
$this->layout->setTopBar($topBar->toHTML());
}
protected function displayHeader() {
$this->blockHeader = new BlockHeader($this);
$this->blockHeader->setHeading(n2_('Settings'));
$general = new MenuItem(n2_('General'));
$general->setUrl($this->getUrlSettingsDefault());
$general->setActive($this->active == 'general');
$this->blockHeader->addMenuItem($general);
$framework = new MenuItem(n2_('Framework'));
$framework->setUrl($this->getUrlSettingsFramework());
$framework->setActive($this->active == 'framework');
$this->blockHeader->addMenuItem($framework);
$fonts = new MenuItem(n2_('Fonts'));
$fonts->setUrl($this->getUrlSettingsFonts());
$fonts->setActive($this->active == 'fonts');
$this->blockHeader->addMenuItem($fonts);
$itemDefaults = new MenuItem(n2_('Layer defaults'));
$itemDefaults->setUrl($this->getUrlSettingsItemDefaults());
$itemDefaults->setActive($this->active == 'itemDefaults');
$this->blockHeader->addMenuItem($itemDefaults);
foreach (GeneratorFactory::getGenerators() as $generator) {
if ($generator->hasConfiguration()) {
$generators = new MenuItem(n2_('Generators'));
$generators->setUrl($this->getUrlSettingsGenerator($generator->getName()));
$this->blockHeader->addMenuItem($generators);
break;
}
}
$this->addHeaderActions();
$this->layout->addContentBlock($this->blockHeader);
}
protected function addHeaderActions() {
}
}

View File

@ -0,0 +1,178 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Cache\AbstractCache;
use Nextend\Framework\Cache\CacheImage;
use Nextend\Framework\Controller\Admin\AdminAjaxController;
use Nextend\Framework\Data\Data;
use Nextend\Framework\Filesystem\Filesystem;
use Nextend\Framework\Font\FontSettings;
use Nextend\Framework\Model\StorageSectionManager;
use Nextend\Framework\Notification\Notification;
use Nextend\Framework\Request\Request;
use Nextend\Framework\Settings;
use Nextend\SmartSlider3\Application\Admin\TraitAdminUrl;
use Nextend\SmartSlider3\Application\Model\ModelGenerator;
use Nextend\SmartSlider3\Application\Model\ModelSettings;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
class ControllerAjaxSettings extends AdminAjaxController {
use TraitAdminUrl;
public function actionDefault() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$settingsModel = new ModelSettings($this);
if ($settingsModel->save()) {
$this->invalidateSliderCache();
Notification::success(n2_('Saved and slider cache invalidated.'));
}
$this->response->redirect($this->getUrlSettingsDefault());
}
public function actionFramework() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$data = Request::$POST->getVar('global');
if (is_array($data)) {
Settings::setAll($data);
$this->invalidateSliderCache();
Notification::success(n2_('Saved and slider cache invalidated.'));
}
$this->response->redirect($this->getUrlSettingsFramework());
}
public function actionFonts() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$fonts = Request::$REQUEST->getVar('fonts', false);
if ($fonts) {
FontSettings::store($fonts);
$this->invalidateSliderCache();
Notification::success(n2_('Saved and slider cache invalidated.'));
}
$this->response->redirect($this->getUrlSettingsFonts());
}
public function actionItemDefaults() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$settingsModel = new ModelSettings($this);
$settingsModel->saveDefaults(Request::$REQUEST->getVar('defaults', array()));
$this->response->redirect($this->getUrlSettingsItemDefaults());
}
public function actionGeneratorConfigure() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$group = Request::$REQUEST->getVar('group');
$this->validateVariable($group, 'group');
$generatorModel = new ModelGenerator($this);
$generatorGroup = $generatorModel->getGeneratorGroup($group);
$configuration = $generatorGroup->getConfiguration();
$configuration->addData(Request::$POST->getVar('generator'));
$this->response->redirect($this->getUrlSettingsGenerator($generatorGroup->getName()));
}
public function actionDismissUpgradePro() {
$this->validateToken();
$storage = StorageSectionManager::getStorage('smartslider');
$storage->set('free', 'upgrade-pro', 1);
$this->response->respond();
}
public function actionRated() {
$this->validateToken();
$storage = StorageSectionManager::getStorage('smartslider');
$storage->set('free', 'rated', 1);
$this->response->respond();
}
public function actionDismissNewsletterSampleSliders() {
$this->validateToken();
$storage = StorageSectionManager::getStorage('smartslider');
$storage->set('free', 'dismissNewsletterSampleSliders', 1);
$this->response->respond();
}
public function actionDismissNewsletterDashboard() {
$this->validateToken();
$storage = StorageSectionManager::getStorage('smartslider');
$storage->set('free', 'dismissNewsletterDashboard', 1);
$this->response->respond();
}
public function actionSubscribed() {
$this->validateToken();
$storage = StorageSectionManager::getStorage('smartslider');
$storage->set('free', 'subscribeOnImport', 1);
$this->response->respond();
}
private function invalidateSliderCache() {
$slidersModel = new ModelSliders($this);
$slidersModel->invalidateCache();
}
public function actionClearCache() {
$this->validateToken();
$this->validatePermission('smartslider_config');
$formData = new Data(Request::$POST->getVar('clear_cache', array()));
if ($formData->get('delete-image-cache')) {
$imageCachePath = CacheImage::getStorage()
->getPath('slider/cache', '', 'image');
if (Filesystem::existsFolder($imageCachePath) && Filesystem::is_writable($imageCachePath)) {
Filesystem::deleteFolder($imageCachePath);
}
}
$slidersModel = new ModelSliders($this);
foreach ($slidersModel->_getAll() as $slider) {
$slidersModel->refreshCache($slider['id']);
}
AbstractCache::clearGroup('n2-ss-0');
AbstractCache::clearGroup('combined');
AbstractCache::clearAll();
Notification::success(n2_('Cache cleared.'));
Request::redirect($this->getUrlSettingsDefault());
}
}

View File

@ -0,0 +1,99 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Notification\Notification;
use Nextend\Framework\Request\Request;
use Nextend\Framework\Settings;
use Nextend\SmartSlider3\Application\Admin\AbstractControllerAdmin;
use Nextend\SmartSlider3\Application\Model\ModelGenerator;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
class ControllerSettings extends AbstractControllerAdmin {
public function actionDefault() {
if ($this->validatePermission('smartslider_config')) {
$view = new ViewSettingsGeneral($this);
$view->display();
}
}
public function actionFramework() {
if ($this->canDo('smartslider_config')) {
$data = Request::$POST->getVar('global');
if (is_array($data)) {
if ($this->validateToken()) {
Settings::setAll($data);
$this->invalidateSliderCache();
Notification::success(n2_('Saved and slider cache invalidated.'));
}
$this->redirect($this->getUrlSettingsFramework());
}
$view = new ViewSettingsFramework($this);
$view->display();
}
}
public function actionFonts() {
if ($this->canDo('smartslider_config')) {
$view = new ViewSettingsFonts($this);
$view->display();
}
}
public function actionItemDefaults() {
if ($this->validatePermission('smartslider_config')) {
$view = new ViewSettingsItemDefaults($this);
$view->display();
}
}
public function actionGeneratorConfigure() {
if ($this->validatePermission('smartslider_config')) {
$view = new ViewGeneratorConfigure($this);
$generatorModel = new ModelGenerator($this);
$group = Request::$REQUEST->getVar('group');
$generatorGroup = $generatorModel->getGeneratorGroup($group);
$configuration = $generatorGroup->getConfiguration();
$view->setGeneratorGroup($generatorGroup);
$view->setConfiguration($configuration);
$view->display();
}
}
public function actionClearCache() {
if ($this->validatePermission('smartslider_config')) {
$view = new ViewSettingsClearCache($this);
$view->display();
}
}
private function invalidateSliderCache() {
$slidersModel = new ModelSliders($this);
$slidersModel->invalidateCache();
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
/**
* @var $this ViewSettingsClearCache
*/
?>
<form id="n2_slider_clear_cache_form" action="<?php echo esc_url($this->getAjaxUrlSettingsClearCache()); ?>" method="post">
<?php
$this->renderForm();
?>
</form>
<script>
document.querySelector('.n2_slider_clear_cache').addEventListener('click', function () {
document.getElementById('n2_slider_clear_cache_form').submit();
});
</script>

View File

@ -0,0 +1,19 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Asset\Js\Js;
/**
* @var $this ViewSettingsFonts
*/
JS::addInline('new _N2.SettingsFonts();');
?>
<form id="n2-ss-form-settings-fonts" method="post" action="<?php echo esc_url($this->getAjaxUrlSettingsFonts()); ?>">
<?php
$this->renderForm();
?>
</form>

View File

@ -0,0 +1,17 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Asset\Js\Js;
/**
* @var $this ViewSettingsFramework
*/
JS::addInline('new _N2.SettingsFramework();');
?>
<form id="n2-ss-form-settings-framework" method="post" action="<?php echo esc_url($this->getAjaxUrlSettingsFramework()); ?>">
<?php
$this->renderForm();
?>
</form>

View File

@ -0,0 +1,19 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Asset\Js\Js;
/**
* @var $this ViewSettingsGeneral
*/
JS::addInline('new _N2.SettingsGeneral();');
?>
<form id="n2-ss-form-settings-general" action="<?php echo esc_url($this->getAjaxUrlSettingsDefault()); ?>" method="post">
<?php
$this->renderForm();
?>
</form>

View File

@ -0,0 +1,20 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Asset\Js\Js;
/**
* @var ViewGeneratorConfigure $this
*/
JS::addInline('new _N2.GeneratorConfigure();');
?>
<form id="n2-ss-form-generator-configure" action="<?php echo esc_url($this->getAjaxUrlSettingsGenerator($this->getGeneratorGroup()
->getName())); ?>" method="post">
<?php
$this->renderForm();
?>
</form>
<div style="height: 200px"></div>

View File

@ -0,0 +1,19 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Asset\Js\Js;
/**
* @var $this ViewSettingsItemDefaults
*/
JS::addInline('new _N2.SettingsItemDefaults();');
?>
<form id="n2-ss-form-settings-item-defaults" action="<?php echo esc_url($this->getAjaxUrlSettingsItemDefaults()); ?>" method="post">
<?php
$this->renderForm();
?>
</form>

View File

@ -0,0 +1,99 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\Header\BlockHeader;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\Header\MenuItem;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\TopBarMain\BlockTopBarMain;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Forms\Button\BlockButtonSave;
use Nextend\SmartSlider3\Generator\AbstractGeneratorGroup;
use Nextend\SmartSlider3\Generator\AbstractGeneratorGroupConfiguration;
use Nextend\SmartSlider3\Generator\GeneratorFactory;
class ViewGeneratorConfigure extends AbstractViewSettings {
protected $active = 'generator';
/** @var AbstractGeneratorGroup */
protected $generatorGroup;
/** @var AbstractGeneratorGroupConfiguration */
protected $configuration;
public function display() {
parent::display();
$this->layout->addBreadcrumb($this->generatorGroup->getLabel(), '');
$this->layout->addContent($this->render('GeneratorConfigure'));
$this->layout->render();
}
protected function displayTopBar() {
$topBar = new BlockTopBarMain($this);
$buttonSave = new BlockButtonSave($this);
$buttonSave->addClass('n2_button--inactive');
$buttonSave->addClass('n2_generator_configuration_save');
$topBar->addPrimaryBlock($buttonSave);
$this->layout->setTopBar($topBar->toHTML());
}
protected function displayHeader() {
$this->blockHeader = new BlockHeader($this);
$this->blockHeader->setHeading(n2_('Generators'));
foreach (GeneratorFactory::getGenerators() as $generatorGroup) {
if ($generatorGroup->hasConfiguration()) {
$button = new MenuItem($generatorGroup->getLabel());
$button->setActive($this->generatorGroup === $generatorGroup);
$button->setUrl($this->getUrlSettingsGenerator($generatorGroup->getName()));
$this->blockHeader->addMenuItem($button);
}
}
$this->layout->addContentBlock($this->blockHeader);
}
/**
* @return AbstractGeneratorGroup
*/
public function getGeneratorGroup() {
return $this->generatorGroup;
}
/**
* @param AbstractGeneratorGroup $generatorGroup
*/
public function setGeneratorGroup($generatorGroup) {
$this->generatorGroup = $generatorGroup;
}
/**
* @return mixed
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* @param mixed $configuration
*/
public function setConfiguration($configuration) {
$this->configuration = $configuration;
}
public function renderForm() {
$this->configuration->render($this);
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Cache\CacheImage;
use Nextend\Framework\Form\Container\ContainerTable;
use Nextend\Framework\Form\Element\Message\Notice;
use Nextend\Framework\Form\Element\OnOff;
use Nextend\Framework\Form\Element\Token;
use Nextend\Framework\Form\Form;
use Nextend\Framework\View\AbstractView;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Core\TopBarMain\BlockTopBarMain;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Forms\Button\BlockButton;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Forms\Button\BlockButtonBack;
use Nextend\SmartSlider3\Application\Admin\Layout\LayoutDefault;
use Nextend\SmartSlider3\Application\Admin\TraitAdminUrl;
class ViewSettingsClearCache extends AbstractView {
use TraitAdminUrl;
/**
* @var LayoutDefault
*/
protected $layout;
public function display() {
$this->layout = new LayoutDefault($this);
$this->layout->addBreadcrumb(n2_('Settings'), 'ssi_16 ssi_16--cog', $this->getUrlSettingsDefault());
$this->layout->addBreadcrumb(n2_('Clear cache'), '', $this->getUrlSettingsClearCache());
$this->displayTopBar();
$this->displayHeader();
$this->layout->render();
}
protected function displayTopBar() {
$topBar = new BlockTopBarMain($this);
$buttonClearCache = new BlockButton($this);
$buttonClearCache->addClass('n2_slider_clear_cache');
$buttonClearCache->setLabel(n2_('Clear cache'));
$buttonClearCache->setBig();
$buttonClearCache->setGreen();
$topBar->addPrimaryBlock($buttonClearCache);
$buttonBack = new BlockButtonBack($this);
$buttonBack->setUrl($this->getUrlSettingsDefault());
$topBar->addPrimaryBlock($buttonBack);
$this->layout->setTopBar($topBar->toHTML());
}
protected function displayHeader() {
$this->layout->addContent($this->render('ClearCache'));
}
public function renderForm() {
$form = new Form($this, 'clear_cache');
new Token($form->getFieldsetHidden());
$settings = new ContainerTable($form->getContainer(), 'clear-cache-options', n2_('Clear cache options'));
$row1 = $settings->createRow('clear-cache');
new OnOff($row1, 'delete-image-cache', n2_('Delete resized image cache'), 0);
$instructions = sprintf(n2_('If enabled the following folder will be %1$spermanently deleted%2$s: %3$s'), '<b>', '</b>', CacheImage::getStorage()
->getPath('slider/cache', '', 'image'));
new Notice($row1, 'instructions', n2_('Instruction'), $instructions);
$form->render();
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Font\FontSettings;
use Nextend\Framework\Font\FontSources;
use Nextend\Framework\Form\Container\ContainerTable;
use Nextend\Framework\Form\Element\Message\Notice;
use Nextend\Framework\Form\Element\Text;
use Nextend\Framework\Form\Element\Textarea;
use Nextend\Framework\Form\Element\Token;
use Nextend\Framework\Form\Form;
class ViewSettingsFonts extends AbstractViewSettings {
protected $active = 'fonts';
public function display() {
parent::display();
$this->layout->addBreadcrumb(n2_('Fonts'), '');
$this->layout->addContent($this->render('Fonts'));
$this->layout->render();
}
public function renderForm() {
$form = new Form($this, 'fonts');
new Token($form->getFieldsetHidden());
$form->loadArray(FontSettings::getData()
->toArray());
$form->loadArray(FontSettings::getPluginsData()
->toArray());
$table = new ContainerTable($form->getContainer(), 'fonts', n2_('Configuration'));
$row1 = $table->createRow('fonts-1');
$instruction = sprintf(n2_('Here you can configure the default font your layers have, and the dropdown list of the fonts. Google Fonts are recognized automatically, but you can use your own custom fonts, too. %1$sLearn how to do that.%2$s'), '<a href="https://smartslider.helpscoutdocs.com/article/1828-using-your-own-fonts" target="_blank">', '</a>');
new Notice($row1, 'instructions', n2_('Instruction'), $instruction);
$row2 = $table->createRow('fonts-2');
new Text($row2, 'default-family', n2_('Default family'), '', array(
'tipLabel' => n2_('Default family'),
'tipDescription' => n2_('This font family is used for the newly added layers.')
));
$row3 = $table->createRow('fonts-1');
new Textarea($row3, 'preset-families', n2_('Preset font families'), '', array(
'width' => 200,
'height' => 300,
'tipLabel' => n2_('Preset font families'),
'tipDescription' => n2_('These font families appear in the dropdown list.')
));
$fountSources = FontSources::getFontSources();
foreach ($fountSources as $fountSource) {
$table = new ContainerTable($form->getContainer(), $fountSource->getName(), $fountSource->getLabel());
$fountSource->renderFields($table);
}
$form->render();
}
}

View File

@ -0,0 +1,81 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Form\Container\ContainerTable;
use Nextend\Framework\Form\Element\OnOff;
use Nextend\Framework\Form\Element\Select;
use Nextend\Framework\Form\Element\Text;
use Nextend\Framework\Form\Element\Token;
use Nextend\Framework\Form\Form;
use Nextend\Framework\Settings;
class ViewSettingsFramework extends AbstractViewSettings {
protected $active = 'framework';
public function display() {
parent::display();
$this->layout->addBreadcrumb(n2_('Framework'), '');
$this->layout->addContent($this->render('Framework'));
$this->layout->render();
}
public function renderForm() {
$values = Settings::getAll();
$form = new Form($this, 'global');
$form->loadArray($values);
$table = new ContainerTable($form->getContainer(), 'framework', n2_('Framework'));
$row1 = $table->createRow('framework-1');
new Token($row1);
new OnOff($row1, 'protocol-relative', n2_('Use protocol-relative URL'), 1, array(
'tipLabel' => n2_('Use protocol-relative URL'),
'tipDescription' => n2_('Loads the URLs without a http or https protocol.')
));
new OnOff($row1, 'header-preload', n2_('Header preload'), 0, array(
'tipLabel' => n2_('Header preload'),
'tipDescription' => n2_('If the slider is an important part of your site, tell the browser to preload its files.'),
'tipLink' => 'https://smartslider.helpscoutdocs.com/article/1785-framework#header-preload'
));
new OnOff($row1, 'force-english-backend', n2_('English UI'), 0, array(
'tipLabel' => n2_('English UI'),
'tipDescription' => n2_('You can keep using Smart Slider 3 in English, even if your backend isn\'t in English.')
));
new OnOff($row1, 'frontend-accessibility', n2_('Improved frontend accessibility'), 1, array(
'tipLabel' => n2_('Improved frontend accessibility'),
'tipDescription' => n2_('Keeps the clicked element (like a button) in focus unless the focus is changed by clicking away.')
));
$table = new ContainerTable($form->getContainer(), 'javascript', 'JavaScript');
$row1 = $table->createRow('javascript-1');
new Text($row1, 'scriptattributes', n2_('Script attributes'), '');
$table = new ContainerTable($form->getContainer(), 'css', 'CSS');
$row1 = $table->createRow('css-1');
new OnOff($row1, 'async-non-primary-css', n2_('Async non-primary CSS'), 0, array(
'tipLabel' => n2_('Async non-primary CSS'),
'tipDescription' => n2_('Google Fonts, icon and lightbox CSS are loaded in a non-blocking way. Disable if you see missing icons, fonts or styles.')
));
$form->render();
}
}

View File

@ -0,0 +1,185 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Form\Container\ContainerTable;
use Nextend\Framework\Form\Element\Breakpoint;
use Nextend\Framework\Form\Element\Hidden;
use Nextend\Framework\Form\Element\Message\Notice;
use Nextend\Framework\Form\Element\MixedField;
use Nextend\Framework\Form\Element\OnOff;
use Nextend\Framework\Form\Element\Select;
use Nextend\Framework\Form\Element\Text;
use Nextend\Framework\Form\Element\Text\Number;
use Nextend\Framework\Form\Element\Text\TextAutoComplete;
use Nextend\Framework\Form\Element\Textarea;
use Nextend\Framework\Form\Element\Token;
use Nextend\Framework\Form\Form;
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Forms\Button\BlockButton;
use Nextend\SmartSlider3\Application\Admin\TraitAdminUrl;
use Nextend\SmartSlider3\Platform\Joomla\JoomlaShim;
use Nextend\SmartSlider3\Settings;
class ViewSettingsGeneral extends AbstractViewSettings {
use TraitAdminUrl;
protected $active = 'general';
const defaults = array(
'desktop-large-portrait' => 1440,
'desktop-large-landscape' => 1440,
'tablet-large-portrait' => 1300,
'tablet-large-landscape' => 1300,
'tablet-portrait' => 1199,
'tablet-landscape' => 1199,
'mobile-large-portrait' => 900,
'mobile-large-landscape' => 1050,
'mobile-portrait' => 700,
'mobile-landscape' => 900,
);
public function display() {
parent::display();
$this->layout->addContent($this->render('General'));
$this->layout->render();
}
protected function addHeaderActions() {
$buttonClearCache = new BlockButton($this);
$buttonClearCache->setBig();
$buttonClearCache->setLabel(n2_('Clear cache'));
$buttonClearCache->setUrl($this->getUrlSettingsClearCache());
$this->blockHeader->addAction($buttonClearCache->toHTML());
}
public function renderForm() {
$data = Settings::getAll();
$form = new Form($this, 'settings');
$form->loadArray($data);
$table = new ContainerTable($form->getContainer(), 'general', n2_('General settings'));
$row1 = $table->createRow('general-1');
new Token($row1);
new Hidden($row1, 'slidersOrder2', '');
new Hidden($row1, 'slidersOrder2Direction', '');
new OnOff($row1, 'autoupdatecheck', n2_('Automatic update check'), 1);
new OnOff($row1, 'slide-as-file', n2_('Alternative save slide'), 0, array(
'tipLabel' => n2_('Alternative save slide'),
'tipDescription' => n2_('If you experience problems during the save this option might solve them.')
));
new OnOff($row1, 'preview-new-window', n2_('Preview in new window'), 0);
$row3 = $table->createRow('general-3');
new OnOff($row3, 'youtube-privacy-enhanced', n2_('YouTube and Vimeo privacy enhanced mode'), 0);
new Number($row3, 'smooth-scroll-speed', n2_('Smooth scroll speed'), 400, array(
'wide' => 5,
'unit' => 'ms'
));
$row4 = $table->createRow('general-4');
new Textarea($row4, 'external-css-files', n2_('Editor - additional CSS files'), '', array(
'width' => 300,
'tipLabel' => n2_('Editor - additional CSS files'),
'tipDescription' => n2_('You can call your own CSS files to our backend, for example, to be able to use custom fonts. Write each URL to a new line.'),
'tipLink' => 'https://smartslider.helpscoutdocs.com/article/1783-general#editor-additional-css-files'
));
$table = new ContainerTable($form->getContainer(), 'general-wordpress', n2_('WordPress settings'));
$rowWordPress = $table->createRow('general-wordpress-1');
new OnOff($rowWordPress, 'editor-icon', n2_('Show button in TinyMCE editor'), 1);
new OnOff($rowWordPress, 'wp-adminbar', n2_('Show in admin bar'), 1);
new OnOff($rowWordPress, 'yoast-sitemap', n2_('YOAST SEO sitemap - add images'), 1);
new Number($rowWordPress, 'wordpress-widget-areas', n2_('Create widget area'), 1, array(
'unit' => n2_('widget area(s)'),
'wide' => 4,
'min' => 0,
'tipLabel' => n2_('Create widget area'),
'tipDescription' => n2_('Creates new widget areas which you can place to your theme for easy publishing.')
));
$rowWordPress2 = $table->createRow('general-wordpress-2');
new OnOff($rowWordPress2, 'wp-ajax-iframe-slider', n2_('Use iframe in AJAX calls'), 0, array(
'tipLabel' => n2_('Use iframe in AJAX calls'),
'tipDescription' => n2_('Loads the slider using an iframe when the page is loaded via AJAX to avoid problems.')
));
$table = new ContainerTable($form->getContainer(), 'breakpoints-table', n2_('Breakpoints'));
$instructionRow = $table->createRow('breakpoints-row-instruction');
$instructions = n2_('Breakpoints define the browser width in pixel when the slider switches to a different device.') . ' ' . n2_('At each slider you can override the global breakpoints with local values.');
new Notice($instructionRow, 'breakpoints-instructions', n2_('Instruction'), $instructions);
new Text\HiddenText($table->getFieldsetLabel(), 'responsive-screen-width-tablet-portrait', false, self::defaults['tablet-portrait']);
new Text\HiddenText($table->getFieldsetLabel(), 'responsive-screen-width-tablet-portrait-landscape', false, self::defaults['tablet-landscape']);
new Text\HiddenText($table->getFieldsetLabel(), 'responsive-screen-width-mobile-portrait', false, self::defaults['mobile-portrait']);
new Text\HiddenText($table->getFieldsetLabel(), 'responsive-screen-width-mobile-portrait-landscape', false, self::defaults['mobile-landscape']);
$rowBreakpoints = $table->createRow('breakpoints-row-1');
new Breakpoint($rowBreakpoints, 'breakpoints', array(
'tabletportrait-portrait' => 'settingsresponsive-screen-width-tablet-portrait',
'tabletportrait-landscape' => 'settingsresponsive-screen-width-tablet-portrait-landscape',
'mobileportrait-portrait' => 'settingsresponsive-screen-width-mobile-portrait',
'mobileportrait-landscape' => 'settingsresponsive-screen-width-mobile-portrait-landscape'
));
$table = new ContainerTable($form->getContainer(), 'focus-offset', n2_('Focus offset'));
$row1 = $table->createRow('focus-offset-1');
new Notice($row1, 'focus-instructions', n2_('Instruction'), n2_('This option is used at the full page layout to decrease the slider height. The "Scroll to slider" option also uses this option to determine where to scroll the slider.'));
$row2 = $table->createRow('focus-offset-2');
$row2HeightOffsetValue = '#wpadminbar';
new TextAutoComplete($row2, 'responsive-focus-top', n2_('Top'), $row2HeightOffsetValue, array(
'style' => 'width:200px;',
'values' => array($row2HeightOffsetValue)
));
new Text($row2, 'responsive-focus-bottom', n2_('Bottom'), '', array(
'style' => 'width:200px;'
));
$table = new ContainerTable($form->getContainer(), 'translate-url', n2_('Translate url'));
$row1 = $table->createRow('translate-url-1');
new Notice($row1, 'translate-url-instruction', n2_('Instruction'), n2_('You can change the frontend URL our assets are loading from. It can be useful after moving to a new domain.'));
$row2 = $table->createRow('translate-url-2');
$translateUrl = new MixedField($row2, 'translate-url', false, '|*|');
new Text($translateUrl, 'translate-url-1', n2_('From'), '', array(
'style' => 'width:200px;',
'tipLabel' => n2_('From'),
'tipDescription' => n2_('The old URL you want to replace. E.g. https://oldsite.com/')
));
new Text($translateUrl, 'translate-url-2', n2_('To'), '', array(
'style' => 'width:200px;',
'tipLabel' => n2_('To'),
'tipDescription' => n2_('The new URL you want to use. E.g. https://newsite.com')
));
$form->render();
echo '<input name="namespace" value="default" type="hidden">';
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace Nextend\SmartSlider3\Application\Admin\Settings;
use Nextend\Framework\Form\Element\Token;
use Nextend\Framework\Form\Form;
use Nextend\SmartSlider3\Renderable\Item\ItemFactory;
class ViewSettingsItemDefaults extends AbstractViewSettings {
protected $active = 'itemDefaults';
public function display() {
parent::display();
$this->layout->addBreadcrumb(n2_('Layer defaults'), '');
$this->layout->addContent($this->render('ItemDefaults'));
$this->layout->render();
}
public function renderForm() {
$form = new Form($this, 'defaults');
new Token($form->getFieldsetHidden());
foreach (ItemFactory::getItems() as $item) {
$item->globalDefaultItemFontAndStyle($form->getContainer());
}
$form->render();
}
}