private function _doInstallUpdate($parent) { $this->_definePaths(); $this->_includeLibs(); // V 1.2.4.q Copy existing config file from /media to current component. Used to recover configuration when upgrading // V 1.2.4.s check if old file exists before deleting stub config file $oldConfigFile = $this->_preserveConfigFolder . 'sh404_upgrade_conf_' . $this->_siteId . '.php'; if (JFile::exists($oldConfigFile)) { // update old config files from VALID_MOS check to _JEXEC $config = JFile::read($oldConfigFile); if ($config && strpos($config, 'VALID_MOS') !== false) { $config = str_replace('VALID_MOS', '_JEXEC', $config); JFile::write($oldConfigFile, $config); // write it back } // now get back old config if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/config/config.sef.php')) { JFile::delete(JPATH_ADMINISTRATOR . '/components/com_sh404sef/config/config.sef.php'); } JFile::copy($oldConfigFile, JPATH_ADMINISTRATOR . '/components/com_sh404sef/config/config.sef.php'); } // restore black/white lists $folder = $this->_preserveConfigFolder . 'sh404_upgrade_conf_security'; if (JFolder::exists($folder)) { $fileList = JFolder::files($folder); if (!empty($fileList)) { foreach ($fileList as $file) { if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/security/' . $file)) { JFile::delete(JPATH_ADMINISTRATOR . '/components/com_sh404sef/security/' . $file); } JFile::copy($this->_preserveConfigFolder . 'sh404_upgrade_conf_security/' . $file, JPATH_ADMINISTRATOR . '/components/com_sh404sef/security/' . $file); } } } // if upgrading rather than installing from scratch, or after an uninstall // we must not copy back saved configuration files and log files // as this would overwrite up to date current ones // note that above we restored main config file and // security data files becomes blank files come // with the extension, so they'll be deleted in any case // and we have to restore them $shouldRestore = $this->_shShouldRestore(); if ($shouldRestore) { // restore log files $folder = $this->_preserveConfigFolder . 'sh404_upgrade_conf_logs'; if (JFolder::exists($folder)) { JFolder::copy($folder, JPATH_ROOT . '/logs/sh404sef', $path = '', $force = true); } // restore customized default params $oldCustomConfigFile = $this->_preserveConfigFolder . 'sh404_upgrade_conf_' . $this->_siteId . '.custom.php'; if (is_readable($oldCustomConfigFile) && filesize($oldCustomConfigFile) > 1000) { // update old config files from VALID_MOS check to _JEXEC $config = JFile::read($oldCustomConfigFile); if ($config && strpos($config, 'VALID_MOS') !== false) { $config = str_replace('VALID_MOS', '_JEXEC', $config); JFile::write($oldCustomConfigFile, $config); // write it back } if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/custom.sef.php')) { JFile::delete(JPATH_ADMINISTRATOR . '/components/com_sh404sef/custom.sef.php'); } $result = JFile::copy($oldCustomConfigFile, JPATH_ADMINISTRATOR . '/components/com_sh404sef/custom.sef.php'); } } // install plugins if (defined('SHLIB_ROOT_PATH')) { // trick of the day: we must fetch an instance of the db using the db helper // before installing the newest version of shLib system plugin. This will // force a decorated db instance to be created and stored, using the shlib // db class version that matches that of the shlib db helper class // As there was interface changes betwen shLib 0.1.x and 0.2.x, this prevents // "method not existing" errors when installing a newer version over an old one // make sure resource manager is available, we'll need it during plugins installs $db = ShlDbHelper::getInstance(); $status = $this->_shInstallPluginGroup('system'); } else { $this->_shInstallPluginGroup('system'); // shLib is not installed yet, let's make it available to us if (!JFile::exists(JPATH_ROOT . '/plugins/system/shlib/shlib.php')) { JFactory::getApplication()->enqueuemessage('shLib was not installed properly, cannot continue. Please try uninstalling and installing again'); return false; } require_once JPATH_ROOT . '/plugins/system/shlib/shlib.php'; $config = array('type' => 'system', 'name' => 'shlib', 'params' => ''); $shLibPlugin = new plgSystemShlib(JDispatcher::getInstance(), $config); $shLibPlugin->onAfterInitialise(); $status = true; } if (!$status) { JFactory::getApplication()->enqueuemessage('There was an error installing one or more system plugins. Please try uninstalling and installing again'); return; } $status = $this->_shInstallPluginGroup('sh404sefcore'); if (!$status) { JFactory::getApplication()->enqueuemessage('There was an error installing one or more sh404SEF core plugins. Please try uninstalling and installing again'); return; } $status = $this->_shInstallPluginGroup('sh404sefextplugins'); if (!$status) { JFactory::getApplication()->enqueuemessage('There was an error installing one or more sh404SEF extension plugins. Please try uninstalling and installing again'); return; } // install module $installer = $parent->getParent(); $source = $installer->getPath('source'); $extensionConfig = array('enabled' => 1, 'access' => 3); $moduleConfig = version_compare(JVERSION, '3.0', 'ge') ? array('position' => 'status', 'published' => 1) : array(); $status = $this->_shInstallModule('mod_sh404sef_cpicon', $source, $extensionConfig, $moduleConfig); // now we insert the 404 error page into the database // from version 1.5.5, the default content of 404 page has been largely modified // to make use of the similar urls plugin (and potentially others) // so we want to make sure people will have the new version of the 404 error page $this->_shUpdateErrorPage(); // apply various DB updates $this->_shUpdateDBStructure(); // message // decide on help file language $languageCode = Sh404sefHelperLanguage::getFamily(); $basePath = JPATH_ROOT . '/administrator/components/com_sh404sef/language/%s.postinstall.php'; // fall back to english if language readme does not exist jimport('joomla.filesystem.file'); if (!JFile::exists(sprintf($basePath, $languageCode))) { $languageCode = 'en'; } include sprintf($basePath, $languageCode); }