Index: trunk/core/kernel/application.php =================================================================== diff -u -r3183 -r3210 --- trunk/core/kernel/application.php (.../application.php) (revision 3183) +++ trunk/core/kernel/application.php (.../application.php) (revision 3210) @@ -117,7 +117,7 @@ if(!$instance) { - if (!defined('APPLICATION_CLASS')) define('APPLICATION_CLASS', 'kApplication'); + safeDefine('APPLICATION_CLASS', 'kApplication'); $class = APPLICATION_CLASS; $instance = new $class(); } @@ -163,25 +163,27 @@ $GLOBALS['debugger']->appendMemoryUsage('Application before Init:'); } - if( !$this->isDebugMode() ) + if( !$this->isDebugMode() && !constOn('DBG_ZEND_PRESENT') ) { error_reporting(0); ini_set('display_errors', 0); } - $error_handler = set_error_handler( Array(&$this,'handleError') ); - if($error_handler) $this->errorHandlers[] = $error_handler; - + if( !constOn('DBG_ZEND_PRESENT') ) + { + $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->ModuleInfo = $this->DB->Query('SELECT * FROM '.TABLE_PREFIX.'Modules ORDER BY LoadOrder', 'Name'); - $cms_on = defined('CMS') && CMS; $rewrite_on = $this->ConfigValue('UseModRewrite'); $admin_on = getArrayValue($_REQUEST, 'admin') || $this->IsAdmin(); - define('MOD_REWRITE', ($rewrite_on || $cms_on) && !$admin_on ? 1 : 0); + define('MOD_REWRITE', ($rewrite_on || constOn('CMS') ) && !$admin_on ? 1 : 0); $this->Factory = new kFactory(); @@ -292,7 +294,7 @@ if($theme_id > 0) return $theme_id; - if (defined('DBG_FORCE_THEME') && DBG_FORCE_THEME) + if ( constOn('DBG_FORCE_THEME') ) { $theme_id = DBG_FORCE_THEME; } @@ -391,7 +393,7 @@ */ function SetDefaultConstants() { - if (!defined('SERVER_NAME')) define('SERVER_NAME', $_SERVER['HTTP_HOST']); + safeDefine('SERVER_NAME', $_SERVER['HTTP_HOST']); $admin_dir = $this->ConfigValue('AdminDirectory'); if(!$admin_dir) $admin_dir = 'admin'; @@ -452,7 +454,7 @@ $template_cache =& $this->recallObject('TemplatesCache'); $t = $this->GetVar('t'); - if(defined('CMS') && CMS) + if( constOn('CMS') ) { $cms_handler =& $this->recallObject('cms_EventHandler'); if( !$template_cache->TemplateExists($t) ) @@ -520,7 +522,7 @@ function SaveBlocksCache() { - /*if (defined('EXPERIMENTAL_PRE_PARSE')) { + /*if (constOn('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().')'); @@ -943,7 +945,7 @@ if ($env_var) { $ret = ENV_VAR_NAME.'='; } - $ret .= defined('INPORTAL_ENV') ? $sid.'-'.$t : $sid.':'.$t; + $ret .= constOn('INPORTAL_ENV') ? $sid.'-'.$t : $sid.':'.$t; $encode = false; if (isset($params['__URLENCODE__'])) { @@ -1241,13 +1243,19 @@ /** * Checks if application is in debug mode * + * @param bool $check_debugger check if kApplication debugger is initialized too, not only for defined DEBUG_MODE constant * @return bool - * @access public * @author Alex + * @access public */ - function isDebugMode() + function isDebugMode($check_debugger = true) { - return defined('DEBUG_MODE') && DEBUG_MODE && is_object($this->Debugger); + $debug_mode = constOn('DEBUG_MODE'); + if($check_debugger) + { + $debug_mode = $debug_mode && is_object($this->Debugger); + } + return $debug_mode; } /** @@ -1258,7 +1266,7 @@ */ function IsAdmin() { - return defined('ADMIN') && ADMIN; + return constOn('ADMIN'); } /** @@ -1268,7 +1276,7 @@ */ function RewriteURLs() { - return defined('MOD_REWRITE') && MOD_REWRITE; + return constOn('MOD_REWRITE'); } /** @@ -1372,7 +1380,7 @@ global $debugger; if($debugger) { - $errorLevel=defined('DBG_SQL_FAILURE') && DBG_SQL_FAILURE ? E_USER_ERROR : E_USER_WARNING; + $errorLevel = constOn('DBG_SQL_FAILURE') ? E_USER_ERROR : E_USER_WARNING; $debugger->dumpVars($_REQUEST); $debugger->appendTrace(); @@ -1383,7 +1391,7 @@ } else { - //$errorLevel = defined('IS_INSTALL') && IS_INSTALL ? E_USER_WARNING : E_USER_ERROR; + //$errorLevel = constOn('IS_INSTALL') ? E_USER_WARNING : E_USER_ERROR; $errorLevel = E_USER_WARNING; trigger_error('SQL Error in sql: '.$sql.', code '.$code.' ('.$msg.')', $errorLevel); /*echo 'xProcessing SQL: '.$sql.'
'; @@ -1403,7 +1411,7 @@ */ function handleError($errno, $errstr, $errfile = '', $errline = '', $errcontext = '') { - if( defined('SILENT_LOG') && SILENT_LOG ) + if( constOn('SILENT_LOG') ) { $fp = fopen(FULL_PATH.'/silent_log.txt','a'); $time = date('d/m/Y H:i:s');