55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||
|
|
||
|
/**
|
||
|
* This class overrides Kohana's URL
|
||
|
*
|
||
|
* @package Redir
|
||
|
* @category Modifications
|
||
|
* @author Deon George
|
||
|
* @copyright (c) 2009-2013 Deon George
|
||
|
* @license http://dev.leenooks.net/license.html
|
||
|
*/
|
||
|
class URL extends Kohana_URL {
|
||
|
// Our method paths for different functions
|
||
|
public static $method_directory = array(
|
||
|
'admin'=>'a',
|
||
|
'affiliate'=>'affiliate', // @todo To retire
|
||
|
'reseller'=>'r',
|
||
|
'task'=>'task',
|
||
|
'user'=>'u',
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* Wrapper to provide a URL::site() link based on function
|
||
|
*/
|
||
|
public static function link($dir,$src,$site=FALSE) {
|
||
|
if (! $dir)
|
||
|
return $src;
|
||
|
|
||
|
if (! array_key_exists($dir,URL::$method_directory))
|
||
|
throw new Kohana_Exception('Unknown directory :dir for :src',array(':dir'=>$dir,':src'=>$src));
|
||
|
|
||
|
$x = URL::$method_directory[$dir].'/'.$src;
|
||
|
|
||
|
return $site ? URL::site($x) : $x;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Function to reveal the real directory for a URL
|
||
|
*/
|
||
|
public static function dir($dir) {
|
||
|
// Quick check if we can do something here
|
||
|
if (! in_array(strtolower($dir),URL::$method_directory))
|
||
|
return $dir;
|
||
|
|
||
|
// OK, we can, find it.
|
||
|
foreach (URL::$method_directory as $k=>$v)
|
||
|
if (strtolower($dir) == $v)
|
||
|
return ucfirst($k);
|
||
|
|
||
|
// If we get here, we didnt have anything.
|
||
|
return $dir;
|
||
|
}
|
||
|
}
|
||
|
?>
|