Exemple #1
0
 function parse(&$siteRouter, &$uri)
 {
     // Call this function only once in the stack, so
     // we can use Joomla default router to parse
     if ($this->parsing) {
         return array();
     }
     $this->parsing = true;
     $mainframe =& JFactory::getApplication();
     JoomSEF::set('sef.global.meta', SEFTools::GetSEFGlobalMeta());
     // Restore global "Add suffix to URLs"
     $sefSuffix = JoomSEF::get('sef.global.orig_sef_suffix');
     $config = JFactory::getConfig();
     $config->set('sef_suffix', $sefSuffix);
     $vars = array();
     $vars = JoomSEF::parse($uri);
     $menu = $mainframe->getMenu('site');
     // Parsing done
     $this->parsing = false;
     // Fix the start variable
     $start = $uri->getVar('start');
     if (!is_null($start) && is_null($uri->getVar('limitstart'))) {
         $uri->delVar('start');
         $vars['limitstart'] = $start;
     }
     //Handle an empty URL (special case)
     if (empty($vars['Itemid']) && empty($vars['option'])) {
         //$item = $menu->getDefault();
         // Workaround until Joomla menu bug will be fixed
         $items = $menu->getItems(array('home', 'language'), array('1', '*'));
         $item = $items[0];
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         // set the information in the request
         $vars = $item->query;
         // get the itemid
         $vars['Itemid'] = $item->id;
         // set the active menu item
         $menu->setActive($vars['Itemid']);
         // set vars
         $this->setRequestVars($vars);
         $this->fixDocument($vars);
         return $vars;
     }
     // Get the item id, if it hasn't been set force it to null
     if (empty($vars['Itemid'])) {
         $vars['Itemid'] = JRequest::getInt('Itemid', null);
     }
     // Set vars
     $this->setVars($vars);
     $siteRouter->setVars($vars);
     // Make sure the Joomla router doesn't process URL any further
     $siteRouter->setMode(JROUTER_MODE_DONT_PARSE);
     // No option? Get the full information from the itemid
     if (empty($vars['option'])) {
         $item = $menu->getItem($this->getVar('Itemid'));
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         $vars = $vars + $item->query;
     }
     // Set the active menu item
     $menu->setActive($this->getVar('Itemid'));
     // Set base href
     //$this->setBaseHref($vars);
     // Set vars
     $this->setRequestVars($vars);
     $this->fixDocument($vars);
     return $vars;
 }
 function getIsPaidVersion()
 {
     if (!isset($this->_isPaidVersion)) {
         $check = SEFTools::GetSEFGlobalMeta();
         $ctrl = md5(implode(file(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_sef' . DS . 'sef.xml')));
         $this->_isPaidVersion = $check == $ctrl;
     }
     return $this->_isPaidVersion;
 }
 function parse(&$uri)
 {
     $mainframe =& JFactory::getApplication();
     $sefConfig =& SEFConfig::getConfig();
     JoomSEF::set('sef.global.meta', SEFTools::GetSEFGlobalMeta());
     // Try to fix the missing question mark if set to
     if ($sefConfig->fixQuestionMark && count($_POST) == 0) {
         $url = $uri->toString();
         $newUrl = preg_replace('/^([^?&]*)&([^?]+=[^?]*)$/', '$1?$2', $url);
         if ($newUrl != $url) {
             // Redirect
             $mainframe->redirect($newUrl, '', 'message', true);
         }
     }
     $vars = array();
     $vars = JoomSEF::parse($uri);
     $menu =& JSite::getMenu(true);
     //Handle an empty URL (special case)
     if (empty($vars['Itemid']) && empty($vars['option'])) {
         $item = $menu->getDefault();
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         // set the information in the request
         $vars = $item->query;
         // get the itemid
         $vars['Itemid'] = $item->id;
         // set the active menu item
         $menu->setActive($vars['Itemid']);
         // set vars
         $this->setRequestVars($vars);
         $this->fixDocument($vars);
         return $vars;
     }
     // Get the item id, if it hasn't been set force it to null
     if (empty($vars['Itemid'])) {
         $vars['Itemid'] = JRequest::getInt('Itemid', null);
     }
     // Get the variables from the uri
     $this->setVars($vars);
     // No option? Get the full information from the itemid
     if (empty($vars['option'])) {
         $item = $menu->getItem($this->getVar('Itemid'));
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         $vars = $vars + $item->query;
     }
     // Set the active menu item
     $menu->setActive($this->getVar('Itemid'));
     // Set base href
     //$this->setBaseHref($vars);
     // Set vars
     $this->setRequestVars($vars);
     $this->fixDocument($vars);
     return $vars;
 }