1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-20 21:32:09 +02:00

e107 class & API changes - work in progress

This commit is contained in:
secretr
2009-07-22 00:49:35 +00:00
parent a4765480ee
commit 90e1078552
2 changed files with 144 additions and 58 deletions

View File

@@ -9,8 +9,8 @@
* General purpose file * General purpose file
* *
* $Source: /cvs_backup/e107_0.8/class2.php,v $ * $Source: /cvs_backup/e107_0.8/class2.php,v $
* $Revision: 1.112 $ * $Revision: 1.113 $
* $Date: 2009-07-21 16:11:02 $ * $Date: 2009-07-22 00:49:34 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -194,8 +194,7 @@ if(!isset($ADMIN_DIRECTORY))
// //
e107_require_once(realpath(dirname(__FILE__).'/'.$HANDLERS_DIRECTORY).'/e107_class.php'); e107_require_once(realpath(dirname(__FILE__).'/'.$HANDLERS_DIRECTORY).'/e107_class.php');
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY'); $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY');
$e107 = e107::getInstance(); $e107 = e107::getInstance()->init($e107_paths, realpath(dirname(__FILE__)));
$e107->init($e107_paths, realpath(dirname(__FILE__)));
$inArray = array("'", ';', '/**/', '/UNION/', '/SELECT/', 'AS '); $inArray = array("'", ';', '/**/', '/UNION/', '/SELECT/', 'AS ');
if (strpos($_SERVER['PHP_SELF'], 'trackback') === false) if (strpos($_SERVER['PHP_SELF'], 'trackback') === false)
@@ -242,12 +241,10 @@ else
// Start the parser; use it to grab the full query string // Start the parser; use it to grab the full query string
// //
e107_require_once(e_HANDLER.'e107Url.php'); //DEPRECATED, BC
$e107->url = new eURL; $e107->url = e107::getUrl(); //TODO - find & replace $e107->url
//DEPRECATED, BC
e107_require_once(e_HANDLER.'e_parse_class.php'); $tp = $e107->tp = e107::getParser(); //TODO - find & replace $tp, $e107->tp
$e107->tp = new e_parse;
$tp = &$e107->tp;
//define("e_QUERY", $matches[2]); //define("e_QUERY", $matches[2]);
//define("e_QUERY", $_SERVER['QUERY_STRING']); //define("e_QUERY", $_SERVER['QUERY_STRING']);
@@ -293,30 +290,29 @@ if (!$ADMIN_DIRECTORY && !$DOWNLOADS_DIRECTORY)
// //
// J: MYSQL INITIALIZATION // J: MYSQL INITIALIZATION
// //
@require_once(e_HANDLER.'traffic_class.php'); $eTraffic = e107::getSingleton('e107_traffic', e_HANDLER.'traffic_class.php');
$eTraffic=new e107_traffic; // We start traffic counting ASAP $eTraffic->Calibrate($eTraffic); // We start traffic counting ASAP
$eTraffic->Calibrate($eTraffic);
define("MPREFIX", $mySQLprefix); define("MPREFIX", $mySQLprefix);
e107_require_once(e_HANDLER.'mysql_class.php'); e107_require_once(e_HANDLER.'mysql_class.php');
$e107->sql =& new db; $sql = $e107->sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
$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');
$merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); $merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
$sql2 =& new db; // create after the initial connection. // create after the initial connection.
//DEPRECATED, BC, call the method only when needed
$sql2 = e107::getDb('sql2');
$sql->db_Mark_Time('Start: Prefs, misc tables'); $sql->db_Mark_Time('Start: Prefs, misc tables');
require_once(e_HANDLER.'admin_log_class.php'); //DEPRECATED, BC, call the method only when needed
$e107->admin_log =& new e_admin_log; $admin_log = $e107->admin_log = e107::getAdminLog(); //TODO - find & replace $admin_log, $e107->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');
exit; exit;
} }
@@ -341,13 +337,13 @@ e107_require_once(e_HANDLER."pref_class.php");
$sysprefs = new prefs; $sysprefs = new prefs;
e107_require_once(e_HANDLER.'cache_handler.php'); e107_require_once(e_HANDLER.'cache_handler.php');
e107_require_once(e_HANDLER.'arraystorage_class.php');
$e107->arrayStorage =& new ArrayData();
$eArrayStorage = &$e107->arrayStorage;
e107_require_once(e_HANDLER.'event_class.php'); //DEPRECATED, BC, call the method only when needed
$e107->e_event = new e107_event; e107_require_once(e_HANDLER.'arraystorage_class.php');
$e_event = &$e107->e_event; $eArrayStorage = $e107->arrayStorage = 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
$PrefCache = ecache::retrieve_sys('SitePrefs', 24 * 60, true); $PrefCache = ecache::retrieve_sys('SitePrefs', 24 * 60, true);
if(!$PrefCache) if(!$PrefCache)
@@ -647,17 +643,14 @@ $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 //DEPRECATED, BC, call the method only when needed
$e107->ecache = new ecache; $e107cache = $e107->ecache = e107::getCache(); //TODO - find & replace $e107cache, $e107->ecache
$e107cache = &$e107->ecache;
e107_require_once(e_HANDLER.'override_class.php'); //DEPRECATED, BC, call the method only when needed
$e107->override = new override; $override = $e107->override = e107::getSingleton('override', e_HANDLER.'override_class.php'); //TODO - find & replace $override, $e107->override
$override = &$e107->override;
e107_require_once(e_HANDLER.'userclass_class.php'); //DEPRECATED, BC, call the method only when needed
$e107->user_class = new user_class; $e_userclass = $e107->user_class = e107::getUserClass(); //TODO - find & replace $e_userclass, $e107->user_class
$e_userclass = &$e107->user_class;
if(isset($pref['notify']) && $pref['notify'] == true) if(isset($pref['notify']) && $pref['notify'] == true)
{ {
@@ -794,15 +787,15 @@ if (!class_exists('e107table'))
# - return null # - return null
# - scope public # - scope public
*/ */
global $override; $override_tablerender = e107::getSingleton('override', e_HANDLER.'override_class.php')->override_check('tablerender');
if ($override_tablerender = $override->override_check('tablerender')) if ($override_tablerender)
{ {
$result = call_user_func($override_tablerender, $caption, $text, $mode, $return); $result = call_user_func($override_tablerender, $caption, $text, $mode, $return);
if ($result == 'return') if ($result == 'return')
{ {
return; return '';
} }
extract($result); extract($result);
} }
@@ -818,15 +811,15 @@ if (!class_exists('e107table'))
else else
{ {
tablestyle($caption, $text, $mode); tablestyle($caption, $text, $mode);
return '';
} }
} }
} }
} }
//############################################################# //#############################################################
//DEPRECATED, BC, call the method only when needed
$e107->ns = new e107table; $ns = $e107->ns = e107::getRender(); //TODO - find & replace $ns, $e107->ns
$ns = &$e107->ns;
$e107->ban(); $e107->ban();
@@ -849,7 +842,7 @@ if ($pref['membersonly_enabled'] && !USER && e_SELF != SITEURL.e_SIGNUP && e_SEL
{ {
if(!isset($_E107['allow_guest'])) if(!isset($_E107['allow_guest']))
{ {
if($_POST['ajax_used'] || $_GET['ajax_used'] || e_PAGE == 'e_ajax.php' || e_PAGE == 'e_js.php' || e_PAGE == 'e_jslib.php') if(e_AJAX_REQUEST || e_PAGE == 'e_ajax.php' || e_PAGE == 'e_js.php' || e_PAGE == 'e_jslib.php')
{ {
exit; exit;
} }
@@ -1173,6 +1166,7 @@ else
define('e_REFERER_SELF', FALSE); define('e_REFERER_SELF', FALSE);
} }
//BC, DEPRECATED - use e107::getDateConvert()
if (!class_exists('convert')) if (!class_exists('convert'))
{ {
require_once(e_HANDLER.'date_handler.php'); require_once(e_HANDLER.'date_handler.php');
@@ -1425,16 +1419,15 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//DEPRECATED - use e107::setRegistry()
function cachevars($id, $var) function cachevars($id, $var)
{ {
global $cachevar; e107::setRegistry('core/cachedvars/'.$id, $var);
$cachevar[$id]=$var;
} }
//DEPRECATED - use e107::getRegistry()
function getcachedvars($id) function getcachedvars($id)
{ {
global $cachevar; e107::getRegistry('core/cachedvars/'.$id, false);
return (isset($cachevar[$id]) ? $cachevar[$id] : false);
} }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

View File

@@ -9,8 +9,8 @@
* e107 Main * e107 Main
* *
* $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.29 $ * $Revision: 1.30 $
* $Date: 2009-07-21 16:11:02 $ * $Date: 2009-07-22 00:49:35 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -178,18 +178,19 @@ class e107
* *
* @param string $class_name * @param string $class_name
* @param string $path optional script path * @param string $path optional script path
* @param string $regpath additional registry path
* @return Object * @return Object
*/ */
public static function getSingleton($class_name, $path = null) public static function getSingleton($class_name, $path = null, $regpath = '')
{ {
$id = 'core/e107/singleton/'.$class_name; $id = 'core/e107/singleton/'.$class_name.$regpath;
if(!e107::getRegistry($id)) if(!e107::getRegistry($id))
{ {
if(null !== $path) if(null !== $path && !class_exists($class_name))
{ {
require_once($path); //no existence/security checks here! e107_require_once($path); //no existence/security checks here!
} }
if(class_exists($class_name)) if(class_exists($class_name, false))
{ {
e107::setRegistry($id, new $class_name()); e107::setRegistry($id, new $class_name());
} }
@@ -209,11 +210,11 @@ class e107
*/ */
public static function getObject($class_name, $arguments = null, $path = null) public static function getObject($class_name, $arguments = null, $path = null)
{ {
if(null !== $path) if(null !== $path && !class_exists($class_name))
{ {
require_once($path); //no existence/security checks here! e107_require_once($path); //no existence/security checks here!
} }
if(class_exists($class_name)) if(class_exists($class_name, false))
{ {
if(null !== $arguments) return $class_name($arguments); if(null !== $arguments) return $class_name($arguments);
return $class_name(); return $class_name();
@@ -233,6 +234,98 @@ class e107
return self::getSingleton('e_parse', e_HANDLER.'e_parse_class.php'); return self::getSingleton('e_parse', e_HANDLER.'e_parse_class.php');
} }
/**
* Retrieve DB singleton object based on the
* $instance_id
*
* @param string $instance_id
* @return db
*/
public static function getDb($instance_id = '')
{
return self::getSingleton('db', e_HANDLER.'mysql_class.php', $instance_id);
}
/**
* Retrieve event singleton object
*
* @return ecache
*/
public static function getCache()
{
return self::getSingleton('ecache', e_HANDLER.'cache_handler.php');
}
/**
* Retrieve user class singleton object
*
* @return user_class
*/
public static function getUserClass()
{
return self::getSingleton('user_class', e_HANDLER.'userclass_class.php');
}
/**
* Retrieve render singleton object
*
* @return e107table
*/
public static function getRender()
{
return self::getSingleton('e107table');
}
/**
* Retrieve event singleton object
*
* @return e107_event
*/
public static function getEvent()
{
return self::getSingleton('e107_event', e_HANDLER.'event_class.php');
}
/**
* Retrieve array storage singleton object
*
* @return ArrayData
*/
public static function getArrayStorage()
{
return self::getSingleton('ArrayData', e_HANDLER.'arraystorage_class.php');
}
/**
* Retrieve URL singleton object
*
* @return eURL
*/
public static function getUrl()
{
return self::getSingleton('eURL', e_HANDLER.'e107Url.php');
}
/**
* Retrieve admin log singleton object
*
* @return e_admin_log
*/
public static function getAdminLog()
{
return self::getSingleton('e_admin_log', e_HANDLER.'admin_log_class.php');
}
/**
* Retrieve date handler singleton object
*
* @return convert
*/
public static function getDateConvert()
{
return self::getSingleton('convert', e_HANDLER.'date_handler.php');
}
/** /**
* @return e107 * @return e107
*/ */