Beispiel #1
0
    /**
     * Method to get the field input markup for a generic list.
     * Use the multiple attribute to enable multiselect.
     *
     * @return  string  The field input markup.
     *
     * @since   11.1
     */
    protected function getInput()
    {
        $request = JFactory::getApplication()->input;
        if (class_exists('JModelLegacy')) {
            $templateModel = JModelLegacy::getInstance('Style', 'TemplatesModel');
        } else {
            $templateModel = JModel::getInstance('Style', 'TemplatesModel');
        }
        $templateData = $templateModel->getItem($request->getInt('id'));
        $templateXml = JSNTplHelper::getManifest($templateData->template);
        $mobileMenuIconType = (string) $templateXml->mobileMenuIconType;
        if (strtolower($mobileMenuIconType) != 'yes') {
            $html[] = '<script type="text/javascript">
				(function($) {
					$(document).ready(function() {
						$("#jsn_mobileMenuIconTypeText").parent().parent().prev().hide();
						$("#jsn_mobileMenuIconTypeText").parent().parent().hide();
					});
				})(jQuery);
			</script>';
        } else {
            $html[] = '<script type="text/javascript">
				(function($) {
					$(document).ready(function() {

						if ($("input[name=\'jsn[mobileMenuIconType]\']:checked").val() == "text")
						{
							$("#jsn_mobileMenuIconTypeText").parent().parent().show();
						} else {
							$("#jsn_mobileMenuIconTypeText").parent().parent().hide();
						}

						$(".radio input[name=\'jsn[mobileMenuIconType]\']").click(function(){
						    if ($(this).val() == "text") {
						    	$("#jsn_mobileMenuIconTypeText").parent().parent().show();
						    } else {
						    	$("#jsn_mobileMenuIconTypeText").parent().parent().hide();
						    }
						});
					});
				})(jQuery);
			</script>';
        }
        $data = array();
        $options = array('default' => $this->value == '' ? (int) $this->element['default'] : $this->value);
        if (isset($this->element['disabled']) && $this->element['disabled'] == 'true') {
            $options['class'] = 'disabled';
            $options['disabled'] = 'disabled';
        }
        // Get all radio options from xml
        foreach ($this->element->children() as $option) {
            $data[] = array('value' => $option['value'], 'text' => (string) $option);
        }
        $html[] = JSNTplFormHelper::radio($this->name, $data, $options);
        return implode($html);
    }
 /**
  * Save active form context to memory when editing an template
  *
  * @param   object  $context  Current context of template form
  * @param   object  $data     Data of the form
  * @return  void
  */
 public function onContentPrepareForm($context, $data)
 {
     if ($context->getName() == 'com_templates.style' and !empty($data)) {
         $templateName = is_object($data) ? $data->template : $data['template'];
         if (JSNTplTemplateRecognization::detect($templateName)) {
             $templateManifest = JSNTplHelper::getManifest($templateName);
             $templateGroup = isset($templateManifest->group) ? trim((string) $templateManifest->group) : '';
             // Create template admin instance
             if ($templateGroup == 'jsntemplate') {
                 self::$_templateAdmin = JSNTplTemplateAdmin::getInstance($context);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Retrieve edition of the template that determined by name
  *
  * @param   string  $name  The template name to retrieve edition
  * @return  string
  */
 public static function getTemplateEdition($name)
 {
     if ($details = JSNTplTemplateRecognization::detect($name)) {
         return $details->edition;
     }
     // Backward compatible
     $registry = JRegistry::getInstance('JSNTplFramework');
     if ($registry->exists('template.edition')) {
         return $registry->get('template.edition');
     }
     $manifest = JSNTplHelper::getManifest($name);
     $edition = isset($manifest->edition) ? (string) $manifest->edition : 'FREE';
     $registry->set('template.edition', $edition);
     return $edition;
 }
 /**
  * Preparing template parameters for the template
  *
  * @return  void
  */
 private function _prepare($loadTemplateCSS, $loadTemplateJS)
 {
     $this->_loadTemplateCSS = $loadTemplateCSS;
     $this->_loadTemplateJS = $loadTemplateJS;
     $templateParams = isset($this->_document->params) ? $this->_document->params : null;
     $templateName = isset($this->_document->template) ? $this->_document->template : null;
     if (empty($templateParams) or empty($templateName) or $templateName == 'system') {
         $templateDetails = JFactory::getApplication()->getTemplate(true);
         $templateParams = $templateDetails->params;
         $templateName = $templateDetails->template;
     }
     // Update show content on frontpage parameter
     $app = JFactory::getApplication();
     $menu = $app->getMenu()->getActive();
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_jsntplframework', JPATH_ADMINISTRATOR);
     $manifest = JSNTplHelper::getManifest($templateName);
     $this->_document->app = JFactory::getApplication();
     $this->_document->template = $templateName;
     $this->_document->version = JSNTplHelper::getTemplateVersion($templateName);
     $this->_document->isFree = !isset($manifest->edition) || $manifest->edition == 'FREE';
     $this->_document->uri = JFactory::getUri();
     $this->_document->rootUrl = $this->_document->uri->root(true);
     $this->_document->templateUrl = $this->_document->rootUrl . '/templates/' . $this->_document->template;
     $columns = array('columnPromoLeft', 'columnPromoRight', 'columnLeft', 'columnRight', 'columnInnerleft', 'columnInnerright');
     // Find customizable columns
     $customColumns = $manifest->xpath('//fieldset[@name="jsn-columns-size"]');
     if (count($customColumns) > 0) {
         $columns = array();
         foreach (end($customColumns)->children() as $column) {
             $columns[] = (string) $column['name'];
         }
     }
     // Add columns to overriable parameter list
     foreach ($columns as $column) {
         $className = $column;
         if (strpos($column, 'column') === 0) {
             $className = substr($column, 6);
         }
         $this->_overrideAttributes[strtolower($className . 'width')] = array('type' => 'integer', 'name' => $column);
     }
     // Load template parameters
     $params = $this->loadParams($templateParams->toArray(), $templateName, true);
     // Detect browser information
     $this->_document->browserInfo = JSNTplUtils::getInstance()->getBrowserInfo();
     $this->_document->isIE = @$this->_document->browserInfo['browser'] == 'msie';
     $this->_document->isIE7 = @$this->_document->browserInfo['browser'] == 'msie' && (int) @$this->_document->browserInfo['version'] == 7;
     // Custom direction from url parameter
     $direction = JFactory::getApplication()->input->getCmd('jsn_setdirection', $this->_document->direction);
     $this->_document->direction = $direction;
     // Apply custom params
     $params = $this->_overrideCustomParams($params);
     $params['showFrontpage'] = is_object($menu) && $menu->home == 1 ? $params['showFrontpage'] == 1 : true;
     if ($this->_document->isFree === true) {
         $params['mobileSupport'] = false;
         $params['useCSS3Effect'] = false;
     }
     // Prepare logo parameter
     if ($params['logoColored']) {
         $params['logoFile'] = "templates/{$templateName}/images/colors/{$params['templateColor']}/logo.png";
     }
     if ($params['mobileSupport'] == false) {
         $params['desktopSwitcher'] = false;
     }
     if (!preg_match('/^[a-zA-Z]+:\\/\\//i', $params['logoFile'])) {
         $params['logoFile'] = JUri::root(true) . '/' . $params['logoFile'];
     }
     // Prepare color variation to show in site tool
     if ($params['colorSelector'] and !@count($params['sitetoolsColorsItems'])) {
         $params['sitetoolsColorsItems'] = $manifest->xpath('//*[@name="sitetoolsColors"]/option');
         if (!$params['sitetoolsColorsItems'] or !@count($params['sitetoolsColorsItems'])) {
             $xml = simplexml_load_file(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/template/params.xml');
             $params['sitetoolsColorsItems'] = $xml->xpath('//*[@name="sitetoolsColors"]/option');
         }
         foreach ($params['sitetoolsColorsItems'] as &$color) {
             $color = (string) $color['value'];
         }
     }
     // Prepare Google Analytics code
     $params['codeAnalytic'] = trim($params['codeAnalytic']);
     if (!empty($params['codeAnalytic'])) {
         if (strpos($params['codeAnalytic'], '<script') === false) {
             $params['codeAnalytic'] = '<script type="text/javascript">' . $params['codeAnalytic'];
         }
         if (strpos($params['codeAnalytic'], '</script>') === false) {
             $params['codeAnalytic'] = $params['codeAnalytic'] . '</script>';
         }
     }
     // Binding parameters to document object
     $this->_document->params = new JRegistry();
     foreach ($params as $key => $value) {
         $this->_document->params->set($key, $value);
         $this->_document->{$key} = $value;
     }
     // Assign helper object
     $this->_document->helper = $this;
     $this->_document->attributes = $this->_overrideAttributes;
     $this->_document->templatePrefix = $this->_document->template . '_';
     // Prepare body class
     $this->_prepareBodyClass();
     // Prepare template styles
     $this->_prepareHead();
 }
Beispiel #5
0
 /**
  * Preparing template parameters for the template
  *
  * @return  void
  */
 private function _prepare($loadTemplateCSS, $loadTemplateJS)
 {
     $this->_loadTemplateCSS = $loadTemplateCSS;
     $this->_loadTemplateJS = $loadTemplateJS;
     $templateParams = isset($this->_document->params) ? $this->_document->params : null;
     $templateName = isset($this->_document->template) ? $this->_document->template : null;
     if (empty($templateParams) or empty($templateName) or $templateName == 'system') {
         $templateDetails = JFactory::getApplication()->getTemplate(true);
         $templateParams = $templateDetails->params;
         $templateName = $templateDetails->template;
     }
     // Get template information
     $this->_template = JSNTplTemplateRecognization::detect($templateName);
     // Update show content on frontpage parameter
     $app = JFactory::getApplication();
     $menu = $app->getMenu()->getActive();
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_jsntplframework', JPATH_ADMINISTRATOR);
     $manifest = JSNTplHelper::getManifest($templateName);
     $this->_document->app = JFactory::getApplication();
     $this->_document->template = $templateName;
     $this->_document->version = JSNTplHelper::getTemplateVersion($templateName);
     $this->_document->isFree = empty($manifest->edition) || $manifest->edition == 'FREE';
     $this->_document->uri = JFactory::getUri();
     $this->_document->rootUrl = $this->_document->uri->root(true);
     $this->_document->templateUrl = $this->_document->rootUrl . '/templates/' . $this->_document->template;
     $columns = array('columnPromoLeft', 'columnPromoRight', 'columnLeft', 'columnRight', 'columnInnerleft', 'columnInnerright');
     // Find customizable columns
     $customColumns = $manifest->xpath('//fieldset[@name="jsn-columns-size"]');
     if (count($customColumns) > 0) {
         $columns = array();
         foreach (end($customColumns)->children() as $column) {
             $columns[] = (string) $column['name'];
         }
     }
     // Add columns to overriable parameter list
     foreach ($columns as $column) {
         $className = $column;
         if (strpos($column, 'column') === 0) {
             $className = substr($column, 6);
         }
         $this->_overrideAttributes[strtolower($className . 'width')] = array('type' => 'string', 'name' => $column);
     }
     // Load template parameters
     $params = $this->loadParams($templateParams->toArray(), $templateName, true);
     // Detect browser information
     $this->_document->browserInfo = JSNTplUtils::getInstance()->getBrowserInfo();
     $this->_document->isIE = @$this->_document->browserInfo['browser'] == 'msie';
     $this->_document->isIE7 = @$this->_document->browserInfo['browser'] == 'msie' && (int) @$this->_document->browserInfo['version'] == 7;
     // Custom direction from url parameter
     $direction = JFactory::getApplication()->input->getCmd('jsn_setdirection', $this->_document->direction);
     $this->_document->direction = $direction;
     // Apply custom params
     $params = $this->_overrideCustomParams($params);
     $params['showFrontpage'] = is_object($menu) && $menu->home == 1 ? $params['showFrontpage'] == 1 : true;
     // Prepare logo parameter
     if ($params['logoColored']) {
         $params['logoFile'] = "templates/{$templateName}/images/colors/{$params['templateColor']}/logo.png";
     }
     if (!empty($params['logoFile']) and !preg_match('/^[a-zA-Z]+:\\/\\//i', $params['logoFile'])) {
         $params['logoFile'] = JUri::root(true) . '/' . $params['logoFile'];
     }
     // Prepare color variation to show in site tool
     if (!isset($params['sitetoolsColorsItems']) and $colorSettings = json_decode($params['sitetoolsColors'])) {
         if (!count($colorSettings->colors)) {
             $params['sitetoolsColorsItems'] = array();
         }
     }
     if ($params['sitetoolsColors'] and !isset($params['sitetoolsColorsItems'])) {
         $params['sitetoolsColorsItems'] = $manifest->xpath('//*[@name="sitetoolsColors"]/option');
         if (!$params['sitetoolsColorsItems'] or !@count($params['sitetoolsColorsItems'])) {
             $xml = simplexml_load_file(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/template/params.xml');
             $params['sitetoolsColorsItems'] = $xml->xpath('//*[@name="sitetoolsColors"]/option');
         }
         if ($params['sitetoolsColorsItems']) {
             foreach ($params['sitetoolsColorsItems'] as &$color) {
                 $color = (string) $color['value'];
             }
         }
         $params['sitetoolsColorsItems'] != false or $params['sitetoolsColorsItems'] = array();
     }
     $params['colorSelector'] = count($params['sitetoolsColorsItems']) ? true : false;
     // Check if site tools has tool to show
     if ($params['sitetoolStyle']) {
         $visible = count($params['sitetoolsColorsItems']);
         if (!$visible) {
             $params['sitetoolStyle'] = false;
         }
     }
     // Prepare Google Analytics code
     $params['codeAnalytic'] = trim($params['codeAnalytic']);
     if (!empty($params['codeAnalytic'])) {
         if (strpos($params['codeAnalytic'], '<script') === false) {
             $params['codeAnalytic'] = '<script type="text/javascript">' . $params['codeAnalytic'];
         }
         if (strpos($params['codeAnalytic'], '</script>') === false) {
             $params['codeAnalytic'] = $params['codeAnalytic'] . '</script>';
         }
     }
     // Check if user specified custom width for any column
     foreach ($columns as $column) {
         if (isset($params[$column])) {
             // Re-generate column name
             $columnName = str_replace('column-', '', strtolower(preg_replace('/([A-Z])/', '-\\1', $column)));
             foreach (array('promoColumns', 'mainColumns', 'contentColumns') as $row) {
                 foreach ($params[$row] as $id => $class) {
                     // Re-fine ID
                     $realId = preg_replace('/^\\d+:/', '', $id);
                     if (str_replace('-', '', $realId) == str_replace('-', '', $columnName)) {
                         if (strcasecmp(substr($params[$column], 0, 4), 'span') != 0) {
                             // Convert framework v1 value type to compatible with framework v2
                             $span = round($params[$column] / (100 / 12));
                         } else {
                             $span = intval(substr($params[$column], 4));
                         }
                         // Alter current parameter value
                         $currentSpan = intval(substr($class, 4));
                         if ($currentSpan != $span) {
                             $params[$row][$id] = "span{$span}";
                             foreach ($params[$row] as $id => $class) {
                                 if (preg_match('/(\\d+:)?(promo|content|component)/', $id)) {
                                     $params[$row][$id] = 'span' . (intval(substr($class, 4)) + ($currentSpan - $span));
                                     // Done altering
                                     break;
                                 }
                             }
                         }
                         // Done altering
                         break 2;
                     }
                 }
             }
         }
     }
     // Process column width
     if (strcasecmp(get_class($this->_document), 'JDocumentHTML') == 0) {
         $utils = JSNTplUtils::getInstance();
         foreach (array('promoColumns', 'mainColumns', 'contentColumns', 'userColumns') as $row) {
             $visible = count($params[$row]);
             $spacing = 0;
             $columns = array();
             foreach ($params[$row] as $id => $class) {
                 // Re-fine ID
                 $realId = preg_replace('/^\\d+:/', '', $id);
                 // Detect the visibility of this column
                 if (!in_array($realId, array('content', 'component')) and !$utils->countModules($realId)) {
                     $visible--;
                     $spacing += intval(str_replace('span', '', $class));
                     $columns[$id] = 0;
                 } else {
                     $columns[$id] = 1;
                 }
             }
             // Expand visible columns if neccessary
             if ($visible < count($params[$row])) {
                 foreach ($columns as $id => $status) {
                     if (!$status) {
                         // Column is invisible, unset data
                         unset($params[$row][$id]);
                     } elseif ($visible > 0) {
                         // Alter column spanning
                         if (count($columns) > 3) {
                             $params[$row][$id] = preg_replace('/span\\d+/i', 'span' . 12 / $visible, $params[$row][$id]);
                         } elseif ($visible == 1) {
                             $params[$row][$id] = preg_replace('/span\\d+/i', 'span12', $params[$row][$id]);
                         }
                     }
                 }
                 if (count($columns) == 3 and $visible == 2) {
                     // Sort columns to ensure correct source code order
                     ksort($columns);
                     $ordering = array_keys($columns);
                     // Always expand main column if left or right is invisible
                     if ($columns[$ordering[0]] and $row != 'userColumns') {
                         $span = intval(str_replace('span', '', $params[$row][$ordering[0]]));
                         $params[$row][$ordering[0]] = preg_replace('/span\\d+/i', 'span' . ($span + $spacing), $params[$row][$ordering[0]]);
                     } else {
                         foreach ($ordering as $key) {
                             if ($columns[$key]) {
                                 $params[$row][$key] = preg_replace('/span\\d+/i', 'span6', $params[$row][$key]);
                             }
                         }
                     }
                 }
             }
             // Set visual column ordering
             $columns = array();
             $ordering = 0;
             foreach ($params[$row] as $id => $class) {
                 // Add class to indicate the order of this column
                 $params[$row][$id] .= ' order' . $ordering++;
             }
             // Sort columns for correct source code ordering
             ksort($params[$row]);
             foreach ($params[$row] as $id => $class) {
                 // Store data for processing visual ordering later
                 $columns[] = array('id' => $id, 'class' => $class);
             }
             // Process visual ordering for visible columns
             foreach ($columns as $ordering => $column) {
                 $visualOrdering = intval(preg_replace('/^.*order(\\d+).*$/', '\\1', $column['class']));
                 $offset = 0;
                 if ($ordering < $visualOrdering) {
                     for ($i = $ordering + 1; $i < $visible; $i++) {
                         $nextOrdering = intval(preg_replace('/^.*order(\\d+).*$/', '\\1', $columns[$i]['class']));
                         if (($ordering == 0 or $nextOrdering > 0) and $nextOrdering < $visualOrdering) {
                             $offset += intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$i]['class']));
                         }
                     }
                 } elseif ($ordering > 0 and $ordering == $visualOrdering and $ordering + 1 < $visible) {
                     for ($i = 0; $i < $ordering; $i++) {
                         if (preg_match('/offset\\d+/', $columns[$i]['class'])) {
                             $offset -= intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$i]['class']));
                         }
                     }
                     if ($offset < 0) {
                         $offset -= intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$ordering]['class']));
                     }
                 } elseif ($ordering > $visualOrdering) {
                     for ($i = 0; $i < $ordering; $i++) {
                         $prevOrdering = intval(preg_replace('/^.*order(\\d+).*$/', '\\1', $columns[$i]['class']));
                         if ($prevOrdering > $visualOrdering) {
                             if (preg_match('/offset\\d+/', $columns[$i]['class'])) {
                                 $offset -= intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$i]['class']));
                                 $offset -= intval(preg_replace('/^.*offset(\\d+).*$/', '\\1', $columns[$i]['class']));
                             } elseif (strpos($columns[$i]['class'], 'offset-') === false) {
                                 $offset -= intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$i]['class']));
                             }
                         } elseif ($i > 0 and $prevOrdering < $visualOrdering) {
                             $offset += intval(preg_replace('/^.*span(\\d+).*$/', '\\1', $columns[$i]['class']));
                         }
                     }
                 }
                 // Set offset so the column display in correct visual ordering
                 if ($offset != 0) {
                     $columns[$ordering]['class'] = preg_replace('/(order\\d+)/', "\\1 offset{$offset}", $columns[$ordering]['class']);
                 }
             }
             // Update column IDs and classes
             foreach ($columns as $column) {
                 unset($params[$row][$column['id']]);
                 // Re-fine ID
                 $realId = preg_replace('/^\\d+:/', '', $column['id']);
                 // Re-fine column order
                 $ordering = intval(preg_replace('/^.*order(\\d+).*$/', '\\1', $column['class'])) + 1;
                 // Split classes to span, order and offset
                 $classes = explode(' ', preg_replace('/order\\d+/', "order{$ordering}", $column['class']));
                 // Reset column data
                 $params[$row][$realId] = array('span' => $classes[0], 'order' => isset($classes[1]) ? $classes[1] : '', 'offset' => isset($classes[2]) ? $classes[2] : '');
             }
         }
         // Prepare social icons
         $socialIcons = array();
         foreach ((array) @$params['socialIcons']['status'] as $channel) {
             // Set default value
             if (@empty($params['socialIcons'][$channel]['link']) and in_array($channel, array('facebook', 'twitter', 'youtube'))) {
                 if (!@isset($params['socialIcons'][$channel]['title'])) {
                     $params['socialIcons'][$channel]['title'] = JText::_('JSN_TPLFW_SOCIAL_NETWORK_INTEGRATION_' . strtoupper($channel));
                 }
                 $params['socialIcons'][$channel]['link'] = "http://www.{$channel}.com/joomlashine";
             }
             if (!@empty($params['socialIcons'][$channel]['link'])) {
                 $socialIcons[$channel] = $params['socialIcons'][$channel];
             }
         }
     }
     $params['socialIcons'] = $socialIcons;
     // Backward compatible: set templateStyle parameter as it still be used in component output only template file
     $params['templateStyle'] = $params['fontStyle']['style'];
     // Binding parameters to document object
     $this->_document->params = new JRegistry();
     foreach ($params as $key => $value) {
         $this->_document->params->set($key, $value);
         $this->_document->{$key} = $value;
     }
     // Assign helper object
     $this->_document->helper = $this;
     $this->_document->attributes = $this->_overrideAttributes;
     $this->_document->templatePrefix = $this->_document->template . '_';
     // Prepare body class
     $this->_prepareBodyClass();
     // Prepare template styles
     $this->_prepareHead();
 }
Beispiel #6
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);
 }
 /**
  * Start process to install template update
  *
  * @return  void
  */
 public function installPackageAction()
 {
     // Initialize variables
     $joomlaConfig = JFactory::getConfig();
     $packageFile = $joomlaConfig->get('tmp_path') . '/jsn-' . $this->template['id'] . '.zip';
     $packagePath = substr($packageFile, 0, -4);
     $templatePath = JPATH_ROOT . '/templates/' . $this->template['name'];
     // Checking downloaded template package
     if (!is_file($packageFile)) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_PACKAGE_FILE_NOT_FOUND'));
     }
     // Check if template is copied to another name
     if ($xml = simplexml_load_file($packagePath . '/template/templateDetails.xml')) {
         if (strcasecmp($this->template['name'], trim((string) $xml->name)) != 0) {
             // Update templateDetails.xml with new name
             $content = str_replace((string) $xml->name, $this->template['name'], JFile::read($packagePath . '/template/templateDetails.xml'));
             JFile::write($packagePath . '/template/templateDetails.xml', $content);
         }
     }
     // Get list of files to be updated
     try {
         $update = JSNTplHelper::getFilesBeingUpdated($this->template['name'], $packageFile);
         if (!$update) {
             throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_PACKAGE_FILE_NOT_FOUND'));
         }
     } catch (Exception $e) {
         throw $e;
     }
     // Include template checksum and manifest files
     in_array('template.checksum', $update['edit']) or $update['edit'][] = 'template.checksum';
     in_array('templateDetails.xml', $update['edit']) or $update['edit'][] = 'templateDetails.xml';
     // Import necessary libraries
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.helper');
     // Update the template
     foreach ($update as $action => $files) {
         foreach ($files as $file) {
             if ($action != 'add') {
                 JFile::delete($templatePath . '/' . $file);
             }
             if ($action != 'delete' and JFolder::create(dirname($templatePath . '/' . $file))) {
                 JFile::copy($packagePath . '/template/' . $file, $templatePath . '/' . $file);
             }
         }
     }
     // Move backup file to template directory
     $source = $joomlaConfig->get('tmp_path') . '/' . $this->template['name'] . '_modified_files.zip';
     $target = $templatePath . '/backups/' . date('y-m-d_H-i-s') . '_modified_files.zip';
     if (is_readable($source)) {
         JFile::copy($source, $target);
         // Remove backup file in temporary directory
         filesize($source) != filesize($target) or JFile::delete($source);
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $packagePath);
     // Check if update success
     $messages = JFactory::getApplication()->getMessageQueue();
     if (class_exists('JError')) {
         $messages = array_merge(JError::getErrors(), $messages);
     }
     foreach ($messages as $message) {
         if (is_array($message) and @$message['type'] == 'error' or is_object($message) and (!method_exists($message, 'get') or $message->get('level') == E_ERROR)) {
             $msg = str_replace(JPATH_ROOT, '', is_array($message) ? $message['message'] : $message->getMessage());
             $errors[$msg] = 1;
         }
     }
     if (@count($errors)) {
         throw new Exception('<ul><li>' . implode('</li><li>', array_keys($errors)) . '</li></ul>');
     }
     // Update template version in manifest cache
     $manifest = JSNTplHelper::getManifest($this->template['name'], true);
     $template = JTable::getInstance('extension');
     $template->load(array('type' => 'template', 'element' => $this->template['name']));
     if ($template->extension_id) {
         // Decode manifest cache
         $template->manifest_cache = json_decode($template->manifest_cache);
         // Set new template version
         $template->manifest_cache->version = (string) $manifest->version;
         // Re-encode manifest cache
         $template->manifest_cache = json_encode($template->manifest_cache);
         // Store new data
         $template->store();
     }
     // Update template version in template definition file
     $content = preg_replace('/\\$JoomlaShine_Template_Version = \'[^\']+\';/i', '$JoomlaShine_Template_Version = \'' . (string) $manifest->version . '\';', JFile::read($templatePath . '/template.defines.php'));
     JFile::write($templatePath . '/template.defines.php', $content);
     // Clear backup state
     JFactory::getApplication()->setUserState('jsn-tplfw-backup-done', 0);
     // Clean up compressed files
     $this->_cleanCache();
 }
    /**
     * Method to get the field input markup for a generic list.
     * Use the multiple attribute to enable multiselect.
     *
     * @return  string  The field input markup.
     *
     * @since   11.1
     */
    protected function getInput()
    {
        $request = JFactory::getApplication()->input;
        if (class_exists('JModelLegacy')) {
            $templateModel = JModelLegacy::getInstance('Style', 'TemplatesModel');
        } else {
            $templateModel = JModel::getInstance('Style', 'TemplatesModel');
        }
        $templateData = $templateModel->getItem($request->getInt('id'));
        $templateXml = JSNTplHelper::getManifest($templateData->template);
        $mobileMenuEffect = (string) $templateXml->mobileMenuEffect;
        $html = array();
        $attr = '';
        // Initialize some field attributes.
        $attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
        $attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
        $attr .= $this->multiple ? ' multiple' : '';
        $attr .= $this->required ? ' required aria-required="true"' : '';
        $attr .= $this->autofocus ? ' autofocus' : '';
        // To avoid user's confusion, readonly="true" should imply disabled="true".
        if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1' || (string) $this->disabled == 'true') {
            $attr .= ' disabled="disabled"';
        }
        // Initialize JavaScript field attributes.
        $attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
        // Get the field options.
        $options = (array) $this->getOptions();
        //if (strtolower($mobileMenuEffect) != 'yes')
        //{
        //Only get default if the template does not support Mobile Menu Effect
        //$options = array(@$options[0]);
        //}
        if (strtolower($mobileMenuEffect) != 'yes') {
            $html[] = '<script type="text/javascript">		
				(function($) {
					$(document).ready(function() {
						$("select[name=\'jsn[mobileMenuEffect]\']").parent().parent().hide();
					});
				})(jQuery);
			
			</script>';
        }
        // Create a read-only list (no name) with hidden input(s) to store the value(s).
        if ((string) $this->readonly == '1' || (string) $this->readonly == 'true') {
            $html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
            // E.g. form field type tag sends $this->value as array
            if ($this->multiple && is_array($this->value)) {
                if (!count($this->value)) {
                    $this->value[] = '';
                }
                foreach ($this->value as $value) {
                    $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"/>';
                }
            } else {
                $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"/>';
            }
        } else {
            $html[] = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
        }
        return implode($html);
    }