Index: trunk/core/kernel/application.php
===================================================================
diff -u -r2592 -r2600
--- trunk/core/kernel/application.php (.../application.php) (revision 2592)
+++ trunk/core/kernel/application.php (.../application.php) (revision 2600)
@@ -7,43 +7,43 @@
* The class incapsulates the main run-cycle of the script, provide access to all other objects in the framework.
*
* The class is a singleton, which means that there could be only one instance of KernelApplication in the script.
-* This could be guranteed by NOT calling the class constuctor directly, but rather calling KernelApplication::Instance() method,
+* This could be guranteed by NOT calling the class constuctor directly, but rather calling KernelApplication::Instance() method,
* which returns an instance of the application. The method gurantees that it will return exactly the same instance for any call.
* See singleton pattern by GOF.
* @package kernel4
*/
class kApplication {
-
+
/**
* Is true, when Init method was called already, prevents double initialization
*
* @var bool
*/
var $InitDone = false;
-
+
/**
* Holds internal TemplateParser object
* @access private
* @var TemplateParser
*/
var $Parser;
-
+
/**
* Holds parser output buffer
* @access private
* @var string
*/
var $HTML;
-
+
/**
* Prevents request from beeing proceeded twice in case if application init is called mere then one time
*
* @var bool
* @todo This is not good anyway (by Alex)
*/
var $RequestProcessed = false;
-
+
/**
* The main Factory used to create
* almost any class of kernel and
@@ -53,42 +53,42 @@
* @var kFactory
*/
var $Factory;
-
+
/**
* Reference to debugger
*
* @var Debugger
*/
var $Debugger = null;
-
+
/**
* Holds all phrases used
* in code and template
*
* @var PhrasesCache
*/
var $Phrases;
-
+
/**
* Holds DBConnection
*
* @var kDBConnection
*/
var $DB;
-
+
/**
* Maintains list of user-defined error handlers
*
* @var Array
*/
var $errorHandlers = Array();
-
+
/**
* Returns kApplication instance anywhere in the script.
*
- * This method should be used to get single kApplication object instance anywhere in the
+ * This method should be used to get single kApplication object instance anywhere in the
* Kernel-based application. The method is guranteed to return the SAME instance of kApplication.
- * Anywhere in the script you could write:
+ * Anywhere in the script you could write:
*
* $application =& kApplication::Instance();
*
@@ -97,8 +97,8 @@
* $this->Application =& kApplication::Instance();
*
* to get the instance of kApplication. Note that we call the Instance method as STATIC - directly from the class.
- * To use descendand of standard kApplication class in your project you would need to define APPLICATION_CLASS constant
- * BEFORE calling kApplication::Instance() for the first time. If APPLICATION_CLASS is not defined the method would
+ * To use descendand of standard kApplication class in your project you would need to define APPLICATION_CLASS constant
+ * BEFORE calling kApplication::Instance() for the first time. If APPLICATION_CLASS is not defined the method would
* create and return default KernelApplication instance.
* @static
* @access public
@@ -107,7 +107,7 @@
function &Instance()
{
static $instance = false;
-
+
if(!$instance)
{
if (!defined('APPLICATION_CLASS')) define('APPLICATION_CLASS', 'kApplication');
@@ -116,7 +116,7 @@
}
return $instance;
}
-
+
/**
* Initializes the Application
*
@@ -129,82 +129,81 @@
function Init()
{
if($this->InitDone) return false;
-
+
if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
{
$GLOBALS['debugger']->appendMemoryUsage('Application before Init:');
}
-
- if( !$this->isDebugMode() )
+
+ if( !$this->isDebugMode() )
{
error_reporting(0);
ini_set('display_errors', 0);
}
-
+
$error_handler = set_error_handler( Array(&$this,'handleError') );
if($error_handler) $this->errorHandlers[] = $error_handler;
-
-
+
+
$this->DB = new kDBConnection(SQL_TYPE, Array(&$this,'handleSQLError') );
$this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB);
$this->DB->debugMode = $this->isDebugMode();
-
+
$this->Factory = new kFactory();
-
+
$this->registerDefaultClasses();
-
$this->SetDefaultConstants();
-
+
// 1. to read configs before doing any recallObject (called from "SetDefaultConstants" anyway)
//$config_reader =& $this->recallObject('kUnitConfigReader');
-
+
if( !$this->GetVar('m_lang') ) $this->SetVar('m_lang', $this->GetDefaultLanguageId() );
if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() );
if( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 0);
-
+
$this->Phrases = new PhrasesCache( $this->GetVar('m_lang') );
-
+
$this->SetVar('lang.current_id', $this->GetVar('m_lang') );
$language =& $this->recallObject('lang.current', null, Array('live_table'=>true) );
-
+
if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() );
$this->SetVar('theme.current_id', $this->GetVar('m_theme') );
-
+
if( !$this->RecallVar('UserGroups') )
{
$ses =& $this->recallObject('Session');
$user_groups = trim($ses->GetField('GroupList'), ',');
if (!$user_groups) $user_groups = $this->ConfigValue('User_GuestGroup');
$this->StoreVar('UserGroups', $user_groups);
}
-
+
if( !$this->RecallVar('curr_iso') ) $this->StoreVar('curr_iso', $this->GetPrimaryCurrency() );
-
+
$this->SetVar('visits_id', $this->RecallVar('visit_id') );
-
+
$this->ValidateLogin(); // TODO: write that method
-
+
if( $this->isDebugMode() )
{
$GLOBALS['debugger']->profileFinish('kernel4_startup');
}
-
+
if( defined('CMS') && CMS == 1 && !$this->GetVar('admin') && !$this->IsAdmin() )
{
define('MOD_REWRITE', 1);
}
-
+
$this->InitDone = true;
return true;
}
-
+
function GetDefaultLanguageId()
{
$table = $this->getUnitOption('lang','TableName');
$id_field = $this->getUnitOption('lang','IDField');
return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryLang = 1');
}
-
+
function GetDefaultThemeId()
{
if (defined('DBG_FORCE_THEME') && DBG_FORCE_THEME){
@@ -214,13 +213,13 @@
$id_field = $this->getUnitOption('theme','IDField');
return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryTheme = 1');
}
-
+
function GetPrimaryCurrency()
{
$this->setUnitOption('mod','AutoLoad',false);
$module =& $this->recallObject('mod');
$this->setUnitOption('mod','AutoLoad',true);
-
+
if( $module->Load('In-Commerce') && $module->GetDBField('Loaded') == 1 )
{
$table = $this->getUnitOption('curr','TableName');
@@ -231,7 +230,7 @@
return 'USD';
}
}
-
+
/**
* Registers default classes such as ItemController, GridController and LoginController
*
@@ -243,17 +242,17 @@
{
$this->registerClass('kArray',KERNEL_PATH.'/utility/params.php');
$this->registerClass('Params',KERNEL_PATH.'/utility/params.php');
-
+
$this->registerClass('HTTPQuery', KERNEL_PATH.'/utility/http_query.php', 'HTTPQuery', Array('Params') );
-
+
$this->registerClass('Session', KERNEL_PATH.'/session/session.php');
$this->registerClass('SessionStorage', KERNEL_PATH.'/session/session.php');
-
+
$this->registerClass('kEventManager', KERNEL_PATH.'/event_manager.php', 'EventManager');
$this->registerClass('kUnitConfigReader', KERNEL_PATH.'/utility/unit_config_reader.php');
-
+
$this->registerClass('Params', KERNEL_PATH.'/utility/params.php', 'kActions');
-
+
$this->registerClass('kFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kOptionsFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kUploadFormatter', KERNEL_PATH.'/utility/formatters.php');
@@ -265,35 +264,35 @@
$this->registerClass('kCCDateFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kUnitFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kFilesizeFormatter', KERNEL_PATH.'/utility/formatters.php');
-
+
$this->registerClass('kTempTablesHandler', KERNEL_PATH.'/utility/temp_handler.php');
-
+
$event_manager =& $this->recallObject('EventManager');
$event_manager->registerBuildEvent('kTempTablesHandler', 'OnTempHandlerBuild');
-
+
$this->registerClass('TemplatesCache',KERNEL_PATH.'/parser/template.php');
$this->registerClass('Template',KERNEL_PATH.'/parser/template.php');
$this->registerClass('TemplateParser',KERNEL_PATH.'/parser/template_parser.php');
-
+
$this->registerClass('MainProcessor', KERNEL_PATH.'/processors/main_processor.php','m_TagProcessor');
-
+
$this->registerClass('kMultipleFilter', KERNEL_PATH.'/utility/filters.php');
$this->registerClass('kDBList', KERNEL_PATH.'/db/dblist.php');
$this->registerClass('kDBItem', KERNEL_PATH.'/db/dbitem.php');
$this->registerClass('kDBEventHandler', KERNEL_PATH.'/db/db_event_handler.php');
$this->registerClass('kDBTagProcessor', KERNEL_PATH.'/db/db_tag_processor.php');
-
+
$this->registerClass('kTagProcessor', KERNEL_PATH.'/processors/tag_processor.php');
$this->registerClass('kEmailMessage',KERNEL_PATH.'/utility/email.php');
$this->registerClass('kSmtpClient',KERNEL_PATH.'/utility/smtp_client.php');
-
+
if (file_exists(MODULES_PATH.'/in-commerce/units/currencies/currency_rates.php')) {
$this->registerClass('kCurrencyRates',MODULES_PATH.'/in-commerce/units/currencies/currency_rates.php');
}
-
+
$this->registerClass('FCKeditor', DOC_ROOT.BASE_PATH.'/admin/editor/cmseditor/fckeditor.php'); // need this?
}
-
+
/**
* Defines default constants if it's not defined before - in config.php
*
@@ -302,14 +301,14 @@
function SetDefaultConstants()
{
if (!defined('SERVER_NAME')) define('SERVER_NAME', $_SERVER['HTTP_HOST']);
-
+
$admin_dir = $this->ConfigValue('AdminDirectory');
if(!$admin_dir) $admin_dir = 'admin';
safeDefine('ADMIN_DIR', $admin_dir);
-
+
$this->registerModuleConstants();
}
-
+
/**
* Registers each module specific constants if any found
*
@@ -323,24 +322,24 @@
if( file_exists($contants_file) ) k4_include_once($contants_file);
}
}
-
+
function ProcessRequest()
{
$event_manager =& $this->recallObject('EventManager');
-
+
if( $this->isDebugMode() && dbg_ConstOn('DBG_SHOW_HTTPQUERY') )
{
global $debugger;
$http_query =& $this->recallObject('HTTPQuery');
$debugger->appendHTML('HTTPQuery:');
$debugger->dumpVars($http_query->_Params);
}
-
+
$event_manager->ProcessRequest();
$event_manager->RunRegularEvents(reBEFORE);
$this->RequestProcessed = true;
}
-
+
/**
* Actually runs the parser against current template and stores parsing result
*
@@ -355,44 +354,44 @@
{
$GLOBALS['debugger']->appendMemoryUsage('Application before Run:');
}
-
+
if (!$this->RequestProcessed) $this->ProcessRequest();
-
+
$this->InitParser();
$template_cache =& $this->recallObject('TemplatesCache');
$t = $this->GetVar('t');
-
+
if(defined('CMS') && CMS)
{
$cms_handler =& $this->recallObject('cms_EventHandler');
if( !$template_cache->TemplateExists($t) )
{
- $t = $cms_handler->GetDesignTemplate();
+ $t = $cms_handler->GetDesignTemplate();
}
else
{
$cms_handler->SetCatByTemplate();
}
}
-
+
if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
{
$GLOBALS['debugger']->appendMemoryUsage('Application before Parsing:');
}
-
+
$this->HTML = $this->Parser->Parse( $template_cache->GetTemplateBody($t), $t );
-
+
if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') )
{
$GLOBALS['debugger']->appendMemoryUsage('Application after Parsing:');
}
}
-
+
function InitParser()
{
if( !is_object($this->Parser) ) $this->Parser =& $this->recallObject('TemplateParser');
}
-
+
/**
* Send the parser results to browser
*
@@ -406,39 +405,39 @@
{
$GLOBALS['debugger']->appendMemoryUsage('Application before Done:');
}
-
+
if( $this->GetVar('admin') )
{
$reg = '/('.preg_quote(BASE_PATH, '/').'.*\.html)(#.*){0,1}(")/sU';
$this->HTML = preg_replace($reg, "$1?admin=1$2$3", $this->HTML);
}
-
+
//eval("?".">".$this->HTML);
-
+
echo $this->HTML;
$this->Phrases->UpdateCache();
-
+
flush();
-
+
$event_manager =& $this->recallObject('EventManager');
$event_manager->RunRegularEvents(reAFTER);
-
+
$session =& $this->recallObject('Session');
$session->SaveData();
//$this->SaveBlocksCache();
}
-
+
function SaveBlocksCache()
{
/*if (defined('EXPERIMENTAL_PRE_PARSE')) {
$data = serialize($this->PreParsedCache);
-
- $this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.time().')');
+
+ $this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.time().')');
}*/
}
-
+
// Facade
-
+
/**
* Returns current session id (SID)
* @access public
@@ -449,13 +448,13 @@
$session =& $this->recallObject('Session');
return $session->GetID();
}
-
+
function DestroySession()
{
$session =& $this->recallObject('Session');
$session->Destroy();
}
-
+
/**
* Returns variable passed to the script as GET/POST/COOKIE
*
@@ -468,7 +467,7 @@
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->Get($var,$mode);
}
-
+
/**
* Returns ALL variables passed to the script as GET/POST/COOKIE
*
@@ -480,11 +479,11 @@
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->GetParams();
}
-
+
/**
* Set the variable 'as it was passed to the script through GET/POST/COOKIE'
*
- * This could be useful to set the variable when you know that
+ * This could be useful to set the variable when you know that
* other objects would relay on variable passed from GET/POST/COOKIE
* or you could use SetVar() / GetVar() pairs to pass the values between different objects.
*
@@ -522,7 +521,7 @@
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->Remove($var);
}
-
+
/**
* Returns session variable value
*
@@ -539,7 +538,7 @@
$session =& $this->recallObject('Session');
return $session->RecallVar($var,$default);
}
-
+
/**
* Stores variable $val in session under name $var
*
@@ -559,15 +558,15 @@
{
$session =& $this->recallObject('Session');
$session->StoreVarDefault($var, $val);
- }
-
+ }
+
/**
- * Links HTTP Query variable with session variable
+ * Links HTTP Query variable with session variable
*
* If variable $var is passed in HTTP Query it is stored in session for later use. If it's not passed it's recalled from session.
* This method could be used for making sure that GetVar will return query or session value for given
* variable, when query variable should overwrite session (and be stored there for later use).
- * This could be used for passing item's ID into popup with multiple tab -
+ * This could be used for passing item's ID into popup with multiple tab -
* in popup script you just need to call LinkVar('id', 'current_id') before first use of GetVar('id').
* After that you can be sure that GetVar('id') will return passed id or id passed earlier and stored in session
* @access public
@@ -587,10 +586,10 @@
$this->SetVar($var, $this->RecallVar($ses_var, $default));
}
}
-
+
/**
* Returns variable from HTTP Query, or from session if not passed in HTTP Query
- *
+ *
* The same as LinkVar, but also returns the variable value taken from HTTP Query if passed, or from session if not passed.
* Returns the default value if variable does not exist in session and was not passed in HTTP Query
*
@@ -618,13 +617,13 @@
$templates_cache =& $this->recallObject('TemplatesCache');
$templates_cache->SetTemplateBody($title,$body);
}
-
+
function ProcessTag($tag_data)
{
$a_tag = new Tag($tag_data,$this->Parser);
return $a_tag->DoProcessTag();
}
-
+
function ProcessParsedTag($prefix, $tag, $params)
{
$a_tag = new Tag('',$this->Parser);
@@ -665,9 +664,9 @@
if (defined('ADMIN') && $prefix == '') $prefix='/admin';
if (defined('ADMIN') && $prefix == '_FRONT_END_') $prefix = '';
$index_file = isset($index_file) ? $index_file : (defined('INDEX_FILE') ? INDEX_FILE : basename($_SERVER['SCRIPT_NAME']));
-
+
if( isset($params['index_file']) ) $index_file = $params['index_file'];
-
+
if (getArrayValue($params, 'opener') == 'u') {
$opener_stack=$this->RecallVar('opener_stack');
if($opener_stack) {
@@ -688,59 +687,59 @@
$t = $this->GetVar('t');
}
}
-
+
$pass = isset($params['pass']) ? $params['pass'] : '';
$pass_events = isset($params['pass_events']) ? $params['pass_events'] : false; // pass events with url
-
-
-
+
+
+
if (defined('MOD_REWRITE') && MOD_REWRITE) {
$env = $this->BuildEnv('', $params, $pass, $pass_events, false);
$env = ltrim($env, ':-');
-
+
$session =& $this->recallObject('Session');
$sid = $session->NeedQueryString() ? '?sid='.$this->GetSID() : '';
// $env = str_replace(':', '/', $env);
$ret = rtrim($this->BaseURL($prefix).$t.'.html/'.$env.'/'.$sid, '/');
-
+
}
else {
$env = $this->BuildEnv($t, $params, $pass, $pass_events);
$ret = $this->BaseURL($prefix).$index_file.'?'.$env;
}
-
+
return $ret;
}
-
+
function BuildEnv($t, $params, $pass='all', $pass_events=false, $env_var=true)
{
$session =& $this->recallObject('Session');
$sid = $session->NeedQueryString() && !(defined('MOD_REWRITE') && MOD_REWRITE) ? $this->GetSID() : '';
if( getArrayValue($params,'admin') == 1 ) $sid = $this->GetSID();
-
+
$ret = '';
if ($env_var) {
$ret = ENV_VAR_NAME.'=';
}
$ret .= defined('INPORTAL_ENV') ? $sid.'-'.$t : $sid.':'.$t;
-
+
$pass = str_replace('all', trim($this->GetVar('passed'), ','), $pass);
-
+
if(strlen($pass) > 0)
{
- $pass_info = array_unique( explode(',',$pass) ); // array( prefix[.special], prefix[.special] ...
+ $pass_info = array_unique( explode(',',$pass) ); // array( prefix[.special], prefix[.special] ...
foreach($pass_info as $pass_element)
{
$ret.=':';
list($prefix)=explode('.',$pass_element);
$query_vars = $this->getUnitOption($prefix,'QueryString');
-
+
//if pass events is off and event is not implicity passed
if(!$pass_events && !isset($params[$pass_element.'_event'])) {
$params[$pass_element.'_event'] = ''; // remove event from url if requested
//otherwise it will use value from get_var
}
-
+
if($query_vars)
{
$tmp_string=Array(0=>$pass_element);
@@ -752,12 +751,12 @@
unset( $params[$pass_element.'_'.$var_name] );
}
}
-
+
$escaped = array();
foreach ($tmp_string as $tmp_val) {
$escaped[] = str_replace(Array('-',':'), Array('\-','\:'), $tmp_val);
}
-
+
if ($this->getUnitOption($prefix, 'PortalStyleEnv') == true) {
$ret.= array_shift($escaped).array_shift($escaped).'-'.implode('-',$escaped);
}
@@ -770,43 +769,43 @@
unset($params['pass']);
unset($params['opener']);
unset($params['m_event']);
-
+
if ($this->GetVar('admin') && !isset($params['admin'])) {
$params['admin'] = 1;
}
-
+
if( getArrayValue($params,'escape') )
{
$ret = addslashes($ret);
unset($params['escape']);
}
-
+
foreach ($params as $param => $value)
{
$ret .= '&'.$param.'='.$value;
}
-
+
return $ret;
}
-
+
function BaseURL($prefix='')
{
return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').BASE_PATH.$prefix.'/';
}
-
+
function Redirect($t='', $params=null, $prefix='', $index_file=null)
{
if ($t == '' || $t === true) $t = $this->GetVar('t');
-
+
// pass prefixes and special from previous url
if (!isset($params['pass'])) $params['pass'] = 'all';
-
+
$location = $this->HREF($t, $prefix, $params, $index_file);
$a_location = $location;
$location = "Location: $location";
//echo " location : $location
";
-
-
+
+
if( $this->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
{
$GLOBALS['debugger']->appendTrace();
@@ -823,18 +822,18 @@
header("$location");
}
}
-
+
$session =& $this->recallObject('Session');
$session->SaveData();
$this->SaveBlocksCache();
exit;
}
-
+
function Phrase($label)
{
return $this->Phrases->GetPhrase($label);
}
-
+
/**
* Replace language tags in exclamation marks found in text
*
@@ -847,7 +846,7 @@
{
return $this->Phrases->ReplaceLanguageTags($text,$force_escape);
}
-
+
/**
* Validtates user in session if required
*
@@ -858,14 +857,14 @@
{
// Original Kostja call
//$login_controller =& $this->Factory->MakeClass(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login'));
-
+
// Call proposed by Alex
//$login_controller =& $this->RecallObject(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login'));
-
+
//$login_controller->CheckLogin();
}
}
-
+
/**
* Returns configuration option value by name
*
@@ -876,7 +875,7 @@
{
return $this->DB->GetOne('SELECT VariableValue FROM '.TABLE_PREFIX.'ConfigurationValues WHERE VariableName = '.$this->DB->qstr($name) );
}
-
+
/**
* Allows to process any type of event
*
@@ -892,11 +891,11 @@
$event_manager =& $this->recallObject('EventManager');
$event_manager->HandleEvent($event);
}
-
+
/**
* Registers new class in the factory
*
- * @param string $real_class Real name of class as in class declaration
+ * @param string $real_class Real name of class as in class declaration
* @param string $file Filename in what $real_class is declared
* @param string $pseudo_class Name under this class object will be accessed using getObject method
* @param Array $dependecies List of classes required for this class functioning
@@ -905,9 +904,9 @@
*/
function registerClass($real_class, $file, $pseudo_class = null, $dependecies = Array() )
{
- $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependecies);
+ $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependecies);
}
-
+
/**
* Add $class_name to required classes list for $depended_class class.
* All required class files are included before $depended_class file is included
@@ -920,7 +919,7 @@
{
$this->Factory->registerDependency($depended_class, $class_name);
}
-
+
/**
* Registers Hook from subprefix event to master prefix event
*
@@ -941,7 +940,7 @@
$event_manager =& $this->recallObject('EventManager');
$event_manager->registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional);
}
-
+
/**
* Allows one TagProcessor tag act as other TagProcessor tag
*
@@ -953,7 +952,7 @@
$aggregator =& $this->recallObject('TagsAggregator', 'kArray');
$aggregator->SetArrayValue($tag_info['AggregateTo'], $tag_info['AggregatedTagName'], Array($tag_info['LocalPrefix'], $tag_info['LocalTagName'], getArrayValue($tag_info, 'LocalSpecial')));
}
-
+
/**
* Returns object using params specified,
* creates it if is required
@@ -966,11 +965,11 @@
*/
function &recallObject($name,$pseudo_class=null,$event_params=Array())
{
- $func_args =& func_get_args();
+ $func_args = func_get_args();
$result =& ref_call_user_func_array( Array(&$this->Factory, 'getObject'), $func_args );
return $result;
}
-
+
/**
* Checks if object with prefix passes was already created in factory
*
@@ -982,7 +981,7 @@
{
return isset($this->Factory->Storage[$name]);
}
-
+
/**
* Removes object from storage by given name
*
@@ -993,7 +992,7 @@
{
$this->Factory->DestroyObject($name);
}
-
+
/**
* Get's real class name for pseudo class,
* includes class file and creates class
@@ -1006,12 +1005,12 @@
*/
function &makeClass($pseudo_class)
{
- $func_args =& func_get_args();
+ $func_args = func_get_args();
$result =& ref_call_user_func_array( Array(&$this->Factory, 'makeClass'), $func_args);
-
+
return $result;
}
-
+
/**
* Checks if application is in debug mode
*
@@ -1023,7 +1022,7 @@
{
return defined('DEBUG_MODE') && DEBUG_MODE;
}
-
+
/**
* Checks if it is admin
*
@@ -1034,7 +1033,7 @@
{
return defined('ADMIN') && ADMIN;
}
-
+
/**
* Reads unit (specified by $prefix)
* option specified by $option
@@ -1050,7 +1049,7 @@
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->getUnitOption($prefix,$option);
}
-
+
/**
* Set's new unit option value
*
@@ -1065,7 +1064,7 @@
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->setUnitOption($prefix,$option,$value);
}
-
+
/**
* Read all unit with $prefix options
*
@@ -1079,7 +1078,7 @@
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->getUnitOptions($prefix);
}
-
+
/**
* Returns true if config exists and is allowed for reading
*
@@ -1091,7 +1090,7 @@
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->prefixRegistred($prefix);
}
-
+
/**
* Splits any mixing of prefix and
* special into correct ones
@@ -1105,7 +1104,7 @@
{
return $this->Factory->processPrefix($prefix_special);
}
-
+
/**
* Set's new event for $prefix_special
* passed
@@ -1119,8 +1118,8 @@
$event_manager =& $this->recallObject('EventManager');
$event_manager->setEvent($prefix_special,$event_name);
}
-
-
+
+
/**
* SQL Error Handler
*
@@ -1133,19 +1132,19 @@
*/
function handleSQLError($code,$msg,$sql)
{
- global $debugger;
+ global $debugger;
if($debugger)
{
$errorLevel=defined('DBG_SQL_FAILURE') && DBG_SQL_FAILURE ? E_USER_ERROR : E_USER_WARNING;
$debugger->dumpVars($_REQUEST);
$debugger->appendTrace();
-
+
$error_msg = ''.$msg.' ('.$code.')
SQL: '.$debugger->formatSQL($sql);
$long_id=$debugger->mapLongError($error_msg);
trigger_error( substr($msg.' ('.$code.') ['.$sql.']',0,1000).' #'.$long_id, $errorLevel);
return true;
}
- else
+ else
{
//$errorLevel = defined('IS_INSTALL') && IS_INSTALL ? E_USER_WARNING : E_USER_ERROR;
$errorLevel = E_USER_WARNING;
@@ -1155,7 +1154,7 @@
return $errorLevel == E_USER_ERROR ? false : true;
}
}
-
+
/**
* Default error handler
*
@@ -1174,9 +1173,9 @@
fwrite($fp, '['.$time.'] #'.$errno.': '.strip_tags($errstr).' in ['.$errfile.'] on line '.$errline."\n");
fclose($fp);
}
-
+
if( !$this->errorHandlers ) return true;
-
+
$i = 0; // while (not foreach) because it is array of references in some cases
$eh_count = count($this->errorHandlers);
while($i < $eh_count)
@@ -1195,7 +1194,7 @@
$i++;
}
}
-
+
/**
* Returns & blocks next ResourceId available in system
*
@@ -1211,7 +1210,7 @@
$this->DB->Query('UNLOCK TABLES');
return $id;
}
-
+
/**
* Returns main prefix for subtable prefix passes
*
@@ -1227,8 +1226,8 @@
$current_prefix = $parent_prefix;
}
return $current_prefix;
- }
-
+ }
+
function EmailEventAdmin($email_event_name, $to_user_id = -1, $send_params = false)
{
return $this->EmailEvent($email_event_name, 1, $to_user_id, $send_params);
@@ -1238,7 +1237,7 @@
{
return $this->EmailEvent($email_event_name, 0, $to_user_id, $send_params);
}
-
+
function EmailEvent($email_event_name, $email_event_type, $to_user_id = -1, $send_params = false)
{
$event = new kEvent('emailevents:OnEmailEvent');
@@ -1253,7 +1252,7 @@
return $event;
}
-
+
function LoggedIn()
{
$user =& $this->recallObject('u');
@@ -1268,7 +1267,7 @@
}
if( $cat_id == 0 )
{
- $cat_hierarchy = Array(0);
+ $cat_hierarchy = Array(0);
}
else
{
@@ -1280,9 +1279,9 @@
$cat_hierarchy = array_reverse($cat_hierarchy);
array_push($cat_hierarchy, 0);
}
-
+
$groups = $this->RecallVar('UserGroups');
-
+
foreach($cat_hierarchy as $category_id)
{
$sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions
@@ -1295,10 +1294,10 @@
return $res;
}
}
-
+
return 0;
}
-
+
/**
* Set's any field of current visit
*
@@ -1311,7 +1310,7 @@
$visit->SetDBField($field, $value);
$visit->Update();
}
-
+
}
?>
\ No newline at end of file