Index: branches/RC/core/kernel/application.php =================================================================== diff -u -N -r11085 -r11336 --- branches/RC/core/kernel/application.php (.../application.php) (revision 11085) +++ branches/RC/core/kernel/application.php (.../application.php) (revision 11336) @@ -230,10 +230,10 @@ if ($memcached_servers && class_exists('Memcache')) { $this->Memcached = new Memcache(); $servers = explode(';', $memcached_servers); - foreach ($servers as $server) { - list ($server, $port) = strpos($server, ':') !== false ? explode(':', $server, 2) : Array ($server, 11211); - $this->Memcached->addServer($server, $port); - } + foreach ($servers as $server) { + list ($server, $port) = strpos($server, ':') !== false ? explode(':', $server, 2) : Array ($server, 11211); + $this->Memcached->addServer($server, $port); + } } //try to set something to cache, if not working - set $this->Memcached to null @@ -282,8 +282,11 @@ ini_set('display_errors', 0); } if (!constOn('DBG_ZEND_PRESENT')) { - $error_handler = set_error_handler( Array(&$this,'handleError') ); - if ($error_handler) $this->errorHandlers[] = $error_handler; + $error_handler = set_error_handler( Array (&$this, 'handleError') ); + if ($error_handler) { + // wrap around previous error handler, if any was set + $this->errorHandlers[] = $error_handler; + } } $this->Conn = new kDBConnection(SQL_TYPE, Array(&$this, 'handleSQLError') ); @@ -473,9 +476,8 @@ $this->ApplicationDie('No Primary Theme Selected or Current Theme is Unknown or Disabled'); } safeDefine('THEMES_PATH', $path); - /* - $theme_id = $this->GetVar('m_theme'); + /*$theme_id = $this->GetVar('m_theme'); if (!$theme_id) { $theme_id = $this->GetDefaultThemeId(); if (!$theme_id) { @@ -486,11 +488,9 @@ $this->SetVar('theme.current_id', $theme_id ); // KOSTJA: this is to fool theme' getPassedId $theme =& $this->recallObject('theme.current'); if (!$theme->IsLoaded() || !$theme->GetDBField('Enabled')) { - if (!defined('IS_INSTALL')) $this->ApplicationDie('Unknown or disabled theme'); + if (!defined('IS_INSTALL')) $this->ApplicationDie('Unknown or disabled theme'); } - safeDefine('THEMES_PATH', '/themes/'.$theme->GetDBField('Name')); -*/ - + safeDefine('THEMES_PATH', '/themes/'.$theme->GetDBField('Name'));*/ } function GetFrontThemePath($force=0) @@ -609,11 +609,7 @@ $this->registerClass('TemplatesCache', KERNEL_PATH.'/parser/template.php',null, 'kDBTagProcessor'); $this->registerClass('Template', KERNEL_PATH.'/parser/template.php'); $this->registerClass('TemplateParser', KERNEL_PATH.'/parser/template_parser.php',null, 'kDBTagProcessor'); - - // Registring it is harmless anyway -// if (defined('NPARSER') && 'NPARSER') { - $this->registerClass('NParser', KERNEL_PATH.'/nparser/nparser.php'); -// } + $this->registerClass('NParser', KERNEL_PATH.'/nparser/nparser.php'); $this->registerClass('kEmailSendingHelper', KERNEL_PATH.'/utility/email_send.php', 'EmailSender', Array('kHelper')); $this->registerClass('kSocket', KERNEL_PATH.'/utility/socket.php', 'Socket'); @@ -808,7 +804,24 @@ define('DBG_SKIP_REPORTING', 1); } } + elseif ($this->GetVar('admin')) { + // viewing front-end through admin's frame + $admin_session =& $this->Application->recallObject('Session.admin'); + $user = (int)$admin_session->RecallVar('user_id'); // in case, when no valid admin session found + $perm_helper =& $this->recallObject('PermissionsHelper'); + /* @var $perm_helper kPermissionsHelper */ + if ($perm_helper->CheckUserPermission($user, 'CATEGORY.MODIFY', 0, 0)) { + // user can edit cms blocks + $editing_mode = $this->GetVar('editing_mode'); + define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_CMS); + } + else { + // user can't edit anything + define('EDITING_MODE', 0); + } + } + if (!$this->RequestProcessed) $this->ProcessRequest(); $this->InitParser(); @@ -882,11 +895,6 @@ $this->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); if ($this->isDebugMode()) { @@ -1057,7 +1065,6 @@ */ function GetVar($name, $default = false) { -// $http_query =& $this->recallObject('HTTPQuery'); return isset($this->HttpQuery->_Params[$name]) ? $this->HttpQuery->_Params[$name] : $default; } @@ -1087,7 +1094,6 @@ */ function SetVar($var,$val) { -// $http_query =& $this->recallObject('HTTPQuery'); return $this->HttpQuery->Set($var, $val); } @@ -1426,7 +1432,7 @@ } // append pass through variables to each link to be build -// $params = array_merge_recursive2($this->getPassThroughVariables($params), $params); + // $params = array_merge_recursive2($this->getPassThroughVariables($params), $params); $params = array_merge($this->getPassThroughVariables($params), $params); if ($force_rewrite || ($this->RewriteURLs($ssl) && !$no_rewrite)) @@ -1729,10 +1735,13 @@ if ($this->GetVar('admin') && !isset($params['admin'])) { $params['admin'] = 1; + + if (!array_key_exists('editing_mode', $params)) { + $params['editing_mode'] = EDITING_MODE; + } } - if( isset($params['escape']) && $params['escape'] ) - { + if (array_key_exists('escape', $params) && $params['escape']) { $ret = addslashes($ret); unset($params['escape']); } @@ -2372,18 +2381,15 @@ $res = false; $i = 0; // while (not foreach) because it is array of references in some cases $eh_count = count($this->errorHandlers); - while($i < $eh_count) - { - if( is_array($this->errorHandlers[$i]) ) - { + while ($i < $eh_count) { + if ( is_array($this->errorHandlers[$i]) ) { $object =& $this->errorHandlers[$i][0]; $method = $this->errorHandlers[$i][1]; $res = $object->$method($errno, $errstr, $errfile, $errline, $errcontext); } - else - { + else { $function = $this->errorHandlers[$i]; - $function($errno, $errstr, $errfile, $errline, $errcontext); + $res = $function($errno, $errstr, $errfile, $errline, $errcontext); } $i++; }