Beispiel #1
0
/**
 * Autoload class file of JSN Template Framework.
 *
 * @param   string  $className  Name of class needs to be loaded.
 *
 * @return  boolean
 */
function jsn_template_framework_class_loader($className)
{
    if (strpos($className, 'JSNTpl') === 0) {
        $path = strtolower(preg_replace('/([A-Z])/', '/\\1', substr($className, 6)));
        $fullPath = JSN_PATH_TPLFRAMEWORK_LIBRARIES . '/' . $path;
        // Load alternative class for backward compatible with old template version
        $app = JFactory::getApplication();
        $tpl = $app->getTemplate();
        if ($app->isSite() and substr($tpl, 0, 4) == 'jsn_' and !JSNTplVersion::isCompatible($tpl, JSNTplHelper::getTemplateVersion($tpl))) {
            if (is_file("{$fullPath}_v1.php") and is_readable("{$fullPath}_v1.php")) {
                $fullPath .= '_v1';
            }
        }
        if (is_file("{$fullPath}.php") and is_readable("{$fullPath}.php")) {
            return include_once "{$fullPath}.php";
        }
        return false;
    }
}
Beispiel #2
0
?>
</span>
								<a class="jsn-update-link btn btn-mini" data-target="template" href="javascript:void(0)">
									<?php 
echo JText::_('JSN_TPLFW_TEMPLATE_DETAILS_UPDATE_TO');
?>
									<span class="jsn-new-version"></span>
								</a>
								<a class="hide" href="http://www.joomlashine.com/joomla-products/changelog.html" target="_blank">
									<?php 
echo JText::_('JSN_TPLFW_TEMPLATE_DETAILS_WHAT_NEW_IN');
?>
									<span class="jsn-new-version"></span>
								</a>
								<?php 
if (!JSNTplVersion::isCompatible($this->data->template, $version)) {
    ?>
								<div class="alert hide">
									<?php 
    echo JText::_('JSN_TPLFW_TEMPLATE_OUT_OF_DATE_NOTICE');
    ?>
								</div>
								<?php 
}
?>
							</div>
						</dd>
					</dl>
				</div>
				<div class="clearbreak"></div>
			</div>
Beispiel #3
0
 /**
  * Load template parameters
  *
  * @param   array   $override      Parameters override.
  * @param   string  $templateName  Template name.
  *
  * @return  array
  */
 public function loadParams($override = null, $templateName)
 {
     static $loadedParams;
     if (!isset($loadedParams) or !isset($loadedParams[$templateName])) {
         if (!is_array($override)) {
             $override = array();
         }
         $xml = JSNTplHelper::getManifest($templateName, true);
         $templateUrl = JUri::root(true) . 'templates/' . $templateName;
         // Load default template parameters
         foreach ($xml->xpath('//defaults/option') as $parameter) {
             $name = (string) $parameter['name'];
             $value = (string) $parameter['value'];
             // Ignore v1 parameter
             if ($name == 'templateStyle') {
                 continue;
             }
             if ($name == 'cssFiles') {
                 $files = array();
                 foreach ($parameter->children() as $item) {
                     $files[] = (string) $item;
                 }
                 $this->_defaultParams[$name] = implode("\r\n", $files);
                 continue;
             }
             if (@count($parameter->children())) {
                 $value = array();
                 foreach ($parameter->children() as $child) {
                     if (isset($child['name'])) {
                         $key = (string) $child['name'];
                         if (substr($key, -2) == '[]') {
                             $key = substr($key, 0, -2);
                             $value[$key][] = isset($child['value']) ? (string) $child['value'] : (string) $child;
                         } else {
                             $value[$key] = isset($child['value']) ? (string) $child['value'] : (string) $child;
                         }
                     } else {
                         $value[] = isset($child['value']) ? (string) $child['value'] : (string) $child;
                     }
                 }
             }
             $type = isset($this->_defaultParams[$name]) ? gettype($this->_defaultParams[$name]) : 'string';
             $this->_defaultParams[$name] = $this->convertType($value, $type);
             if ($type == 'string') {
                 $this->_defaultParams[$name] = str_replace('{templateUrl}', $templateUrl, $this->_defaultParams[$name]);
             }
         }
         if (!isset($this->_defaultParams['logoFile']) or empty($this->_defaultParams['logoFile'])) {
             $this->_defaultParams['logoFile'] = 'templates/' . $templateName . '/images/logo.png';
         }
         // Store finalized parameters
         $loadedParams[$templateName] = array_merge($this->_defaultParams, $override);
         // Migrate v1 parameters to v2 if necessary
         if (JSNTplVersion::isCompatible($templateName, JSNTplHelper::getTemplateVersion($templateName))) {
             $loadedParams[$templateName] = JSNTplTemplateMigration::migrate($loadedParams[$templateName]);
         }
     }
     return $loadedParams[$templateName];
 }
Beispiel #4
0
 /**
  * This method use to generate XML for template form definition
  *
  * @return  object
  */
 private function _generateFormXML()
 {
     $adminXml = simplexml_load_string('<?xml version="1.0" encoding="utf-8" ?><form><fields name="jsn"></fields></form>');
     $optionsXml = $this->templateXml->options;
     $context = array();
     if (JSNTplVersion::isCompatible($this->data->template, JSNTplHelper::getTemplateVersion($this->data->template))) {
         $formXml = simplexml_load_file(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/template/params.xml');
     } else {
         // Template is not compatible with framework v2, load old params declaration file
         $formXml = simplexml_load_file(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/template/params_v1.xml');
     }
     foreach ($optionsXml->xpath('//*[@method]') as $node) {
         $nodeType = (string) $node->getName();
         $method = (string) $node['method'];
         if (!in_array($nodeType, array('fieldset', 'field'))) {
             continue;
         }
         if (!isset($context[$method])) {
             $context[$method] = array();
         }
         $context[$method][(string) $node['name']] = $node;
     }
     $this->_addNodes($formXml->fields->children(), $adminXml->fields, $context);
     // Disable fieldset when edition is free
     if (strtolower($this->templateEdition->getEdition()) == 'free') {
         foreach ($adminXml->xpath('//fieldset[@pro="true"]') as $fieldset) {
             foreach ($fieldset->children() as $input) {
                 if ($input->getName() == 'fieldset') {
                     foreach ($input->children() as $_input) {
                         $_input->addAttribute('disabled', 'true');
                     }
                     continue;
                 }
                 $input->addAttribute('disabled', 'true');
             }
         }
     }
     $replacement = array('{templateUrl}' => JUri::root(true) . '/templates/' . $this->data->template);
     // Set default values
     foreach ($this->templateXml->xpath('//defaults/option') as $option) {
         $name = (string) $option['name'];
         $value = '';
         if (isset($option['value'])) {
             $value = (string) $option['value'];
         } elseif (count($option->children()) > 0) {
             $_value = array();
             foreach ($option->children() as $item) {
                 $_value[] = (string) $item;
             }
             $value = implode("\r\n", $_value);
         }
         foreach ($adminXml->xpath('//field[@name="' . $name . '"]') as $field) {
             $field['defaultValue'] = str_replace(array_keys($replacement), array_values($replacement), $value);
         }
     }
     $logoField = current($adminXml->xpath('//field[@name="logoFile"]'));
     $logoField['defaultValue'] = 'templates/' . $this->data->template . '/images/logo.png';
     return $adminXml;
 }