/** * Render intro view * * @return void */ public function introAction() { // Get upgrade details from JoomlaShine server $response = null; try { $response = JSNTplHttpRequest::get(JSN_TPLFRAMEWORK_UPGRADE_DETAILS); $response = json_decode($response['body'], true); } catch (Exception $e) { // Do nothing } if ($response != null) { // Get response belonging to current template if (isset($response[$this->template['id']])) { $response = $response[$this->template['id']]; } elseif (isset($response['template'])) { $response = $response['template']; } else { $response = $response['default']; } // Get current template edition $currentEdition = strcasecmp($this->template['edition'], 'free') == 0 ? 'free' : 'pro'; // Prepare content $content = isset($response['pro']) ? $response['pro'] : ''; if ($currentEdition == 'free') { $content = $response['free'] . $content; } } $this->render('intro', array('template' => $this->template, 'data' => isset($content) ? $content : $response)); }
/** * Get list of supported editions for current template. * * @return array */ protected function loadEditions() { $cacheFile = JPATH_SITE . '/templates/' . $this->data->template . '/editions.json'; // Retrieve template editions from cache file if (is_file($cacheFile) and is_readable($cacheFile)) { $editions = json_decode(JFile::read($cacheFile), true); if (!empty($editions)) { $this->editions = $editions; return $editions; } } try { $response = JSNTplHttpRequest::get(JSN_TPLFRAMEWORK_VERSIONING_URL . '?category=cat_template'); $json = json_decode(trim($response['body']), true); } catch (Exception $e) { // Do nothing } // Return only free edition if cannot parse data returned from server if (empty($json) or !is_array($json) or !isset($json['items'])) { $this->editions = array('FREE'); } else { $templateId = JSNTplHelper::getTemplateId($this->data->template); $this->editions = array('FREE'); foreach ($json['items'] as $item) { if (isset($item['identified_name']) && $templateId == $item['identified_name']) { if (isset($item['editions']) and is_array($item['editions'])) { foreach ($item['editions'] as $edition) { $e = strtoupper(trim($edition['edition'])); in_array($e, $this->editions) or $this->editions[] = $e; } } elseif (isset($item['edition']) and !empty($item['edition'])) { $e = strtoupper(trim($item['edition'])); in_array($e, $this->editions) or $this->editions[] = $e; } } } } // Cache edition data $buffer = json_encode($this->editions); JFile::write($cacheFile, $buffer); }
/** * Action to execute queries from sample data file * * @return void */ public function installDataAction() { try { // Create a backup of Joomla database $this->_backupDatabase(); // Initialize variables $config = JFactory::getConfig(); $tmpPath = $config->get('tmp_path'); $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)); $version = (string) $xml['version']; $joomla_ver = (string) $xml['joomla-version']; // Compare versions $templateVersion = JSNTplHelper::getTemplateVersion($this->template['name']); $joomlaVersion = new JVersion(); if (version_compare($templateVersion, $version, '<')) { throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_SAMPLE_DATA_OUT_OF_DATED', $templateVersion), 99); } if (!empty($joomla_ver) and version_compare($joomlaVersion->getShortVersion(), $joomla_ver, '<')) { throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_JOOMLA_OUT_OF_DATE', $joomlaVersion->getShortVersion()), 99); } $thirdComponents = array(); $thirdComponentErrors = array(); // Looping to each extension type=component to get information and dependencies foreach ($xml->xpath('//extension[@author="3rd_party"]') as $component) { if (isset($component['author']) && $component['author'] == '3rd_party') { $attrs = (array) $component->attributes(); $attrs = $attrs['@attributes']; $componentType = (string) $attrs['type']; $namePrefix = array('component' => 'com_', 'module' => 'mod_'); $componentName = isset($namePrefix[(string) $attrs['type']]) ? $namePrefix[$componentType] . $attrs['name'] : (string) $attrs['name']; $state = $this->_getExtensionState($componentName, (string) $attrs['version'], true); $thirdComponents[] = array('id' => $attrs['name'], 'state' => $state, 'full_name' => (string) $attrs['full_name'], 'version' => (string) $attrs['version'], 'type' => $componentType); } } if (count($thirdComponents)) { foreach ($thirdComponents as $thirdComponent) { if ($thirdComponent['state'] == 'install') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NOT_INSTALLED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } elseif ($thirdComponent['state'] == 'update') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NEED_TO_INSTALLED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } elseif ($thirdComponent['state'] == 'unsupported') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NOT_SUPPORTED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } else { //do nothing } } } if (count($thirdComponentErrors)) { $strThirdComponentError = '<ul>'; foreach ($thirdComponentErrors as $thirdComponentError) { $strThirdComponentError .= '<li>' . $thirdComponentError . '</li>'; } $strThirdComponentError .= '</ul>'; throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION', $strThirdComponentError), 99); } // Temporary backup data $this->_backupThirdPartyModules(); $this->_backupThirdPartyAdminModules(); $this->_backupThirdPartyMenus(); // Start transaction before manipulate database $this->dbo->transactionStart(); // Delete admin modules $this->_deleteThirdPartyAdminModules(); // Disable execution timeout if (!JSNTplHelper::isDisabledFunction('set_time_limit')) { set_time_limit(0); } $attentions = array(); // Loop each extension to execute queries foreach ($xml->xpath('//extension') as $extension) { if (isset($extension['author']) && $extension['author'] == 'joomlashine') { $extensionType = (string) $extension['type']; $namePrefix = array('component' => 'com_', 'module' => 'mod_'); $extensionName = isset($namePrefix[(string) $extension['type']]) ? $namePrefix[$extensionType] . $extension['name'] : (string) $extension['name']; // Check if JoomlaShine extension is installed $canInstall = JSNTplHelper::isInstalledExtension($extensionName); if ($canInstall == false and $extensionType == 'component') { // Add to attention list when extension is not installed $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['description'], 'url' => (string) $extension['producturl']); } } else { $canInstall = true; $extensionName = 'com_' . (string) $extension['name']; } if ($canInstall === true) { // Get sample data queries if ($queries = $extension->xpath("task[@name=\"dbinstall\"]/parameters/parameter") and @count($queries)) { // Execute sample data queries foreach ($queries as $query) { // Find remote assets then download to local system if (preg_match_all('#(http://demo.joomlashine.com/[^\\s\\t\\r\\n]+/media/joomlashine/)[^\\s\\t\\r\\n]+\\.(js|css|bmp|gif|ico|jpg|png|svg|ttf|otf|eot|woff)#', $query, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $keepAsIs = false; if (!isset($this->mediaFolder)) { // Detect a writable folder to store demo assets foreach (array('media', 'cache', 'tmp') as $folder) { $folder = JPATH_ROOT . "/{$folder}"; if (is_dir($folder) and is_writable($folder) and JFolder::create("{$folder}/joomlashine")) { $this->mediaFolder = "{$folder}/joomlashine"; break; } } } if (isset($this->mediaFolder)) { // Generate path to store demo asset $mediaFile = str_replace($match[1], "{$this->mediaFolder}/", $match[0]); // Download demo asset only once if (!is_file($mediaFile)) { try { JSNTplHttpRequest::get($match[0], $mediaFile); } catch (Exception $e) { $keepAsIs = true; } } // Alter sample data query if (!$keepAsIs) { $query = str_replace($match[0], str_replace(JPATH_ROOT . '/', '', $mediaFile), $query); } } } } // Execute query $this->dbo->setQuery((string) $query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } } } } // Restore backed up data $this->_restoreThirdPartyData(); $this->_rebuildMenus(); // Disable default template $q = $this->dbo->getQuery(true); $q->update('#__template_styles'); $q->set('home = 0'); $q->where('client_id = 0'); $q->where('home = 1'); $this->dbo->setQuery($q); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } // Set installed template the default one $q = $this->dbo->getQuery(true); $q->update('#__template_styles'); $q->set('home = 1'); $q->where('id = ' . (int) $this->request->getInt('styleId')); $this->dbo->setQuery($q); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } // Commit database change $this->dbo->transactionCommit(); // Clean up temporary data JInstallerHelper::cleanupInstall("{$tmpPath}/{$this->template['name']}_sampledata.zip", "{$tmpPath}/{$this->template['name']}_sampledata"); // Clean up assets table for extension that is not installed if (count($attentions)) { foreach ($attentions as $attention) { $this->_cleanExtensionAssets('com_' . $attention['id']); } } // Set final response $this->setResponse(array('attention' => $attentions)); } catch (Exception $e) { throw $e; } }
/** * Download product installation package from lightcart. * Return path to downloaded package when download successfull * * @param string $id Identified name of the product * @param string $edition Product edition to download * @param string $username Customer username * @param string $password Customer password * @param string $savePath Path to save downloaded package * * @return string */ public static function downloadPackage($id, $edition = null, $username = null, $password = null, $savePath = null) { $joomlaVersion = JSNTplHelper::getJoomlaVersion(2); // Send request to joomlashine server to checking customer information $query = array('controller=remoteconnectauthentication', 'task=authenticate', 'tmpl=component', 'identified_name=' . $id, 'joomla_version=' . $joomlaVersion, 'upgrade=yes', 'custom=1', 'language=' . JFactory::getLanguage()->getTag()); if (!empty($edition)) { $query[] = 'edition=' . $edition; } if (!empty($username) && !empty($password)) { $query[] = 'username='******'password='******'tmp_path') : $savePath; $downloadUrl = JSN_TPLFRAMEWORK_LIGHTCART_URL . '&' . implode('&', $query); $filePath = $tmpPath . '/jsn-' . $id . '.zip'; try { JSNTplHttpRequest::get($downloadUrl, $filePath, array('content-type' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream', 'application/x-compress', 'application/x-compressed', 'multipart/x-zip'))); } catch (Exception $e) { // Check if we have LightCart error code? if (strlen($e->getMessage() == 5 and preg_match('/^ERR[0-9]+$/', $e->getMessage()))) { throw new Exception(JText::_('JSN_TPLFW_LIGHTCART_ERROR_' . $e->getMessage())); } else { throw $e; } } return $filePath; }
/** * Download templates information data from JoomlaShine server * * @return object */ public static function getVersionData() { if (empty(self::$versionData)) { try { $response = JSNTplHttpRequest::get(JSN_TPLFRAMEWORK_VERSIONING_URL . '?category=cat_template'); } catch (Exception $e) { throw $e; } self::$versionData = json_decode($response['body'], true); } // Return result return self::$versionData; }
/** * Action to execute queries from sample data file * * @return void */ public function installDataAction() { // Disable execution timeout if (!JSNTplHelper::isDisabledFunction('set_time_limit')) { set_time_limit(0); } try { // Create a backup of Joomla database $this->_backupDatabase(); // Initialize variables if (!isset($this->temporary_path) || empty($this->temporary_path)) { $config = JFactory::getConfig(); $this->temporary_path = $config->get('tmp_path') . "/{$this->template['name']}_sampledata.zip"; $this->temporary_path = pathinfo($this->temporary_path, PATHINFO_DIRNAME) . '/' . pathinfo($this->temporary_path, PATHINFO_FILENAME); JPath::clean($this->temporary_path); } $xmlFiles = glob("{$this->temporary_path}/*.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)); $version = (string) $xml['version']; $joomla_ver = (string) $xml['joomla-version']; // Compare versions $templateVersion = JSNTplHelper::getTemplateVersion($this->template['name']); $joomlaVersion = new JVersion(); if (version_compare($templateVersion, $version, '<')) { throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_SAMPLE_DATA_OUT_OF_DATED', $templateVersion), 99); } if (!empty($joomla_ver) and version_compare($joomlaVersion->getShortVersion(), $joomla_ver, '<')) { throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_JOOMLA_OUT_OF_DATE', $joomlaVersion->getShortVersion()), 99); } $thirdComponents = array(); $thirdComponentErrors = array(); // Looping to each extension type=component to get information and dependencies foreach ($xml->xpath('//extension[@author="3rd_party"]') as $component) { if (isset($component['author']) && $component['author'] == '3rd_party') { $attrs = (array) $component->attributes(); $attrs = $attrs['@attributes']; $componentType = (string) $attrs['type']; $namePrefix = array('component' => 'com_', 'module' => 'mod_'); $componentName = isset($namePrefix[(string) $attrs['type']]) ? $namePrefix[$componentType] . $attrs['name'] : (string) $attrs['name']; $state = $this->_getExtensionState($componentName, (string) $attrs['version'], true, (string) $attrs['type']); $thirdComponents[] = array('id' => $attrs['name'], 'state' => $state, 'full_name' => (string) $attrs['full_name'], 'version' => (string) $attrs['version'], 'type' => $componentType); } } if (count($thirdComponents)) { foreach ($thirdComponents as $thirdComponent) { if ($thirdComponent['state'] == 'install') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NOT_INSTALLED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } elseif ($thirdComponent['state'] == 'update') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NEED_TO_INSTALLED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } elseif ($thirdComponent['state'] == 'unsupported') { $thirdComponentErrors[] = JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION_NOT_SUPPORTED', strtoupper($thirdComponent['full_name']) . ' ' . $thirdComponent['type'], $thirdComponent['version']); } else { //do nothing } } } if (count($thirdComponentErrors)) { $strThirdComponentError = '<ul>'; foreach ($thirdComponentErrors as $thirdComponentError) { $strThirdComponentError .= '<li>' . $thirdComponentError . '</li>'; } $strThirdComponentError .= '</ul>'; throw new Exception(JText::sprintf('JSN_TPLFW_ERROR_THIRD_EXTENSION', $strThirdComponentError), 99); } // Temporary backup data $this->_backupThirdPartyModules(); $this->_backupThirdPartyAdminModules(); $this->_backupThirdPartyMenus(); // Delete admin modules $this->_deleteThirdPartyAdminModules(); // Loop each extension to execute queries $attentions = array(); foreach ($xml->xpath('//extension') as $extension) { // Get sample data queries. $queries = $extension->xpath('task[@name="dbinstall"]/parameters/parameter'); // Verify extension. $canInstall = true; $extensionType = (string) $extension['type']; $namePrefix = array('component' => 'com_', 'module' => 'mod_'); $extensionName = isset($namePrefix[(string) $extension['type']]) ? $namePrefix[$extensionType] . $extension['name'] : (string) $extension['name']; if (isset($extension['author']) && $extension['author'] == 'joomlashine') { // Check if JoomlaShine extension is installed $canInstall = JSNTplHelper::isInstalledExtension($extensionName, $extensionType); if ($canInstall == false and $extensionType == 'component') { // Add to attention list when extension is not installed $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['description'], 'url' => (string) $extension['producturl']); } } elseif ($extension['type'] == 'component') { // Check if 3rd-party component is installed. $canInstall = JSNTplHelper::isInstalledExtension($extensionName); if (!$canInstall) { // Add to attention list. $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['title'], 'modules' => $extension->xpath('modules/module'), 'plugins' => $extension->xpath('plugins/plugin'), 'display' => count($queries) ? true : false); } else { // Verify version of the installed 3rd-party component. $state = $this->_getExtensionState($extensionName, (string) $extension['version'], true); if ('update' == $state) { // Add to attention list. $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['title'], 'modules' => $extension->xpath('modules/module'), 'plugins' => $extension->xpath('plugins/plugin'), 'message' => JText::sprintf('JSN_TPLFW_UPDATE_3RD_PARTY_EXTENSION_FIRST', $this->_getExtensionVersion($extensionName), (string) $extension['version']), 'display' => count($queries) ? true : false); $canInstall = false; } elseif ('unsupported' == $state) { // Add to attention list. $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['title'], 'modules' => $extension->xpath('modules/module'), 'plugins' => $extension->xpath('plugins/plugin'), 'message' => JText::sprintf('JSN_TPLFW_UNSUPPORTED_3RD_PARTY_EXTENSION_VERSION', $this->_getExtensionVersion($extensionName), (string) $extension['version']), 'display' => count($queries) ? true : false); $canInstall = false; } else { // Make sure all required modules are installed also. $missing = array(); foreach ($extension->xpath('modules/module') as $module) { if (!@is_dir(JPATH_ROOT . '/modules/' . (string) $module)) { if ((string) $module['title'] != '') { $missing[] = (string) $module['title']; } } } foreach ($extension->xpath('plugins/plugin') as $plugin) { if (!@is_dir(JPATH_ROOT . '/plugins/' . (string) $plugin['group'] . '/' . (string) $plugin)) { if ((string) $plugin['title'] != '') { $missing[] = (string) $plugin['title']; } } } if (count($missing)) { // Add to attention list. $attentions[] = array('id' => (string) $extension['name'], 'name' => (string) $extension['title'], 'modules' => $extension->xpath('modules/module'), 'plugins' => $extension->xpath('plugins/plugin'), 'missing' => $missing, 'message' => JText::_('JSN_TPLFW_MISSING_3RD_PARTY_EXTENSION_DEPENDENCIES'), 'display' => count($queries) ? true : false); $canInstall = false; } } } } if ($canInstall) { // Execute sample data queries foreach ($queries as $query) { // Find remote assets then download to local system if (preg_match_all('#(http://demo.joomlashine.com/[^\\s\\t\\r\\n]+/media/joomlashine/)[^\\s\\t\\r\\n]+\\.(js|css|bmp|gif|ico|jpg|png|svg|ttf|otf|eot|woff)#', $query, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $keepAsIs = false; if (!isset($this->mediaFolder)) { // Detect a writable folder to store demo assets foreach (array('media', 'cache', 'tmp') as $folder) { $folder = JPATH_ROOT . "/{$folder}"; if (is_dir($folder) and is_writable($folder) and JFolder::create("{$folder}/joomlashine")) { $this->mediaFolder = "{$folder}/joomlashine"; break; } } } if (isset($this->mediaFolder)) { // Generate path to store demo asset $mediaFile = str_replace($match[1], "{$this->mediaFolder}/", $match[0]); // Download demo asset only once if (!is_file($mediaFile)) { try { JSNTplHttpRequest::get($match[0], $mediaFile); } catch (Exception $e) { $keepAsIs = true; } } // Alter sample data query if (!$keepAsIs) { $query = str_replace($match[0], str_replace(JPATH_ROOT . '/', '', $mediaFile), $query); } } } } // Execute query $this->dbo->setQuery((string) $query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Update component ID for linked menu items. if ($extension['type'] == 'component') { // Get component ID. $query = $this->dbo->getQuery(true); $query->select('extension_id')->from('#__extensions')->where('type = ' . $query->quote('component'))->where('element = ' . $query->quote($extensionName)); $this->dbo->setQuery($query); $component_id = $this->dbo->loadResult(); // Update component ID for all menu items that link to this component. $query = $this->dbo->getQuery(true); $query->update('#__menu')->set('component_id = ' . $query->quote($component_id))->where('type = ' . $query->quote('component'))->where("link LIKE 'index.php?option={$extensionName}&%'"); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Copy images if has. if (isset($extension['images']) && @is_dir($this->temporary_path . '/' . (string) $extension['images'])) { // Backup existing folder. JFolder::move(JPATH_ROOT . '/' . (string) $extension['images'], JPATH_ROOT . '/' . (string) $extension['images'] . '-backup-at-' . date('y-m-d_H-i-s')); // Delete current folder. JFolder::delete(JPATH_ROOT . '/' . (string) $extension['images']); // Move sample images folder. JFolder::move($this->temporary_path . '/' . (string) $extension['images'], JPATH_ROOT . '/' . (string) $extension['images']); } // Download and install extended style if has. if (isset($extension['ext-style-package'])) { // Download extended style package. $template = JSNTplTemplateRecognization::detect($this->template['name']); $fileUrl = 'http://www.joomlashine.com/index.php?option=com_lightcart&controller=remoteconnectauthentication' . '&task=authenticate&tmpl=component&upgrade=yes&identified_name=ext_style&edition=' . '&joomla_version=' . JSNTplHelper::getJoomlaVersion(2) . '&file_attr=' . '{"identified_template_name":"tpl_' . strtolower($template->name) . '"' . ',"ext_style":"' . (string) $extension['ext-style-package'] . '"}'; // Download file to temporary folder. try { $response = JSNTplHttpRequest::get($fileUrl, $this->temporary_path . '/' . (string) $extension['ext-style-package'] . '_ext_style.zip'); } catch (Exception $e) { throw $e; } // Check download response headers. if ($response['header']['content-type'] != 'application/zip') { throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_CANNOT_LOCATED_FILE')); } // Install extended style. JArchive::extract($this->temporary_path . '/' . (string) $extension['ext-style-package'] . '_ext_style.zip', JPATH_ROOT . '/' . (string) $extension['ext-style-path']); // Fix for old extended style package of OS Property. if (false !== strpos((string) $extension['ext-style-path'], '/com_osproperty/')) { $template = 'jsn_' . strtolower($template->name); if (@file_exists(JPATH_ROOT . '/' . (string) $extension['ext-style-path'] . "/{$template}/template.xml")) { JFile::copy(JPATH_ROOT . '/' . (string) $extension['ext-style-path'] . "/{$template}/template.xml", JPATH_ROOT . '/' . (string) $extension['ext-style-path'] . "/{$template}/{$template}.xml"); } } } // Manipulate data for K2. if ('com_k2' == $extensionName) { // Update user mapping for K2 items table. $user = JFactory::getUser(); $query = $this->dbo->getQuery(true); $query->update('#__k2_items')->set('created_by = ' . $query->quote($user->id)); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } // Update user mapping for K2 users table. $query = $this->dbo->getQuery(true); $query->update('#__k2_users')->set('userID = ' . $query->quote($user->id)); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Manipulate data for OS Property. if ('com_osproperty' == $extensionName) { // Update user mapping for agents table. $user = JFactory::getUser(); $query = $this->dbo->getQuery(true); $query->update('#__osrs_agents')->set('user_id = ' . $query->quote($user->id)); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Unpublish menu item replacement published before. if (isset($extension['menu-replacement'])) { $items = array_map('intval', explode(',', (string) $extension['menu-replacement'])); $query = $this->dbo->getQuery(true); $query->update('#__menu')->set('published = 0')->where('id IN (' . implode(', ', $items) . ')')->where('published = 1'); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Unpublish module replacement published before. if (isset($extension['module-replacement'])) { $items = array_map('intval', explode(',', (string) $extension['module-replacement'])); $query = $this->dbo->getQuery(true); $query->update('#__modules')->set('published = 0')->where('id IN (' . implode(', ', $items) . ')')->where('published = 1'); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } } else { // Check if sample data contains menu item replacement for use when extension is missing. if (isset($extension['menu-replacement'])) { if (isset($menu_replacement)) { $menu_replacement = array_merge($menu_replacement, array_map('intval', explode(',', (string) $extension['menu-replacement']))); } else { $menu_replacement = array_map('intval', explode(',', (string) $extension['menu-replacement'])); } } // Check if sample data contains module replacement for use when extension is missing. if (isset($extension['module-replacement'])) { if (isset($module_replacement)) { $module_replacement = array_merge($module_replacement, array_map('intval', explode(',', (string) $extension['module-replacement']))); } else { $module_replacement = array_map('intval', explode(',', (string) $extension['module-replacement'])); } } } } // Disable default template $query = $this->dbo->getQuery(true); $query->update('#__template_styles'); $query->set('home = 0'); $query->where('client_id = 0'); $query->where('home = 1'); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } // Set installed template the default one $query = $this->dbo->getQuery(true); $query->update('#__template_styles'); $query->set('home = 1'); $query->where('id = ' . (int) $this->request->getInt('styleId')); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } // Publish menu item replacement. if (isset($menu_replacement)) { $query = $this->dbo->getQuery(true); $query->update('#__menu')->set('published = 1')->where('id IN (' . implode(', ', $menu_replacement) . ')'); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } // Publish module replacement. if (isset($module_replacement)) { $query = $this->dbo->getQuery(true); $query->update('#__modules')->set('published = 1')->where('id IN (' . implode(', ', $module_replacement) . ')'); $this->dbo->setQuery($query); if (!$this->dbo->{$this->queryMethod}()) { throw new Exception($this->dbo->getErrorMsg()); } } } catch (Exception $e) { $error = $e; } // Restore backed up data $this->_restoreThirdPartyData(); $this->_rebuildMenus(); // Clean up temporary data JInstallerHelper::cleanupInstall("{$this->temporary_path}.zip", $this->temporary_path); // Clean up junk data for extension that is not installed if (count($attentions)) { foreach ($attentions as $i => $attention) { // Clean up junk data imported during sample data installation. $this->_cleanJunkData('com_' . $attention['id'], isset($attention['modules']) ? $attention['modules'] : null, isset($attention['plugins']) ? $attention['plugins'] : null); // Make sure extension has name defined. if (!isset($attention['name']) || empty($attention['name'])) { unset($attentions[$i]); } elseif (isset($attention['display']) && !$attention['display']) { unset($attentions[$i]); } else { // Remove data that are not necessary any more. if (isset($attention['modules'])) { unset($attentions[$i]['modules']); } if (isset($attention['plugins'])) { unset($attentions[$i]['plugins']); } } } } // Check if there is any error catched? if (isset($error)) { throw $error; } // Set final response $this->setResponse(array('attention' => array_values($attentions))); }
$editionClass = 'jsn-free-edition'; } else { $editionClass = 'jsn-pro-edition'; } // Get next template edition $nextEdition = str_replace('PRO ', '', $this->templateEdition->getNextEdition()); // Get installed template version $version = JSNTplHelper::getTemplateVersion($this->data->template); // Get list of JoomlaShine template for cross promotion $promotion = $nextEdition == 'STANDARD' ? true : false; if ($promotion) { $config = JFactory::getConfig(); $cache = $config->get('tmp_path') . '/jsn_templates.json'; if (!@is_file($cache) || !@is_readable($cache) || time() - filemtime($cache) > 86400) { try { $jsn_templates = JSNTplHttpRequest::get('http://demo.joomlashine.com/products-intro/assets/json/showlist-templates-' . ($nextEdition == 'STANDARD' ? 'free' : 'pro') . '.json', $cache); $jsn_templates = $jsn_templates['body']; } catch (Exception $e) { // Disable cross promotion $promotion = false; } } else { $jsn_templates = JFile::read($cache); } if ($jsn_templates = json_decode($jsn_templates)) { $jsn_templates = $jsn_templates->showlist->images->image; } else { $promotion = false; } } $jversion = new JVersion();