Location: PHPKode > projects > injooosm > components/com_injooosm/router.bak.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: router.php 2009-06-24 15:40:19 svn $
 * @author Michael Pfister
 * @package injooosm
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

/*
 * Function to convert a system URL to a SEF URL
 */
function injooosmBuildRoute(&$query) {

	$segments = array();
	
	$menu = &JSite::getMenu();
	if (empty($query['Itemid'])) {
		$menuItem = &$menu->getActive();
	} else {
		$menuItem = &$menu->getItem($query['Itemid']);
	}
	
	if (isset($query['view'])){
		$segments[] = $query['view'];
		unset($query['view']);
	}
	if (isset($query['layout'])){
		$segments[] = $query['layout'];
		unset($query['layout']);
	}
	if (isset($query['id'])){
		$segments[] = $query['id'];
		unset($query['id']);	
	}
	if (isset($query['controller'])) {
		$segments[] = $query['controller'];
		unset($query['controller']);
	}
	if (isset($query['task'])) {
		$segments[] = $query['task'];
		unset($query['task']);
	}
	
	return $segments;
}
/*
 * Function to convert a SEF URL back to a system URL
 */
function injooosmParseRoute($segments) {

	$vars = array();

	//Get the active menu item
	$menu =& JSite::getMenu();
	$item =& $menu->getActive();

	// Count route segments
	$count = count($segments);

	switch($segments[1]) {

		case 'list':
			$vars['view'] = 'tracks';
			$vars['layout'] = 'list';
			break;

		case 'track':
			$vars['view'] = 'tracks';
			$vars['layout'] = 'track';
			$vars['id'] = $segments[2];
		break;

		case 'form':
			$vars['view'] = 'tracks';
			$vars['layout'] = 'form';
			$vars['id'] = $segments[2];
		break;

		case 'user':
			$vars['view'] = 'tracks';
			$vars['layout'] = 'user';
		break;

		case 'tracks':
			$vars['controller'] = 'tracks';
			$vars['task'] = 'delete';
			$vars['id'] = $segments[0];
		break;
	}
	return $vars;
}
Return current item: injooosm