/**
  * Load the site
  *
  * This function checks if the site exists in the request, or in the session. If not it
  * falls back on the default site.
  *
  * @param	string	$site 	The name of the site to load
  * @return	void
  * @throws  KException 	If the site could not be found
  * @since	Nooku Server 0.7
  */
 protected function _loadSite($default)
 {
     $method = strtolower(KRequest::method());
     if (KRequest::has($method . '.site')) {
         $site = KRequest::get($method . '.site', 'cmd');
     } else {
         $site = JFactory::getSession()->get('site', $default);
     }
     parent::_loadSite($site);
 }
Example #2
0
	/**
	 * Load the site
	 * 
	 * This function checks if the site exists in the request, it not it tries
	 * to get the site form the url falling back on the default is no site was
	 * found
	 * 
	 * @param	string	$site 	The name of the site to load
	 * @return	void
	 * @throws  KException 	If the site could not be found
	 * @since	Nooku Server 0.7
	 */
    protected function _loadSite($site)
	{
	    $method = strtolower(KRequest::method());
	    
	    if(!KRequest::has($method.'.site')) 
	    {
		    $uri  =	clone(JURI::getInstance());
	    	$path = trim(str_replace(array(JURI::base(true)), '', $uri->getPath()), '/');
	    	$path = trim(str_replace('index.php', '', $path), '/');
	    	
		    $segments = array();
		    if(!empty($path)) {
			    $segments = explode('/', $path);
		    }

		    if(!empty($segments))
		    {
		        // Check if the site exists
	            if(KFactory::get('com://admin/sites.model.sites')->getList()->find($segments[0])) {
                    $site = array_shift($segments);
                }
		    }
	    } 
	    else $site = KRequest::get($method.'.site', 'cmd');
	    
	    parent::_loadSite($site);
	}