Esempio n. 1
0
	public function onInstallerViewAfterLastTab()
	{
		if ($this->params->get('tab_position', 0)) {
			$this->getChanges();
		}
		$ishathor = $this->isHathor() ? 1 : 0;
		$installfrom = $this->getInstallFrom();
		$installfromon = $installfrom ? 1 : 0;

		$document = JFactory::getDocument();
		$ver = new JVersion;
		$min = JFactory::getConfig()->get('debug') ? '' : '.min';

		$installer = new JInstaller();
		$manifest = $installer->isManifest(JPATH_PLUGINS . DIRECTORY_SEPARATOR . 'installer' . DIRECTORY_SEPARATOR . 'webinstaller' . DIRECTORY_SEPARATOR . 'webinstaller.xml');

		$apps_base_url = addslashes($this->appsBaseUrl);
		$apps_installat_url = base64_encode(JURI::current(true) . '?option=com_installer&view=install');
		$apps_installfrom_url = addslashes($installfrom);
		$apps_product = base64_encode($ver->PRODUCT);
		$apps_release = base64_encode($ver->RELEASE);
		$apps_dev_level = base64_encode($ver->DEV_LEVEL);
		$btntxt = JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL', true);
		$pv = base64_encode($manifest->version);
		$updatestr1 = JText::_('COM_INSTALLER_WEBINSTALLER_INSTALL_UPDATE_AVAILABLE', true);
		$obsoletestr = JText::_('COM_INSTALLER_WEBINSTALLER_INSTALL_OBSOLETE', true);
		$updatestr2 = JText::_('JLIB_INSTALLER_UPDATE', true);

		$javascript = <<<END
apps_base_url = '$apps_base_url';
apps_installat_url = '$apps_installat_url';
apps_installfrom_url = '$apps_installfrom_url';
apps_product = '$apps_product';
apps_release = '$apps_release';
apps_dev_level = '$apps_dev_level';
apps_is_hathor = $ishathor;
apps_installfromon = $installfromon;
apps_btntxt = '$btntxt';
apps_pv = '$pv';
apps_updateavail1 = '$updatestr1';
apps_updateavail2 = '$updatestr2';
apps_obsolete = '$obsoletestr';

jQuery(document).ready(function() {
	if (apps_installfromon)
	{
		jQuery('#myTabTabs a[href="#web"]').click();
	}
	var link = jQuery('#myTabTabs a[href="#web"]').get(0);
	var eventpoint = jQuery(link).closest('li');
	if (apps_is_hathor)
	{
		jQuery('#mywebinstaller').show();
		link = jQuery('#mywebinstaller a');
		eventpoint = link;
	}

	jQuery(eventpoint).click(function (event){
		if (!Joomla.apps.loaded) {
			Joomla.apps.initialize();
		}
	});
	
	if (apps_installfrom_url != '') {
		var tag = 'li';
		if (apps_is_hathor)
		{
			tag = 'a';
		}
		jQuery(link).closest(tag).click();
	}

	if (!apps_is_hathor)
	{
		if(typeof jQuery('#myTabTabs a[href="'+localStorage.getItem('tab-href')+'"]').prop('tagName') == 'undefined' ||
			localStorage.getItem('tab-href') == null ||
			localStorage.getItem('tab-href') == 'undefined' ||
			!localStorage.getItem('tab-href')) {
			window.localStorage.setItem('tab-href', jQuery('#myTabTabs a').get(0).href.replace(/^.+?#/, '#'));
		}
	
		if (apps_installfrom_url == '' && localStorage.getItem('tab-href') == '#web')
		{
			jQuery('#myTabTabs li').each(function(index, value){
				value.removeClass('active');
			});
			jQuery(eventpoint).addClass('active');
			window.localStorage.setItem('tab-href', jQuery(eventpoint).children('a').attr('href'));
			if (jQuery(eventpoint).children('a').attr('href') == '#web')
			{
				jQuery(eventpoint).click();
			}
		}
	}
});

		
END;

		$document->addScriptDeclaration($javascript);
		$document->addScript(JURI::root() . 'plugins/installer/webinstaller/js/client' . $min . '.js?jversion=' . JVERSION);
		$document->addStyleSheet(JURI::root() . 'plugins/installer/webinstaller/css/client' . $min . '.css?jversion=' . JVERSION);
	}
Esempio n. 2
0
 /**
  * Rebuild update sites tables.
  *
  * @return  void
  *
  * @since   3.6
  *
  * @throws  Exception on ACL error
  */
 public function rebuild()
 {
     if (!JFactory::getUser()->authorise('core.admin', 'com_installer')) {
         throw new Exception(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_NOT_PERMITTED'), 403);
     }
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     // Check if Joomla Extension plugin is enabled.
     if (!JPluginHelper::isEnabled('extension', 'joomla')) {
         $query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))->where($db->quoteName('element') . ' = ' . $db->quote('joomla'))->where($db->quoteName('folder') . ' = ' . $db->quote('extension'));
         $db->setQuery($query);
         $pluginId = (int) $db->loadResult();
         $link = JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $pluginId);
         $app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_REBUILD_EXTENSION_PLUGIN_NOT_ENABLED', $link), 'error');
         return;
     }
     $clients = array(JPATH_SITE, JPATH_ADMINISTRATOR);
     $extensionGroupFolders = array('components', 'modules', 'plugins', 'templates', 'language', 'manifests');
     $pathsToSearch = array();
     // Identifies which folders to search for manifest files.
     foreach ($clients as $clientPath) {
         foreach ($extensionGroupFolders as $extensionGroupFolderName) {
             // Components, modules, plugins, templates, languages and manifest (files, libraries, etc)
             if ($extensionGroupFolderName != 'plugins') {
                 foreach (glob($clientPath . '/' . $extensionGroupFolderName . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath) {
                     array_push($pathsToSearch, $extensionFolderPath);
                 }
             } else {
                 foreach (glob($clientPath . '/' . $extensionGroupFolderName . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $pluginGroupFolderPath) {
                     foreach (glob($pluginGroupFolderPath . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath) {
                         array_push($pathsToSearch, $extensionFolderPath);
                     }
                 }
             }
         }
     }
     // Gets Joomla core update sites Ids.
     $joomlaUpdateSitesIds = implode(', ', $this->getJoomlaUpdateSitesIds(0));
     // Delete from all tables (except joomla core update sites).
     $query = $db->getQuery(true)->delete($db->quoteName('#__update_sites'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
     $db->setQuery($query);
     $db->execute();
     $query = $db->getQuery(true)->delete($db->quoteName('#__update_sites_extensions'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
     $db->setQuery($query);
     $db->execute();
     $query = $db->getQuery(true)->delete($db->quoteName('#__updates'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
     $db->setQuery($query);
     $db->execute();
     $count = 0;
     // Gets Joomla core extension Ids.
     $joomlaCoreExtensionIds = implode(', ', $this->getJoomlaUpdateSitesIds(1));
     // Search for updateservers in manifest files inside the folders to search.
     foreach ($pathsToSearch as $extensionFolderPath) {
         $tmpInstaller = new JInstaller();
         $tmpInstaller->setPath('source', $extensionFolderPath);
         // Main folder manifests (higher priority)
         $parentXmlfiles = JFolder::files($tmpInstaller->getPath('source'), '.xml$', false, true);
         // Search for children manifests (lower priority)
         $allXmlFiles = JFolder::files($tmpInstaller->getPath('source'), '.xml$', 1, true);
         // Create an unique array of files ordered by priority
         $xmlfiles = array_unique(array_merge($parentXmlfiles, $allXmlFiles));
         if (!empty($xmlfiles)) {
             foreach ($xmlfiles as $file) {
                 // Is it a valid Joomla installation manifest file?
                 $manifest = $tmpInstaller->isManifest($file);
                 if (!is_null($manifest)) {
                     // Search if the extension exists in the extensions table. Excluding joomla core extensions (id < 10000) and discovered extensions.
                     $query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('name') . ' = ' . $db->quote($manifest->name))->where($db->quoteName('type') . ' = ' . $db->quote($manifest['type']))->where($db->quoteName('extension_id') . ' NOT IN (' . $joomlaCoreExtensionIds . ')')->where($db->quoteName('state') . ' != -1');
                     $db->setQuery($query);
                     $eid = (int) $db->loadResult();
                     if ($eid && $manifest->updateservers) {
                         // Set the manifest object and path
                         $tmpInstaller->manifest = $manifest;
                         $tmpInstaller->setPath('manifest', $file);
                         // Load the extension plugin (if not loaded yet).
                         JPluginHelper::importPlugin('extension', 'joomla');
                         // Fire the onExtensionAfterUpdate
                         JFactory::getApplication()->triggerEvent('onExtensionAfterUpdate', array('installer' => $tmpInstaller, 'eid' => $eid));
                         $count++;
                     }
                 }
             }
         }
     }
     if ($count > 0) {
         $app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_SUCCESS'), 'message');
     } else {
         $app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_MESSAGE'), 'message');
     }
 }
Esempio n. 3
0
 function getComponentManifestFile($com)
 {
     $short_element = str_replace('com_', '', $com);
     $manifestPath = JPATH_ADMINISTRATOR . '/components/' . $com . '/' . 'manifest.xml';
     $shortElementManifestPath = JPATH_ADMINISTRATOR . '/components/' . $com . '/' . $short_element . '.xml';
     if (JFile::exists($manifestPath)) {
         $file = $manifestPath;
     }
     if (JFile::exists($shortElementManifestPath)) {
         $file = $shortElementManifestPath;
     }
     if (empty($file)) {
         return false;
     }
     $installer = new JInstaller();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         $manifest = $installer->isManifest($file);
     } else {
         // Joomla! 1.5 code here
         $manifest = $installer->_isManifest($file);
     }
     return $manifest;
 }
 /**
  * Tests the isManifest method
  *
  * @since   3.1
  *
  * @return  void
  */
 public function testIsManifest()
 {
     $this->assertThat($this->object->isManifest(__DIR__ . '/data/pkg_joomla.xml'), $this->isInstanceOf('SimpleXmlElement'), 'Ensure JInstaller::isManifest properly tests a valid manifest file');
 }
Esempio n. 5
0
 function install()
 {
     $extDir = JPATH_ROOT . '/components/com_sef/sef_ext';
     $db = $this->parent->getDBO();
     $this->manifest =& $this->parent->getManifest();
     $xml = $this->manifest;
     $name = (string) $xml->name;
     $name = JFilterInput::getInstance()->clean($name, 'string');
     $this->set('name', $name);
     $description = (string) $xml->description;
     if (is_a($description, 'JSimpleXMLElement')) {
         $this->parent->set('message', JText::_($description));
     } else {
         $this->parent->set('message', '');
     }
     if (count($xml->files->children())) {
         foreach ($xml->files->children() as $file) {
             if ((string) $file->attributes()->sef_ext) {
                 $element = (string) $file->attributes()->sef_ext;
                 if (substr($element, 0, 13) != 'ext_joomsef4_') {
                     $element = 'ext_joomsef4_' . $element;
                 }
                 $this->set('element', $element);
                 break;
             }
         }
     }
     if (!empty($element)) {
         $this->parent->setPath('extension_root', $extDir);
     } else {
         $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEFEXT_INSTALL_NO_FILE', JText::_('JLIB_INSTALLER_' . $this->route)));
         return false;
     }
     $this->route = 'install';
     $query = "SELECT extension_id, state, params \n";
     $query .= "FROM #__extensions \n";
     $query .= "WHERE type=" . $db->quote('sef_ext') . " \n";
     $query .= "AND element=" . $db->quote($element);
     $db->setQuery($query);
     $ext_o = $db->loadObject();
     if (!is_null($ext_o)) {
         $id = $ext_o->extension_id;
     } else {
         $id = null;
     }
     if (file_exists($this->parent->getPath('extension_root')) && (!$this->parent->isOverwrite() || $this->parent->isUpgrade())) {
         if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update') || is_a($xml->update, 'SimpleXMLElement'))) {
             $this->parent->setOverwrite(true);
             $this->parent->setUpgrade(true);
             if ($id && $ext_o->state != -2) {
                 $this->route = 'update';
             }
         } else {
             if (!$this->parent->isOverwrite()) {
                 $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEFEXT_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route), $this->parent->getPath('extension_root')));
             }
         }
     }
     if ((string) $xml->scriptfile) {
         $script = (string) $xml->scriptfile;
         $script_file = $this->parent->getPath('source') . '/' . $script;
         if (is_file($script_file)) {
             include_once $script_file;
             $class = $element . 'InstallerScript';
             if (class_exists($class)) {
                 $this->parent->manifestClass = new $class($this);
                 $this->set('manifest_script', $script);
             }
         }
     }
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
         if ($this->parent->manifestClass->preflight($this->route, $this) === false) {
             $this->parent->abort(JText::_('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_CUSTOM_INSTALL_FAILURE'));
             return false;
         }
     }
     $msg = ob_get_contents();
     ob_end_clean();
     if (!file_exists($this->parent->getPath('extension_root'))) {
         if (JFolder::create($this->parent->getPath('extension_root'))) {
             $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_CREATE_DIRECTORY', $this->parent->getPath('extension_root')));
             return false;
         }
     }
     $this->old_files = null;
     if ($this->route == 'update') {
         $old = null;
         $tmp = new JInstaller();
         $option = str_replace('ext_joomsef4_', 'com_', $this->get('element'));
         $tmp_manifest = $tmp->isManifest($this->parent->getPath('extension_root') . '/' . $option . '.xml');
         if ($tmp_manifest) {
             $this->old_files = $tmp_manifest->files;
         }
     }
     if (!$this->parent->parseFiles($xml->files, -1, $this->old_files)) {
         $this->parent->abort();
         return false;
     }
     if ($this->get('manifest_script')) {
         $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script');
         $path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script');
         if (!file_exists($path['desc'])) {
             if (!$this->parent->copyFiles(array($path))) {
                 $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_MANIFEST', JText::_('JLIB_INSTALLER_' . $this->route)));
                 return false;
             }
         }
     }
     JTable::addIncludePath(JPATH_LIBRARIES . '/joomla/database/table');
     $row = JTable::getInstance('extension');
     if ($id && $ext_o->state != -2) {
         $row->load($id);
         $row->name = $this->get('name');
         $row->manifest_cache = $this->parent->generateManifestCache();
         $row->store();
     } else {
         if (is_object($ext_o) && $ext_o->state == -2) {
             $row->extension_id = $id;
         }
         $row->name = $this->get('name');
         $row->type = 'sef_ext';
         $row->element = $element;
         $row->enabled = 1;
         $row->protected = 0;
         $row->access = 1;
         $row->client_id = 0;
         $row->state = 0;
         if (!is_object($ext_o) || $ext_o->state != -2) {
             if (isset($this->manifest->install->defaultParams)) {
                 $row->params = SEFTools::getDefaultParams($this->manifest->install->defaultParams);
             }
             if (isset($this->manifest->install->defaultFilters)) {
                 $row->custom_data = SEFTools::getDefaultFilters($this->manifest->install->defaultFilters);
             }
         }
         $row->system_data = '';
         $row->manifest_cache = $this->parent->generateManifestCache();
         if (!$row->store()) {
             $this->parent->abort(Jtext::sprintf('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true)));
             return false;
         }
         $this->parent->pushStep(array('type' => 'extension', 'id' => $row->extension_id));
         $id = $row->extension_id;
     }
     if ($this->route == 'install') {
         $utfresult = $this->parent->parseSQLFiles($this->manifest->install->sql);
         if ($utfresult === false) {
             // Install failed, rollback changes
             $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true)));
             return false;
         }
         if ($this->manifest->update) {
             $this->parent->setSchemaVersion($this->manifest->update->schemas, $row->extension_id);
         } else {
             $query = "SELECT COUNT(*) FROM #__schemas \n";
             $query .= "WHERE extension_id=" . $row->extension_id;
             $db->setQuery($query);
             $cnt = $db->loadResult();
             if ($cnt == 0) {
                 $query = "INSERT INTO #__schemas \n";
                 $query .= "SET extension_id=" . $row->extension_id . ", version_id=" . $db->quote((string) $xml->version);
             } else {
                 $query = "UPDATE #__schemas \n";
                 $query .= "SET version_id=" . $db->quote((string) $xml->version) . " \n";
                 $query .= "WHERE extension_id=" . $row->extension_id . " \n";
             }
             $db->setQuery($query);
             $db->query();
         }
     } else {
         if ($this->manifest->update) {
             if (isset($this->manifest->update->schemas)) {
                 $result = $this->parent->parseSchemaUpdates($this->manifest->update->schemas, $row->extension_id);
                 if ($result === false) {
                     $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEF_UPDATE_SQL_ERROR', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true)));
                     return false;
                 }
             }
         } else {
             $query = "SELECT COUNT(*) FROM #__schemas \n";
             $query .= "WHERE extension_id=" . $row->extension_id;
             $db->setQuery($query);
             $cnt = $db->loadResult();
             if ($cnt == 0) {
                 $query = "INSERT INTO #__schemas \n";
                 $query .= "SET extension_id=" . $row->extension_id . ", version_id=" . $db->quote((string) $xml->version);
             } else {
                 $query = "UPDATE #__schemas \n";
                 $query .= "SET version_id=" . $db->quote((string) $xml->version) . " \n";
                 $query .= "WHERE extension_id=" . $row->extension_id . " \n";
             }
             $db->setQuery($query);
             $db->query();
         }
     }
     // Remove any pending updates in Joomla update cache
     $update = JTable::getInstance('update');
     $uid = $update->find(array('element' => $element, 'type' => 'sef_ext', 'client_id' => '', 'folder' => ''));
     if ($uid) {
         $update->delete($uid);
     }
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, $this->route)) {
         if ($this->parent->manifestClass->{$this->route}($this) === false) {
             $this->parent->abort(JText::_('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_CUSTOM_INSTALL_FAILURE'));
             return false;
         }
     }
     $msg .= ob_get_contents();
     ob_end_clean();
     if (!$this->parent->copyManifest(-1)) {
         $this->parent->abort(JText::sprintf('COM_SEF_INSTALLER_ABORT_SEF_INSTALL_COPY_SETUP', JText::_('JLIB_INSTALLER_' . $this->route)));
         return false;
     }
     ob_start();
     ob_implicit_flush(false);
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'postflight')) {
         $this->parent->manifestClass->postflight($this->route, $this);
     }
     $msg .= ob_get_contents();
     ob_end_clean();
     if ($msg != '') {
         $this->parent->set('extension_message', $msg);
     }
     // Remove already created URLs for this extension from database
     // 25.4.2012: Only remove automatic URLs that are not locked!
     $component = str_replace('ext_joomsef4_', 'com_', $element);
     $query = "DELETE FROM `#__sefurls` WHERE (`origurl` LIKE '%option={$component}&%' OR `origurl` LIKE '%option={$component}') AND `dateadd` = '0000-00-00' AND `locked` = 0";
     $db->setQuery($query);
     if (!$db->query()) {
         $this->parent->abort(JText::_('COM_SEF_SEF_EXTENSION') . ' ' . JText::_('COM_SEF_INSTALL') . ': ' . JText::_('COM_SEF_ERROR_SQL') . " " . $db->stderr(true));
         return false;
     }
     return $id;
 }