/**
  * 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_SOCIAL_NETWORK_INTEGRATION_MISSING_OPTIONS');
     }
     // Initialize field value
     is_array($this->value) or $this->value = array();
     // Pass value to option array
     $this->options = $this->value;
     // Preset social channel status array
     @is_array($this->options['status']) or $this->options['status'] = array();
     // Parse field options
     foreach ($this->element->option as $channel) {
         // Store social channel data
         $this->options[(string) $channel['name']] = array('title' => (string) $channel, 'link' => isset($this->options[(string) $channel['name']]['link']) ? $this->options[(string) $channel['name']]['link'] : (string) $channel['value'], 'placeholder' => (string) $channel['placeholder']);
         // If channel is configured, add it to status array if missing
         if ($this->options[(string) $channel['name']]['link'] != '' and !in_array((string) $channel['name'], $this->options['status'])) {
             $this->options['status'][] = (string) $channel['name'];
         }
     }
     // Prepare other field attributes
     $this->disabled = (string) $this->element['disabled'] == 'true';
     return parent::getInput();
 }
Exemplo n.º 2
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_COLUMN_DECLARATION');
     }
     // Get template model
     $templateModel = class_exists('JModelLegacy') ? JModelLegacy::getInstance('Style', 'TemplatesModel') : JModel::getInstance('Style', 'TemplatesModel');
     // Get style data
     $this->data = $templateModel->getItem(JFactory::getApplication()->input->getInt('id'));
     // Instantiate helper class of JSN Template Framework
     $helper = JSNTplTemplateHelper::getInstance();
     // Finalize template parameters
     $this->data->params = $helper->loadParams($this->data->params, $this->data->template);
     // Check for layout ajustment image
     $this->hasHelper = is_readable(JPATH_ROOT . '/templates/' . $this->data->template . '/template_layout_adjustment.jpg');
     // Parse column declaration
     foreach ($this->element->option as $group) {
         $gname = (string) $group['name'];
         // Pass values to options array
         if (@is_array($this->data->params[$gname])) {
             foreach ($this->data->params[$gname] as $oname => $value) {
                 $this->options[$gname][preg_replace('/^\\d+:/', '', $oname)] = $value;
             }
         }
         // Parse columns
         $this->parseColumns($group, $this->options[$gname]);
     }
     return parent::getInput();
 }
Exemplo n.º 3
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();
 }
 public function getInput()
 {
     $defaultValues = array('list' => array(), 'colors' => array());
     foreach ($this->element->option as $option) {
         $value = (string) $option['value'];
         $this->defaultOptions[$value] = array('label' => (string) $option, 'value' => $value);
         $defaultValues['list'][] = $value;
         $defaultValues['colors'][] = $value;
     }
     $this->optionList = array_keys($this->defaultOptions);
     $this->optionChecked = $this->optionList;
     // Get template model
     $templateModel = class_exists('JModelLegacy') ? JModelLegacy::getInstance('Style', 'TemplatesModel') : JModel::getInstance('Style', 'TemplatesModel');
     // Get style data
     $this->data = $templateModel->getItem(JFactory::getApplication()->input->getInt('id'));
     // Generate param name
     $this->paramName = (string) $this->element['name'];
     if (isset($this->data->params[$this->paramName])) {
         $decodedValue = json_decode($this->data->params[$this->paramName]);
         if (is_array($decodedValue->list)) {
             $optionList = array();
             foreach ($decodedValue->list as $item) {
                 if (isset($this->defaultOptions[$item])) {
                     $optionList[] = $item;
                 }
             }
             $arrayDiff = array_diff($this->optionList, $optionList);
             $this->optionList = array_merge($optionList, $arrayDiff);
         }
         if (@is_array($decodedValue->colors)) {
             if (count($arrayDiff)) {
                 $this->optionChecked = array_merge($optionList, array_diff($this->optionChecked, $decodedValue->colors));
             } else {
                 $this->optionChecked = $decodedValue->colors;
             }
         }
     } else {
         $this->data->params[$this->paramName] = array('list' => $this->optionList, 'colors' => $this->optionChecked);
     }
     $this->disabled = isset($this->element['disabled']) and $this->element['disabled'] == 'true';
     $this->disabledClass = $this->disabled ? 'disabled' : '';
     return parent::getInput();
 }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
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_COLUMN_DECLARATION');
     }
     // Get template data
     $data = JSNTplHelper::getEditingTemplate();
     // Parse column declaration
     foreach ($this->element->option as $group) {
         $gname = (string) $group['name'];
         // Pass values to options array
         if (@is_array($data->params[$gname])) {
             foreach ($data->params[$gname] as $oname => $value) {
                 $this->options[$gname][preg_replace('/^\\d+:/', '', $oname)] = $value;
             }
         }
         // Parse columns
         $this->parseColumns($group, $this->options[$gname]);
     }
     return parent::getInput();
 }
 public function getInput()
 {
     $defaultValues = array('list' => array(), 'colors' => array());
     foreach ($this->element->option as $option) {
         $value = (string) $option['value'];
         $this->defaultOptions[$value] = array('label' => (string) $option, 'value' => $value);
         $defaultValues['list'][] = $value;
         $defaultValues['colors'][] = $value;
     }
     $this->optionList = array_keys($this->defaultOptions);
     $this->optionChecked = $this->optionList;
     if (!empty($this->value)) {
         $decodedValue = json_decode($this->value);
         if (is_array($decodedValue->list)) {
             $optionList = array();
             foreach ($decodedValue->list as $item) {
                 if (isset($this->defaultOptions[$item])) {
                     $optionList[] = $item;
                 } elseif (@isset($decodedValue->colors[$item])) {
                     unset($decodedValue->colors[$item]);
                 }
             }
             $arrayDiff = array_diff($this->optionList, $optionList);
             $this->optionList = array_merge($optionList, $arrayDiff);
         }
         if (is_array($decodedValue->colors) and !empty($decodedValue->colors)) {
             if (count($arrayDiff)) {
                 $this->optionChecked = array_merge($optionList, array_diff($this->optionChecked, $decodedValue->colors));
             } else {
                 $this->optionChecked = $decodedValue->colors;
             }
         }
     } else {
         $this->value = array('list' => $this->optionList, 'colors' => $this->optionChecked);
     }
     $this->disabled = isset($this->element['disabled']) && $this->element['disabled'] == 'true';
     $this->disabledClass = $this->disabled ? 'disabled' : '';
     return parent::getInput();
 }
Exemplo n.º 9
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_FONT_MISSING_DEFAULT_FONT_STYLES');
     }
     // Initialize field value
     !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('style' => $this->value);
     }
     // Store default font style for this option
     if (is_string($this->default)) {
         $this->default = array('style' => $this->default);
     }
     // Parse default font style options
     foreach ($this->element->option as $option) {
         // Store option
         $this->options[(string) $option['name']] = array('label' => (string) $option['label'], 'customizable' => isset($option['customizable']) ? (int) $option['customizable'] : 0);
         foreach ($option->children() as $default) {
             $this->default[(string) $option['name']][$default->getName()] = array('type' => (string) $default['type'], 'family' => (string) $default['family'], 'primary' => (string) $default['primary'], 'secondary' => (string) $default['secondary'], 'file' => (string) $default['file']);
         }
         // Store default font size for this option
         if (isset($option['defaultFontSize'])) {
             $this->default[(string) $option['name']]['size'] = (int) $option['defaultFontSize'];
         }
     }
     // Preset missing field value
     foreach (array_keys($this->options) as $style) {
         foreach ($this->sections as $section) {
             if (!isset($this->value[$style][$section]) and isset($this->default[$style][$section])) {
                 $this->value[$style][$section] = $this->default[$style][$section];
             }
             // Prepare font family value
             if (isset($this->value[$style][$section]['family'])) {
                 $this->value[$style][$section]['family'] = str_replace("\\'", "'", $this->value[$style][$section]['family']);
             }
             // Prepare secondary font value
             if (isset($this->value[$style][$section]['secondary'])) {
                 $this->value[$style][$section]['secondary'] = str_replace("\\'", "'", $this->value[$style][$section]['secondary']);
             }
         }
         if (!isset($this->value[$style]['size']) and isset($this->default[$style]['size'])) {
             $this->value[$style]['size'] = $this->default[$style]['size'];
         }
     }
     // Prepare other field attributes
     $this->disabled = (string) $this->element['disabled'] == 'true';
     return parent::getInput();
 }
Exemplo n.º 10
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 model
     $templateModel = class_exists('JModelLegacy') ? JModelLegacy::getInstance('Style', 'TemplatesModel') : JModel::getInstance('Style', 'TemplatesModel');
     // Get style data
     $this->data = $templateModel->getItem(JFactory::getApplication()->input->getInt('id'));
     // Instantiate helper class of JSN Template Framework
     $helper = JSNTplTemplateHelper::getInstance();
     // Finalize template parameters
     $this->data->params = $helper->loadParams($this->data->params, $this->data->template);
     // Initialize field value
     if (isset($this->data->params[(string) $this->element['name']])) {
         $this->value = $this->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' : 'text', 'options' => $option->children(), 'class' => '', 'pro' => (string) $option['pro'] == 'true' ? true : false);
         if (isset($option['validate'])) {
             $this->options[(string) $option['name']]['class'] = 'validate-' . str_replace(' ', '-', (string) $option['validate']);
         }
         // 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'];
             }
         }
     }
     // Get template edition
     $this->edition = JSNTplTemplateEdition::getInstance($this->data);
     return parent::getInput();
 }