Example #1
0
 /**
  * Return an instance of JSNTplTemplateEdition class.
  *
  * @return  JSNTplTemplateEdition
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new JSNTplTemplateEdition();
     }
     return self::$instance;
 }
 /**
  * Return instance of JSNTplTemplateEdition object
  *
  * @param   JObject  $data  Template data object
  * @return  JSNTplTemplateEdition
  */
 public static function getInstance($data)
 {
     if (!self::$_instance instanceof JSNTplTemplateEdition) {
         self::$_instance = new JSNTplTemplateEdition($data);
     }
     return self::$_instance;
 }
 /**
  * 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();
 }
Example #4
0
 /**
  * Constructor for template admin
  *
  * @param   JForm  $context  Current context of template admin.
  */
 private function __construct(JForm $context)
 {
     if (class_exists('JModelLegacy')) {
         $templateModel = JModelLegacy::getInstance('Style', 'TemplatesModel');
     } else {
         $templateModel = JModel::getInstance('Style', 'TemplatesModel');
     }
     $request = JFactory::getApplication()->input;
     $this->baseUrl = JUri::root(true);
     $this->baseAssetUrl = $this->baseUrl . '/plugins/system/jsntplframework/assets';
     $this->context = $context;
     $this->data = $templateModel->getItem($request->getInt('id'));
     $this->version = new JVersion();
     $this->doc = JFactory::getDocument();
     $this->helper = JSNTplTemplateHelper::getInstance($this->data->template);
     $this->templateXml = JSNTplHelper::getManifest($this->data->template);
     // Retrieve template form instance
     $this->templateForm = JForm::getInstance('com_templates.style', 'style', array('control' => 'jform', 'load_data' => true));
     $this->templateEdition = JSNTplTemplateEdition::getInstance($this->data);
     // Load cache engine
     $this->cache = JFactory::getCache('plg_system_jsntplframework');
     // Load language
     $language = JFactory::getLanguage();
     $language->load('tpl_' . $this->data->template, JPATH_ROOT);
 }
Example #5
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 edition
$edition = JSNTplTemplateEdition::getInstance();
?>
<div class="control-group">
	<div class="control-label">
		<label for="<?php 
echo "{$this->id}_type";
?>
" rel="tipsy" original-title="<?php 
echo JText::_('JSN_TPLFW_WIDTH_TYPE_DESC');
?>
"><?php 
echo JText::_('JSN_TPLFW_WIDTH_TYPE');
?>
</label>
	</div>
	<div class="controls">