first
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
abstract class AbstractContainer implements ContainerContainedInterface {
|
||||
|
||||
use TraitContainer;
|
||||
|
||||
/**
|
||||
* @var ContainerContainedInterface
|
||||
*/
|
||||
protected $first, $last;
|
||||
|
||||
protected $controlName = '';
|
||||
|
||||
/**
|
||||
* @var ContainerInterface;
|
||||
*/
|
||||
private $previous, $next;
|
||||
|
||||
public function getPrevious() {
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainedInterface|null $element
|
||||
*/
|
||||
public function setPrevious($element = null) {
|
||||
$this->previous = $element;
|
||||
}
|
||||
|
||||
public function getNext() {
|
||||
return $this->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainedInterface|null $element
|
||||
*/
|
||||
public function setNext($element = null) {
|
||||
$this->next = $element;
|
||||
if ($element) {
|
||||
$element->setPrevious($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove() {
|
||||
$this->getParent()
|
||||
->removeElement($this);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$this->renderContainer();
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$element->renderContainer();
|
||||
$element = $element->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getControlName() {
|
||||
return $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $controlName
|
||||
*/
|
||||
public function setControlName($controlName) {
|
||||
$this->controlName = $controlName;
|
||||
}
|
||||
}
|
@ -0,0 +1,376 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Insert\AbstractInsert;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
abstract class AbstractField implements ContainedInterface {
|
||||
|
||||
/**
|
||||
* @var AbstractField;
|
||||
*/
|
||||
private $previous, $next;
|
||||
|
||||
public function getPrevious() {
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField|null $element
|
||||
*/
|
||||
public function setPrevious($element = null) {
|
||||
$this->previous = $element;
|
||||
}
|
||||
|
||||
public function getNext() {
|
||||
return $this->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField|null $element
|
||||
*/
|
||||
public function setNext($element = null) {
|
||||
$this->next = $element;
|
||||
if ($element) {
|
||||
$element->setPrevious($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove() {
|
||||
$this->getParent()
|
||||
->removeElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var TraitFieldset
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $controlName = '';
|
||||
|
||||
protected $defaultValue;
|
||||
|
||||
protected $fieldID;
|
||||
|
||||
private $exposeName = true;
|
||||
|
||||
protected $tip = '';
|
||||
|
||||
protected $tipLabel = '';
|
||||
|
||||
protected $tipDescription = '';
|
||||
|
||||
protected $tipLink = '';
|
||||
|
||||
protected $rowClass = '';
|
||||
|
||||
protected $rowAttributes = array();
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $post = '';
|
||||
|
||||
protected $relatedFields = array();
|
||||
|
||||
protected $relatedFieldsOff = array();
|
||||
|
||||
/**
|
||||
* AbstractField constructor.
|
||||
*
|
||||
* @param TraitFieldset|AbstractInsert $insertAt
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param string $default
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
|
||||
if ($insertAt instanceof ContainerInterface) {
|
||||
$this->parent = $insertAt;
|
||||
$this->parent->addElement($this);
|
||||
} else if ($insertAt instanceof AbstractInsert) {
|
||||
$this->parent = $insertAt->insert($this);
|
||||
}
|
||||
|
||||
$this->controlName = $this->parent->getControlName();
|
||||
|
||||
$this->fieldID = $this->generateId($this->controlName . $this->name);
|
||||
|
||||
$this->defaultValue = $default;
|
||||
|
||||
foreach ($parameters as $option => $value) {
|
||||
$option = 'set' . $option;
|
||||
$this->{$option}($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getID() {
|
||||
return $this->fieldID;
|
||||
}
|
||||
|
||||
public function setDefaultValue($defaultValue) {
|
||||
$this->defaultValue = $defaultValue;
|
||||
}
|
||||
|
||||
public function setExposeName($exposeName) {
|
||||
$this->exposeName = $exposeName;
|
||||
}
|
||||
|
||||
public function getPost() {
|
||||
return $this->post;
|
||||
}
|
||||
|
||||
public function setPost($post) {
|
||||
$this->post = $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tip
|
||||
*/
|
||||
public function setTip($tip) {
|
||||
$this->tip = $tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tipLabel
|
||||
*/
|
||||
public function setTipLabel($tipLabel) {
|
||||
$this->tipLabel = $tipLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tipDescription
|
||||
*/
|
||||
public function setTipDescription($tipDescription) {
|
||||
$this->tipDescription = $tipDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tipLink
|
||||
*/
|
||||
public function setTipLink($tipLink) {
|
||||
$this->tipLink = $tipLink;
|
||||
}
|
||||
|
||||
public function setRowClass($rowClass) {
|
||||
$this->rowClass .= $rowClass;
|
||||
}
|
||||
|
||||
public function getRowClass() {
|
||||
return $this->rowClass;
|
||||
}
|
||||
|
||||
public function getClass() {
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
public function setClass($class) {
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
protected function getFieldName() {
|
||||
if ($this->exposeName) {
|
||||
return $this->controlName . '[' . $this->name . ']';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
return array(
|
||||
$this->fetchTooltip(),
|
||||
$this->fetchElement()
|
||||
);
|
||||
}
|
||||
|
||||
public function displayLabel() {
|
||||
echo wp_kses($this->fetchTooltip(), Sanitize::$adminFormTags);
|
||||
}
|
||||
|
||||
public function displayElement() {
|
||||
echo wp_kses($this->fetchElement(), Sanitize::$adminFormTags);
|
||||
}
|
||||
|
||||
protected function fetchTooltip() {
|
||||
|
||||
if ($this->label === false || $this->label === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$attributes = array(
|
||||
'for' => $this->fieldID
|
||||
);
|
||||
|
||||
|
||||
$post = '';
|
||||
if (!empty($this->tipDescription)) {
|
||||
$tipAttributes = array(
|
||||
'class' => 'ssi_16 ssi_16--info',
|
||||
'data-tip-description' => $this->tipDescription
|
||||
);
|
||||
if (!empty($this->tipLabel)) {
|
||||
$tipAttributes['data-tip-label'] = $this->tipLabel;
|
||||
}
|
||||
if (!empty($this->tipLink)) {
|
||||
$tipAttributes['data-tip-link'] = $this->tipLink;
|
||||
}
|
||||
$post .= Html::tag('i', $tipAttributes);
|
||||
}
|
||||
|
||||
return Html::tag('label', $attributes, $this->label) . $post;
|
||||
}
|
||||
|
||||
protected function fetchNoTooltip() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function fetchElement();
|
||||
|
||||
public function getValue() {
|
||||
return $this->getForm()
|
||||
->get($this->name, $this->defaultValue);
|
||||
}
|
||||
|
||||
public function setValue($value) {
|
||||
$this->parent->getForm()
|
||||
->set($this->name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rowAttributes
|
||||
*/
|
||||
public function setRowAttributes($rowAttributes) {
|
||||
$this->rowAttributes = $rowAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRowAttributes() {
|
||||
return $this->rowAttributes;
|
||||
}
|
||||
|
||||
public function setStyle($style) {
|
||||
$this->style = $style;
|
||||
}
|
||||
|
||||
protected function getStyle() {
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $relatedFields
|
||||
*/
|
||||
public function setRelatedFields($relatedFields) {
|
||||
$this->relatedFields = $relatedFields;
|
||||
}
|
||||
|
||||
public function setRelatedFieldsOff($relatedFieldsOff) {
|
||||
$this->relatedFieldsOff = $relatedFieldsOff;
|
||||
}
|
||||
|
||||
protected function renderRelatedFields() {
|
||||
if (!empty($this->relatedFields) || !empty($this->relatedFieldsOff)) {
|
||||
$options = array(
|
||||
'relatedFieldsOn' => $this->relatedFields,
|
||||
'relatedFieldsOff' => $this->relatedFieldsOff
|
||||
);
|
||||
Js::addInline('new _N2.FormRelatedFields("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateId($name) {
|
||||
|
||||
return str_replace(array(
|
||||
'[',
|
||||
']',
|
||||
' '
|
||||
), array(
|
||||
'',
|
||||
'',
|
||||
''
|
||||
), $name);
|
||||
}
|
||||
|
||||
public function getLabelClass() {
|
||||
if ($this->label === false) {
|
||||
return 'n2_field--label-none';
|
||||
} else if ($this->label === '') {
|
||||
return 'n2_field--label-placeholder';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLabel() {
|
||||
return !empty($this->label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm() {
|
||||
return $this->parent->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getControlName() {
|
||||
return $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $controlName
|
||||
*/
|
||||
public function setControlName($controlName) {
|
||||
$this->controlName = $controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TraitFieldset
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getPath() {
|
||||
return $this->parent->getPath() . '/' . $this->name;
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
use Nextend\Framework\Form\Insert\AbstractInsert;
|
||||
|
||||
abstract class AbstractFieldset implements ContainerContainedInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
/**
|
||||
* @var ContainedInterface;
|
||||
*/
|
||||
private $previous, $next;
|
||||
|
||||
public function getPrevious() {
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
public function setPrevious($element = null) {
|
||||
$this->previous = $element;
|
||||
}
|
||||
|
||||
public function getNext() {
|
||||
return $this->next;
|
||||
}
|
||||
|
||||
public function setNext($element = null) {
|
||||
$this->next = $element;
|
||||
if ($element) {
|
||||
$element->setPrevious($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove() {
|
||||
$this->getParent()
|
||||
->removeElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $controlName = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
/**
|
||||
* Container constructor.
|
||||
*
|
||||
* @param ContainerInterface|AbstractInsert $insertAt
|
||||
* @param $name
|
||||
* @param boolean|string $label
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name, $label = false, $parameters = array()) {
|
||||
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
|
||||
if ($insertAt instanceof ContainerInterface) {
|
||||
$this->parent = $insertAt;
|
||||
$this->parent->addElement($this);
|
||||
} else if ($insertAt instanceof AbstractInsert) {
|
||||
$this->parent = $insertAt->insert($this);
|
||||
}
|
||||
|
||||
$this->controlName = $this->parent->getControlName();
|
||||
|
||||
foreach ($parameters as $option => $value) {
|
||||
$option = 'set' . $option;
|
||||
$this->{$option}($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$this->renderContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$element->displayElement();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLabel() {
|
||||
return !empty($this->label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm() {
|
||||
return $this->parent->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getControlName() {
|
||||
return $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $controlName
|
||||
*/
|
||||
public function setControlName($controlName) {
|
||||
$this->controlName = $controlName;
|
||||
}
|
||||
|
||||
public function hasFields() {
|
||||
|
||||
return !empty($this->flattenElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*/
|
||||
public function setClass($class) {
|
||||
$this->class = $class;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
use Nextend\Framework\Pattern\MVCHelperTrait;
|
||||
|
||||
abstract class AbstractFormManager {
|
||||
|
||||
use MVCHelperTrait;
|
||||
|
||||
/**
|
||||
* AbstractFormManager constructor.
|
||||
*
|
||||
* @param MVCHelperTrait $MVCHelper
|
||||
*/
|
||||
public function __construct($MVCHelper) {
|
||||
|
||||
$this->setMVCHelper($MVCHelper);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Base;
|
||||
|
||||
class PlatformFormBase {
|
||||
|
||||
public function tokenize() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function tokenizeUrl() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function checkToken() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
interface ContainedInterface {
|
||||
|
||||
/**
|
||||
* @return ContainedInterface|null
|
||||
*/
|
||||
public function getPrevious();
|
||||
|
||||
/**
|
||||
* @param ContainedInterface|null $element
|
||||
*/
|
||||
public function setPrevious($element = null);
|
||||
|
||||
/**
|
||||
* @return ContainedInterface|null
|
||||
*/
|
||||
public function getNext();
|
||||
|
||||
/**
|
||||
* @param ContainedInterface|null $element
|
||||
*/
|
||||
public function setNext($element = null);
|
||||
|
||||
public function remove();
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getParent();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath();
|
||||
|
||||
public function render();
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
|
||||
class ContainerAlternative extends ContainerGeneral {
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
|
||||
class ContainerRowGroup extends ContainerGeneral {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_form__table_row_group" data-field="table-row-group-' . esc_attr($this->name) . '">';
|
||||
if ($this->label !== false) {
|
||||
echo '<div class="n2_form__table_row_group_label">';
|
||||
echo esc_html($this->label);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="n2_form__table_row_group_rows" data-field="table-row-group-rows-' . esc_attr($this->name) . '">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return FieldsetRow
|
||||
*/
|
||||
public function createRow($name) {
|
||||
|
||||
return new FieldsetRow($this, $name);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
|
||||
class ContainerSubform extends ContainerGeneral {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div id="' . esc_attr($this->getId()) . '" class="n2_form__subform">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
return 'n2_form__subform_' . $this->controlName . '_' . $this->name;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
|
||||
class ContainerTab extends ContainerGeneral {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_form__tab" data-related-form="' . esc_attr($this->getForm()
|
||||
->getId()) . '" data-tab="' . esc_attr($this->getId()) . '">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
return 'n2_form__tab_' . $this->controlName . '_' . $this->name;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container;
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetRow;
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetTableLabel;
|
||||
|
||||
class ContainerTable extends ContainerGeneral {
|
||||
|
||||
/**
|
||||
* @var FieldsetTableLabel
|
||||
*/
|
||||
protected $fieldsetLabel;
|
||||
|
||||
protected $fieldsetLabelPosition = 'start';
|
||||
|
||||
public function __construct($insertAt, $name, $label = false, $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $parameters);
|
||||
|
||||
$labelContainer = new ContainerAlternative($this, $name . '-container-label');
|
||||
$this->fieldsetLabel = new FieldsetTableLabel($labelContainer, $name . '-label', false);
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_form__table" data-field="table-' . esc_attr($this->name) . '">';
|
||||
echo '<div class="n2_form__table_label">';
|
||||
echo '<div class="n2_form__table_label_title">';
|
||||
echo esc_html($this->label);
|
||||
echo '</div>';
|
||||
if ($this->fieldsetLabel->hasFields()) {
|
||||
echo '<div class="n2_form__table_label_fields n2_form__table_label_fields--' . esc_attr($this->fieldsetLabelPosition) . '">';
|
||||
$this->fieldsetLabel->renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
if ($this->first) {
|
||||
echo '<div class="n2_form__table_rows" data-field="table-rows-' . esc_attr($this->name) . '">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return FieldsetRow
|
||||
*/
|
||||
public function createRow($name) {
|
||||
|
||||
return new FieldsetRow($this, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param string $label
|
||||
*
|
||||
* @return ContainerRowGroup
|
||||
*/
|
||||
public function createRowGroup($name, $label) {
|
||||
|
||||
return new ContainerRowGroup($this, $name, $label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FieldsetTableLabel
|
||||
*/
|
||||
public function getFieldsetLabel() {
|
||||
return $this->fieldsetLabel;
|
||||
}
|
||||
|
||||
public function setFieldsetPositionEnd() {
|
||||
$this->fieldsetLabelPosition = 'end';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
|
||||
class ContainerAnimation extends ContainerGeneral {
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $label
|
||||
*
|
||||
* @return ContainerAnimationTab
|
||||
*/
|
||||
public function createTab($name, $label) {
|
||||
return new ContainerAnimationTab($this, $name, $label);
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_container_animation" data-field="animation-' . esc_attr($this->name) . '">';
|
||||
echo '<div class="n2_container_animation__buttons">';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
if ($element instanceof ContainerAnimationTab) {
|
||||
echo '<div class="n2_container_animation__button" data-related-tab="' . esc_attr($element->getName()) . '">' . esc_html($element->getLabel()) . '</div>';
|
||||
}
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '<div class="n2_container_animation__tabs">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
|
||||
class ContainerAnimationTab extends ContainerGeneral {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_container_animation__tab" data-tab="' . esc_attr($this->name) . '">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class ContainerDesign extends ContainerGeneral {
|
||||
|
||||
public function __construct(ContainerInterface $insertAt, $name) {
|
||||
parent::__construct($insertAt, $name);
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
$id = 'n2_css_' . $this->name;
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'id' => $id,
|
||||
'class' => 'n2_ss_design_' . $this->name
|
||||
)), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$element->renderContainer();
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
echo wp_kses(Html::closeTag('div'), Sanitize::$basicTags);
|
||||
|
||||
$options = array(
|
||||
'ajaxUrl' => $this->getForm()
|
||||
->createAjaxUrl('css/index')
|
||||
);
|
||||
|
||||
Js::addInline('new _N2.BasicCSS(' . json_encode($id) . ', ' . json_encode($options) . ');');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Container\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\ContainerGeneral;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
|
||||
class ContainerSettings extends ContainerGeneral {
|
||||
|
||||
public function __construct(ContainerInterface $insertAt, $name, $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, false, $parameters);
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_ss_layer_window__tab_panel" data-panel="' . esc_attr($this->name) . '">';
|
||||
parent::renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
interface ContainerContainedInterface extends ContainerInterface, ContainedInterface {
|
||||
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
use Nextend\Framework\Form\Insert\AbstractInsert;
|
||||
|
||||
class ContainerGeneral extends AbstractContainer {
|
||||
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
protected $name = '';
|
||||
|
||||
protected $label = '';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
/**
|
||||
* Container constructor.
|
||||
*
|
||||
* @param ContainerInterface|AbstractInsert $insertAt
|
||||
* @param string $name
|
||||
* @param boolean|string $label
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name, $label = false, $parameters = array()) {
|
||||
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
|
||||
if ($insertAt instanceof ContainerInterface) {
|
||||
$this->parent = $insertAt;
|
||||
$this->parent->addElement($this);
|
||||
} else if ($insertAt instanceof AbstractInsert) {
|
||||
$this->parent = $insertAt->insert($this);
|
||||
}
|
||||
|
||||
$this->controlName = $this->parent->getControlName();
|
||||
|
||||
foreach ($parameters as $option => $value) {
|
||||
$option = 'set' . $option;
|
||||
$this->{$option}($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function removeElement($element) {
|
||||
$previous = $element->getPrevious();
|
||||
$next = $element->getNext();
|
||||
|
||||
if ($this->first === $element) {
|
||||
$this->first = $next;
|
||||
}
|
||||
|
||||
if ($this->last === $element) {
|
||||
$this->last = $previous;
|
||||
}
|
||||
|
||||
if ($previous) {
|
||||
$previous->setNext($next);
|
||||
} else {
|
||||
$next->setPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getPath() {
|
||||
return $this->parent->getPath() . '/' . $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*/
|
||||
public function setClass($class) {
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLabel() {
|
||||
return !empty($this->label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel() {
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm() {
|
||||
return $this->parent->getForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getControlName() {
|
||||
return $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $controlName
|
||||
*/
|
||||
public function setControlName($controlName) {
|
||||
$this->controlName = $controlName;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
interface ContainerInterface {
|
||||
|
||||
/**
|
||||
* @param ContainedInterface $element
|
||||
*/
|
||||
public function addElement($element);
|
||||
|
||||
/**
|
||||
* @param ContainedInterface $element
|
||||
* @param ContainedInterface $target
|
||||
*/
|
||||
public function insertElementBefore($element, $target);
|
||||
|
||||
/**
|
||||
* @param ContainedInterface $element
|
||||
* @param ContainedInterface $target
|
||||
*/
|
||||
public function insertElementAfter($element, $target);
|
||||
|
||||
/**
|
||||
* @param ContainedInterface $element
|
||||
*/
|
||||
public function removeElement($element);
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
*
|
||||
* @return ContainedInterface
|
||||
*/
|
||||
public function getElement($path);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath();
|
||||
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getControlName();
|
||||
|
||||
public function renderContainer();
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Fieldset\FieldsetHidden;
|
||||
|
||||
class ContainerMain extends AbstractContainer {
|
||||
|
||||
/**
|
||||
* @var Form
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* @var FieldsetHidden
|
||||
*/
|
||||
protected $fieldsetHidden;
|
||||
|
||||
/**
|
||||
* ContainerMain constructor.
|
||||
*
|
||||
* @param Form $form
|
||||
*/
|
||||
public function __construct($form) {
|
||||
$this->form = $form;
|
||||
$this->controlName = $form->getControlName();
|
||||
|
||||
$this->fieldsetHidden = new FieldsetHidden($this);
|
||||
}
|
||||
|
||||
public function removeElement($element) {
|
||||
$previous = $element->getPrevious();
|
||||
$next = $element->getNext();
|
||||
|
||||
if ($this->first === $element) {
|
||||
$this->first = $next;
|
||||
}
|
||||
|
||||
if ($this->last === $element) {
|
||||
$this->last = $previous;
|
||||
}
|
||||
|
||||
if ($previous) {
|
||||
$previous->setNext($next);
|
||||
} else {
|
||||
$next->setPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
public function getParent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPath() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm() {
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return 'ContainerMain';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FieldsetHidden
|
||||
*/
|
||||
public function getFieldsetHidden() {
|
||||
return $this->fieldsetHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ContainerContainedInterface
|
||||
*/
|
||||
public function getFirst() {
|
||||
return $this->first;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
abstract class AbstractChooser extends AbstractFieldHidden {
|
||||
|
||||
protected $hasClear = true;
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $width;
|
||||
|
||||
abstract protected function addScript();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addScript();
|
||||
|
||||
$this->renderRelatedFields();
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_chooser ' . $this->class
|
||||
), $this->pre() . parent::fetchElement() . $this->field() . $this->post());
|
||||
}
|
||||
|
||||
protected function pre() {
|
||||
|
||||
}
|
||||
|
||||
protected function field() {
|
||||
$style = '';
|
||||
if ($this->width) {
|
||||
$style = 'width: ' . $this->width . 'px;';
|
||||
}
|
||||
|
||||
return '<div class="n2_field_chooser__label" style="' . $style . '"></div>';
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
|
||||
$html = '';
|
||||
if ($this->hasClear) {
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_chooser__clear'
|
||||
), Html::tag('i', array('class' => 'ssi_16 ssi_16--circularremove'), ''));
|
||||
}
|
||||
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_chooser__choose'
|
||||
), '<i class="ssi_16 ssi_16--plus"></i>');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasClear
|
||||
*/
|
||||
public function setHasClear($hasClear) {
|
||||
$this->hasClear = $hasClear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
abstract class AbstractChooserText extends AbstractFieldHidden {
|
||||
|
||||
protected $hasClear = true;
|
||||
|
||||
protected $width = 130;
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $type = 'text';
|
||||
|
||||
abstract protected function addScript();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addScript();
|
||||
|
||||
$this->renderRelatedFields();
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_text' . $this->class
|
||||
), $this->pre() . $this->field() . $this->post());
|
||||
}
|
||||
|
||||
protected function pre() {
|
||||
|
||||
}
|
||||
|
||||
protected function field() {
|
||||
|
||||
if ($this->type === 'hidden') {
|
||||
return Html::tag('input', array(
|
||||
'type' => 'text',
|
||||
'style' => 'width: ' . $this->width . 'px;',
|
||||
'disabled' => 'disabled'
|
||||
), false, false);
|
||||
}
|
||||
|
||||
return Html::tag('input', array(
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'value' => $this->getValue(),
|
||||
'type' => $this->type,
|
||||
'style' => 'width: ' . $this->width . 'px;',
|
||||
'autocomplete' => 'off'
|
||||
), false, false);
|
||||
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
|
||||
$html = '';
|
||||
if ($this->hasClear) {
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_text__clear',
|
||||
'tabindex' => -1
|
||||
), Html::tag('i', array('class' => 'ssi_16 ssi_16--circularremove'), ''));
|
||||
}
|
||||
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_text__choose',
|
||||
'aria-label' => n2_('Choose')
|
||||
), '<i class="ssi_16 ssi_16--plus"></i>');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasClear
|
||||
*/
|
||||
public function setHasClear($hasClear) {
|
||||
$this->hasClear = $hasClear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class AbstractFieldHidden extends AbstractField {
|
||||
|
||||
protected $hasTooltip = true;
|
||||
|
||||
protected $type = 'hidden';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = false, $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
}
|
||||
|
||||
protected function fetchTooltip() {
|
||||
if ($this->hasTooltip) {
|
||||
return parent::fetchTooltip();
|
||||
} else {
|
||||
return $this->fetchNoTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
return Html::tag('input', array(
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'value' => $this->getValue(),
|
||||
'type' => $this->type,
|
||||
'autocomplete' => 'off'
|
||||
), false, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Breakpoint extends AbstractField implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
protected $fields = array();
|
||||
|
||||
protected $enables = false;
|
||||
|
||||
protected $global = false;
|
||||
|
||||
public function __construct($insertAt, $name = '', $fields = array(), $enables = false, $global = false) {
|
||||
|
||||
$this->fields = $fields;
|
||||
$this->enables = $enables;
|
||||
$this->global = $global;
|
||||
|
||||
parent::__construct($insertAt, $name, false, '');
|
||||
}
|
||||
|
||||
public function getLabelClass() {
|
||||
|
||||
return parent::getLabelClass() . ' n2_field--raw';
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$orientation = new Tab($this, $this->name . '-orientation', n2_('Orientation'), 'portrait', array(
|
||||
'options' => array(
|
||||
'portrait' => n2_('Portrait'),
|
||||
'landscape' => n2_('Landscape')
|
||||
)
|
||||
));
|
||||
$devices = array(
|
||||
array(
|
||||
'id' => 'mobileportrait',
|
||||
'icon' => 'ssi_16 ssi_16--mobileportrait',
|
||||
'label' => n2_('Mobile')
|
||||
),
|
||||
array(
|
||||
'id' => 'tabletportrait',
|
||||
'icon' => 'ssi_16 ssi_16--tabletportrait',
|
||||
'label' => n2_('Tablet')
|
||||
),
|
||||
array(
|
||||
'id' => 'desktopportrait',
|
||||
'icon' => 'ssi_16 ssi_16--desktopportrait',
|
||||
'label' => n2_('Desktop')
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$preHtml = '';
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$preHtml .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
$html = '';
|
||||
|
||||
for ($i = 0; $i < count($devices); $i++) {
|
||||
$html .= Html::tag('div', array(
|
||||
'data-id' => $devices[$i]['id'],
|
||||
'class' => 'n2_field_breakpoint__device'
|
||||
), '<div class="n2_field_breakpoint__device_enable" data-n2tip="' . $devices[$i]['label'] . '"><i class="' . $devices[$i]['icon'] . '"></i></div>');
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'orientation' => $orientation->getID(),
|
||||
'fields' => $this->fields,
|
||||
'enables' => $this->enables,
|
||||
'global' => $this->global
|
||||
);
|
||||
|
||||
Js::addInline('new _N2.FormElementBreakpoint("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
|
||||
return '<div id="' . $this->getID() . '" class="n2_field_breakpoint"><div class="n2_field_breakpoint__pre_fields">' . $preHtml . '</div><div class="n2_field_breakpoint__breakpoint_container" data-orientation="portrait">' . $html . '</div></div>';
|
||||
}
|
||||
|
||||
public function decorateElement($element) {
|
||||
return $this->parent->decorateElement($element);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Button extends AbstractField {
|
||||
|
||||
protected $url = '';
|
||||
|
||||
protected $target = '';
|
||||
|
||||
protected $buttonLabel = '';
|
||||
|
||||
protected $classes = array('n2_field_button');
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $buttonLabel = '', $parameters = array()) {
|
||||
$this->buttonLabel = $buttonLabel;
|
||||
parent::__construct($insertAt, $name, $label, '', $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
return Html::tag('a', $this->getAttributes(), $this->buttonLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className
|
||||
*/
|
||||
public function addClass($className) {
|
||||
$this->classes[] = $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getAttributes() {
|
||||
$attributes = array(
|
||||
'id' => $this->fieldID,
|
||||
'class' => implode(' ', $this->classes)
|
||||
);
|
||||
|
||||
if (!empty($this->url)) {
|
||||
$attributes['href'] = $this->url;
|
||||
if (!empty($this->target)) {
|
||||
$attributes['target'] = $this->target;
|
||||
}
|
||||
} else {
|
||||
$attributes['href'] = '#';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function setUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function setTarget($target) {
|
||||
$this->target = $target;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Button;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Button;
|
||||
|
||||
class ButtonIcon extends Button {
|
||||
|
||||
protected $hoverTip = '';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $icon = '', $parameters = array()) {
|
||||
|
||||
$this->classes[] = 'n2_field_button--icon';
|
||||
parent::__construct($insertAt, $name, $label, '<i class="' . $icon . '"></i>', $parameters);
|
||||
}
|
||||
|
||||
protected function getAttributes() {
|
||||
$attributes = parent::getAttributes();
|
||||
|
||||
if (!empty($this->hoverTip)) {
|
||||
$attributes['data-n2tip'] = $this->hoverTip;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hoverTip
|
||||
*/
|
||||
public function setHoverTip($hoverTip) {
|
||||
$this->hoverTip = $hoverTip;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Button;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Button;
|
||||
|
||||
class ButtonMoreLess extends Button {
|
||||
|
||||
public function __construct($insertAt, $name, $label = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, n2_('More'), $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$options = array(
|
||||
'labelMore' => n2_('More'),
|
||||
'labelLess' => n2_('Less')
|
||||
);
|
||||
|
||||
if (!empty($this->relatedFields)) {
|
||||
$options['relatedFields'] = $this->relatedFields;
|
||||
}
|
||||
|
||||
Js::addInline('new _N2.FormElementButtonMoreLess("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Button;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Button;
|
||||
|
||||
class ButtonRecordViewer extends Button {
|
||||
|
||||
public function __construct($insertAt, $name = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, '', n2_('View records'), $parameters);
|
||||
|
||||
|
||||
$this->addClass('n2_field_button--blue');
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$ajaxRecordUrl = $this->getForm()
|
||||
->createAjaxUrl(array(
|
||||
'generator/recordstable'
|
||||
));
|
||||
Js::addInline('new _N2.FieldRecordViewer(' . json_encode($this->fieldID) . ',' . json_encode($ajaxRecordUrl) . ');');
|
||||
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class CheckboxOnOff extends AbstractFieldHidden {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $icon;
|
||||
|
||||
protected $invert = false;
|
||||
|
||||
protected $checkboxTip;
|
||||
|
||||
public function __construct($insertAt, $name, $label, $icon, $default = 0, $parameters = array()) {
|
||||
|
||||
$this->icon = $icon;
|
||||
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$options = array(
|
||||
'invert' => $this->invert,
|
||||
'relatedFields' => $this->relatedFields
|
||||
);
|
||||
|
||||
Js::addInline('new _N2.FormElementCheckboxOnOff("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
$attr = array(
|
||||
'class' => 'n2_field_checkbox_onoff' . ($this->isActive() ? ' n2_field_checkbox_onoff--active' : '')
|
||||
);
|
||||
|
||||
if (!empty($this->checkboxTip)) {
|
||||
$attr['data-n2tip'] = $this->checkboxTip;
|
||||
}
|
||||
|
||||
return Html::tag('div', $attr, '<i class="' . $this->icon . '"></i>' . parent::fetchElement());
|
||||
}
|
||||
|
||||
protected function isActive() {
|
||||
|
||||
$value = $this->getValue();
|
||||
|
||||
if (!$this->invert && $value) {
|
||||
return true;
|
||||
} else if ($this->invert && !$value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $invert
|
||||
*/
|
||||
public function setInvert($invert) {
|
||||
$this->invert = $invert;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tip
|
||||
*/
|
||||
public function setCheckboxTip($tip) {
|
||||
$this->checkboxTip = $tip;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
|
||||
class Connected extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_connected ';
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_connected__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Decoration extends AbstractFieldHidden {
|
||||
|
||||
protected $value = null;
|
||||
|
||||
protected $options = array(
|
||||
'italic' => 'ssi_16 ssi_16--italic',
|
||||
'underline' => 'ssi_16 ssi_16--underline'
|
||||
);
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->value = explode('||', $this->getValue());
|
||||
|
||||
$html = Html::tag('div', array(
|
||||
'class' => 'n2_field_decoration',
|
||||
'style' => $this->style
|
||||
), $this->renderOptions() . parent::fetchElement());
|
||||
|
||||
Js::addInline('new _N2.FormElementDecoration("' . $this->fieldID . '", ' . json_encode(array_keys($this->options)) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOptions() {
|
||||
|
||||
$length = count($this->options) - 1;
|
||||
|
||||
$html = '';
|
||||
$i = 0;
|
||||
foreach ($this->options as $value => $class) {
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_decoration__option ' . ($this->isSelected($value) ? ' n2_field_decoration__option--selected' : ''),
|
||||
'data-value' => $value
|
||||
), Html::tag('i', array('class' => $class)));
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function isSelected($value) {
|
||||
if (in_array($value, $this->value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = $style;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Devices extends AbstractFieldHidden {
|
||||
|
||||
private $values = array();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = Html::tag('div', array(
|
||||
'id' => $this->fieldID,
|
||||
'class' => 'n2_field_radio_icon'
|
||||
), $this->generateOptions());
|
||||
|
||||
Js::addInline('new _N2.FormElementDevices("' . $this->fieldID . '", ' . json_encode($this->values) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function generateOptions() {
|
||||
$options = array(
|
||||
'desktop-portrait' => 'ssi_16 ssi_16--desktopportrait',
|
||||
'tablet-portrait' => 'ssi_16 ssi_16--tabletportrait',
|
||||
'mobile-portrait' => 'ssi_16 ssi_16--mobileportrait'
|
||||
);
|
||||
|
||||
|
||||
$html = '';
|
||||
$i = 0;
|
||||
foreach ($options as $value => $class) {
|
||||
$this->values[] = $value;
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_radio__option'
|
||||
), Html::tag('i', array(
|
||||
'class' => $class
|
||||
)) . Html::tag('input', array(
|
||||
'type' => 'hidden',
|
||||
'id' => $this->fieldID . '-' . $value
|
||||
)));
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class EmptyArea extends AbstractField {
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
return Html::tag('div', array(
|
||||
'id' => $this->fieldID
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Font\FontManager;
|
||||
use Nextend\Framework\Font\FontParser;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Font extends AbstractFieldHidden {
|
||||
|
||||
protected $mode = '';
|
||||
|
||||
protected $css = '';
|
||||
|
||||
protected $style2 = '';
|
||||
|
||||
protected $preview = '';
|
||||
|
||||
|
||||
protected function addScript() {
|
||||
|
||||
FontManager::enqueue($this->getForm());
|
||||
|
||||
Js::addInline('new _N2.FormElementFont("' . $this->fieldID . '", {
|
||||
mode: "' . $this->mode . '",
|
||||
label: "' . $this->label . '",
|
||||
style: "' . $this->style . '",
|
||||
style2: "' . $this->style2 . '",
|
||||
preview: ' . json_encode($this->preview) . '
|
||||
});');
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addScript();
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_font'
|
||||
), n2_('Font') . parent::fetchElement());
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
|
||||
return FontParser::parse(parent::getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
*/
|
||||
public function setMode($mode) {
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
*/
|
||||
public function setCss($css) {
|
||||
$this->css = $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style2
|
||||
*/
|
||||
public function setStyle2($style2) {
|
||||
$this->style2 = $style2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $preview
|
||||
*/
|
||||
public function setPreview($preview) {
|
||||
$this->preview = $preview;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class Gap extends AbstractFieldHidden implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
private static $separator = '|*|';
|
||||
|
||||
protected $unit = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
$default = explode(self::$separator, $this->defaultValue);
|
||||
$value = explode(self::$separator, $this->getValue());
|
||||
$value = $value + $default;
|
||||
|
||||
$html = "<div class='n2_field_margin_padding' style='" . $this->style . "'>";
|
||||
|
||||
$html .= '<div class="n2_field_margin_padding__pre_label"><i class="ssi_16 ssi_16--unlink"></i></div>';
|
||||
$subElements = array();
|
||||
$i = 0;
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$element->setExposeName(false);
|
||||
if (isset($value[$i])) {
|
||||
$element->setDefaultValue($value[$i]);
|
||||
}
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
$subElements[$i] = $element->getID();
|
||||
$i++;
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
if ($this->unit) {
|
||||
$html .= '<div class="n2_field_unit"><div class="n2_field_unit__current_unit">' . $this->unit . '</div></div>';
|
||||
}
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
$html .= "</div>";
|
||||
|
||||
Js::addInline('new _N2.FormElementGap("' . $this->fieldID . '", ' . json_encode($subElements) . ', "' . self::$separator . '");');
|
||||
|
||||
$this->renderRelatedFields();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $unit
|
||||
*/
|
||||
public function setUnit($unit) {
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
public function getControlName() {
|
||||
return $this->name . $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Group;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Grouping;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class GroupCheckboxOnOff extends Grouping {
|
||||
|
||||
protected function fetchElement() {
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_group_checkbox_onoff'
|
||||
), parent::fetchElement());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class Grouping extends AbstractField implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
protected $rowClass = 'n2_field__grouping';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = false, $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, '', $parameters);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = '';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function decorateElement($element) {
|
||||
|
||||
return $this->parent->decorateElement($element);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
class Hidden extends AbstractFieldHidden {
|
||||
|
||||
protected $hasTooltip = false;
|
||||
|
||||
public function __construct($insertAt, $name = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, false, $default, $parameters);
|
||||
}
|
||||
|
||||
public function getRowClass() {
|
||||
return 'n2_form_element--hidden';
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Hidden;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Font\FontManager;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
|
||||
class HiddenFont extends AbstractFieldHidden {
|
||||
|
||||
protected $rowClass = 'n2_form_element--hidden';
|
||||
|
||||
protected $mode = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
FontManager::enqueue($this->getForm());
|
||||
|
||||
Js::addInline('new _N2.FormElementFontHidden("' . $this->fieldID . '", {
|
||||
mode: "' . $this->mode . '",
|
||||
label: "' . $this->label . '"
|
||||
});');
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
*/
|
||||
public function setMode($mode) {
|
||||
$this->mode = $mode;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Hidden;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\OnOff;
|
||||
|
||||
class HiddenOnOff extends OnOff {
|
||||
|
||||
protected $rowClass = 'n2_form_element--hidden';
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Hidden;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\Style\StyleManager;
|
||||
|
||||
class HiddenStyle extends AbstractFieldHidden {
|
||||
|
||||
protected $rowClass = 'n2_form_element--hidden';
|
||||
|
||||
protected $mode = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
StyleManager::enqueue($this->getForm());
|
||||
|
||||
Js::addInline('new _N2.FormElementStyleHidden("' . $this->fieldID . '", {
|
||||
mode: "' . $this->mode . '",
|
||||
label: "' . $this->label . '"
|
||||
});');
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
*/
|
||||
public function setMode($mode) {
|
||||
$this->mode = $mode;
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class IconTab extends AbstractFieldHidden {
|
||||
|
||||
protected $options = array();
|
||||
protected $relatedValueFields = array();
|
||||
protected $relatedAttribute = '';
|
||||
protected $tooltips = array();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$value = $this->getValue();
|
||||
if (!empty($value)) {
|
||||
$this->defaultValue = $value;
|
||||
} else if (empty($this->defaultValue)) {
|
||||
$this->defaultValue = array_keys($this->options)[0];
|
||||
}
|
||||
|
||||
$html = Html::openTag("div", array(
|
||||
"id" => $this->fieldID . "_icon_tab",
|
||||
"class" => "n2_field_icon_tab",
|
||||
"style" => $this->style
|
||||
));
|
||||
|
||||
$html .= $this->renderOptions();
|
||||
|
||||
$html .= Html::closeTag("div");
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
if (!empty($this->relatedAttribute)) {
|
||||
$options['relatedAttribute'] = $this->relatedAttribute;
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
if (!empty($this->relatedValueFields)) {
|
||||
$options['relatedValueFields'] = $this->relatedValueFields;
|
||||
}
|
||||
|
||||
Js::addInline('new _N2.FormElementIconTab("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tooltips
|
||||
*/
|
||||
public function setTooltips($tooltips) {
|
||||
|
||||
$this->tooltips = $tooltips;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $relatedValueFields
|
||||
*/
|
||||
public function setRelatedValueFields($relatedValueFields) {
|
||||
$this->relatedValueFields = $relatedValueFields;
|
||||
}
|
||||
|
||||
public function renderOptions() {
|
||||
$html = '';
|
||||
foreach ($this->options as $option => $icon) {
|
||||
$class = 'n2_field_icon_tab__option';
|
||||
if ($option == $this->defaultValue) {
|
||||
$class .= ' n2_field_icon_tab__option--selected';
|
||||
}
|
||||
|
||||
$element = array(
|
||||
"class" => $class,
|
||||
"data-ssoption" => $option
|
||||
);
|
||||
|
||||
if (isset($this->tooltips[$option])) {
|
||||
$element += array(
|
||||
"data-n2tip" => $this->tooltips[$option]
|
||||
);
|
||||
|
||||
}
|
||||
$html .= Html::openTag("div", $element);
|
||||
$html .= Html::openTag("i", array(
|
||||
"class" => $icon
|
||||
));
|
||||
$html .= Html::closeTag("i");
|
||||
$html .= Html::closeTag("div");
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
|
||||
class LayerWindowFocus extends AbstractField {
|
||||
|
||||
/**
|
||||
* @var AbstractField
|
||||
*/
|
||||
protected $fieldImage;
|
||||
|
||||
/**
|
||||
* @var AbstractField
|
||||
*/
|
||||
protected $fieldFocusX;
|
||||
|
||||
/**
|
||||
* @var AbstractField
|
||||
*/
|
||||
protected $fieldFocusY;
|
||||
|
||||
|
||||
/**
|
||||
* LayerWindowFocus constructor.
|
||||
*
|
||||
* @param $insertAt
|
||||
* @param $name
|
||||
* @param $label
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name, $label, $parameters = array()) {
|
||||
|
||||
parent::__construct($insertAt, $name, $label, '', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $fieldImage
|
||||
* @param AbstractField $fieldFocusX
|
||||
* @param AbstractField $fieldFocusY
|
||||
*/
|
||||
public function setFields($fieldImage, $fieldFocusX, $fieldFocusY) {
|
||||
|
||||
$this->fieldImage = $fieldImage;
|
||||
$this->fieldFocusX = $fieldFocusX;
|
||||
$this->fieldFocusY = $fieldFocusY;
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
Js::addInline('new _N2.FormElementLayerWindowFocus("' . $this->fieldID . '", ' . json_encode(array(
|
||||
'image' => $this->fieldImage->getID(),
|
||||
'focusX' => $this->fieldFocusX->getID(),
|
||||
'focusY' => $this->fieldFocusY->getID(),
|
||||
)) . ');');
|
||||
|
||||
return '<div id="' . $this->fieldID . '" class="n2_field_layer_window_focus" style="width:314px;"><img class="n2_field_layer_window_focus__image" alt="Error"></div>';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class MarginPadding extends AbstractFieldHidden implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
private static $separator = '|*|';
|
||||
|
||||
protected $unit = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
$default = explode(self::$separator, $this->defaultValue);
|
||||
$value = explode(self::$separator, $this->getValue());
|
||||
$value = $value + $default;
|
||||
|
||||
$html = "<div class='n2_field_margin_padding' style='" . $this->style . "'>";
|
||||
|
||||
$html .= '<div class="n2_field_margin_padding__pre_label"><i class="ssi_16 ssi_16--unlink"></i></div>';
|
||||
$subElements = array();
|
||||
$i = 0;
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$element->setExposeName(false);
|
||||
if (isset($value[$i])) {
|
||||
$element->setDefaultValue($value[$i]);
|
||||
}
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
$subElements[$i] = $element->getID();
|
||||
$i++;
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
if ($this->unit) {
|
||||
$html .= '<div class="n2_field_unit"><div class="n2_field_unit__current_unit">' . $this->unit . '</div></div>';
|
||||
}
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
$html .= "</div>";
|
||||
|
||||
Js::addInline('new _N2.FormElementMarginPadding("' . $this->fieldID . '", ' . json_encode($subElements) . ', "' . self::$separator . '");');
|
||||
|
||||
$this->renderRelatedFields();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $unit
|
||||
*/
|
||||
public function setUnit($unit) {
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
public function getControlName() {
|
||||
return $this->name . $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
|
||||
abstract class Message extends AbstractField {
|
||||
|
||||
protected $description = '';
|
||||
|
||||
protected $classes = array('n2_field_message');
|
||||
|
||||
public function __construct($insertAt, $name, $label, $description) {
|
||||
$this->description = $description;
|
||||
parent::__construct($insertAt, $name, $label);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
return '<div class="' . implode(' ', $this->classes) . '">' . $this->description . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Message;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Message;
|
||||
|
||||
class Notice extends Message {
|
||||
|
||||
public function __construct($insertAt, $name, $label, $description) {
|
||||
$this->classes[] = 'n2_field_message--notice';
|
||||
parent::__construct($insertAt, $name, $label, $description);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Message;
|
||||
|
||||
use Nextend\Framework\Form\Element\Message;
|
||||
|
||||
class Warning extends Message {
|
||||
|
||||
protected $description = '';
|
||||
|
||||
public function __construct($insertAt, $name, $description) {
|
||||
$this->classes[] = 'n2_field_message--warning';
|
||||
parent::__construct($insertAt, $name, n2_('Warning'), $description);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
return '<div class="' . implode(' ', $this->classes) . '">' . $this->description . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class MixedField extends AbstractFieldHidden implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
private $separator = '|*|';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $rowClass = 'n2_field_mixed ';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$default = explode($this->separator, $this->defaultValue);
|
||||
$value = explode($this->separator, $this->getValue());
|
||||
$value = $value + $default;
|
||||
|
||||
$html = '';
|
||||
$subElements = array();
|
||||
$i = 0;
|
||||
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$element->setExposeName(false);
|
||||
if (isset($value[$i])) {
|
||||
$element->setDefaultValue($value[$i]);
|
||||
}
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$subElements[$i] = $element->getID();
|
||||
$i++;
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementMixed("' . $this->fieldID . '", ' . json_encode($subElements) . ', "' . $this->separator . '");');
|
||||
|
||||
return $this->decorate($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = $style;
|
||||
}
|
||||
|
||||
public function getControlName() {
|
||||
return $this->name . $this->controlName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
return $this->parent->decorateElement($element);
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\MixedField;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\Element\MixedField;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Form\Element\Text\Color;
|
||||
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Border extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_mixed_border ';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
new NumberAutoComplete($this, $this->name . '-1', false, '', array(
|
||||
'values' => array(
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
5
|
||||
),
|
||||
'min' => 0,
|
||||
'wide' => 3,
|
||||
'unit' => 'px',
|
||||
'relatedFields' => array(
|
||||
$this->generateId($this->getControlName() . $this->name . '-2'),
|
||||
$this->generateId($this->getControlName() . $this->name . '-3')
|
||||
)
|
||||
));
|
||||
|
||||
new Select($this, $this->name . '-2', false, '', array(
|
||||
'options' => array(
|
||||
'none' => n2_('None'),
|
||||
'dotted' => n2_('Dotted'),
|
||||
'dashed' => n2_('Dashed'),
|
||||
'solid' => n2_('Solid'),
|
||||
'double' => n2_('Double'),
|
||||
'groove' => n2_('Groove'),
|
||||
'ridge' => n2_('Ridge'),
|
||||
'inset' => n2_('Inset'),
|
||||
'outset' => n2_('Outset')
|
||||
)
|
||||
));
|
||||
|
||||
new Color($this, $this->name . '-3', false, '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return Html::tag('div', array(
|
||||
'data-field' => $element->getID()
|
||||
), $elementHtml[1]);
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed_border__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\MixedField;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\Element\MixedField;
|
||||
use Nextend\Framework\Form\Element\Text\Color;
|
||||
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
|
||||
|
||||
class BoxShadow extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_mixed_box_shadow ';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
for ($i = 1; $i < 5; $i++) {
|
||||
new NumberAutoComplete($this, $this->name . '-' . $i, false, 0, array(
|
||||
'wide' => 3
|
||||
));
|
||||
}
|
||||
new Color($this, $this->name . '-5', false, '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed_box_shadow__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\MixedField;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\Element\MixedField;
|
||||
use Nextend\Framework\Form\Element\Text\NumberSlider;
|
||||
use Nextend\Framework\Form\Element\Unit;
|
||||
|
||||
class FontSize extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_mixed_font_size ';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
new NumberSlider($this, $this->name . '-1', false, '', array(
|
||||
'min' => 1,
|
||||
'max' => 10000,
|
||||
'sliderMax' => 100,
|
||||
'units' => array(
|
||||
'pxMin' => 1,
|
||||
'pxMax' => 10000,
|
||||
'pxSliderMax' => 100,
|
||||
'%Min' => 1,
|
||||
'%Max' => 10000,
|
||||
'%SliderMax' => 600
|
||||
),
|
||||
'style' => 'width: 22px;'
|
||||
));
|
||||
new Unit($this, $this->name . '-2', false, '', array(
|
||||
'units' => array(
|
||||
'px' => 'px',
|
||||
'%' => '%'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed_font_size__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\MixedField;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\MixedField;
|
||||
use Nextend\Framework\Form\Element\Radio;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class GeneratorOrder extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_mixed_generator_order ';
|
||||
|
||||
protected $options = array();
|
||||
|
||||
public function __construct($insertAt, $name = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, false, $default, $parameters);
|
||||
|
||||
new Select($this, $name . '-1', n2_('Field'), '', $this->options);
|
||||
|
||||
new Radio($this, $name . '-2', n2_('Order'), '', array(
|
||||
'options' => array(
|
||||
'asc' => n2_('Ascending'),
|
||||
'desc' => n2_('Descending')
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed_generator_order__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
|
||||
protected function setOptions($options) {
|
||||
$this->options = array(
|
||||
'options' => $options
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\MixedField;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\Element\MixedField;
|
||||
use Nextend\Framework\Form\Element\Text\Color;
|
||||
use Nextend\Framework\Form\Element\Text\NumberAutoComplete;
|
||||
|
||||
class TextShadow extends MixedField {
|
||||
|
||||
protected $rowClass = 'n2_field_mixed_text_shadow ';
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
for ($i = 1; $i < 4; $i++) {
|
||||
new NumberAutoComplete($this, $this->name . '-' . $i, false, 0, array(
|
||||
'wide' => 3
|
||||
));
|
||||
}
|
||||
new Color($this, $this->name . '-4', false, '', array(
|
||||
'alpha' => true
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
$elementHtml = $element->render();
|
||||
|
||||
return $elementHtml[1];
|
||||
}
|
||||
|
||||
protected function decorate($html) {
|
||||
|
||||
return '<div class="n2_field_mixed_text_shadow__container" style="' . $this->style . '">' . $html . '</div>';
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
|
||||
class OnOff extends AbstractFieldHidden {
|
||||
|
||||
protected $relatedFieldsOn = array();
|
||||
|
||||
protected $relatedAttribute = '';
|
||||
|
||||
protected $values = array(
|
||||
0 => 0,
|
||||
1 => 1
|
||||
);
|
||||
|
||||
protected $customValues = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = '<div class="n2_field_onoff' . $this->isOn() . '" role="switch" aria-checked="false" tabindex="0" aria-label="' . $this->label . '">' . parent::fetchElement() . '<div class="n2_field_onoff__slider"><div class="n2_field_onoff__slider_bullet"></div></div><div class="n2_field_onoff__labels"><div class="n2_field_onoff__label n2_field_onoff__label_off">' . n2_('Off') . '</div><div class="n2_field_onoff__label n2_field_onoff__label_on">' . n2_('On') . '</div></div></div>';
|
||||
|
||||
$options = array();
|
||||
|
||||
if ($this->customValues) {
|
||||
$options['values'] = $this->customValues;
|
||||
}
|
||||
if (!empty($this->relatedFieldsOff)) {
|
||||
$options['relatedFieldsOff'] = $this->relatedFieldsOff;
|
||||
}
|
||||
if (!empty($this->relatedFieldsOn)) {
|
||||
$options['relatedFieldsOn'] = $this->relatedFieldsOn;
|
||||
}
|
||||
if (!empty($this->relatedAttribute)) {
|
||||
$options['relatedAttribute'] = $this->relatedAttribute;
|
||||
}
|
||||
|
||||
Js::addInline('new _N2.FormElementOnoff("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function isOn() {
|
||||
$value = $this->getValue();
|
||||
if (($this->customValues && $this->customValues[$value]) || (!$this->customValues && $value)) {
|
||||
return ' n2_field_onoff--on';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $relatedFields
|
||||
*/
|
||||
public function setRelatedFieldsOn($relatedFields) {
|
||||
$this->relatedFieldsOn = $relatedFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $relatedFields
|
||||
*/
|
||||
public function setRelatedFieldsOff($relatedFields) {
|
||||
$this->relatedFieldsOff = $relatedFields;
|
||||
}
|
||||
|
||||
public function setRelatedAttribute($relatedAttribute) {
|
||||
$this->relatedAttribute = $relatedAttribute;
|
||||
}
|
||||
|
||||
public function setCustomValues($offValue = 0, $onValue = 1) {
|
||||
|
||||
if ($offValue === 0 && $onValue === 1) {
|
||||
$this->customValues = false;
|
||||
} else {
|
||||
$this->customValues = array();
|
||||
$this->customValues[$offValue] = 0;
|
||||
$this->customValues[$onValue] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function setInvert($isInvert) {
|
||||
if ($isInvert) {
|
||||
$this->setCustomValues(1, 0);
|
||||
} else {
|
||||
$this->setCustomValues(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Radio extends AbstractFieldHidden {
|
||||
|
||||
protected $options = array();
|
||||
|
||||
protected $class = 'n2_field_radio';
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $value;
|
||||
|
||||
protected function addScript() {
|
||||
Js::addInline('new _N2.FormElementRadio("' . $this->fieldID . '", ' . json_encode(array_keys($this->options)) . ', ' . json_encode($this->relatedFields) . ');');
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->value = $this->getValue();
|
||||
|
||||
$html = Html::tag('div', array(
|
||||
'class' => $this->class,
|
||||
'style' => $this->style
|
||||
), $this->renderOptions() . parent::fetchElement());
|
||||
|
||||
$this->addScript();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOptions() {
|
||||
|
||||
$html = '';
|
||||
$i = 0;
|
||||
foreach ($this->options as $value => $label) {
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_radio__option' . ($this->isSelected($value) ? ' n2_field_radio__option--selected' : '')
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_radio__option_marker'
|
||||
), '<i class="ssi_16 ssi_16--check"></i>') . '<div class="n2_field_radio__option_label">' . $label . '</div>');
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function isSelected($value) {
|
||||
if ((string)$value == $this->value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function setStyle($style) {
|
||||
$this->style = $style;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Radio;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Radio;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
abstract class AbstractRadioIcon extends Radio {
|
||||
|
||||
protected $class = 'n2_field_radio_icon';
|
||||
|
||||
protected function renderOptions() {
|
||||
|
||||
$html = '';
|
||||
$i = 0;
|
||||
foreach ($this->options as $value => $class) {
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_radio__option' . ($this->isSelected($value) ? ' n2_field_radio__option--selected' : '')
|
||||
), Html::tag('i', array('class' => $class)));
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Radio;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractFieldHidden;
|
||||
use Nextend\Framework\Url\Url;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
abstract class ImageList extends AbstractFieldHidden {
|
||||
|
||||
protected $hasDisabled = true;
|
||||
|
||||
protected $width = 44;
|
||||
|
||||
protected $column = 5;
|
||||
|
||||
protected $options = array();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$jsParameters = array(
|
||||
'width' => $this->width
|
||||
);
|
||||
|
||||
if ($this->hasDisabled) {
|
||||
$jsParameters['hasDisabled'] = true;
|
||||
}
|
||||
|
||||
$html = Html::openTag("div", array(
|
||||
'class' => 'n2_field_image_list',
|
||||
'style' => $this->style
|
||||
));
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
$html .= '<div class="n2_field_image_list__preview">';
|
||||
|
||||
$html .= '</div>';
|
||||
$html .= '<i class="n2_field_image_list__arrow ssi_16 ssi_16--selectarrow"></i>';
|
||||
|
||||
$html .= $this->postHTML();
|
||||
|
||||
$html .= Html::closeTag('div');
|
||||
|
||||
$frontendOptions = array();
|
||||
foreach ($this->options as $key => $option) {
|
||||
$frontendOptions[$key] = array(
|
||||
'url' => Url::pathToUri($option['path'])
|
||||
);
|
||||
|
||||
if (!empty($option['label'])) {
|
||||
$frontendOptions[$key]['label'] = $option['label'];
|
||||
}
|
||||
}
|
||||
|
||||
$jsParameters['column'] = min($this->column, count($this->options) + ($this->hasDisabled ? 1 : 0));
|
||||
$jsParameters['options'] = $frontendOptions;
|
||||
|
||||
Js::addInline('new _N2.FormElementImageList("' . $this->fieldID . '", ' . json_encode($jsParameters) . ', ' . json_encode($this->relatedFields) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasDisabled
|
||||
*/
|
||||
public function setHasDisabled($hasDisabled) {
|
||||
$this->hasDisabled = $hasDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $column
|
||||
*/
|
||||
public function setColumn($column) {
|
||||
$this->column = $column;
|
||||
}
|
||||
|
||||
protected function postHTML() {
|
||||
return '';
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Radio;
|
||||
|
||||
use Nextend\Framework\Filesystem\Filesystem;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
|
||||
class ImageListFromFolder extends ImageList implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
protected $folder = '';
|
||||
|
||||
protected $filenameOnly = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->initOptions();
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
|
||||
private function initOptions() {
|
||||
|
||||
$value = $this->getValue();
|
||||
$currentValue = basename($value);
|
||||
if ($value !== $currentValue) {
|
||||
$this->setValue($currentValue);
|
||||
}
|
||||
|
||||
|
||||
$files = Filesystem::files($this->folder);
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
$ext = pathinfo($files[$i], PATHINFO_EXTENSION);
|
||||
$extensions = array(
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'png',
|
||||
'svg',
|
||||
'gif',
|
||||
'webp'
|
||||
);
|
||||
if (in_array($ext, $extensions)) {
|
||||
|
||||
$path = $this->folder . $files[$i];
|
||||
|
||||
if ($this->filenameOnly) {
|
||||
$value = pathinfo($files[$i], PATHINFO_FILENAME);
|
||||
} else {
|
||||
$value = basename($files[$i]);
|
||||
}
|
||||
|
||||
$this->options[$value] = array(
|
||||
'path' => $path
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->options[$currentValue])) {
|
||||
foreach ($this->options as $value => $option) {
|
||||
if (pathinfo($value, PATHINFO_FILENAME) == $currentValue) {
|
||||
$currentValue = $value;
|
||||
$this->setValue($currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function postHTML() {
|
||||
if ($this->first) {
|
||||
$html = '<div class="n2_field_image_list__fields">';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function setFolder($folder) {
|
||||
$this->folder = $folder;
|
||||
}
|
||||
|
||||
public function setFilenameOnly($value) {
|
||||
$this->filenameOnly = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
$html = '<div class="n2_field">';
|
||||
$html .= '<div class="n2_field__label">';
|
||||
$html .= $element->fetchTooltip();
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="n2_field__element">';
|
||||
$html .= $element->fetchElement();
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Radio;
|
||||
|
||||
class TextAlign extends AbstractRadioIcon {
|
||||
|
||||
protected $options = array(
|
||||
'inherit' => 'ssi_16 ssi_16--none',
|
||||
'left' => 'ssi_16 ssi_16--textleft',
|
||||
'center' => 'ssi_16 ssi_16--textcenter',
|
||||
'right' => 'ssi_16 ssi_16--textright',
|
||||
'justify' => 'ssi_16 ssi_16--textjustify'
|
||||
);
|
||||
|
||||
/**
|
||||
* @param $excluded array
|
||||
*/
|
||||
public function setExcludeOptions($excluded) {
|
||||
foreach ($excluded as $exclude) {
|
||||
if (isset($this->options[$exclude])) {
|
||||
unset($this->options[$exclude]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class RichTextarea extends AbstractField {
|
||||
|
||||
protected $fieldStyle = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
Js::addInline('new _N2.FormElementRichText("' . $this->fieldID . '");');
|
||||
|
||||
$tools = array(
|
||||
Html::tag('div', array(
|
||||
'class' => 'n2_field_textarea_rich__button',
|
||||
'data-action' => 'bold'
|
||||
), Html::tag('I', array('class' => 'ssi_16 ssi_16--bold'))),
|
||||
Html::tag('div', array(
|
||||
'class' => 'n2_field_textarea_rich__button',
|
||||
'data-action' => 'italic'
|
||||
), Html::tag('I', array('class' => 'ssi_16 ssi_16--italic'))),
|
||||
Html::tag('div', array(
|
||||
'class' => 'n2_field_textarea_rich__button',
|
||||
'data-action' => 'link'
|
||||
), Html::tag('I', array('class' => 'ssi_16 ssi_16--link')))
|
||||
);
|
||||
|
||||
$buttons = Html::tag('div', array(
|
||||
'class' => 'n2_field_textarea_rich__buttons'
|
||||
), implode('', $tools));
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_textarea_rich',
|
||||
'style' => $this->style
|
||||
), $buttons . Html::tag('textarea', array(
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'autocomplete' => 'off',
|
||||
'style' => $this->fieldStyle
|
||||
), $this->getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fieldStyle
|
||||
*/
|
||||
public function setFieldStyle($fieldStyle) {
|
||||
$this->fieldStyle = $fieldStyle;
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Select extends AbstractFieldHidden {
|
||||
|
||||
public $value;
|
||||
|
||||
protected $values = array();
|
||||
protected $options = array();
|
||||
protected $optgroup = array();
|
||||
protected $isMultiple = false;
|
||||
protected $size = '';
|
||||
|
||||
protected $relatedValueFields = array();
|
||||
protected $relatedAttribute = '';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->values = explode('||', $this->getValue());
|
||||
if (!is_array($this->values)) {
|
||||
$this->values = array();
|
||||
}
|
||||
|
||||
$html = Html::openTag("div", array(
|
||||
"class" => "n2_field_select",
|
||||
"style" => $this->style
|
||||
));
|
||||
|
||||
$selectAttributes = array(
|
||||
'id' => $this->fieldID . '_select',
|
||||
'name' => 'select' . $this->getFieldName(),
|
||||
'aria-labelledby' => $this->fieldID,
|
||||
'autocomplete' => 'off'
|
||||
);
|
||||
|
||||
if (!empty($this->size)) {
|
||||
$selectAttributes['size'] = $this->size;
|
||||
}
|
||||
|
||||
if ($this->isMultiple) {
|
||||
$selectAttributes['multiple'] = 'multiple';
|
||||
$selectAttributes['class'] = 'nextend-element-hastip';
|
||||
$selectAttributes['title'] = n2_('Hold down the ctrl (Windows) or command (MAC) button to select multiple options.');
|
||||
}
|
||||
|
||||
$html .= Html::tag('select', $selectAttributes, $this->renderOptions($this->options) . (!empty($this->optgroup) ? $this->renderOptgroup() : ''));
|
||||
|
||||
$html .= Html::closeTag("div");
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
$options = array();
|
||||
|
||||
if (!empty($this->relatedFields)) {
|
||||
$options['relatedFields'] = $this->relatedFields;
|
||||
}
|
||||
|
||||
if (!empty($this->relatedValueFields)) {
|
||||
$options['relatedValueFields'] = $this->relatedValueFields;
|
||||
}
|
||||
|
||||
if (!empty($this->relatedAttribute)) {
|
||||
$options['relatedAttribute'] = $this->relatedAttribute;
|
||||
}
|
||||
|
||||
Js::addInline('new _N2.FormElementList("' . $this->fieldID . '", ' . json_encode($options) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOptgroup() {
|
||||
$html = '';
|
||||
foreach ($this->optgroup as $label => $options) {
|
||||
if (is_array($options)) {
|
||||
$html .= "<optgroup label='" . $label . "'>";
|
||||
$html .= $this->renderOptions($options);
|
||||
$html .= "</optgroup>";
|
||||
} else {
|
||||
$html .= $this->renderOption($label, $options);
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOptions($options) {
|
||||
$html = '';
|
||||
foreach ($options as $value => $label) {
|
||||
$html .= $this->renderOption($value, $label);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function renderOption($value, $label) {
|
||||
|
||||
return '<option value="' . esc_attr($value) . '" ' . $this->isSelected($value) . '>' . $label . '</option>';
|
||||
}
|
||||
|
||||
protected function isSelected($value) {
|
||||
if (in_array($value, $this->values)) {
|
||||
return ' selected="selected"';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $optgroup
|
||||
*/
|
||||
public function setOptgroup($optgroup) {
|
||||
$this->optgroup = $optgroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isMultiple
|
||||
*/
|
||||
public function setIsMultiple($isMultiple) {
|
||||
$this->isMultiple = $isMultiple;
|
||||
$this->size = 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $size
|
||||
*/
|
||||
public function setSize($size) {
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
protected function createTree(&$list, &$new, $parent, $cindent = '', $indent = '- ') {
|
||||
|
||||
if (isset($new[$parent])) {
|
||||
for ($i = 0; $i < count($new[$parent]); $i++) {
|
||||
$new[$parent][$i]->treename = $cindent . $new[$parent][$i]->name;
|
||||
$list[] = $new[$parent][$i];
|
||||
$this->createTree($list, $new, $new[$parent][$i]->cat_ID, $cindent . $indent, $indent);
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function setRelatedValueFields($relatedValueFields) {
|
||||
$this->relatedValueFields = $relatedValueFields;
|
||||
}
|
||||
|
||||
public function setRelatedAttribute($relatedAttribute) {
|
||||
$this->relatedAttribute = $relatedAttribute;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class Easing extends Select {
|
||||
|
||||
protected $options = array(
|
||||
"linear" => "Linear",
|
||||
"easeInQuad" => "Quad In",
|
||||
"easeOutQuad" => "Quad Out",
|
||||
"easeInOutQuad" => "Quad In Out",
|
||||
"easeInCubic" => "Cubic In",
|
||||
"easeOutCubic" => "Cubic Out",
|
||||
"easeInOutCubic" => "Cubic In Out",
|
||||
"easeInQuart" => "Quart In",
|
||||
"easeOutQuart" => "Quart Out",
|
||||
"easeInOutQuart" => "Quart In Out",
|
||||
"easeInQuint" => "Quint In",
|
||||
"easeOutQuint" => "Quint Out",
|
||||
"easeInOutQuint" => "Quint In Out",
|
||||
"easeInSine" => "Sine In",
|
||||
"easeOutSine" => "Sine Out",
|
||||
"easeInOutSine" => "Sine In Out",
|
||||
"easeInExpo" => "Expo In",
|
||||
"easeOutExpo" => "Expo Out",
|
||||
"easeInOutExpo" => "Expo In Out",
|
||||
"easeInCirc" => "Circ In",
|
||||
"easeOutCirc" => "Circ Out",
|
||||
"easeInOutCirc" => "Circ In Out",
|
||||
"easeInElastic" => "Elastic In",
|
||||
"easeOutElastic" => "Elastic Out",
|
||||
"easeInOutElastic" => "Elastic In Out",
|
||||
"easeInBack" => "Back In",
|
||||
"easeOutBack" => "Back Out",
|
||||
"easeInOutBack" => "Back In Out",
|
||||
"easeInBounce" => "Bounce In",
|
||||
"easeOutBounce" => "Bounce Out",
|
||||
"easeInOutBounce" => "Bounce In Out"
|
||||
);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class FillMode extends Select {
|
||||
|
||||
protected $useGlobal = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->options = array(
|
||||
'fill' => n2_('Fill'),
|
||||
'blurfit' => n2_('Blur fit'),
|
||||
'fit' => n2_('Fit'),
|
||||
'stretch' => n2_('Stretch'),
|
||||
'center' => n2_('Center')
|
||||
);
|
||||
|
||||
if ($this->useGlobal) {
|
||||
$this->options = array_merge(array(
|
||||
'default' => n2_('Slider\'s default')
|
||||
), $this->options);
|
||||
}
|
||||
|
||||
return parent::fetchElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useGlobal
|
||||
*/
|
||||
public function setUseGlobal($useGlobal) {
|
||||
$this->useGlobal = $useGlobal;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class Filter extends Select {
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
$no_label = strtolower($this->label);
|
||||
|
||||
$this->options = array(
|
||||
'0' => n2_('All'),
|
||||
'1' => $this->label,
|
||||
'-1' => sprintf(n2_('Not %s'), $no_label)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class FontWeight extends Select {
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = false, $default = '', $parameters = array()) {
|
||||
$this->options = array(
|
||||
'0' => n2_('Normal'),
|
||||
'1' => n2_('Bold'),
|
||||
'100' => '100',
|
||||
'200' => '200 - ' . n2_('Extra light'),
|
||||
'300' => '300 - ' . n2_('Light'),
|
||||
'400' => '400 - ' . n2_('Normal'),
|
||||
'500' => '500',
|
||||
'600' => '600 - ' . n2_('Semi bold'),
|
||||
'700' => '700 - ' . n2_('Bold'),
|
||||
'800' => '800 - ' . n2_('Extra bold'),
|
||||
'900' => '900'
|
||||
);
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class Gradient extends Select {
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
$this->options = array(
|
||||
'off' => n2_('Off'),
|
||||
'vertical' => '↓',
|
||||
'horizontal' => '→',
|
||||
'diagonal1' => '↗',
|
||||
'diagonal2' => '↘'
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class LinkTarget extends Select {
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '_self', array $parameters = array()) {
|
||||
$this->options = array(
|
||||
'_self' => n2_('Self'),
|
||||
'_blank' => n2_('New'),
|
||||
'_parent' => n2_('Parent'),
|
||||
'_top' => n2_('Top')
|
||||
);
|
||||
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
use Nextend\Framework\Platform\Platform;
|
||||
|
||||
class SelectFile extends Select {
|
||||
|
||||
/**
|
||||
* File constructor.
|
||||
*
|
||||
* @param $insertAt
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param string $default
|
||||
* @param string $extension
|
||||
* @param array $parameters
|
||||
*
|
||||
*/
|
||||
public function __construct($insertAt, $name = '', $label = '', $default = '', $extension = '', $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
|
||||
$dir = Platform::getPublicDirectory();
|
||||
$files = scandir($dir);
|
||||
$validated_files = array();
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == $extension) {
|
||||
$validated_files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
$this->options[''] = n2_('Choose');
|
||||
|
||||
foreach ($validated_files as $f) {
|
||||
$this->options[$f] = $f;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class Skin extends Select {
|
||||
|
||||
protected $fixed = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementSkin("' . $this->fieldID . '", "' . str_replace($this->name, '', $this->fieldID) . '", ' . json_encode($this->options) . ', ' . json_encode($this->fixed) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function renderOptions($options) {
|
||||
$html = '';
|
||||
if (!$this->fixed) {
|
||||
$html .= '<option value="0" selected="selected">' . n2_('Choose') . '</option>';
|
||||
}
|
||||
foreach ($options as $value => $option) {
|
||||
$html .= '<option ' . $this->isSelected($value) . ' value="' . $value . '">' . $option['label'] . '</option>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $fixed
|
||||
*/
|
||||
public function setFixed($fixed) {
|
||||
$this->fixed = $fixed;
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Select;
|
||||
|
||||
|
||||
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\View\Html;
|
||||
|
||||
abstract class SubFormIcon extends AbstractFieldHidden {
|
||||
|
||||
protected $ajaxUrl = '';
|
||||
|
||||
/**
|
||||
* @var ContainerSubform
|
||||
*/
|
||||
protected $containerSubform;
|
||||
|
||||
protected $plugins = array();
|
||||
|
||||
protected $options = array();
|
||||
|
||||
/**
|
||||
* SubFormIcon constructor.
|
||||
*
|
||||
* @param TraitFieldset $insertAt
|
||||
* @param string $name
|
||||
* @param ContainerInterface $container
|
||||
* @param string $ajaxUrl
|
||||
* @param string $default
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($insertAt, $name, $container, $ajaxUrl, $default = '', $parameters = array()) {
|
||||
|
||||
$this->ajaxUrl = $ajaxUrl;
|
||||
|
||||
parent::__construct($insertAt, $name, '', $default, $parameters);
|
||||
|
||||
$this->loadOptions();
|
||||
|
||||
$this->containerSubform = new ContainerSubform($container, $name . '-subform');
|
||||
|
||||
$this->getCurrentPlugin($this->getValue())
|
||||
->renderFields($this->containerSubform);
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$currentValue = $this->getValue();
|
||||
|
||||
Js::addInline('
|
||||
new _N2.FormElementSubformIcon(
|
||||
"' . $this->fieldID . '",
|
||||
"' . $this->ajaxUrl . '",
|
||||
"' . $this->containerSubform->getId() . '",
|
||||
"' . $currentValue . '"
|
||||
);
|
||||
');
|
||||
$html = Html::openTag('div', array(
|
||||
'class' => 'n2_field_subform_icon'
|
||||
));
|
||||
foreach ($this->options as $value => $option) {
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_subform_icon__option' . ($value == $currentValue ? ' n2_field_subform_icon__option--selected' : ''),
|
||||
'data-value' => $value
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_subform_icon__option_icon'
|
||||
), '<i class="' . $option['icon'] . '"></i>') . Html::tag('div', array(
|
||||
'class' => 'n2_field_subform_icon__option_label'
|
||||
), $option['label']));
|
||||
}
|
||||
|
||||
$html .= parent::fetchElement() . '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected abstract function loadOptions();
|
||||
|
||||
|
||||
protected function getCurrentPlugin($value) {
|
||||
|
||||
if (!isset($this->plugins[$value])) {
|
||||
list($value) = array_keys($this->plugins);
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
return $this->plugins[$value];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
*/
|
||||
public function removeOption($option) {
|
||||
if (isset($this->options[$option])) {
|
||||
unset($this->options[$option]);
|
||||
|
||||
if ($this->getValue() === $option) {
|
||||
$this->setValue($this->defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class SelectIcon extends AbstractFieldHidden {
|
||||
|
||||
protected $options;
|
||||
|
||||
public function __construct($insertAt, $name = '', $label = false, $options = array(), $default = '', $parameters = array()) {
|
||||
|
||||
$this->options = $options;
|
||||
|
||||
parent::__construct($insertAt, $name, $label, $default, $parameters);
|
||||
}
|
||||
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$currentValue = $this->getValue();
|
||||
|
||||
$html = Html::openTag('div', array(
|
||||
'class' => 'n2_field_select_icon'
|
||||
));
|
||||
|
||||
foreach ($this->options as $value => $option) {
|
||||
|
||||
$classes = array('n2_field_select_icon__option');
|
||||
if ($currentValue == $value) {
|
||||
$classes[] = 'n2_field_select_icon__option--selected';
|
||||
}
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => implode(' ', $classes),
|
||||
'data-value' => $value
|
||||
), Html::tag('div', array(
|
||||
'class' => 'n2_field_select_icon__option_icon'
|
||||
), '<i class="' . $option['icon'] . '"></i>') . Html::tag('div', array(
|
||||
'class' => 'n2_field_select_icon__option_label'
|
||||
), $option['label']) . Html::tag('div', array(
|
||||
'class' => 'n2_field_select_icon__selected_marker'
|
||||
), '<i class="ssi_16 ssi_16--check"></i>'));
|
||||
}
|
||||
|
||||
$html .= Html::closeTag('div');
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementSelectIcon("' . $this->fieldID . '", ' . json_encode(array()) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\Style\StyleManager;
|
||||
use Nextend\Framework\Style\StyleParser;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Style extends AbstractFieldHidden {
|
||||
|
||||
protected $mode = '';
|
||||
|
||||
protected $font = '';
|
||||
|
||||
protected $font2 = '';
|
||||
|
||||
protected $style2 = '';
|
||||
|
||||
protected $preview = '';
|
||||
|
||||
protected $css = '';
|
||||
|
||||
protected function addScript() {
|
||||
|
||||
StyleManager::enqueue($this->getForm());
|
||||
|
||||
$preview = preg_replace_callback('/url\(\'(.*?)\'\)/', array(
|
||||
$this,
|
||||
'fixPreviewImages'
|
||||
), $this->preview);
|
||||
|
||||
Js::addInline('new _N2.FormElementStyle("' . $this->fieldID . '", {
|
||||
mode: "' . $this->mode . '",
|
||||
label: "' . $this->label . '",
|
||||
font: "' . $this->font . '",
|
||||
font2: "' . $this->font2 . '",
|
||||
style2: "' . $this->style2 . '",
|
||||
preview: ' . json_encode($preview) . '
|
||||
});');
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addScript();
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_style'
|
||||
), n2_('Style') . parent::fetchElement());
|
||||
}
|
||||
|
||||
public function fixPreviewImages($matches) {
|
||||
return "url(" . ResourceTranslator::toUrl($matches[1]) . ")";
|
||||
}
|
||||
|
||||
public function getValue() {
|
||||
|
||||
return StyleParser::parse(parent::getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
*/
|
||||
public function setMode($mode) {
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $font
|
||||
*/
|
||||
public function setFont($font) {
|
||||
$this->font = $font;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $font2
|
||||
*/
|
||||
public function setFont2($font2) {
|
||||
$this->font2 = $font2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style2
|
||||
*/
|
||||
public function setStyle2($style2) {
|
||||
$this->style2 = $style2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $preview
|
||||
*/
|
||||
public function setPreview($preview) {
|
||||
$this->preview = $preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
*/
|
||||
public function setCss($css) {
|
||||
$this->css = $css;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Tab extends AbstractFieldHidden {
|
||||
|
||||
protected $options = array();
|
||||
protected $relatedValueFields = array();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
if (empty($this->defaultValue) && !empty($this->options)) {
|
||||
$this->defaultValue = array_keys($this->options)[0];
|
||||
}
|
||||
|
||||
$html = Html::openTag("div", array(
|
||||
"id" => $this->fieldID . "_tab",
|
||||
"class" => "n2_field_tab",
|
||||
"style" => $this->style
|
||||
));
|
||||
|
||||
$html .= $this->renderOptions();
|
||||
|
||||
$html .= Html::closeTag("div");
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementTab("' . $this->fieldID . '", ' . json_encode($this->relatedValueFields) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $relatedValueFields
|
||||
*/
|
||||
public function setRelatedValueFields($relatedValueFields) {
|
||||
$this->relatedValueFields = $relatedValueFields;
|
||||
}
|
||||
|
||||
public function renderOptions() {
|
||||
$html = '';
|
||||
foreach ($this->options as $option => $label) {
|
||||
$class = 'n2_field_tab__option';
|
||||
if ($option == $this->defaultValue) {
|
||||
$class .= ' n2_field_tab__option--selected';
|
||||
}
|
||||
$html .= Html::openTag("div", array(
|
||||
"class" => $class,
|
||||
"data-ssoption" => $option
|
||||
));
|
||||
$html .= $label;
|
||||
$html .= Html::closeTag("div");
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\ContainerInterface;
|
||||
use Nextend\Framework\Form\TraitFieldset;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Text extends AbstractField implements ContainerInterface {
|
||||
|
||||
use TraitFieldset;
|
||||
|
||||
protected $attributes = array();
|
||||
|
||||
public $fieldType = 'text';
|
||||
|
||||
protected $unit = false;
|
||||
|
||||
protected function addScript() {
|
||||
Js::addInline('new _N2.FormElementText("' . $this->fieldID . '");');
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$this->addScript();
|
||||
|
||||
if ($this->getValue() === '') {
|
||||
$this->class .= 'n2_field_text--empty ';
|
||||
}
|
||||
|
||||
$html = Html::openTag('div', array(
|
||||
'class' => 'n2_field_text ' . $this->getClass()
|
||||
));
|
||||
|
||||
$html .= $this->pre();
|
||||
$html .= Html::tag('input', $this->attributes + array(
|
||||
'type' => $this->fieldType,
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'value' => $this->getValue(),
|
||||
'style' => $this->getStyle(),
|
||||
'autocomplete' => 'off'
|
||||
), false, false);
|
||||
|
||||
$html .= $this->post();
|
||||
|
||||
if (!empty($this->unit)) {
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_text__unit'
|
||||
), $this->unit);
|
||||
}
|
||||
$html .= "</div>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function setUnit($unit) {
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
protected function pre() {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
|
||||
if ($this->first) {
|
||||
$html = '';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
$html .= $this->decorateElement($element);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
return '<div class="n2_field_text__post">' . $html . '</div>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
list($label, $fieldHTML) = $element->render();
|
||||
|
||||
return $fieldHTML;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
|
||||
class Color extends Text {
|
||||
|
||||
protected $alpha = false;
|
||||
|
||||
protected $class = 'n2_field_color ';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
if ($this->alpha) {
|
||||
$this->class .= 'n2_field_color--alpha ';
|
||||
}
|
||||
|
||||
$html = parent::fetchElement();
|
||||
Js::addInline('new _N2.FormElementColor("' . $this->fieldID . '", ' . intval($this->alpha) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function pre() {
|
||||
|
||||
return '<div class="n2-field-color-preview n2_checker_box"><div class="n2-field-color-preview-inner"></div></div>';
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $alpha
|
||||
*/
|
||||
public function setAlpha($alpha) {
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
|
||||
class Disabled extends Text {
|
||||
|
||||
protected $attributes = array('disabled' => 'disabled');
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Font\FontSettings;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
|
||||
class Family extends Text {
|
||||
|
||||
protected $class = 'n2_field_autocomplete n2_autocomplete_position_to';
|
||||
|
||||
protected function addScript() {
|
||||
parent::addScript();
|
||||
|
||||
$families = FontSettings::getPresetFamilies();
|
||||
Js::addInline('_N2.AutocompleteSimple("' . $this->fieldID . '", ' . json_encode($families) . ');');
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Browse\BrowseManager;
|
||||
use Nextend\Framework\Form\Element\AbstractChooserText;
|
||||
use Nextend\Framework\Image\Image;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\Sanitize;
|
||||
|
||||
class FieldImage extends AbstractChooserText {
|
||||
|
||||
protected $attributes = array();
|
||||
|
||||
protected $relatedAlt = '';
|
||||
|
||||
protected $class = ' n2_field_text_image';
|
||||
|
||||
protected function addScript() {
|
||||
|
||||
$options = array();
|
||||
if (!empty($this->relatedAlt)) {
|
||||
$options['alt'] = $this->relatedAlt;
|
||||
}
|
||||
|
||||
Js::addInline("new _N2.FormElementImage('" . $this->fieldID . "', " . json_encode($options) . " );");
|
||||
}
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
BrowseManager::enqueue($this->getForm());
|
||||
|
||||
$html = parent::fetchElement();
|
||||
|
||||
Image::initLightbox();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function pre() {
|
||||
|
||||
return '<div class="n2_field_text_image__preview" style="' . $this->getImageStyle() . '"></div>';
|
||||
}
|
||||
|
||||
protected function getImageStyle() {
|
||||
$image = $this->getValue();
|
||||
if (empty($image) || $image[0] == '{') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'background-image: url(' . esc_url(ResourceTranslator::toUrl($image)) . ');';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $relatedAlt
|
||||
*/
|
||||
public function setRelatedAlt($relatedAlt) {
|
||||
$this->relatedAlt = $relatedAlt;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Image\ImageManager;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldImageResponsive extends FieldImage {
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = parent::fetchElement();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Browse\BrowseManager;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\Image\Image;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Folder extends Text {
|
||||
|
||||
protected $width = 300;
|
||||
|
||||
protected function addScript() {
|
||||
|
||||
BrowseManager::enqueue($this->getForm());
|
||||
|
||||
Image::initLightbox();
|
||||
|
||||
Js::addInline("new _N2.FormElementFolders('" . $this->fieldID . "' );");
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
|
||||
$html = Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_text__clear',
|
||||
'tabindex' => -1
|
||||
), Html::tag('i', array('class' => 'ssi_16 ssi_16--circularremove'), ''));
|
||||
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_text__choose',
|
||||
'aria-label' => n2_('Choose')
|
||||
), '<i class="ssi_16 ssi_16--plus"></i>');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
|
||||
class HiddenText extends Text {
|
||||
|
||||
public $fieldType = 'hidden';
|
||||
|
||||
public function getRowClass() {
|
||||
return 'n2_form_element--hidden';
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Number extends Text {
|
||||
|
||||
protected $class = 'n2_field_number ';
|
||||
|
||||
protected $min = false;
|
||||
protected $max = false;
|
||||
protected $sublabel = '';
|
||||
|
||||
protected $units = false;
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
if ($this->min === false) {
|
||||
$this->min = '-Number.MAX_VALUE';
|
||||
}
|
||||
|
||||
if ($this->max === false) {
|
||||
$this->max = 'Number.MAX_VALUE';
|
||||
}
|
||||
|
||||
$this->addScript();
|
||||
|
||||
$this->renderRelatedFields();
|
||||
|
||||
$html = Html::openTag('div', array(
|
||||
'class' => 'n2_field_text ' . $this->getClass()
|
||||
));
|
||||
|
||||
if (!empty($this->sublabel)) {
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_text__pre_label'
|
||||
), $this->sublabel);
|
||||
}
|
||||
|
||||
$html .= $this->pre();
|
||||
|
||||
$html .= Html::tag('input', array(
|
||||
'type' => $this->fieldType,
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'value' => $this->getValue(),
|
||||
'style' => $this->getStyle(),
|
||||
'autocomplete' => 'off'
|
||||
), false, false);
|
||||
|
||||
$html .= $this->post();
|
||||
|
||||
if ($this->unit) {
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_number__unit'
|
||||
), $this->unit);
|
||||
}
|
||||
$html .= "</div>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function addScript() {
|
||||
Js::addInline('new _N2.FormElementNumber("' . $this->fieldID . '", ' . $this->min . ', ' . $this->max . ', ' . json_encode($this->units) . ');');
|
||||
}
|
||||
|
||||
public function setMin($min) {
|
||||
$this->min = $min;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
*/
|
||||
public function setMax($max) {
|
||||
$this->max = $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sublabel
|
||||
*/
|
||||
public function setSublabel($sublabel) {
|
||||
$this->sublabel = $sublabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|array $units
|
||||
*/
|
||||
public function setUnits($units) {
|
||||
$this->units = $units;
|
||||
}
|
||||
|
||||
public function setWide($wide) {
|
||||
switch ($wide) {
|
||||
case 2:
|
||||
$this->style .= 'width:20px;';
|
||||
break;
|
||||
case 3:
|
||||
$this->style .= 'width:26px;';
|
||||
break;
|
||||
case 4:
|
||||
$this->style .= 'width:32px;';
|
||||
break;
|
||||
case 5:
|
||||
$this->style .= 'width:44px;';
|
||||
break;
|
||||
case 6:
|
||||
$this->style .= 'width:60px;';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
|
||||
class NumberAutoComplete extends Number {
|
||||
|
||||
protected $values = array();
|
||||
|
||||
protected $class = 'n2_field_number n2_autocomplete_position_to ';
|
||||
|
||||
protected function addScript() {
|
||||
parent::addScript();
|
||||
|
||||
Js::addInline('_N2.AutocompleteSimple("' . $this->fieldID . '", ' . json_encode($this->values) . ');');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function setValues($values) {
|
||||
$this->values = $values;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
|
||||
class NumberSlider extends Number {
|
||||
|
||||
protected $step = 1;
|
||||
|
||||
protected $sliderMax;
|
||||
|
||||
protected function fetchElement() {
|
||||
$html = parent::fetchElement();
|
||||
|
||||
Js::addInline('new _N2.FormElementNumberSlider("' . $this->fieldID . '", ' . json_encode(array(
|
||||
'min' => floatval($this->min),
|
||||
'max' => floatval($this->sliderMax),
|
||||
'step' => floatval($this->step),
|
||||
'units' => $this->units
|
||||
)) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $step
|
||||
*/
|
||||
public function setStep($step) {
|
||||
$this->step = $step;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sliderMax
|
||||
*/
|
||||
public function setSliderMax($sliderMax) {
|
||||
$this->sliderMax = $sliderMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max
|
||||
*/
|
||||
public function setMax($max) {
|
||||
parent::setMax($max);
|
||||
|
||||
if ($this->sliderMax === null) {
|
||||
$this->sliderMax = $max;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
|
||||
class TextAutoComplete extends Text {
|
||||
|
||||
protected $class = 'n2_field_autocomplete n2_autocomplete_position_to';
|
||||
|
||||
protected $values = array();
|
||||
|
||||
protected function addScript() {
|
||||
parent::addScript();
|
||||
|
||||
Js::addInline('_N2.AutocompleteSimple("' . $this->fieldID . '", ' . json_encode($this->values) . ');');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function setValues($values) {
|
||||
$this->values = $values;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\Text;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class TextMultiAutoComplete extends Text {
|
||||
|
||||
protected $options = array();
|
||||
|
||||
protected $class = 'n2_field_autocomplete ';
|
||||
|
||||
protected function addScript() {
|
||||
Js::addInline('new _N2.FormElementAutocomplete("' . $this->fieldID . '", ' . json_encode($this->options) . ');');
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
return Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_text__clear',
|
||||
'tabindex' => -1
|
||||
), Html::tag('i', array('class' => 'ssi_16 ssi_16--circularremove'), ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions($options) {
|
||||
$this->options = $options;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\Element\AbstractChooserText;
|
||||
use Nextend\Framework\Pattern\MVCHelperTrait;
|
||||
use Nextend\Framework\Platform\Platform;
|
||||
|
||||
class Url extends AbstractChooserText {
|
||||
|
||||
protected function addScript() {
|
||||
Js::addInline("new _N2.FormElementUrl('" . $this->fieldID . "', " . $this->getElementUrlParameters($this->getForm()) . " );");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MVCHelperTrait $MVCHelper
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getElementUrlParameters($MVCHelper) {
|
||||
$params = array(
|
||||
'hasPosts' => Platform::hasPosts()
|
||||
);
|
||||
|
||||
$params['url'] = $MVCHelper->createAjaxUrl("content/searchlink");
|
||||
$params['labelButton'] = 'WordPress';
|
||||
$params['labelDescription'] = n2_(/** @lang text */ 'Select a page or a blog post from your WordPress site.');
|
||||
|
||||
return json_encode($params);
|
||||
}
|
||||
|
||||
protected function post() {
|
||||
if (!Platform::hasPosts()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return parent::post();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Text;
|
||||
|
||||
|
||||
use Nextend\Framework\Browse\BrowseManager;
|
||||
|
||||
class Video extends FieldImage {
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
BrowseManager::enqueue($this->getForm());
|
||||
|
||||
$html = parent::fetchElement();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Textarea extends AbstractField {
|
||||
|
||||
protected $width = 200;
|
||||
|
||||
protected $height = 44;
|
||||
|
||||
protected $minHeight = 44;
|
||||
|
||||
protected $classes = array(
|
||||
'n2_field_textarea'
|
||||
);
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
Js::addInline('new _N2.FormElementText("' . $this->fieldID . '");');
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => implode(' ', $this->classes),
|
||||
'style' => $this->style
|
||||
), Html::tag('textarea', array(
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'autocomplete' => 'off',
|
||||
'style' => 'width:' . $this->width . 'px;height:' . $this->height . 'px;min-height:' . $this->minHeight . 'px;'
|
||||
), Sanitize::esc_textarea($this->getValue())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width) {
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $height
|
||||
*/
|
||||
public function setHeight($height) {
|
||||
$this->height = $height;
|
||||
if ($this->minHeight > $height) {
|
||||
$this->minHeight = $height;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $minHeight
|
||||
*/
|
||||
public function setMinHeight($minHeight) {
|
||||
$this->minHeight = $minHeight;
|
||||
}
|
||||
|
||||
public function setFieldStyle($style) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element\Textarea;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\Element\Textarea;
|
||||
|
||||
class TextareaInline extends Textarea {
|
||||
|
||||
protected $width = 200;
|
||||
|
||||
protected $height = 26;
|
||||
|
||||
protected $classes = array(
|
||||
'n2_field_textarea',
|
||||
'n2_field_textarea--inline'
|
||||
);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Form\Form;
|
||||
|
||||
class Token extends Hidden {
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
return Form::tokenize();
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Unit extends AbstractFieldHidden {
|
||||
|
||||
protected $style = '';
|
||||
|
||||
protected $units = array();
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$values = array();
|
||||
|
||||
$html = "<div class='n2_field_unit' style='" . $this->style . "'>";
|
||||
|
||||
$currentValue = $this->getValue();
|
||||
$currentLabel = '';
|
||||
|
||||
$html .= Html::openTag('div', array(
|
||||
'class' => 'n2_field_unit__units'
|
||||
));
|
||||
foreach ($this->units as $unit) {
|
||||
$values[] = $unit;
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_unit__unit'
|
||||
), $unit);
|
||||
|
||||
if ($currentValue == $unit) {
|
||||
$currentLabel = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
$html .= Html::tag('div', array(
|
||||
'class' => 'n2_field_unit__current_unit'
|
||||
), $currentLabel);
|
||||
|
||||
$html .= parent::fetchElement();
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
Js::addInline('new _N2.FormElementUnits("' . $this->fieldID . '", ' . json_encode($values) . ');');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $style
|
||||
*/
|
||||
public function setStyle($style) {
|
||||
$this->style = $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $units
|
||||
*/
|
||||
public function setUnits($units) {
|
||||
$this->units = $units;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Element;
|
||||
|
||||
use Nextend\Framework\Asset\Js\Js;
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class Upload extends AbstractField {
|
||||
|
||||
protected $class = 'n2-form-element-file ';
|
||||
|
||||
protected function fetchElement() {
|
||||
|
||||
$html = '';
|
||||
$html .= '<div class="n2_field_chooser__label"></div>';
|
||||
$html .= Html::tag('a', array(
|
||||
'href' => '#',
|
||||
'class' => 'n2_field_chooser__choose'
|
||||
), '<i class="ssi_16 ssi_16--plus"></i>');
|
||||
|
||||
$html .= Html::tag('input', array(
|
||||
'type' => 'file',
|
||||
'id' => $this->fieldID,
|
||||
'name' => $this->getFieldName(),
|
||||
'value' => $this->getValue(),
|
||||
'autocomplete' => 'off'
|
||||
), false, false);
|
||||
|
||||
Js::addInline('new _N2.FormElementUpload("' . $this->fieldID . '");');
|
||||
|
||||
return Html::tag('div', array(
|
||||
'class' => 'n2_field_chooser n2_field_upload '
|
||||
), $html);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset;
|
||||
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
|
||||
class FieldsetHidden extends AbstractFieldset {
|
||||
|
||||
public function __construct($insertAt) {
|
||||
|
||||
parent::__construct($insertAt, '');
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
if ($this->first) {
|
||||
echo '<div class="n2_form_element--hidden">';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
echo wp_kses($this->decorateElement($element), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldsetRow extends AbstractFieldset {
|
||||
|
||||
public function __construct($insertAt, $name, $parameters = array()) {
|
||||
parent::__construct($insertAt, $name, false, $parameters);
|
||||
}
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
$classes = array('n2_form__table_row');
|
||||
if (!$this->isVisible) {
|
||||
$classes[] = 'n2_form__table_row--hidden';
|
||||
}
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => implode(' ', $classes),
|
||||
'data-field' => 'table-row-' . $this->name
|
||||
)), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
echo wp_kses($this->decorateElement($element), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$hasLabel = $element->hasLabel();
|
||||
|
||||
$classes = array(
|
||||
'n2_field',
|
||||
$element->getLabelClass(),
|
||||
$element->getRowClass()
|
||||
);
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => implode(' ', array_filter($classes)),
|
||||
'data-field' => $element->getID()
|
||||
) + $element->getRowAttributes()), Sanitize::$adminFormTags);
|
||||
|
||||
if ($hasLabel) {
|
||||
echo "<div class='n2_field__label'>";
|
||||
$element->displayLabel();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "<div class='n2_field__element'>";
|
||||
$element->displayElement();
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Sanitize;
|
||||
|
||||
class FieldsetRowPlain extends FieldsetRow {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_form__table_row_plain" data-field="table-row-plain-' . esc_attr($this->name) . '">';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
echo wp_kses($this->decorateElement($element), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$element->displayElement();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldsetTableLabel extends AbstractFieldset {
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => 'n2_form__table_label_field ' . $element->getRowClass(),
|
||||
'data-field' => $element->getID()
|
||||
) + $element->getRowAttributes()) . $this->decorateElement($element) . "</div>", Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldsetVisualSet extends AbstractFieldset {
|
||||
|
||||
public function renderContainer() {
|
||||
echo '<div class="n2_form__visual_set" data-field="visual-set-' . esc_attr($this->name) . '">';
|
||||
|
||||
echo "<div class='n2_form__visual_set_label'>" . esc_html($this->label) . '</div>';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
echo wp_kses($this->decorateElement($element), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$classes = array(
|
||||
'n2_field',
|
||||
$element->getRowClass()
|
||||
);
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => implode(' ', array_filter($classes)),
|
||||
'data-field' => $element->getID()
|
||||
) + $element->getRowAttributes()), Sanitize::$adminFormTags);
|
||||
|
||||
$element->displayElement();
|
||||
|
||||
echo "</div>";
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset\LayerWindow;
|
||||
|
||||
use Nextend\Framework\Form\Element\Button\ButtonIcon;
|
||||
use Nextend\Framework\Form\Element\Select;
|
||||
|
||||
class FieldsetDesign extends FieldsetLayerWindowLabelFields {
|
||||
|
||||
public function __construct($insertAt, $name, $label) {
|
||||
parent::__construct($insertAt, $name, $label);
|
||||
|
||||
$this->addAttribute('data-fieldset-type', 'design');
|
||||
|
||||
new ButtonIcon($this->fieldsetLabel, $name . '-reset-to-normal', false, 'ssi_16 ssi_16--reset', array(
|
||||
'hoverTip' => n2_('Reset to normal state'),
|
||||
'rowAttributes' => array(
|
||||
'data-design-feature' => 'reset-to-normal'
|
||||
)
|
||||
));
|
||||
new Select($this->fieldsetLabel, $name . '-element', false, '', array(
|
||||
'rowAttributes' => array(
|
||||
'data-design-feature' => 'element'
|
||||
)
|
||||
));
|
||||
new Select($this->fieldsetLabel, $name . '-state', false, '', array(
|
||||
'rowAttributes' => array(
|
||||
'data-design-feature' => 'state'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
protected function renderTitle() {
|
||||
|
||||
echo '<div class="n2_fields_layer_window__label">' . esc_html($this->label) . '</div>';
|
||||
|
||||
if ($this->fieldsetLabel->hasFields()) {
|
||||
echo '<div class="n2_fields_layer_window__title_fields">';
|
||||
$this->fieldsetLabel->renderContainer();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parentDesign
|
||||
*/
|
||||
public function setParentDesign($parentDesign) {
|
||||
$this->addAttribute('data-parent-design', $parentDesign);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldsetInsideLabel extends AbstractFieldset {
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => 'n2_form__table_label_field ' . $element->getRowClass(),
|
||||
'data-field' => $element->getID()
|
||||
) + $element->getRowAttributes()), Sanitize::$adminFormTags);
|
||||
$element->displayElement();
|
||||
echo "</div>";
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Form\Fieldset\LayerWindow;
|
||||
|
||||
|
||||
use Nextend\Framework\Form\AbstractField;
|
||||
use Nextend\Framework\Form\AbstractFieldset;
|
||||
use Nextend\Framework\Sanitize;
|
||||
use Nextend\Framework\View\Html;
|
||||
|
||||
class FieldsetLayerWindow extends AbstractFieldset {
|
||||
|
||||
protected $attributes = array();
|
||||
|
||||
public function renderContainer() {
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => 'n2_fields_layer_window',
|
||||
'data-field' => 'fieldset-layer-window-' . $this->name
|
||||
) + $this->attributes), Sanitize::$adminFormTags);
|
||||
|
||||
if (!empty($this->label)) {
|
||||
echo '<div class="n2_fields_layer_window__title">';
|
||||
$this->renderTitle();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="n2_fields_layer_window__fields">';
|
||||
|
||||
$element = $this->first;
|
||||
while ($element) {
|
||||
echo wp_kses($this->decorateElement($element), Sanitize::$adminFormTags);
|
||||
|
||||
$element = $element->getNext();
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
protected function renderTitle() {
|
||||
|
||||
echo '<div class="n2_fields_layer_window__label">' . esc_html($this->label) . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractField $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function decorateElement($element) {
|
||||
|
||||
ob_start();
|
||||
|
||||
$hasLabel = $element->hasLabel();
|
||||
|
||||
$classes = array(
|
||||
'n2_field',
|
||||
$element->getLabelClass(),
|
||||
$element->getRowClass()
|
||||
);
|
||||
|
||||
echo wp_kses(Html::openTag('div', array(
|
||||
'class' => implode(' ', array_filter($classes)),
|
||||
'data-field' => $element->getID()
|
||||
) + $element->getRowAttributes()), Sanitize::$adminFormTags);
|
||||
|
||||
if ($hasLabel) {
|
||||
echo "<div class='n2_field__label'>";
|
||||
$element->displayLabel();
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "<div class='n2_field__element'>";
|
||||
$element->displayElement();
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function setAttributes($attributes) {
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addAttribute($name, $value) {
|
||||
$this->attributes[$name] = $value;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user