Example #1
0
 function setTemplateInfo()
 {
     $objUtils = JSNUtils::getInstance();
     $objReadXMLFile = new JSNReadXMLFile();
     $templateManifest = $objReadXMLFile->getTemplateManifestFileInformation();
     if ($templateManifest['edition'] != '' && $templateManifest['edition'] != 'free') {
         $edition = 'pro ' . $templateManifest['edition'];
     } else {
         $edition = 'free';
     }
     $this->_edition = $edition;
     $this->_based_identified_name = '';
     $this->_identified_name = str_replace('jsn', 'tpl', strtolower($templateManifest['name']));
     $this->_joomla_version = $objUtils->getJoomlaVersion(true);
     $this->_full_name = strtolower($templateManifest['full_name']);
     $this->_name = strtolower($templateManifest['name']);
     $this->_template_version = $templateManifest['version'];
 }
Example #2
0
 function installSampleData()
 {
     $defaultTimeout = ini_get('max_execution_time');
     @set_time_limit(360);
     $file_name = JRequest::getVar('file_name');
     $foldertmp = JPATH_ROOT . DS . 'tmp';
     $folderbackup = $this->_template_folder_path . DS . 'backups';
     $link = '';
     $errors = array();
     $isNotExisted = array();
     $obj_read_xml_file = new JSNReadXMLFile();
     $session = JFactory::getSession();
     $login_identifier = md5('state_login_' . strtolower($this->_template_name));
     $sessionExtFailedId = md5('exts_failed_install_' . strtolower($this->_template_name));
     //$identifier 		= md5('state_installation_'.strtolower($this->_template_name));
     $state_login = $session->get($login_identifier, false, 'jsntemplatesession');
     $failedExts = $session->get($sessionExtFailedId, array(), 'jsntemplatesession');
     if (!$state_login) {
         jexit('Invalid Token');
     }
     $obj_sample_data_helper = new JSNSampleDataHelper();
     $array_non_basic_module = $obj_sample_data_helper->getNonBasicModule();
     $array_non_basic_admin_module = $obj_sample_data_helper->getNonBasicAdminModule();
     $array_3rd_extension_menu = $obj_sample_data_helper->getThirdExtensionMenus();
     $domain = $obj_sample_data_helper->getDomain();
     if (!is_writable($foldertmp)) {
         $obj_sample_data_helper->deleteSampleDataFile($file_name);
         echo json_encode(array('download' => false, 'message' => JText::_('JSN_SAMPLE_DATA_TEMP_FOLDER_UNWRITABLE'), 'redirect_link' => $link));
         return;
     }
     $path = $foldertmp . DS . $file_name;
     if (!JFile::exists($path)) {
         echo json_encode(array('install' => false, 'message' => JText::_('JSN_SAMPLE_DATA_PACKAGE_FILE_NOT_FOUND'), 'redirect_link' => $link, 'manual' => true));
         return;
     }
     $unpackage = $obj_sample_data_helper->unpackPackage($file_name);
     if ($unpackage) {
         $sample_xml_data = $obj_read_xml_file->getSampleDataFileContent($unpackage, $this->_template_name);
         $installed_data = $sample_xml_data['installed_data'];
         if ($installed_data && is_array($installed_data)) {
             if (trim($sample_xml_data['version']) != trim($this->_template_version)) {
                 $obj_sample_data_helper->deleteSampleDataFile($file_name);
                 $obj_sample_data_helper->deleteSampleDataFolder($unpackage);
                 echo json_encode(array('install' => false, 'message' => JText::_('JSN_SAMPLE_DATA_OUTDATED_PRODUCT'), 'redirect_link' => $link));
                 return;
             } else {
                 foreach ($failedExts as $key => $value) {
                     unset($installed_data[$key]);
                     if (isset($value['message']) && $value['message'] != '') {
                         $errors[] = $value['message'];
                     }
                     /* Only for an extension that doesn't exist, not can-not-be upgraded one */
                     if (isset($value['exist']) && $value['exist'] === false) {
                         $isNotExisted[] = $key;
                     }
                 }
                 $obj_backup = JSNBackup::getInstance();
                 if (is_writable($folderbackup)) {
                     $backup_file_name = $obj_backup->executeBackup($this->_template_folder_path . DS . 'backups', $domain, $installed_data);
                 } else {
                     $backup_file_name = '';
                 }
                 $obj_sample_data_helper->deleteNonBasicAdminModule();
                 $obj_sample_data_helper->installSampleData($installed_data);
                 /* Clean up records of non-installed extensions */
                 if (count($isNotExisted)) {
                     $asset = JTable::getInstance('Asset');
                     foreach ($isNotExisted as $element) {
                         $element = 'com_' . $element;
                         /* Delete assets record */
                         if ($asset->loadByName($element)) {
                             $asset->delete();
                         }
                         /* Disable menu items (if available) */
                         $obj_sample_data_helper->disableMenuItems($element);
                     }
                 }
                 $obj_sample_data_helper->runQueryNonBasicModule($array_non_basic_module);
                 $obj_sample_data_helper->runQueryNonBasicModule($array_non_basic_admin_module, true);
                 $obj_sample_data_helper->restoreThirdExtensionMenus($array_3rd_extension_menu);
                 $obj_sample_data_helper->rebuildMenu();
                 $obj_sample_data_helper->copyContentFromFilesFolder($unpackage);
                 $obj_sample_data_helper->deleteSampleDataFolder($unpackage);
                 $obj_sample_data_helper->setDefaultTemplate(strtolower($this->_template_name));
                 $obj_sample_data_helper->deleteSampleDataFile($file_name);
                 //$session->set($identifier, true, 'jsntemplatesession');
                 $session->set($login_identifier, false, 'jsntemplatesession');
                 echo json_encode(array('install' => true, 'message' => '', 'redirect_link' => $link, 'warnings' => $errors, 'backup_file_name' => $backup_file_name));
                 $session->clear($sessionExtFailedId, 'jsntemplatesession');
                 return;
             }
         } else {
             $obj_sample_data_helper->deleteSampleDataFile($file_name);
             echo json_encode(array('install' => false, 'message' => JText::_('JSN_SAMPLE_DATA_INVALID'), 'redirect_link' => $link, 'manual' => true));
             return;
         }
     } else {
         $obj_sample_data_helper->deleteSampleDataFile($file_name);
         echo json_encode(array('install' => false, 'message' => JText::_('JSN_SAMPLE_DATA_UNABLE_EXTRACT_PACKAGE'), 'redirect_link' => $link));
         exit;
     }
     return;
 }
Example #3
0
 /**
  * Get template positions
  *
  */
 public function getPositions($template)
 {
     jimport('joomla.filesystem.folder');
     $result = array();
     $client = JApplicationHelper::getClientInfo(0);
     if ($client === false) {
         return false;
     }
     require_once 'jsn_readxmlfile.php';
     $jsn_readxml = new JSNReadXMLFile();
     $positions = $jsn_readxml->getTemplatePositions();
     $positions = array_unique($positions);
     if (count($positions)) {
         foreach ($positions as $value) {
             $classModule = new stdClass();
             $classModule->value = $value;
             $classModule->text = $value;
             if (preg_match("/-m+\$/", $value)) {
                 $result['mobile'][] = $classModule;
             } else {
                 $result['desktop'][] = $classModule;
             }
         }
     }
     return $result;
 }
Example #4
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
 * @version   $Id: jsn_autoupdater.php 11613 2012-03-08 09:31:14Z hieudm $
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
require_once 'includes' . DS . 'jsn_defines.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_utils.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_readxmlfile.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_auto_updater_helper.php';
$session = JFactory::getSession();
$obj_read_xml_file = new JSNReadXMLFile();
$obj_utils = new JSNUtils();
$obj_updater_helper = new JSNAutoUpdaterHelper();
$template_manifest = $obj_read_xml_file->getTemplateManifestFileInformation();
$manifest_cache = $obj_utils->getTemplateManifestCache();
$manifest_cache = json_decode($manifest_cache);
/* Determine front-end index path, including lang sef if available */
$frontIndexPath = JURI::root() . $obj_utils->determineFrontendIndex();
/* Form template identified_name */
$explodedName = explode('_', $template_manifest['name']);
$templateIdName = 'tpl_' . $explodedName[1];
/* Get template latest version from session if possible */
$templateVersionSesId = md5('template_version_' . strtolower($template_manifest['full_name']));
$versionFromSes = $session->get($templateVersionSesId, null, 'jsntemplatesession');
if (!is_null($versionFromSes)) {
    $latest_version = $versionFromSes;
Example #5
0
<?php

/**
 * @author    JoomlaShine.com http://www.joomlashine.com
 * @copyright Copyright (C) 2008 - 2012 JoomlaShine.com. All rights reserved.
 * @license   GNU/GPL v2 http://www.gnu.org/licenses/gpl-2.0.html
 * @version   $Id: jsn_upgrade.php 13532 2012-06-26 03:20:42Z ngocpm $
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
require_once 'includes' . DS . 'jsn_defines.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_utils.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_readxmlfile.php';
require_once 'includes' . DS . 'lib' . DS . 'jsn_proupgrade_helper.php';
$jsnUtils = new JSNUtils();
$jsnReadXml = new JSNReadXMLFile();
$joomlaVersion = $jsnUtils->getJoomlaVersion(true);
$templateManifest = $jsnReadXml->getTemplateManifestFileInformation();
$templateLowName = strtolower($templateManifest['full_name']);
$jsnUpgradeHelper = new JSNProUpgradeHelper($templateManifest, $joomlaVersion);
$task = JRequest::getVar('task', '');
$manualUpgrade = JRequest::getVar('manual', 0);
$autoUpgradeTried = JRequest::getVar('auto_tried', 0, 'GET');
$templateStyleId = JRequest::getInt('template_style_id', 0, 'GET');
$frontIndexPath = JURI::root() . $jsnUtils->determineFrontendIndex();
/* Session variables */
$session = JFactory::getSession();
$sessionTemp = array();
$sessionTemp['upgrader'] = md5('jsn_upgrader_' . $templateLowName);
$sessionTemp['joomla_login'] = md5('joomla_login_' . $templateLowName);
$sessionTemp['jsn_login'] = md5('jsn_login_' . $templateLowName);
Example #6
0
 function determineExtInstallation($extInfo)
 {
     $needInstall = false;
     $outdated = false;
     $proEdition = false;
     $sdHelperInstance = new JSNSampleDataHelper();
     /* Check if the extension has already been installed */
     $extensionExists = $this->checkExistingExtension($extInfo->name, $extInfo->type);
     if ($extensionExists === false) {
         $needInstall = true;
     } else {
         $xmlReaderInstance = new JSNReadXMLFile();
         $utilInstance = new JSNUtils();
         $extManifestInfo = $xmlReaderInstance->getExtensionManifestFileInformation($extInfo->name, $extInfo->manifestPath);
         // $extLatestVersion = $utilInstance->getLatestProductVersion($extInfo->identifiedName, $extInfo->name);
         /* Fall-back: use version supplied in sample data file */
         // if ($extLatestVersion === false)
         // {
         // 	$extLatestVersion = $extInfo->version;
         // }
         $extLatestVersion = $extInfo->version;
         /* Version outdated, need to update */
         if ($extManifestInfo['version'] != $extLatestVersion) {
             $outdated = true;
             /* FREE edition will get updated */
             if ($extManifestInfo['edition'] == '' || strtolower($extManifestInfo['edition']) == 'free') {
                 $needInstall = true;
             } else {
                 if ($extInfo->hasData === true) {
                     $proEdition = true;
                 }
             }
         }
     }
     $result = new stdClass();
     $result->toInstall = $needInstall;
     $result->exist = $extensionExists;
     $result->outdated = $outdated;
     $result->proEdition = $proEdition;
     return $result;
 }