Пример #1
0
 /**
  * Get active instance of template helper object
  *
  * @param   string  $name  Name of the template
  *
  * @return  JSNTplTemplateHelper
  */
 public static function getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new JSNTplTemplateHelper();
     }
     return self::$_instance;
 }
Пример #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();
 }
 /**
  * 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();
 }
Пример #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_ERROR_MISSING_OPTIONS');
     }
     // 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']];
     } 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);
 }
Пример #5
0
 /**
  * Get editing template.
  *
  * @return  object  Object containing template details or NULL if failure.
  */
 public static function &getEditingTemplate()
 {
     if (!isset(self::$templateData)) {
         $app = JFactory::getApplication();
         $data = null;
         if ($app->input->getCmd('option') == 'com_templates' and $app->input->getCmd('view') == 'style' and $app->input->getCmd('layout') == 'edit' and $app->input->getInt('id')) {
             // Get template model
             $model = class_exists('JModelLegacy') ? JModelLegacy::getInstance('Style', 'TemplatesModel') : JModel::getInstance('Style', 'TemplatesModel');
             // Get style data
             $data = $model->getItem($app->input->getInt('id'));
             // Instantiate helper class of JSN Template Framework
             $helper = JSNTplTemplateHelper::getInstance();
             // Prepare template parameters
             $data->params = $helper->loadParams($data->params, $data->template);
         }
         // Store template data
         self::$templateData = $data;
     }
     return self::$templateData;
 }
Пример #6
0
<?php

/**
 * @author    JoomlaShine.com http://www.joomlashine.com
 * @copyright Copyright (C) 2008 - 2011 JoomlaShine.com. All rights reserved.
 * @license   GNU/GPL v2 http://www.gnu.org/licenses/gpl-2.0.html
 */
// No direct access
defined('_JEXEC') or die('Restricted index access');
// Load template framework
if (!defined('JSN_PATH_TPLFRAMEWORK')) {
    require_once JPATH_ROOT . '/plugins/system/jsntplframework/jsntplframework.defines.php';
    require_once JPATH_ROOT . '/plugins/system/jsntplframework/libraries/joomlashine/loader.php';
}
// Preparing template parameters
JSNTplTemplateHelper::prepare();
// Get template utilities
$jsnutils = JSNTplUtils::getInstance();
?>
<!DOCTYPE html>
<!-- <?php 
echo $this->template . ' ' . JSNTplHelper::getTemplateVersion($this->template);
?>
 -->
<html lang="<?php 
echo $this->language;
?>
" dir="<?php 
echo $this->direction;
?>
">
Пример #7
0
 /**
  *
  * Only render empty component
  */
 public function renderEmptyComponent()
 {
     $document = JFactory::getDocument();
     $component = $document->getBuffer('component');
     $component_buffer = JSNTplTemplateHelper::openTag('div', array('class' => "jsn-component-container", 'id' => "jsnrender-component")) . JSNTplTemplateHelper::openTag('p') . $document->getTitle() . JSNTplTemplateHelper::closeTag('p') . JSNTplTemplateHelper::closeTag('div');
     $document->setBuffer($component_buffer, 'component');
 }
Пример #8
0
 * @license   GNU/GPL v2 http://www.gnu.org/licenses/gpl-2.0.html
 */
// No direct access
defined('_JEXEC') or die('Restricted index access');
// Load template framework
if (!defined('JSN_PATH_TPLFRAMEWORK')) {
    require_once JPATH_ROOT . '/plugins/system/jsntplframework/jsntplframework.defines.php';
    require_once JPATH_ROOT . '/plugins/system/jsntplframework/libraries/joomlashine/loader.php';
}
define('YOURBASEPATH', dirname(__FILE__));
if (!isset($this->error)) {
    $this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
    $this->debug = false;
}
// Preparing template parameters
JSNTplTemplateHelper::prepare(false, false);
// Retrieve document object
$document = JFactory::getDocument();
/* URL where logo image should link to (! without preceding slash !)
   Leave this box empty if you want your logo to be clickable. */
$logoLink = $document->logoLink;
if (strpos($logoLink, "http") === false && $logoLink != '') {
    $utils = JSNTplUtils::getInstance();
    $logoLink = $utils->trimPreceddingSlash($logoLink);
    $logoLink = $this->baseurl . '/' . $logoLink;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- <?php 
echo $document->template;
?>
Пример #9
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);
 }