1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 12:41:51 +02:00

more e107 class & API cahnges:

- magic __get() added to e107 and e_parse classes;
- resolved sch_load() related issues;
- more object getter;
This commit is contained in:
secretr 2009-07-23 15:29:07 +00:00
parent 27c85b32f9
commit 9c219f52a9
5 changed files with 198 additions and 61 deletions

View File

@ -9,8 +9,8 @@
* General purpose file
*
* $Source: /cvs_backup/e107_0.8/class2.php,v $
* $Revision: 1.114 $
* $Date: 2009-07-22 14:32:51 $
* $Revision: 1.115 $
* $Date: 2009-07-23 15:29:07 $
* $Author: secretr $
*
*/
@ -241,10 +241,11 @@ else
// Start the parser; use it to grab the full query string
//
//DEPRECATED, BC
$e107->url = e107::getUrl(); //TODO - find & replace $e107->url
//DEPRECATED, BC
$tp = $e107->tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp
//DEPRECATED, BC
//$e107->url = e107::getUrl(); - caught by __get()
//TODO - find & replace $e107->url
//DEPRECATED, BC, $e107->tp caught by __get()
$tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp
//define("e_QUERY", $matches[2]);
//define("e_QUERY", $_SERVER['QUERY_STRING']);
@ -297,19 +298,22 @@ define("MPREFIX", $mySQLprefix);
e107_require_once(e_HANDLER.'mysql_class.php');
$sql = $e107->sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
//DEPRECATED, BC, $e107->sql caught by __get()
$sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
$sql->db_SetErrorReporting(FALSE);
$sql->db_Mark_Time('Start: SQL Connect');
$merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
// create after the initial connection.
//DEPRECATED, BC, call the method only when needed
$sql2 = e107::getDb('sql2');
$sql2 = e107::getDb('sql2'); //TODO find & replace all $sql2 calls
$sql->db_Mark_Time('Start: Prefs, misc tables');
//DEPRECATED, BC, call the method only when needed
$admin_log = $e107->admin_log = e107::getAdminLog(); //TODO - find & replace $admin_log, $e107->admin_log
//DEPRECATED, BC, call the method only when needed, $e107->admin_log caught by __get()
$admin_log = e107::getAdminLog(); //TODO - find & replace $admin_log, $e107->admin_log
if ($merror === 'e1')
{
@ -338,12 +342,11 @@ $sysprefs = new prefs;
e107_require_once(e_HANDLER.'cache_handler.php');
//DEPRECATED, BC, call the method only when needed
e107_require_once(e_HANDLER.'arraystorage_class.php');
$eArrayStorage = $e107->arrayStorage = e107::getArrayStorage(); //TODO - find & replace $eArrayStorage, $e107->arrayStorage
//DEPRECATED, BC, call the method only when needed, $e107->arrayStorage caught by __get()
$eArrayStorage = e107::getArrayStorage(); //TODO - find & replace $eArrayStorage, $e107->arrayStorage
//DEPRECATED, BC, call the method only when needed
$e_event = $e107->e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event
//DEPRECATED, BC, call the method only when needed, $e107->e_event caught by __get()
$e_event = e107::getEvent(); //TODO - find & replace $e_event, $e107->e_event
$PrefCache = ecache::retrieve_sys('SitePrefs', 24 * 60, true);
if(!$PrefCache)
@ -643,15 +646,16 @@ $sql->db_Mark_Time('(Start: Pref/multilang done)');
//
$sql -> db_Mark_Time('Start: Misc resources. Online user tracking, cache');
//DEPRECATED, BC, call the method only when needed
$e107cache = $e107->ecache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache
//DEPRECATED, BC, call the method only when needed, $e107->ecache caught by __get()
$e107cache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache
//DEPRECATED, BC, call the method only when needed
$override = $e107->override = e107::getSingleton('override', e_HANDLER.'override_class.php'); //TODO - find & replace $override, $e107->override
//DEPRECATED, BC, call the method only when needed, $e107->override caught by __get()
$override = e107::getSingleton('override', e_HANDLER.'override_class.php'); //TODO - find & replace $override, $e107->override
//DEPRECATED, BC, call the method only when needed
$e_userclass = $e107->user_class = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class
//DEPRECATED, BC, call the method only when needed, $e107->user_class caught by __get()
$e_userclass = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class
//TODO - move the check to e107::notify()? What's the idea behind $pref['notify']?
if(isset($pref['notify']) && $pref['notify'] == true)
{
e107_require_once(e_HANDLER.'notify_class.php');
@ -818,8 +822,8 @@ if (!class_exists('e107table'))
}
//#############################################################
//DEPRECATED, BC, call the method only when needed
$ns = $e107->ns = e107::getRender(); //TODO - find & replace $ns, $e107->ns
//DEPRECATED, BC, call the method only when needed, $e107->ns caught by __get()
$ns = e107::getRender(); //TODO - find & replace $ns, $e107->ns
$e107->ban();
@ -1108,7 +1112,7 @@ else
//----------------------------
// ********* This is probably a bodge! Work out what to do properly. Has to be done when $pref valid
//FIXED - undefined $register_sc
$tp->sch_load();
//$tp->sch_load(); - will be auto-initialized by first $tp->e_sc call - see e_parse->__get()
$exclude_lan = array('lan_signup.php'); // required for multi-language.
@ -1639,10 +1643,7 @@ function init_session()
$sql->db_Mark_Time('Start: Go online');
if(!isset($_E107['no_online']) && varset($pref['track_online']))
{
e107_require_once(e_HANDLER."online_class.php");
$e107->e_online = new e_online;
$e_online = &$e107->e_online;
$e_online->online($pref['track_online'], $pref['flood_protect']);
e107::getOnline()->online($pref['track_online'], $pref['flood_protect']);
}
function cookie($name, $value, $expire=0, $path = '/', $domain = '', $secure = 0)

View File

@ -9,8 +9,8 @@
* e107 Main
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
* $Revision: 1.31 $
* $Date: 2009-07-22 14:32:50 $
* $Revision: 1.32 $
* $Date: 2009-07-23 15:29:07 $
* $Author: secretr $
*/
@ -22,15 +22,41 @@ if (!defined('e107_INIT')) { exit; }
*/
class e107
{
var $server_path;
var $e107_dirs;
var $http_path;
var $https_path;
var $base_path;
var $file_path;
var $relative_base_path;
var $_ip_cache;
var $_host_name_cache;
public $server_path;
public $e107_dirs;
public $http_path;
public $https_path;
public $base_path;
public $file_path;
public $relative_base_path;
public $_ip_cache;
public $_host_name_cache;
public $site_theme;
/**
* Used for runtime caching of user extended struct
*
* @var array
* @see get_user_data()
*/
public $extended_struct;
/**
* User login name
*
* @var string
* @see init_session()
*/
public $currentUser = '';
/**
* Run once load core shortcodes
* while initialize SC parser
*
* @var boolen
*/
protected static $_sc_core_loaded = false;
/**
* Singleton instance
@ -46,10 +72,6 @@ class e107
* @var array
*/
private static $_registry = array();
var $sql;
var $tp;
var $url;
/**
@ -234,6 +256,22 @@ class e107
return self::getSingleton('e_parse', e_HANDLER.'e_parse_class.php');
}
/**
* Retrieve sc parser singleton object
*
* @return e_shortcode
*/
public static function getScParser()
{
$sc = self::getSingleton('e_shortcode', e_HANDLER.'shortcode_handler.php');
if(!self::$_sc_core_loaded)
{
$sc->loadCoreShortcodes();
self::$_sc_core_loaded = true;
}
return $sc;
}
/**
* Retrieve DB singleton object based on the
* $instance_id
@ -341,6 +379,26 @@ class e107
return self::getSingleton('convert', e_HANDLER.'date_handler.php');
}
/**
* Retrieve notify handler singleton object
*
* @return notify
*/
public static function getNotify()
{
return self::getSingleton('notify', e_HANDLER.'notify_class.php');
}
/**
* Retrieve online users handler singleton object
*
* @return e_online
*/
public static function getOnline()
{
return self::getSingleton('e_online', e_HANDLER.'online_class.php');
}
/**
* Get core template. Use this method for templates, which are following the
* new template standards:
@ -1138,5 +1196,66 @@ class e107
return (null !== $separator ? implode($separator, $ret) : $ret);
}
public function __get($name)
{
switch ($name)
{
case 'tp':
$ret = e107::getParser();
break;
case 'sql':
$ret = e107::getDb();
break;
case 'ecache':
$ret = e107::getCache();
break;
case 'arrayStorage':
$ret = e107::getArrayStorage();
break;
case 'e_event':
$ret = e107::getEvent();
break;
case 'ns':
$ret = e107::getRender();
break;
case 'url':
$ret = e107::getUrl();
break;
case 'admin_log':
$ret = e107::getAdminLog();
break;
case 'override':
$ret = e107::getSingleton('override', e_HANDLER.'override_class.php');
break;
case 'notify':
$ret = e107::getNotify();
break;
case 'e_online':
$ret = e107::getOnline();
break;
case 'user_class':
$ret = e107::getUserClass();
break;
default:
trigger_error('$e107->$'.$name.' not defined', E_USER_WARNING);
return null;
break;
}
$this->$name = $ret;
return $ret;
}
}
?>

View File

@ -9,9 +9,9 @@
* Text processing and parsing functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
* $Revision: 1.54 $
* $Date: 2009-07-19 11:44:28 $
* $Author: marj_nl_fr $
* $Revision: 1.55 $
* $Date: 2009-07-23 15:29:07 $
* $Author: secretr $
*
*/
if (!defined('e107_INIT')) { exit; }
@ -23,7 +23,8 @@ class e_parse
{
var $isutf8 = FALSE; // Flag for global use indicates whether utf-8 character set
var $utfAction; // Determine how to handle utf-8. 0 = 'do nothing' 1 = 'use mb_string' 2 = emulation
var $e_sc; // Shortcode processor
// Shortcode processor - see __get()
//var $e_sc;
var $e_bb; // BBCode processor
var $e_pf; // Profanity filter
var $e_emote; // Emote filter
@ -271,7 +272,7 @@ class e_parse
// Initialise the shortcode handler - has to be done when $prefs valid, so can't be done in constructor ATM
function sch_load($noCore=false)
/*function sch_load($noCore=false)
{
if (!is_object($this->e_sc))
{
@ -282,7 +283,7 @@ class e_parse
$this->e_sc->loadCoreShortcodes();
}
}
}
}*/
@ -371,7 +372,7 @@ class e_parse
function parseTemplate($text, $parseSCFiles = TRUE, $extraCodes = "")
{
$this->sch_load();
//$this->sch_load();
return $this->e_sc->parseCodes($text, $parseSCFiles, $extraCodes);
}
@ -1330,6 +1331,23 @@ class e_parse
return "<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+".$reassembled.$subject.";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+".$reassembled."; return true;' onmouseout='window.status=\"\";return true;'>".$words.'</a>';
}
public function __get($name)
{
switch ($name)
{
case 'e_sc':
$ret = e107::getScParser();
break;
default:
trigger_error('$e107->$'.$name.' not defined', E_USER_WARNING);
return null;
break;
}
$this->$name = $ret;
return $ret;
}
}
?>

View File

@ -9,9 +9,9 @@
* Forum plugin notify configuration
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/notify_class.php,v $
* $Revision: 1.4 $
* $Date: 2008-12-21 18:15:04 $
* $Author: mcfly_e107 $
* $Revision: 1.5 $
* $Date: 2009-07-23 15:29:07 $
* $Author: secretr $
*
*/
@ -73,9 +73,9 @@ class notify
}
//DEPRECATED, BC, call the method only when needed, $e107->notify caught by __get()
global $nt;
$e107->notify = new notify;
$nt = &$e107->notify;
$nt = e107::getNotify(); //TODO - find & replace $nt, $e107->notify
function notify_usersup($data)

View File

@ -12,9 +12,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
| $Revision: 1.27 $
| $Date: 2009-07-21 06:31:23 $
| $Author: e107coders $
| $Revision: 1.28 $
| $Date: 2009-07-23 15:29:07 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@ -22,9 +22,8 @@ if (!defined('e107_INIT')) { exit; }
function register_shortcode($classFunc, $codes, $path='', $force=false)
{
$e107 = e107::getInstance();
$sc = &$e107->tp->e_sc;
$sc = e107::getScParser();
//If codes is set to true, let's go get a list of shortcode methods
if(is_bool($codes) && $codes === true)
{