Exemplo n.º 1
0
 /**
  * Create aceSEF URLs
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see 		http://www.joomace.net/joomla-extensions/acesef
  * @see			_getSiteRoute()
  * @access 		private
  * @param 		string	$url	the original URL to turn into SEF
  * @return 		string SEF URL
  * @since 		3.0
  */
 private function _aceSef($url)
 {
     jimport('joomla.application.router');
     require_once JPATH_ROOT . '/includes/application.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_acesef/library/router.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_acesef/library/loader.php';
     $router = new JRouterAcesef();
     $uri = $router->build($url);
     return $uri->toString();
 }
Exemplo n.º 2
0
 function updateURLs($rows, $where)
 {
     // Nothing to update
     if (is_null($rows) || count($rows) == 0) {
         return 0;
     }
     // Load the needed classes
     jimport('joomla.application.router');
     require_once JPATH_ROOT . '/' . 'includes' . '/' . 'application.php';
     require_once JPATH_ACESEF_ADMIN . '/' . 'library' . '/' . 'router.php';
     if (AcesefUtility::JoomFishInstalled()) {
         require_once JPATH_ROOT . '/' . 'components' . '/' . 'com_joomfish' . '/' . 'helpers' . '/' . 'defines.php';
         JLoader::register('JoomfishManager', JOOMFISH_ADMINPATH . '/' . 'classes' . '/' . 'JoomfishManager.class.php');
         JLoader::register('JoomFishVersion', JOOMFISH_ADMINPATH . '/' . 'version.php');
         JLoader::register('JoomFish', JOOMFISH_PATH . '/' . 'helpers' . '/' . 'joomfish.class.php');
     }
     // First, delete all the URLs
     if (!AceDatabase::query("DELETE FROM #__acesef_urls{$where}")) {
         return 0;
     }
     // Create AceSEF router
     $router = new JRouterAcesef();
     // JoomFish patch
     if (AcesefUtility::JoomFishInstalled()) {
         $mainframe = JFactory::getApplication();
         // Set mainframe as frontend
         $mainframe->_clientId = 0;
         // Initialize JoomFish plugin
         if (!class_exists('plgSystemJFDatabase')) {
             require JPATH_PLUGINS . '/' . 'system' . '/' . 'jfdatabase.php';
         }
         $params = JPluginHelper::getPlugin('system', 'jfdatabase');
         $dispatcher = JDispatcher::getInstance();
         $plugin = new plgSystemJFDatabase($dispatcher, (array) $params);
         $plugin->onAfterInitialise();
         // Get the mainframe back to backend
         $mainframe->_clientId = 1;
     }
     // Update URLs one by one
     for ($i = 0, $n = count($rows); $i < $n; $i++) {
         $row =& $rows[$i];
         $old_real_url = $row->url_real;
         $old_sef_url = $row->url_sef;
         $new_sef_uri = $router->build($old_real_url);
         $new_sef_url = ltrim(str_replace(JURI::root(), '', $new_sef_uri->_uri), '/');
         // SEF URL changed, add it to Moved URLs
         if ($old_sef_url != $new_sef_url) {
             // Already exists?
             $id = AceDatabase::loadResult("SELECT id FROM #__acesef_urls_moved WHERE url_old = " . AceDatabase::quote($old_sef_url) . " AND url_new = " . AceDatabase::quote($new_sef_url) . " LIMIT 1");
             if (!$id) {
                 AceDatabase::query("INSERT IGNORE INTO #__acesef_urls_moved (url_old, url_new) VALUES (" . AceDatabase::quote($old_sef_url) . ", " . AceDatabase::quote($new_sef_url) . ")");
             }
         }
     }
     return count($rows);
 }