2008-11-25 16:26:03 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
+ ----------------------------------------------------------------------------+
|
|
|
|
|
| e107 website system
|
|
|
|
|
|
|
|
|
|
|
| <EFBFBD>Steve Dunstan 2001-2002
|
|
|
|
|
| http://e107.org
|
|
|
|
|
| jalist@e107.org
|
|
|
|
|
|
|
|
|
|
|
| Released under the terms and conditions of the
|
|
|
|
|
| GNU General Public License (http://gnu.org).
|
|
|
|
|
|
|
|
|
|
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107Url.php,v $
|
2008-11-26 21:00:23 +00:00
|
|
|
|
| $Revision: 1.7 $
|
|
|
|
|
| $Date: 2008-11-26 21:00:23 $
|
2008-11-26 11:06:49 +00:00
|
|
|
|
| $Author: secretr $
|
2008-11-25 16:26:03 +00:00
|
|
|
|
+----------------------------------------------------------------------------+
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class eURL
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var $_link_handlers = array();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get plugin url
|
|
|
|
|
*
|
|
|
|
|
* @param string $section
|
|
|
|
|
* @param string $urlType
|
|
|
|
|
* @param string|array $urlItems
|
|
|
|
|
* @return string URL
|
|
|
|
|
*/
|
|
|
|
|
function getUrl($section, $urlType, $urlItems = array())
|
|
|
|
|
{
|
|
|
|
|
if (!is_array($urlItems))
|
|
|
|
|
{
|
|
|
|
|
$urlItems = array($urlItems => 1);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-26 03:24:51 +00:00
|
|
|
|
$handlerId = $section . '/' . $urlType; if (!isset($this->_link_handlers[$handlerId]))
|
2008-11-25 16:26:03 +00:00
|
|
|
|
if (!isset($this->_link_handlers[$handlerId]))
|
|
|
|
|
{
|
|
|
|
|
$this->_link_handlers[$handlerId] = $this->_initHandler($section, $urlType);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-25 17:02:02 +00:00
|
|
|
|
if($link = call_user_func($this->_link_handlers[$handlerId], $urlItems))
|
|
|
|
|
{
|
|
|
|
|
return $link;
|
|
|
|
|
}
|
|
|
|
|
return '#url-not-found';
|
2008-11-25 16:26:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _initHandler($section, $urlType)
|
|
|
|
|
{
|
2008-11-26 11:06:49 +00:00
|
|
|
|
global $pref; //FIXME pref handler, $e107->prefs instance
|
|
|
|
|
|
2008-11-25 16:26:03 +00:00
|
|
|
|
$core = false;
|
|
|
|
|
if (strpos($section, ':') !== false)
|
|
|
|
|
{
|
|
|
|
|
list($tmp, $section) = explode(':', $section, 2);
|
|
|
|
|
$core = ($tmp === 'core');
|
|
|
|
|
}
|
2008-11-26 13:28:35 +00:00
|
|
|
|
elseif (isset($this->_link_handlers['plugin:'.$section]))
|
|
|
|
|
{
|
|
|
|
|
return $this->_link_handlers['plugin:'.$section];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$handlerId = $section . '/' . $urlType;
|
|
|
|
|
$handler = 'url_' . $section . '_' . $urlType;
|
2008-11-25 16:26:03 +00:00
|
|
|
|
|
|
|
|
|
// Check to see if custom code is active and exists
|
|
|
|
|
if (varsettrue($pref['url_config'][$section]))
|
|
|
|
|
{
|
2008-11-26 21:00:23 +00:00
|
|
|
|
// Search the central url config repository - one config to rull them all
|
2008-11-25 16:26:03 +00:00
|
|
|
|
$fileName = ($core ? e_FILE."url/custom/base/{$handlerId}.php" : e_FILE."url/custom/plugins/{$handlerId}.php");
|
|
|
|
|
if (is_readable($fileName))
|
|
|
|
|
{
|
|
|
|
|
include_once ($fileName);
|
|
|
|
|
}
|
|
|
|
|
if (function_exists($handler))
|
|
|
|
|
{
|
|
|
|
|
return $handler;
|
|
|
|
|
}
|
2008-11-26 21:00:23 +00:00
|
|
|
|
// Search for custom url config released with the plugin
|
|
|
|
|
if (!$core)
|
|
|
|
|
{
|
|
|
|
|
$fileName = e_PLUGIN."{$section}/url/custom/{$urlType}.php";
|
|
|
|
|
if (is_readable($fileName))
|
|
|
|
|
{
|
|
|
|
|
include_once ($fileName);
|
|
|
|
|
}
|
|
|
|
|
if (function_exists($handler))
|
|
|
|
|
{
|
|
|
|
|
return $handler;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-25 16:26:03 +00:00
|
|
|
|
}
|
2008-11-26 21:00:23 +00:00
|
|
|
|
// Search the default url config - the last station
|
2008-11-25 16:26:03 +00:00
|
|
|
|
$fileName = ($core ? e_FILE."url/base/{$handlerId}.php" : e_PLUGIN."{$section}/url/{$urlType}.php");
|
|
|
|
|
if (is_readable($fileName))
|
|
|
|
|
{
|
|
|
|
|
include_once ($fileName);
|
|
|
|
|
}
|
|
|
|
|
return $handler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Preparing for PHP5
|
|
|
|
|
Exmample future calls (after stopping PHP4 support):
|
|
|
|
|
$e107->url->getForum('post', array('edit' => 10));
|
|
|
|
|
$e107->url->getCoreUser('user', array('id' => 10));
|
|
|
|
|
|
|
|
|
|
function __call($method, $arguments) {
|
|
|
|
|
if (strpos($method, "getCore") === 0)
|
|
|
|
|
{
|
|
|
|
|
$section = strtolower(substr($method, 7));
|
|
|
|
|
return $this->getCoreUrl($section, varset($arguments[0]), varset($arguments[1]));
|
|
|
|
|
}
|
|
|
|
|
elseif (strpos($method, "get") === 0)
|
|
|
|
|
{
|
|
|
|
|
$section = strtolower(substr($method, 3));
|
|
|
|
|
return $this->getUrl($section, varset($arguments[0]), varset($arguments[1]));
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|