first
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractChooser;
|
||||
use Nextend\SmartSlider3\Slider\SliderType\Simple\SliderTypeSimple;
|
||||
|
||||
class BackgroundAnimation extends AbstractChooser {
|
||||
|
||||
|
||||
protected function addScript() {
|
||||
|
||||
Js::addStaticGroup(SliderTypeSimple::getAssetsPath() . '/dist/smartslider-backgroundanimation.min.js', 'smartslider-backgroundanimation');
|
||||
|
||||
Js::addInline('new _N2.FormElementAnimationManager("' . $this->fieldID . '", "backgroundanimationManager");');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
use Nextend\Framework\Form\Element\IconTab;
|
||||
|
||||
class BackgroundImage extends IconTab {
|
||||
|
||||
protected $relatedAttribute = 'slide-background-type';
|
||||
|
||||
protected function fetchElement() {
|
||||
$this->options = array(
|
||||
'image' => 'ssi_16 ssi_16--image',
|
||||
'color' => 'ssi_16 ssi_16--color'
|
||||
);
|
||||
|
||||
|
||||
$this->tooltips = array(
|
||||
'image' => n2_('Image'),
|
||||
'video' => n2_('Video'),
|
||||
'color' => n2_('Color')
|
||||
);
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Columns extends AbstractFieldHidden {
|
||||
|
||||
protected $hasTooltip = false;
|
||||
|
||||
public function __construct($insertAt, $name = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, false, $default, $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
Js::addInline('new _N2.FormElementColumns("' . $this->fieldID . '");');
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_columns'
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_columns__content'
|
||||
), '') . Html::tag('div', array(
|
||||
'class' => 'n2_field_columns__add',
|
||||
'data-n2tip' => n2_('Add column')
|
||||
), '<div class="ssi_16 ssi_16--plus"></div>') . parent::fetchElement());
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Container\ContainerSubform;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
use Nextend\Framework\Url\Url;
|
||||
use Nextend\SmartSlider3\Widget\Group\AbstractWidgetGroup;
|
||||
|
||||
class ControlTypePicker extends AbstractFieldHidden {
|
||||
|
||||
protected $hasTooltip = false;
|
||||
|
||||
protected $options = array();
|
||||
|
||||
protected $plugins = array();
|
||||
|
||||
protected $ajaxUrl = '';
|
||||
|
||||
/**
|
||||
* @var ContainerSubform
|
||||
*/
|
||||
protected $containerSubform;
|
||||
|
||||
/** @var AbstractWidgetGroup */
|
||||
private $widgetGroup;
|
||||
|
||||
/**
|
||||
* SubFormIcon constructor.
|
||||
*
|
||||
* @param TraitFieldset $insertAt
|
||||
* @param string $name
|
||||
* @param ContainerInterface $container
|
||||
* @param string $ajaxUrl
|
||||
* @param AbstractWidgetGroup $widgetGroup
|
||||
* @param string $default
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name, $container, $ajaxUrl, $widgetGroup, $default = '', $parameters = array()) {
|
||||
|
||||
$this->name = $name;
|
||||
$this->widgetGroup = $widgetGroup;
|
||||
|
||||
$this->ajaxUrl = $ajaxUrl;
|
||||
|
||||
parent::__construct($insertAt, $name, false, $default, $parameters);
|
||||
|
||||
$this->initOptions();
|
||||
|
||||
$this->containerSubform = new ContainerSubform($container, $name . '-subform');
|
||||
|
||||
$this->getCurrentPlugin($this->getValue())
|
||||
->renderFields($this->containerSubform);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
$html = '<div class="n2_field_control_type_picker">';
|
||||
foreach ($this->options as $key => $option) {
|
||||
$html .= '<div class="n2_field_control_type_picker__item" data-controltype="' . $key . '">';
|
||||
$html .= '<img alt="" src="' . Url::pathToUri($option['path']) . '">';
|
||||
$html .= '<div class="n2_field_control_type_picker__selected_marker"><i class="ssi_16 ssi_16--check"></i></div>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
$html .= parent::fetchElement();
|
||||
$html .= '</div>';
|
||||
|
||||
Js::addInline('new _N2.FormElementControlTypePicker( "' . $this->fieldID . '", ' . json_encode(array(
|
||||
'ajaxUrl' => $this->ajaxUrl,
|
||||
'target' => $this->containerSubform->getId(),
|
||||
'originalValue' => $this->getValue()
|
||||
)) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
protected function getCurrentPlugin($value) {
|
||||
|
||||
if (!isset($this->plugins[$value])) {
|
||||
list($value) = array_keys($this->plugins);
|
||||
}
|
||||
|
||||
return $this->plugins[$value];
|
||||
}
|
||||
|
||||
private function initOptions() {
|
||||
|
||||
$this->plugins = $this->widgetGroup->getWidgets();
|
||||
|
||||
foreach ($this->plugins as $name => $type) {
|
||||
$this->options[$name] = array(
|
||||
'path' => $type->getSubFormImagePath()
|
||||
);
|
||||
}
|
||||
if (count($this->options) == 1) {
|
||||
$this->parent->hide();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Text\Number;
|
||||
use Nextend\Framework\Form\Element\Text\NumberSlider;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class DatePicker extends AbstractFieldHidden implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
protected $rowClass = 'n2_field_mixed ';
|
||||
|
||||
protected $onOffLabel = '';
|
||||
|
||||
protected $hasOnOff = true;
|
||||
|
||||
private $dateTimeFields = array();
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = false, $default = '', $parameters = array()) {
|
||||
|
||||
$this->onOffLabel = $label;
|
||||
|
||||
parent::__construct($insertAt, $name, false, $default, $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
$this->addDatePicker();
|
||||
|
||||
$subElements = array();
|
||||
foreach ($this->dateTimeFields as $dateTimeField) {
|
||||
|
||||
$dateTimeField->setExposeName(false);
|
||||
$subElements[] = $dateTimeField->getID();
|
||||
}
|
||||
|
||||
$html = '';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
$element->setExposeName(false);
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementDatePicker("' . $this->fieldID . '", ' . json_encode($subElements) . ', ' . json_encode($this->hasOnOff) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
return $this->parent->decorateElement($element);
|
||||
}
|
||||
|
||||
protected function addDatePicker() {
|
||||
|
||||
$defaultParts = explode(' ', $this->defaultValue);
|
||||
$defaultDateParts = explode('-', $defaultParts[0]);
|
||||
$defaultTimeParts = explode(':', $defaultParts[1]);
|
||||
$defaultArray = array_merge($defaultDateParts, $defaultTimeParts);
|
||||
|
||||
$valueParts = explode(' ', $this->getValue());
|
||||
$valueDateParts = explode('-', $valueParts[0]);
|
||||
$valueTimeParts = explode(':', $valueParts[1]);
|
||||
$valueArray = array_merge($valueDateParts, $valueTimeParts);
|
||||
|
||||
$valueArray = $valueArray + $defaultArray;
|
||||
|
||||
$dateGroup = new Grouping($this, $this->name . '-date');
|
||||
|
||||
$controlName = $this->getControlName();
|
||||
if ($this->hasOnOff) {
|
||||
$this->dateTimeFields[] = new OnOff($dateGroup, $this->name . '-enable', $this->onOffLabel, 0, array(
|
||||
'relatedFieldsOn' => array(
|
||||
$controlName . $this->name . '-year',
|
||||
$controlName . $this->name . '-month',
|
||||
$controlName . $this->name . '-day',
|
||||
$controlName . $this->name . '-hour',
|
||||
$controlName . $this->name . '-minute'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
//YEAR
|
||||
$this->dateTimeFields[] = new Number($dateGroup, $this->name . '-year', n2_('Year'), $valueArray[0], array(
|
||||
'wide' => 4,
|
||||
'min' => 1970,
|
||||
'max' => 9999
|
||||
));
|
||||
|
||||
//MONTH
|
||||
$months = array();
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$formattedValue = sprintf("%02d", $i);
|
||||
$months[$formattedValue] = $formattedValue;
|
||||
}
|
||||
$this->dateTimeFields[] = new Select($dateGroup, $this->name . '-month', n2_('Month'), $valueArray[1], array(
|
||||
'options' => $months
|
||||
));
|
||||
|
||||
//DAY
|
||||
$days = array();
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
$formattedValue = sprintf("%02d", $i);
|
||||
$days[$formattedValue] = $formattedValue;
|
||||
}
|
||||
|
||||
$this->dateTimeFields[] = new Select($dateGroup, $this->name . '-day', n2_('Day'), $valueArray[2], array(
|
||||
'options' => $days
|
||||
));
|
||||
|
||||
$timeGroup = new Grouping($this, $this->name . '-time');
|
||||
|
||||
//HOUR
|
||||
$hours = array();
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$formattedValue = sprintf("%02d", $i);
|
||||
$hours[$formattedValue] = $formattedValue;
|
||||
}
|
||||
$this->dateTimeFields[] = new Select($timeGroup, $this->name . '-hour', n2_('Hour'), $valueArray[3], array(
|
||||
'options' => $hours
|
||||
));
|
||||
|
||||
//MINUTE
|
||||
$this->dateTimeFields[] = new NumberSlider($timeGroup, $this->name . '-minute', n2_('Minute'), $valueArray[4], array(
|
||||
'wide' => 2,
|
||||
'min' => 0,
|
||||
'max' => 59
|
||||
));
|
||||
}
|
||||
|
||||
protected function setOnOff($hasOnOff) {
|
||||
$this->hasOnOff = $hasOnOff;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Group;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
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\Unit;
|
||||
use Nextend\Framework\View\Html;
|
||||
use Nextend\SmartSlider3\Form\Element\WidgetArea;
|
||||
|
||||
class WidgetPosition extends Grouping {
|
||||
|
||||
protected $rowClass = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addSimple();
|
||||
|
||||
Js::addInline('new _N2.FormElementWidgetPosition("' . $this->fieldID . '");');
|
||||
|
||||
$html = '';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
return Html::tag('div', array(
|
||||
'id' => $this->fieldID,
|
||||
'class' => 'n2_field_widget_position'
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_widget_position__label'
|
||||
), '') . '<i class="n2_field_widget_position__arrow ssi_16 ssi_16--selectarrow"></i>' . Html::tag('div', array(
|
||||
'class' => 'n2_field_widget_position__popover'
|
||||
), $html));
|
||||
}
|
||||
|
||||
protected function addSimple() {
|
||||
|
||||
$simple = new Grouping($this, $this->name . '-simple');
|
||||
|
||||
new WidgetArea($simple, $this->name . '-area', false);
|
||||
new Select($simple, $this->name . '-stack', n2_('Stack'), 1, array(
|
||||
'options' => array(
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
5 => 5
|
||||
)
|
||||
));
|
||||
new Number($simple, $this->name . '-offset', n2_('Offset'), 0, array(
|
||||
'wide' => 4,
|
||||
'unit' => 'px'
|
||||
));
|
||||
}
|
||||
|
||||
protected function addAdvanced() {
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\Request\Request;
|
||||
use Nextend\SmartSlider3\Application\Admin\Layout\Block\Slider\SliderPublish\BlockPublishSlider;
|
||||
|
||||
class PublishSlider extends AbstractFieldHidden {
|
||||
|
||||
protected $hasTooltip = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
ob_start();
|
||||
|
||||
$blockPublishSlider = new BlockPublishSlider($this->getForm());
|
||||
$blockPublishSlider->setSliderID(Request::$GET->getInt('sliderid'));
|
||||
|
||||
$sliderAliasOrID = Request::$GET->getVar('slideraliasorid');
|
||||
if (!empty($sliderAliasOrID)) {
|
||||
if (is_numeric($sliderAliasOrID)) {
|
||||
$blockPublishSlider->setSliderID($sliderAliasOrID);
|
||||
} else {
|
||||
$blockPublishSlider->setSliderAlias($sliderAliasOrID);
|
||||
}
|
||||
}
|
||||
|
||||
$blockPublishSlider->display();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Radio;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio\AbstractRadioIcon;
|
||||
|
||||
class FlexAlign extends AbstractRadioIcon {
|
||||
|
||||
protected $options = array(
|
||||
'flex-start' => 'ssi_16 ssi_16--verticaltop',
|
||||
'center' => 'ssi_16 ssi_16--verticalcenter',
|
||||
'flex-end' => 'ssi_16 ssi_16--verticalbottom',
|
||||
'space-between' => 'ssi_16 ssi_16--verticalbetween',
|
||||
'space-around' => 'ssi_16 ssi_16--verticalaround'
|
||||
);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Radio;
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio\AbstractRadioIcon;
|
||||
|
||||
class HorizontalAlign extends AbstractRadioIcon {
|
||||
|
||||
protected $inherit = false;
|
||||
|
||||
protected $options = array(
|
||||
'left' => 'ssi_16 ssi_16--horizontalleft',
|
||||
'center' => 'ssi_16 ssi_16--horizontalcenter',
|
||||
'right' => 'ssi_16 ssi_16--horizontalright'
|
||||
);
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', array $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
if ($this->inherit) {
|
||||
$this->options = array(
|
||||
'inherit' => 'ssi_16 ssi_16--none'
|
||||
) + $this->options;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $inherit
|
||||
*/
|
||||
public function setInherit($inherit) {
|
||||
$this->inherit = $inherit;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Radio;
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio\AbstractRadioIcon;
|
||||
|
||||
class InnerAlign extends AbstractRadioIcon {
|
||||
|
||||
protected $hasInherit = true;
|
||||
|
||||
protected function renderOptions() {
|
||||
|
||||
if ($this->hasInherit) {
|
||||
$this->options['inherit'] = 'ssi_16 ssi_16--none';
|
||||
}
|
||||
|
||||
$this->options = array_merge($this->options, array(
|
||||
'left' => 'ssi_16 ssi_16--textleft',
|
||||
'center' => 'ssi_16 ssi_16--textcenter',
|
||||
'right' => 'ssi_16 ssi_16--textright'
|
||||
));
|
||||
|
||||
return parent::renderOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasInherit
|
||||
*/
|
||||
public function setHasInherit($hasInherit) {
|
||||
$this->hasInherit = $hasInherit;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Radio;
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio\AbstractRadioIcon;
|
||||
|
||||
class VerticalAlign extends AbstractRadioIcon {
|
||||
|
||||
protected $options = array(
|
||||
'top' => 'ssi_16 ssi_16--verticaltop',
|
||||
'middle' => 'ssi_16 ssi_16--verticalcenter',
|
||||
'bottom' => 'ssi_16 ssi_16--verticalbottom'
|
||||
);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element\Select;
|
||||
|
||||
use Nextend\Framework\Form\Element\Select\SubFormIcon;
|
||||
use Nextend\SmartSlider3\Slider\ResponsiveType\AbstractResponsiveTypeAdmin;
|
||||
use Nextend\SmartSlider3\Slider\ResponsiveType\ResponsiveTypeFactory;
|
||||
|
||||
class ResponsiveSubFormIcon extends SubFormIcon {
|
||||
|
||||
/** @var AbstractResponsiveTypeAdmin[] */
|
||||
protected $plugins = array();
|
||||
|
||||
protected function loadOptions() {
|
||||
|
||||
$this->plugins = ResponsiveTypeFactory::getAdminTypes();
|
||||
|
||||
foreach ($this->plugins as $name => $type) {
|
||||
$this->options[$name] = array(
|
||||
'label' => $type->getLabel(),
|
||||
'icon' => $type->getIcon()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class WidgetArea extends AbstractFieldHidden {
|
||||
|
||||
protected $hasTooltip = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
$areas = '';
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$areas .= Html::tag('div', array(
|
||||
'class' => 'n2_field_widget_area__area' . $this->isSelected($i),
|
||||
'data-area' => $i
|
||||
));
|
||||
}
|
||||
|
||||
$html = Html::tag('div', array(
|
||||
'class' => 'n2_field_widget_area'
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_widget_area__inner'
|
||||
)) . $areas . parent::fetchElement());
|
||||
|
||||
Js::addInline('new _N2.FormElementSliderWidgetArea("' . $this->fieldID . '");');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function isSelected($i) {
|
||||
if ($i == $this->getValue()) {
|
||||
return ' n2_field_widget_area__area--selected';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user