english/components/com_weblinks/router.php
/**
 * Parse the segments of a URL.
 *
 * @param	array	The segments of the URL to parse.
 *
 * @return	array	The URL attributes to be used by the application.
 */
Parse the segments of a URL.
@param       array   The segments of the URL to parse.

@return      array   The URL attributes to be used by the application.
Parse the segments of a URL . @param array The segments of the URL to parse . @return array The URL attributes to be used by the application .
function WeblinksParseRoute($segments)
{
	$vars = array();
	$app	= JFactory::getApplication();
	$menu	= $app->getMenu();
	$item	= $menu->getActive();
	$params = JComponentHelper::getParams('com_weblinks');
	$advanced = $params->get('sef_advanced_link', 0);
	$count = count($segments);
	if (!isset($item)) {
		$vars['view']	= $segments[0];
		$vars['id']		= $segments[$count - 1];
		return $vars;
	}
	$id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root';
	$category = JCategories::getInstance('Weblinks')->get($id);
	$categories = $category->getChildren();
	$found = 0;
	foreach($segments as $segment)
	{
		foreach($categories as $category)
		{
			if (($category->slug == $segment) || ($advanced && $category->alias == str_replace(':', '-',$segment))) {
				$vars['id'] = $category->id;
				$vars['view'] = 'category';
				$categories = $category->getChildren();
				$found = 1;
				break;
			}
		}
		if ($found == 0) {
			if ($advanced) {
				$db = JFactory::getDBO();
				$query = 'SELECT id FROM #__weblinks WHERE catid = '.$vars['id'].' AND alias = '.$db->Quote(str_replace(':', '-',$segment));
				$db->setQuery($query);
				$id = $db->loadResult();
			}
			else {
				$id = $segment;
			}
			$vars['id'] = $id;
			$vars['view'] = 'weblink';
			break;
		}
		$found = 0;
	}
	return $vars;
}
function WeblinksParseRoute ( $ segments ) { $ vars = array ( ) ; $ app = JFactory :: getApplication ( ) ; $ menu = $ app -> getMenu ( ) ; $ item = $ menu -> getActive ( ) ; $ params = JComponentHelper :: getParams ( 'com_weblinks' ) ; $ advanced = $ params -> get ( 'sef_advanced_link' , 0 ) ; $ count = count ( $ segments ) ; if ( ! isset ( $ item ) ) { $ vars [ 'view' ] = $ segments [ 0 ] ; $ vars [ 'id' ] = $ segments [ $ count - 1 ] ; return $ vars ; } $ id = ( isset ( $ item -> query [ 'id' ] ) && $ item -> query [ 'id' ] > 1 ) ? $ item -> query [ 'id' ] : 'root' ; $ category = JCategories :: getInstance ( 'Weblinks' ) -> get ( $ id ) ; $ categories = $ category -> getChildren ( ) ; $ found = 0 ; foreach ( $ segments as $ segment ) { foreach ( $ categories as $ category ) { if ( ( $ category -> slug == $ segment ) || ( $ advanced && $ category -> alias == str_replace ( ':' , '-' , $ segment ) ) ) { $ vars [ 'id' ] = $ category -> id ; $ vars [ 'view' ] = 'category' ; $ categories = $ category -> getChildren ( ) ; $ found = 1 ; break ; } } if ( $ found == 0 ) { if ( $ advanced ) { $ db = JFactory :: getDBO ( ) ; $ query = 'SELECT id FROM #__weblinks WHERE catid = ' . $ vars [ 'id' ] . ' AND alias = ' . $ db -> Quote ( str_replace ( ':' , '-' , $ segment ) ) ; $ db -> setQuery ( $ query ) ; $ id = $ db -> loadResult ( ) ; } else { $ id = $ segment ; } $ vars [ 'id' ] = $ id ; $ vars [ 'view' ] = 'weblink' ; break ; } $ found = 0 ; } return $ vars ; }
Parse the segments of a URL.
Parse the segments of a URL .
//Get the active menu item. // Count route segments // Standard routing for weblinks. // From the categories view, we can only jump to a category.