/** * 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(); }
/** * 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); }
/** * 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; }
/** * 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); }