예제 #1
0
 /**
  * Process checking customer information
  *
  * @return  void
  */
 public function authAction()
 {
     // Process posted back data that sent from client
     if ($this->request->getMethod() == 'POST') {
         $username = $this->request->getString('username', '');
         $password = $this->request->getString('password', '');
         // Create new HTTP Request
         try {
             $orderedEditions = JSNTplApiLightcart::getOrderedEditions($this->template['id'], $username, $password);
         } catch (Exception $e) {
             throw $e;
         }
         $edition = $this->template['edition'];
         if ($edition != 'FREE' and strpos($edition, 'PRO ') === false) {
             $edition = 'PRO ' . $edition;
         }
         if (in_array($edition, $orderedEditions)) {
             $this->setResponse(array('id' => $this->template['id'], 'edition' => $edition, 'joomlaVersion' => JSNTplHelper::getJoomlaVersion(2), 'username' => urlencode($username), 'password' => urlencode($password)));
         } else {
             throw new Exception(JText::_('JSN_TPLFW_ERROR_API_ERR02'));
         }
     }
 }
예제 #2
0
 /**
  * Download template package
  *
  * @return  void
  */
 public function downloadPackageAction()
 {
     JSNTplHelper::isDisabledFunction('set_time_limit') or set_time_limit(0);
     try {
         $packageFile = JSNTplApiLightcart::downloadPackage($this->template['id'], $this->request->getString('edition'), $this->request->getString('username'), $this->request->getString('password'));
     } catch (Exception $e) {
         throw $e;
     }
     $this->session->set($this->template['id'] . '.upgradePackage', $packageFile);
 }
예제 #3
0
 /**
  * Action to handle install extension request.
  *
  * @param   string  $id  Identified name of the extension to be installed.
  *
  * @return  void
  */
 public function installExtensionAction($id = null)
 {
     JSNTplHelper::isDisabledFunction('set_time_limit') or set_time_limit(0);
     // Get necessary variables
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $tmpPath = $config->get('tmp_path');
     if (empty($id)) {
         $id = $this->request->getString('id');
     }
     // Disable debug system
     $config->set('debug', 0);
     // Path to sample data file
     $xmlFiles = glob("{$tmpPath}/{$this->template['name']}_sampledata/*.xml");
     if (empty($xmlFiles)) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_SAMPLE_DATA_PACKAGE'));
     }
     // Load XML document
     $xml = simplexml_load_file(current($xmlFiles));
     $extensions = $xml->xpath("//extension[@identifiedname=\"{$id}\"]");
     if (!empty($extensions)) {
         $extension = current($extensions);
         $name = (string) $extension['name'];
         $type = (string) $extension['type'];
         switch ($type) {
             case 'component':
                 $name = 'com_' . $name;
                 break;
             case 'module':
                 $name = 'mod_' . $name;
                 break;
         }
         $this->_cleanExtensionAssets($name);
         // Install JSN Extension Framework first if not already installed
         if ($type == 'component') {
             // Get details about JSN Extension Framework
             $extfw = $xml->xpath('//extension[@identifiedname="ext_framework"]');
             if (!empty($extfw)) {
                 $extfw = current($extfw);
                 if ($this->_getExtensionState((string) $extfw['name'], (string) $extfw['version']) != 'installed') {
                     // Install JSN Extension Framework
                     try {
                         $this->installExtensionAction('ext_framework');
                     } catch (Exception $e) {
                         throw $e;
                     }
                 }
             }
         }
     }
     // Download package from lightcart
     try {
         $packageFile = JSNTplApiLightcart::downloadPackage($id, 'FREE', null, null, "{$tmpPath}/{$this->template['name']}_sampledata/");
     } catch (Exception $e) {
         throw $e;
     }
     if (!is_file($packageFile)) {
         throw new Exception("Package file not found: {$packageFile}");
     }
     // Load extension installation library
     jimport('joomla.installer.helper');
     // Rebuild menu structure
     $this->_rebuildMenus();
     // Extract downloaded package
     $unpackedInfo = JInstallerHelper::unpack($packageFile);
     $installer = JInstaller::getInstance();
     if (empty($unpackedInfo) or !isset($unpackedInfo['dir'])) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_EXTENSION_PACKAGE_FILE'));
     }
     // Install extracted package
     $installResult = $installer->install($unpackedInfo['dir']);
     if ($installResult === false) {
         foreach (JError::getErrors() as $error) {
             throw $error;
         }
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $unpackedInfo['dir']);
     $this->_activeExtension(array('type' => $type, 'name' => $name));
     // Rebuild menu structure
     $this->_rebuildMenus();
 }
예제 #4
0
 public function downloadFrameworkAction()
 {
     if (!JSNTplHelper::isDisabledFunction('set_time_limit')) {
         set_time_limit(0);
     }
     // Download package file
     try {
         JSNTplApiLightcart::downloadPackage('tpl_framework');
     } catch (Exception $e) {
         throw $e;
     }
 }