Esempio n. 1
0
 /**
  * Proxy the router parse function to fix a bug in the core
  *
  * @param	object	$url	The URI to parse
  * @return	array
  */
 public function parse($uri)
 {
     $nooku = KFactory::get('admin::com.nooku.model.nooku');
     $app = KFactory::get('lib.joomla.application');
     // Perform the actual parse
     $result = parent::parse($uri);
     $this->setVars($result);
     // Redirect if the language has changed
     $old = $nooku->getLanguage();
     $new = KInput::get('lang', array('post', 'get'), 'lang');
     if (isset($new) && strtolower($new) != strtolower($old)) {
         //Set the language
         $nooku->setLanguage($new);
         if (KInput::getMethod() == 'POST') {
             $uri->setVar('lang', $new);
             $route = JRoute::_($uri->toString(), false);
             /*
              * Dirty hack. Joomla URI class transforms cid[] into cid[0]
              * 
              * TODO : either fix in KUri or in the koowa javascript uri parser
              */
             $route = str_replace('cid[0]', 'cid[]', $route);
             $app->redirect($route);
         }
     }
     return $result;
 }
 /**
  * Tests the parse method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testParse()
 {
     $uri = JUri::getInstance('http://localhost');
     $this->assertThat($this->object->parse($uri), $this->isType('array'), 'JRouterAdministrator::parse() returns an empty array.');
 }
 /**
  * Tests the parse method
  *
  * @return  void
  * @testdox JRouterAdministrator::parse() returns an array
  * @since   3.0
  */
 public function testParse()
 {
     $uri = JUri::getInstance('http://localhost');
     $vars = $this->object->parse($uri);
     $this->assertTrue(is_array($vars));
 }