Beispiel #1
0
 /**
  * Constructor
  *
  * @return  void
  */
 private function __construct()
 {
     // Get data for editing template
     $this->data = JSNTplHelper::getEditingTemplate();
     // Get template edition
     $this->edition = (string) $this->data->xml->edition;
     // Load supported editions
     $this->loadEditions();
     // Set default edition if necessary
     if (empty($this->edition)) {
         $this->edition = 'FREE';
     }
 }
Beispiel #2
0
 /**
  * Generate HTML code for input field.
  *
  * @return  string
  */
 public function getInput()
 {
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     // Preset values
     $data->_JSNListColor = new stdClass();
     $defaultValues = array('list' => array(), 'colors' => array());
     foreach ($this->element->option as $option) {
         $value = (string) $option['value'];
         $data->_JSNListColor->default[$value] = array('label' => (string) $option, 'value' => $value);
         $defaultValues['list'][] = $value;
         $defaultValues['colors'][] = $value;
     }
     $data->_JSNListColor->option['list'] = array_keys($data->_JSNListColor->default);
     $data->_JSNListColor->option['checked'] = $data->_JSNListColor->option['list'];
     // Generate param name
     $paramName = (string) $this->element['name'];
     if (isset($data->params[$paramName])) {
         $decodedValue = json_decode($data->params[$paramName]);
         if ($decodedValue and is_array($decodedValue->list)) {
             $optionList = array();
             foreach ($decodedValue->list as $item) {
                 if (isset($data->_JSNListColor->default[$item])) {
                     $optionList[] = $item;
                 }
             }
             $arrayDiff = array_diff($data->_JSNListColor->option['list'], $optionList);
             $data->_JSNListColor->option['list'] = array_merge($optionList, $arrayDiff);
         }
         if (@is_array($decodedValue->colors)) {
             if (count($arrayDiff)) {
                 $data->_JSNListColor->option['checked'] = array_merge($optionList, array_diff($data->_JSNListColor->option['checked'], $decodedValue->colors));
             } else {
                 $data->_JSNListColor->option['checked'] = $decodedValue->colors;
             }
         }
     } else {
         $data->params[$paramName] = array('list' => $data->_JSNListColor->option['list'], 'colors' => $data->_JSNListColor->option['checked']);
     }
     // Prepare other field attributes
     $this->disabled = 'true' == (string) $this->element['disabled'];
     return parent::getInput();
 }
Beispiel #3
0
 public function getInput()
 {
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     // Preset values
     $data->_JSNListColor = new stdClass();
     $defaultValues = array('list' => array(), 'colors' => array());
     foreach ($this->element->option as $option) {
         $value = (string) $option['value'];
         $data->_JSNColorList->default[$value] = array('label' => (string) $option, 'value' => $value);
         $defaultValues['list'][] = $value;
         $defaultValues['colors'][] = $value;
     }
     $data->_JSNColorList->option['list'] = array_keys($data->_JSNColorList->default);
     $data->_JSNListColor->option['checked'] = $data->_JSNColorList->option['list'];
     if (!empty($this->value)) {
         $decodedValue = json_decode($this->value);
         if (is_array($decodedValue->list)) {
             $optionList = array();
             foreach ($decodedValue->list as $item) {
                 if (isset($data->_JSNColorList->default[$item])) {
                     $optionList[] = $item;
                 } elseif (@isset($decodedValue->colors[$item])) {
                     unset($decodedValue->colors[$item]);
                 }
             }
             $arrayDiff = array_diff($data->_JSNColorList->option['list'], $optionList);
             $data->_JSNColorList->option['list'] = array_merge($optionList, $arrayDiff);
         }
         if (is_array($decodedValue->colors) and !empty($decodedValue->colors)) {
             if (count($arrayDiff)) {
                 $data->_JSNListColor->option['checked'] = array_merge($optionList, array_diff($data->_JSNListColor->option['checked'], $decodedValue->colors));
             } else {
                 $data->_JSNListColor->option['checked'] = $decodedValue->colors;
             }
         }
     } else {
         $this->value = array('list' => $data->_JSNColorList->option['list'], 'colors' => $data->_JSNListColor->option['checked']);
     }
     $this->disabled = isset($this->element['disabled']) && $this->element['disabled'] == 'true';
     $this->disabledClass = $this->disabled ? 'disabled' : '';
     return parent::getInput();
 }
Beispiel #4
0
 /**
  * Parse field declaration to render input.
  *
  * @return  void
  */
 public function getInput()
 {
     // Make sure we have options declared
     if (!isset($this->element->option)) {
         return JText::_('JSN_TPLFW_LAYOUT_MISSING_WIDTH_TYPE_DECLARATION');
     }
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     // Initialize field value
     if (isset($data->params[(string) $this->element['name']])) {
         $this->value = $data->params[(string) $this->element['name']];
     } else {
         !empty($this->value) or $this->value = (string) $this->element['default'];
         if (is_string($this->value)) {
             $this->value = (substr($this->value, 0, 1) == '{' and substr($this->value, -1) == '}') ? json_decode($this->value, true) : array('type' => $this->value);
         }
     }
     // Parse default template width type options
     foreach ($this->element->option as $option) {
         // Store option
         $this->options[(string) $option['name']] = array('label' => (string) $option['label'], 'suffix' => (string) $option['suffix'], 'type' => count($option->children()) ? (int) $option['multiple'] ? 'checkbox' : 'radio' : 'number', 'options' => $option->children(), 'class' => (string) $option['class'], 'pro' => (string) $option['pro'] == 'true' ? true : false);
         // Preset missing field value with default value
         if (!isset($this->value[(string) $option['name']])) {
             if (count($option->children())) {
                 foreach ($option->children() as $child) {
                     if ((string) $child['default'] == 'checked') {
                         if ((int) $option['multiple']) {
                             $this->value[(string) $option['name']][] = (string) $child['value'];
                         } else {
                             $this->value[(string) $option['name']] = (string) $child['value'];
                         }
                     }
                 }
             } else {
                 $this->value[(string) $option['name']] = (string) $option['default'];
             }
         }
     }
     return parent::getInput();
 }
Beispiel #5
0
 /**
  * Parse field declaration to render input.
  *
  * @return  void
  */
 public function getInput()
 {
     // Make sure we have options declared
     if (!isset($this->element->option)) {
         return JText::_('JSN_TPLFW_ERROR_MISSING_OPTIONS');
     }
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     // Initialize field value
     if (isset($data->params[(string) $this->element['name']])) {
         $this->value = $data->params[(string) $this->element['name']];
     } elseif (empty($this->value)) {
         $this->value = (string) $this->element['default'];
     }
     if (is_string($this->value)) {
         $this->value = (substr($this->value, 0, 1) == '{' and substr($this->value, -1) == '}') ? json_decode($this->value, true) : array($this->value => 1);
     }
     // Parse field attributes
     $options['class'] = isset($this->element['class']) ? (string) $this->element['class'] : '';
     $options['disabled'] = '';
     if (isset($this->element['disabled']) and $this->element['disabled'] == 'true') {
         $options['class'] .= ' disabled';
         $options['disabled'] = ' disabled="disabled"';
     }
     // Get all checkbox options from xml
     $data = array();
     foreach ($this->element->children() as $option) {
         // Check if option is checked
         if (is_array($this->value)) {
             $checked = (array_key_exists((string) $option['value'], $this->value) and $this->value[(string) $option['value']]);
         } else {
             $checked = (isset($option['default']) and (string) $option['default'] == 'checked');
         }
         $data[] = array('value' => (string) $option['value'], 'text' => (string) $option, 'checked' => $checked ? ' checked="checked"' : '');
     }
     return JSNTplFormHelper::checkbox($this->name, $data, $options);
 }
Beispiel #6
0
 /**
  * Function to parse column declaration.
  *
  * @param   array  $group    Array of SimpleXMLElement object respresent  a group of columns.
  * @param   array  &$option  Option array to store column data.
  *
  * @return  void
  */
 protected function parseColumns($group, &$option)
 {
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     foreach ($group->children() as $column) {
         $cname = (string) $column['name'];
         $value = isset($option[$cname]) ? $option[$cname] : (string) $column['default'];
         $order = ($order = (int) $column['sourceCodeOrder']) < 10 ? "0{$order}" : $order;
         // Store option
         $option[$cname] = array('label' => (string) $column['label'], 'value' => $value, 'order' => $order);
         // Does this column has nested column?
         if (count($column->children())) {
             $option[$cname]['columns'] = array();
             // Pass values to options array
             if (@is_array($data->params["{$cname}Columns"])) {
                 foreach ($data->params["{$cname}Columns"] as $oname => $value) {
                     $option[$cname]['columns'][preg_replace('/^\\d+:/', '', $oname)] = $value;
                 }
             }
             // Parse nested columns
             $this->parseColumns($column, $option[$cname]['columns']);
         }
     }
 }
Beispiel #7
0
<?php

/**
 * @version     $Id$
 * @package     JSNTPLFW
 * @author      JoomlaShine Team <*****@*****.**>
 * @copyright   Copyright (C) 2012 JoomlaShine.com. All Rights Reserved.
 * @license     GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.joomlashine.com
 * Technical Support:  Feedback - http://www.joomlashine.com/contact-us/get-support.html
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Get template data
$data = JSNTplHelper::getEditingTemplate();
// Generate param name
$paramName = (string) $this->element['name'];
?>
<div class="jsn-color-list jsn-color-list-v1 <?php 
echo $this->disabledClass;
?>
">
	<ul class="jsn-items-list ui-sortable" data-target="#<?php 
echo $this->id;
?>
">
		<?php 
foreach ($data->_JSNColorList->option['list'] as $item) {
    ?>
		<?php