1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

More work on eUrl

This commit is contained in:
mcfly
2008-11-25 16:26:03 +00:00
parent 52e6697bae
commit b7f0185feb
7 changed files with 241 additions and 200 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/class2.php,v $ | $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.72 $ | $Revision: 1.73 $
| $Date: 2008-11-24 20:18:59 $ | $Date: 2008-11-25 16:26:02 $
| $Author: secretr $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
// //
@@ -277,7 +277,9 @@ define("MPREFIX", $mySQLprefix);
e107_require_once(e_HANDLER."mysql_class.php"); e107_require_once(e_HANDLER."mysql_class.php");
$sql =& new db; $e107->sql =& new db;
$sql = &$e107->sql;
$sql->db_SetErrorReporting(FALSE); $sql->db_SetErrorReporting(FALSE);
$sql->db_Mark_Time('Start: SQL Connect'); $sql->db_Mark_Time('Start: SQL Connect');
@@ -287,7 +289,8 @@ $sql->db_Mark_Time('Start: Prefs, misc tables');
require_once(e_HANDLER.'admin_log_class.php'); require_once(e_HANDLER.'admin_log_class.php');
$admin_log = new e_admin_log(); $e107->admin_log =& new e_admin_log;
$admin_log = &$e107->admin_log;
if ($merror === "e1") { if ($merror === "e1") {
message_handler("CRITICAL_ERROR", 6, ": generic, ", "class2.php"); message_handler("CRITICAL_ERROR", 6, ": generic, ", "class2.php");
@@ -563,13 +566,15 @@ e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/".e_LANGUAGE."_custom.php");
$tp->initCharset(); // Now we know the site CHARSET, define how to handle utf-8 as necessary $tp->initCharset(); // Now we know the site CHARSET, define how to handle utf-8 as necessary
if($pref['sitelanguage'] != e_LANGUAGE && isset($pref['multilanguage']) && $pref['multilanguage'] && !$pref['multilanguage_subdomain'])
if($pref['sitelanguage'] != e_LANGUAGE && isset($pref['multilanguage']) && $pref['multilanguage'] && !$pref['multilanguage_subdomain']){ {
list($clc) = explode("_",CORE_LC); list($clc) = explode("_",CORE_LC);
define("e_LAN", strtolower($clc)); define("e_LAN", strtolower($clc));
define("e_LANQRY", "[".e_LAN."]"); define("e_LANQRY", "[".e_LAN."]");
unset($clc); unset($clc);
}else{ }
else
{
define("e_LAN", FALSE); define("e_LAN", FALSE);
define("e_LANQRY", FALSE); define("e_LANQRY", FALSE);
} }
@@ -581,13 +586,16 @@ $sql->db_Mark_Time('(Start: Pref/multilang done)');
$sql -> db_Mark_Time('Start: Misc resources. Online user tracking, cache'); $sql -> db_Mark_Time('Start: Misc resources. Online user tracking, cache');
// cache class // cache class
$e107cache = new ecache; $e107->ecache = new ecache;
$e107cache = &$e107->ecache;
e107_require_once(e_HANDLER."override_class.php"); e107_require_once(e_HANDLER."override_class.php");
$override=new override; $e107->override = new override;
$override = &$e107->override;
e107_require_once(e_HANDLER."event_class.php"); e107_require_once(e_HANDLER."event_class.php");
$e_event=new e107_event; $e107->e_event = new e107_event;
$e_event = &$e107->e_event;
if (isset($pref['notify']) && $pref['notify'] == true) { if (isset($pref['notify']) && $pref['notify'] == true) {
e107_require_once(e_HANDLER.'notify_class.php'); e107_require_once(e_HANDLER.'notify_class.php');
@@ -725,7 +733,9 @@ if (!class_exists('e107_table')) {
} }
//############################################################# //#############################################################
$ns=new e107table;
$e107->ns = new e107table;
$ns = &$e107->ns;
$e107->ban(); $e107->ban();
@@ -1189,7 +1199,8 @@ function get_user_data($uid, $extra = "")
if (!isset($e_userclass) && !is_object($e_userclass)) if (!isset($e_userclass) && !is_object($e_userclass))
{ {
require_once(e_HANDLER."userclass_class.php"); require_once(e_HANDLER."userclass_class.php");
$e_userclass = new user_class; $e107->e_userclass = new user_class;
$e_userclass = &$e107->e_userclass;
} }
$var['user_class'] = $e_userclass->get_all_user_classes($var['user_class']); $var['user_class'] = $e_userclass->get_all_user_classes($var['user_class']);
@@ -1418,7 +1429,8 @@ $sql->db_Mark_Time('Start: Go online');
if(!isset($_E107['no_online']) && varset($pref['track_online'])) if(!isset($_E107['no_online']) && varset($pref['track_online']))
{ {
e107_require_once(e_HANDLER."online_class.php"); e107_require_once(e_HANDLER."online_class.php");
$e_online = new e_online(); $e107->e_online = new e_online;
$e_online = &$e107->e_online;
$e_online->online($pref['track_online'], $pref['flood_protect']); $e_online->online($pref['track_online'], $pref['flood_protect']);
} }

View File

@@ -1,6 +1,6 @@
// $Id: url.sc,v 1.2 2008-11-24 18:18:47 mcfly_e107 Exp $ // $Id: url.sc,v 1.3 2008-11-25 16:26:02 mcfly_e107 Exp $
$e107 = e107::getInstance(); $e107 = e107::getInstance();
list($part, $section, $type, $parms) = explode('::', $parm, 4); list($section, $type, $parms) = explode('|', $parm, 3);
if(strpos($parms, '=') !== false) if(strpos($parms, '=') !== false)
{ {
parse_str($parms, $p); parse_str($parms, $p);
@@ -9,9 +9,4 @@ else
{ {
$p[$parms] = 1; $p[$parms] = 1;
} }
$e107->url->core = ($part == 'core'); return $e107->url->getURL($section, $type, $p);
if($e107->url->createURL($section, $type, $p))
{
return $e107->url->link;
}
return 'Failed';

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107Url.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e107Url.php,v $
| $Revision: 1.1 $ | $Revision: 1.2 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -20,47 +20,82 @@
class eURL class eURL
{ {
var $core = false; var $_link_handlers = array();
var $link = '';
function createURL($section, $urlType, $urlItems) /**
* 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)) if (!is_array($urlItems))
{ {
$urlItems = array($urlItems => 1); $urlItems = array($urlItems => 1);
} }
$functionName = 'url_'.$section.'_'.$urlType;
if(!function_exists($functionName)) $handlerId = $section . '/' . $urlType;
if (!isset($this->_link_handlers[$handlerId]))
{ {
$fileName = ($this->core ? e_FILE."url/custom/base/{$section}/{$urlType}.php" : e_FILE."url/custom/plugins/{$section}/{$urlType}.php"); $this->_link_handlers[$handlerId] = $this->_initHandler($section, $urlType);
if(is_readable($fileName))
{
include_once($fileName);
}
else
{
$fileName = ($this->core ? e_FILE."url/base/{$section}/{$urlType}.php" : e_PLUGIN."{$section}/url/{$urlType}.php");
if(is_readable($fileName))
{
include_once($fileName);
}
else
{
return false;
}
}
if(!function_exists($functionName))
{
return false;
}
} }
if($this->link = call_user_func($functionName, $urlItems)) return (string )call_user_func($this->_link_handlers[$handlerId], $urlItems);
}
function _initHandler($section, $urlType)
{ {
return true; $handlerId = $section . '/' . $urlType;
$handler = 'url_' . $section . '_' . $urlType;
$core = false;
if (strpos($section, ':') !== false)
{
list($tmp, $section) = explode(':', $section, 2);
$core = ($tmp === 'core');
} }
return false; // Check to see if custom code is active and exists
if (varsettrue($pref['url_config'][$section]))
{
$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;
}
}
$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 '';
}
*/
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
| $Revision: 1.24 $ | $Revision: 1.25 $
| $Date: 2008-11-25 14:36:33 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -42,14 +42,13 @@ class e107
* @param string $e107_root_path * @param string $e107_root_path
* @return e107 * @return e107
*/ */
function e107($e107_paths, $e107_root_path) function e107()
{ {
if(defined('e107_php4_check') && constant('e107_php4_check')) if(defined('e107_php4_check') && constant('e107_php4_check'))
{ {
echo ('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use e107::getInstance()'); echo ('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use e107::getInstance()');
exit(); exit();
} }
$this->_init($e107_paths, $e107_root_path);
} }
function _init($e107_paths, $e107_root_path) function _init($e107_paths, $e107_root_path)

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $
| $Revision: 1.6 $ | $Revision: 1.7 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -350,14 +350,13 @@ if($pm_info['pm_to'] == USERID)
SC_END SC_END
SC_BEGIN SEND_PM_LINK SC_BEGIN SEND_PM_LINK
$e107 = e107::getInstance();
$pm_outbox = pm_getInfo('outbox'); $pm_outbox = pm_getInfo('outbox');
if($pm_outbox['outbox']['filled'] < 100) if($pm_outbox['outbox']['filled'] < 100)
{ {
$e107->url->core = false; $e107 = e107::getInstance();
if($e107->url->createUrl('pm','main','send')) if($link = $e107->url->getUrl('pm','main','send'))
{ {
return "<a href='{$e107->url->link}'>".PM_SEND_LINK."</a>"; return "<a href='{$link}'>".PM_SEND_LINK."</a>";
} }
} }
return ""; return "";

View File

@@ -11,13 +11,12 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
global $sysprefs, $pref, $pm_prefs; global $sysprefs, $pref, $pm_prefs;
if(!isset($pm_prefs['perpage'])) if(!isset($pm_prefs['perpage']))
{ {
@@ -31,6 +30,7 @@ define("PM_OUTBOX_ICON", "<img src='".e_PLUGIN_ABS."pm/images/mail_send.png' sty
define("PM_SEND_LINK", LAN_PM_35); define("PM_SEND_LINK", LAN_PM_35);
define("NEWPM_ANIMATION", "<img src='".e_PLUGIN_ABS."pm/images/newpm.gif' alt='' style='border:0' />"); define("NEWPM_ANIMATION", "<img src='".e_PLUGIN_ABS."pm/images/newpm.gif' alt='' style='border:0' />");
$sc_style['SEND_PM_LINK']['pre'] = "<br /><br />[ "; $sc_style['SEND_PM_LINK']['pre'] = "<br /><br />[ ";
$sc_style['SEND_PM_LINK']['post'] = " ]"; $sc_style['SEND_PM_LINK']['post'] = " ]";
@@ -47,19 +47,20 @@ $sc_style['NEWPM_ANIMATE']['post'] = "</a>";
if(!isset($pm_menu_template)) if(!isset($pm_menu_template))
{ {
$pm_menu_template = " $pm_menu_template = "
<a href='{URL=plugin::pm::main::box=inbox}'>".PM_INBOX_ICON."</a> <a href='{URL=pm|main|box=inbox}'>".PM_INBOX_ICON."</a>
<a href='{URL=plugin::pm::main::box=inbox}'>".LAN_PM_25."</a> <a href='{URL=pm|main|box=inbox}'>".LAN_PM_25."</a>
{NEWPM_ANIMATE} {NEWPM_ANIMATE}
<br /> <br />
{INBOX_TOTAL} ".LAN_PM_36.", {INBOX_UNREAD} ".LAN_PM_37." {INBOX_FILLED} {INBOX_TOTAL} ".LAN_PM_36.", {INBOX_UNREAD} ".LAN_PM_37." {INBOX_FILLED}
<br /> <br />
<a href='{URL=plugin::pm::main::box=outbox}'>".PM_OUTBOX_ICON."</a> <a href='{URL=pm|main|box=outbox}'>".PM_OUTBOX_ICON."</a>
<a href='{URL=plugin::pm::main::box=outbox}'>".LAN_PM_26."</a><br /> <a href='{URL=pm|main|box=outbox}'>".LAN_PM_26."</a><br />
{OUTBOX_TOTAL} ".LAN_PM_36.", {OUTBOX_UNREAD} ".LAN_PM_37." {OUTBOX_FILLED} {OUTBOX_TOTAL} ".LAN_PM_36.", {OUTBOX_UNREAD} ".LAN_PM_37." {OUTBOX_FILLED}
{SEND_PM_LINK} {SEND_PM_LINK}
"; ";
} }
if(check_class($pm_prefs['pm_class'])) if(check_class($pm_prefs['pm_class']))
{ {
global $tp, $pm_inbox; global $tp, $pm_inbox;

View File

@@ -1,5 +1,5 @@
<?php <?php
// $Id: main.php,v 1.2 2008-11-25 16:26:03 mcfly_e107 Exp $
function url_pm_main($parms) function url_pm_main($parms)
{ {
if(isset($parms['box'])) if(isset($parms['box']))