Esempio n. 1
0
 function onAfterInitialise()
 {
     $mainframe =& JFactory::getApplication();
     // register our autoloader
     $this->_registerAutoloader();
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.class.php';
     // for now we declare sefConfig as global, as this would break
     //too many 3rd party plugins if otherwise
     // TODO : update doc so that new plugins use new method to get config
     global $sefConfig;
     $sefConfig =& shRouter::shGetConfig();
     if (!$mainframe->isAdmin() && $sefConfig->shSecEnableSecurity) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shSec.php';
         // do security checks
         shDoSecurityChecks();
         shCleanUpSecLogFiles();
         // see setting in class file for clean up frequency
     }
     if (!$sefConfig->Enabled) {
         // go away if not enabled
         return;
     }
     DEFINE('SH404SEF_IS_RUNNING', 1);
     if (!$mainframe->isAdmin()) {
         // setup our JPagination replacement, so as to bring
         // back # of items per page in the url, in order
         // to properly calculate pagination
         // will only work if php > 5, so test for that
         if (version_compare(phpversion(), '5.0') >= 0) {
             // this register the old file, but do not load it if PHP5
             // will prevent further calls to the same jimport()
             // to actually do anything, because the 'joomla.html.pagination' key
             // is now registered statically in Jloader::import()
             jimport('joomla.html.pagination');
             // now we can register our own path
             JLoader::register('JPagination', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'pagination.php');
         }
         // include more sh404SEF stuff
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shCache.php';
         // override router class with our :
         $previousRouter =& $mainframe->getRouter();
         // create an instance of our class
         $shRouter = new shRouter();
         // store the previous router
         $shRouter->jRouter = clone $previousRouter;
         // make sure the cloned Joomla router is activated
         $shRouter->jRouter->setMode(JROUTER_MODE_SEF);
         // then override
         $previousRouter = $shRouter;
         // load plugins, as per configuration
         $this->_loadPlugins($type = 'sh404sefcore');
         // start decoding URL + decide possible redirects
         include JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shInit.php';
     }
 }
Esempio n. 2
0
 function onAfterInitialise()
 {
     $mainframe =& JFactory::getApplication();
     // register our autoloader
     $this->_registerAutoloader();
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.class.php';
     // for now we declare sefConfig as global, as this would break
     //too many 3rd party plugins if otherwise
     // TODO : update doc so that new plugins use new method to get config
     global $sefConfig;
     $sefConfig =& shRouter::shGetConfig();
     // prevent timezone not set warnings to appear all over,
     // especially for PHP 5.3.3+
     $oldLevel = error_reporting(0);
     $serverTimezone = date_default_timezone_get();
     error_reporting($oldLevel);
     date_default_timezone_set($serverTimezone);
     if (!$mainframe->isAdmin() && $sefConfig->shSecEnableSecurity) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shSec.php';
         // do security checks
         shDoSecurityChecks();
         shCleanUpSecLogFiles();
         // see setting in class file for clean up frequency
     }
     // optionnally collect page creation time
     if (!$mainframe->isAdmin() && $sefConfig->analyticsEnableTimeCollection) {
         jimport('joomla.error.profiler');
         // creating the profiler object will start the counter
         $profiler =& JProfiler::getInstance('sh404sef_profiler');
     }
     // load plugins, as per configuration
     $this->_loadPlugins($type = 'sh404sefcore');
     // load extension plugins, created by others
     $this->_loadPlugins($type = 'sh404sefext');
     // hook to be able to install other SEF extension plugins
     Sh404sefHelperExtplugins::loadInstallAdapters();
     // another hook to allow other SEF extensions language file to be loaded
     Sh404sefHelperExtplugins::loadLanguageFiles();
     if (!$sefConfig->Enabled) {
         // go away if not enabled
         return;
     }
     if (!defined('SH404SEF_IS_RUNNING')) {
         DEFINE('SH404SEF_IS_RUNNING', 1);
     }
     if (!$mainframe->isAdmin()) {
         // setup our JPagination replacement, so as to bring
         // back # of items per page in the url, in order
         // to properly calculate pagination
         // will only work if php > 5, so test for that
         if (version_compare(phpversion(), '5.0') >= 0) {
             // this register the old file, but do not load it if PHP5
             // will prevent further calls to the same jimport()
             // to actually do anything, because the 'joomla.html.pagination' key
             // is now registered statically in Jloader::import()
             jimport('joomla.html.pagination');
             // now we can register our own path
             JLoader::register('JPagination', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'pagination.php');
         }
         // override router class with our :
         $previousRouter =& $mainframe->getRouter();
         // create an instance of our class
         $shRouter = new shRouter();
         // store the previous router
         $shRouter->jRouter = clone $previousRouter;
         // make sure the cloned Joomla router is activated
         $shRouter->jRouter->setMode(JROUTER_MODE_SEF);
         // then override
         $previousRouter = $shRouter;
         // start decoding URL + decide possible redirects
         include JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shInit.php';
     }
 }
Esempio n. 3
0
 public function onAfterInitialise()
 {
     // prevent warning on php5.3+
     $this->_fixTimeWarning();
     // get joomla application object
     $app =& JFactory::getApplication();
     // register our autoloader
     $this->_registerAutoloader();
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.class.php';
     // get our configuration
     $sefConfig =& Sh404sefFactory::getConfig();
     // hook for a few SEO hacks
     if ($app->isSite()) {
         $this->_hacks(JRequest::get(), $sefConfig);
     }
     // security layer
     if (!$app->isAdmin() && $sefConfig->shSecEnableSecurity) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shSec.php';
         // do security checks
         shDoSecurityChecks();
         shCleanUpSecLogFiles();
         // see setting in class file for clean up frequency
     }
     // optionnally collect page creation time
     if (!$app->isAdmin() && $sefConfig->analyticsEnableTimeCollection) {
         jimport('joomla.error.profiler');
         // creating the profiler object will start the counter
         $profiler =& JProfiler::getInstance('sh404sef_profiler');
     }
     // load plugins, as per configuration
     $this->_loadPlugins($type = 'sh404sefcore');
     // load extension plugins, created by others
     $this->_loadPlugins($type = 'sh404sefext');
     // hook to be able to install other SEF extension plugins
     Sh404sefHelperExtplugins::loadInstallAdapters();
     // another hook to allow other SEF extensions language file to be loaded
     Sh404sefHelperExtplugins::loadLanguageFiles();
     if (!$sefConfig->Enabled) {
         // go away if not enabled
         return;
     }
     // fake language filter
     if ($sefConfig->enableMultiLingualSupport) {
         $app->set('menu_associations', 1);
         if (!$app->isAdmin()) {
             $app->setLanguageFilter(true);
         }
     }
     if (!defined('SH404SEF_IS_RUNNING')) {
         DEFINE('SH404SEF_IS_RUNNING', 1);
     }
     if (!$app->isAdmin()) {
         // setup our JPagination replacement, so as to bring
         // back # of items per page in the url, in order
         // to properly calculate pagination
         // will only work if php > 5, so test for that
         if (version_compare(phpversion(), '5.0') >= 0) {
             // this register the old file, but do not load it if PHP5
             // will prevent further calls to the same jimport()
             // to actually do anything, because the 'joomla.html.pagination' key
             // is now registered statically in Jloader::import()
             jimport('joomla.html.pagination');
             // now we can register our own path
             JLoader::register('JPagination', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'pagination.php');
         }
         // attach parse and build rules to Joomla router
         $joomlaRouter = $app->getRouter();
         $pageInfo =& Sh404sefFactory::getPageInfo();
         $pageInfo->router = new Sh404sefClassRouter();
         $joomlaRouter->attachParseRule(array($pageInfo->router, 'parseRule'));
         $joomlaRouter->attachBuildRule(array($pageInfo->router, 'buildRule'));
         // forece J! router config to SEF if at least one of the installed
         // components has been set to use raw J! router
         if (!empty(Sh404sefFactory::getConfig()->useJoomlaRouter)) {
             $joomlaRouter->setMode(JROUTER_MODE_SEF);
         }
         // pretend SEF is on, mostly for Joomla SEF plugin to work
         // as it checks directly 'sef' value in config, instead of
         // usgin $router->getMode()
         JFactory::$config->set('sef', 1);
         // kill Joomla suffix, so that it doesn't add or remove it in the parsing/building process
         JFactory::$config->set('sef_suffix', 0);
         // we use opposite setting from J!
         $mode = 1 - $sefConfig->shRewriteMode;
         JFactory::$config->set('sef_rewrite', $mode);
         // perform startup operations, such as detecting request caracteristics
         // and checking redirections
         $pageInfo->router->startup(JURI::getInstance());
     }
 }