/** * Attach css, js and create toolbar for Info view * * @param midxed $params */ private function _makeViewInfo($params = null) { // add our own css JHtml::styleSheet('list.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/'); // decide on help file language $languageCode = Sh404sefHelperLanguage::getFamily(); $basePath = JPATH_ROOT . '/administrator/components/com_sh404sef/language/%s.readme.php'; // fall back to english if language readme does not exist jimport('joomla.filesystem.file'); if (!JFile::exists(sprintf($basePath, $languageCode))) { $languageCode = 'en'; } $this->assign('readmeFilename', sprintf($basePath, $languageCode)); // add title $title = Sh404sefHelperGeneral::makeToolbarTitle(JText::_('COM_SH404SEF_TITLE_SUPPORT'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title'); JFactory::getApplication()->set('JComponentTitle', $title); }
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); }
/** * Attach css, js and create toolbar for Info view * * @param midxed $params */ private function _makeViewInfo($params = null) { // add our own css JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/list.css'); // decide on help file language $languageCode = Sh404sefHelperLanguage::getFamily(); $basePath = JPATH_ROOT . '/administrator/components/com_sh404sef/language/%s.readme.php'; // fall back to english if language readme does not exist jimport('joomla.filesystem.file'); if (!JFile::exists(sprintf($basePath, $languageCode))) { $languageCode = 'en'; } $this->assign('readmeFilename', sprintf($basePath, $languageCode)); if (version_compare(JVERSION, '3.0', 'ge')) { // render submenu sidebar $this->sidebar = JHtmlSidebar::render(); // add modal css and js ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument()); ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument()); JToolbarHelper::title(JText::_('COM_SH404SEF_TITLE_SUPPORT'), 'sh404sef-toolbar-title'); } else { // add title $title = Sh404sefHelperGeneral::makeToolbarTitle(JText::_('COM_SH404SEF_TITLE_SUPPORT'), $icon = 'sh404sef', $class = 'sh404sef-toolbar-title'); JFactory::getApplication()->JComponentTitle = $title; } }
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 . DS . 'components' . DS . 'com_sh404sef' . DS . 'config' . DS . 'config.sef.php')) { JFile::delete(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'config' . DS . 'config.sef.php'); } JFile::copy($oldConfigFile, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'config' . DS . '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 . DS . 'components' . DS . 'com_sh404sef' . DS . 'security' . DS . $file)) { JFile::delete(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'security' . DS . $file); } JFile::copy($this->_preserveConfigFolder . 'sh404_upgrade_conf_security' . DS . $file, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'security' . DS . $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)) { $fileList = JFolder::files($folder); if (!empty($fileList)) { foreach ($fileList as $file) { JFile::copy($this->_preserveConfigFolder . 'sh404_upgrade_conf_logs' . DS . $file, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'logs' . DS . $file); } } } // 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 . DS . 'components' . DS . 'com_sh404sef' . DS . 'custom.sef.php')) { JFile::delete(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'custom.sef.php'); } $result = JFile::copy($oldCustomConfigFile, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'custom.sef.php'); } } $sef_config_class = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.class.php'; // setup autoloader, so that base classes work // get Joomla autloader out spl_autoload_unregister("__autoload"); // add our own include JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'helpers' . DS . 'autoloader.php'; $registered = spl_autoload_register(array('Sh404sefAutoloader', 'doAutoload')); // stitch back Joomla's at the end of the list if (function_exists("__autoload")) { spl_autoload_register("__autoload"); } // Make sure class was loaded. if (!class_exists('shSEFConfig')) { if (is_readable($sef_config_class)) { include JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'shSEFConfig.class.php'; require_once $sef_config_class; } else { JError::RaiseError(500, JText::_('COM_SH404SEF_NOREAD') . "( {$sef_config_class} )<br />" . JText::_('COM_SH404SEF_CHK_PERMS')); } } $sefConfig = new shSEFConfig(); // install module $installer = $parent->getParent(); $source = $installer->getPath('source'); $extensionConfig = array('enabled' => 1, 'access' => 3); $moduleConfig = array(); $status = $this->_shInstallModule('mod_sh404sef_cpicon', $source, $extensionConfig, $moduleConfig); // custom language switcher module disabled for now, not needed //$extensionConfig = array(); //$moduleConfig = array(); //$status = $this->_shInstallModule( 'mod_sh_languages', $source, $extensionConfig, $moduleConfig); // install plugins $status = $this->_shInstallPluginGroup('system'); $status = $this->_shInstallPluginGroup('sh404sefcore'); $status = $this->_shInstallPluginGroup('sh404sefextplugins'); // 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 . DS . 'administrator' . DS . 'components' . DS . 'com_sh404sef' . DS . 'language' . DS . '%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); }