Index: branches/5.2.x/core/kernel/languages/phrases_cache.php
===================================================================
diff -u -r15012 -r15073
--- branches/5.2.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 15012)
+++ branches/5.2.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 15073)
@@ -1,6 +1,6 @@
Ids) && count($this->Ids) > 0 && $this->Ids != $this->OriginalIds;
}
- function GetPhrase($label, $allow_editing = true, $use_admin = false)
+ /**
+ * Returns translation of given label
+ *
+ * @param string $label
+ * @param bool $allow_editing return translation link, when translation is missing on current language
+ * @param bool $use_admin use current Admin Console language to translate phrase
+ * @return string
+ * @access public
+ */
+ public function GetPhrase($label, $allow_editing = true, $use_admin = false)
{
if ( !isset($this->LanguageId) ) {
//actually possible when custom field contains references to language labels and its being rebuilt in OnAfterConfigRead
Index: branches/5.2.x/core/kernel/utility/debugger.php
===================================================================
diff -u -r15012 -r15073
--- branches/5.2.x/core/kernel/utility/debugger.php (.../debugger.php) (revision 15012)
+++ branches/5.2.x/core/kernel/utility/debugger.php (.../debugger.php) (revision 15073)
@@ -1,6 +1,6 @@
rowSeparator = '@' . (is_object($application->Factory) && $application->InitDone ? $application->GetSID() : 0) . '@';
+ $this->rowSeparator = '@' . (/*is_object($application->Factory) &&*/ $application->InitDone ? $application->GetSID() : 0) . '@';
// $this->rowSeparator = '@' . rand(0, 100000) . '@';
// include debugger files from this url
@@ -1548,7 +1548,7 @@
$Debugger.DOMViewerURL = '';
$Debugger.EditorPath = '';
$Debugger.DebugURL = 'baseURL.'/debugger_responce.php?sid='.$this->rowSeparator.'&path='.urlencode($dbg_path); ?>';
- $Debugger.EventURL = 'Factory) && $application->InitDone ? $application->HREF('dummy', '', Array ('pass' => 'm', '__NO_REWRITE__' => 1)) : ''; ?>';
+ $Debugger.EventURL = 'Factory) &&*/ $application->InitDone ? $application->HREF('dummy', '', Array ('pass' => 'm', '__NO_REWRITE__' => 1)) : ''; ?>';
$Debugger.BasePath = 'basePath; ?>';
Application->GetVar('m_theme');
+ }
+
+ $not_found = $this->Application->ConfigValue('ErrorTemplate');
+ $vars['t'] = $not_found ? $not_found : 'error_notfound';
+
+ $themes_helper =& $this->Application->recallObject('ThemesHelper');
+ /* @var $themes_helper kThemesHelper */
+
+ $vars['m_cat_id'] = $themes_helper->getPageByTemplate($vars['t'], $theme_id);
+
+ header('HTTP/1.0 404 Not Found');
+
+ return $vars;
+ }
}
\ No newline at end of file
Index: branches/5.2.x/core/kernel/managers/rewrite_url_processor.php
===================================================================
diff -u -r15012 -r15073
--- branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15012)
+++ branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15073)
@@ -350,15 +350,7 @@
}
if ( $this->_partsToParse ) {
- $not_found = $this->Application->ConfigValue('ErrorTemplate');
- $vars['t'] = $not_found ? $not_found : 'error_notfound';
-
- $themes_helper =& $this->Application->recallObject('ThemesHelper');
- /* @var $themes_helper kThemesHelper */
-
- $vars['m_cat_id'] = $themes_helper->getPageByTemplate($vars['t'], $vars['m_theme']);
-
- header('HTTP/1.0 404 Not Found');
+ $vars = array_merge($vars, $this->manager->prepare404($vars['m_theme']));
}
return $vars;
Index: branches/5.2.x/core/kernel/managers/cache_manager.php
===================================================================
diff -u -r15033 -r15073
--- branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 15033)
+++ branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 15073)
@@ -1,6 +1,6 @@
Application->InitManagers();
- $this->Application->Factory->setFromCache($cache);
- $this->Application->UnitConfigReader->setFromCache($cache);
- $this->Application->EventManager->setFromCache($cache);
+ $this->Application->setFromCache($cache);
$aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
/* @var $aggregator kArray */
$aggregator->setFromCache($cache);
$this->setFromCache($cache);
- $this->Application->setFromCache($cache);
unset($cache);
return true;
@@ -311,10 +308,13 @@
*/
public function EmptyUnitCache()
{
+ // maybe discover keys automatically from corresponding classes
$cache_keys = Array (
'Factory.Files', 'Factory.realClasses', 'Factory.Dependencies',
- 'EventManager.buildEvents', 'EventManager.beforeHooks',
- 'EventManager.afterHooks', 'EventManager.scheduledTasks',
+ 'ConfigReader.prefixFiles',
+ 'EventManager.beforeHooks', 'EventManager.afterHooks', 'EventManager.scheduledTasks', 'EventManager.buildEvents',
+ 'Application.ReplacementTemplates', 'Application.RewriteListeners', 'Application.ModuleInfo',
+ 'Application.ConfigHash', 'Application.ConfigCacheIds',
);
$empty_cache = Array ();
@@ -323,8 +323,8 @@
$empty_cache[$cache_key] = Array ();
}
- $this->Application->Factory->setFromCache($empty_cache);
- $this->Application->EventManager->setFromCache($empty_cache);
+ $this->Application->setFromCache($empty_cache);
+ $this->setFromCache($empty_cache);
// otherwise ModulesHelper indirectly used from includeConfigFiles won't work
$this->Application->RegisterDefaultClasses();
@@ -343,12 +343,9 @@
$this->preloadConfigVars(); // preloading will put to cache
$cache = array_merge(
- $this->Application->Factory->getToCache(),
- $this->Application->UnitConfigReader->getToCache(),
- $this->Application->EventManager->getToCache(),
+ $this->Application->getToCache(),
$aggregator->getToCache(),
- $this->getToCache(),
- $this->Application->getToCache()
+ $this->getToCache()
);
$cache_rebuild_by = SERVER_NAME . ' (' . getenv('REMOTE_ADDR') . ') - ' . adodb_date('d/m/Y H:i:s');
Index: branches/5.2.x/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -r15033 -r15073
--- branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 15033)
+++ branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 15073)
@@ -1,6 +1,6 @@
prefixFiles;
$this->Application->cacheManager->EmptyUnitCache();
+ $this->prefixFiles = $prefix_files_backup;
// parse all configs
$this->ProcessAllConfigs = true;
Index: branches/5.2.x/core/kernel/application.php
===================================================================
diff -u -r15033 -r15073
--- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15033)
+++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15073)
@@ -1,6 +1,6 @@
-* The class incapsulates the main run-cycle of the script, provide access to all other objects in the framework.
+* The class encapsulates 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 kApplication in the script.
* This could be guaranteed by NOT calling the class constructor directly, but rather calling kApplication::Instance() method,
@@ -37,117 +37,131 @@
*
* @var bool
*/
- var $InitDone = false;
+ public $InitDone = false;
/**
- * Holds internal NParser object
- * @access private
- * @var NParser
- */
- var $Parser;
+ * Holds internal NParser object
+ *
+ * @var NParser
+ * @access public
+ */
+ public $Parser;
/**
- * Holds parser output buffer
- * @access private
- * @var string
- */
- var $HTML;
+ * Holds parser output buffer
+ *
+ * @var string
+ * @access protected
+ */
+ protected $HTML = '';
/**
- * The main Factory used to create
- * almost any class of kernel and
- * modules
- *
- * @access private
- * @var kFactory
- */
- var $Factory;
+ * The main Factory used to create
+ * almost any class of kernel and
+ * modules
+ *
+ * @var kFactory
+ * @access protected
+ */
+ protected $Factory;
/**
* Template names, that will be used instead of regular templates
*
* @var Array
+ * @access public
*/
- var $ReplacementTemplates = Array ();
+ public $ReplacementTemplates = Array ();
/**
* Mod-Rewrite listeners used during url building and parsing
*
* @var Array
+ * @access public
*/
- var $RewriteListeners = Array ();
+ public $RewriteListeners = Array ();
/**
* Reference to debugger
*
* @var Debugger
+ * @access public
*/
- var $Debugger = null;
+ public $Debugger = null;
/**
* Holds all phrases used
* in code and template
*
* @var PhrasesCache
+ * @access public
*/
- var $Phrases;
+ public $Phrases;
/**
* Modules table content, key - module name
*
* @var Array
+ * @access public
*/
- var $ModuleInfo = Array();
+ public $ModuleInfo = Array ();
/**
* Holds DBConnection
*
* @var kDBConnection
+ * @access public
*/
- var $Conn = null;
+ public $Conn = null;
/**
* Maintains list of user-defined error handlers
*
* @var Array
+ * @access public
*/
- var $errorHandlers = Array();
+ public $errorHandlers = Array ();
/**
* Maintains list of user-defined exception handlers
*
* @var Array
+ * @access public
*/
- var $exceptionHandlers = Array();
+ public $exceptionHandlers = Array ();
// performance needs:
/**
* Holds a reference to httpquery
*
* @var kHttpQuery
+ * @access public
*/
- var $HttpQuery = null;
+ public $HttpQuery = null;
/**
* Holds a reference to UnitConfigReader
*
* @var kUnitConfigReader
+ * @access public
*/
- var $UnitConfigReader = null;
+ public $UnitConfigReader = null;
/**
* Holds a reference to Session
*
* @var Session
+ * @access public
*/
- var $Session = null;
+ public $Session = null;
/**
* Holds a ref to kEventManager
*
* @var kEventManager
+ * @access public
*/
- var $EventManager = null;
+ public $EventManager = null;
/**
* Holds a ref to kUrlManager
@@ -161,89 +175,92 @@
* Ref for TemplatesCache
*
* @var TemplatesCache
+ * @access public
*/
- var $TemplatesCache = null;
+ public $TemplatesCache = null;
- var $CompilationCache = array(); //used when compiling templates
- var $CachedProcessors = array(); //used when running compiled templates
-
- var $LambdaElements = 1; // for autonumbering unnamed RenderElements [any better place for this prop? KT]
-
/**
* Holds current NParser tag while parsing, can be used in error messages to display template file and line
*
* @var _BlockTag
+ * @access public
*/
- var $CurrentNTag = null;
+ public $CurrentNTag = null;
/**
* Object of unit caching class
*
* @var kCacheManager
+ * @access public
*/
- var $cacheManager = null;
+ public $cacheManager = null;
/**
* Tells, that administrator has authenticated in administrative console
* Should be used to manipulate data change OR data restrictions!
*
* @var bool
+ * @access public
*/
- var $isAdminUser = false;
+ public $isAdminUser = false;
/**
* Tells, that admin version of "index.php" was used, nothing more!
* Should be used to manipulate data display!
*
* @var bool
+ * @access public
*/
- var $isAdmin = false;
+ public $isAdmin = false;
- /**
+ /**
* Instance of site domain object
*
* @var kDBItem
+ * @access public
+ * @todo move away into separate module
*/
- var $siteDomain = null;
+ public $siteDomain = null;
/**
* Prevent kApplication class to be created directly, only via Instance method
*
+ * @access protected
*/
protected function __construct()
{
}
/**
- * Returns kApplication instance anywhere in the script.
- *
- * This method should be used to get single kApplication object instance anywhere in the
- * Kernel-based application. The method is guaranteed to return the SAME instance of kApplication.
- * Anywhere in the script you could write:
- *
- * $application =& kApplication::Instance();
- *
- * or in an object:
- *
- * $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 descendant 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.
- *
- * Pattern: Singleton
- *
- * @static
- * @access public
- * @return kApplication
- */
+ * Returns kApplication instance anywhere in the script.
+ *
+ * This method should be used to get single kApplication object instance anywhere in the
+ * Kernel-based application. The method is guaranteed to return the SAME instance of kApplication.
+ * Anywhere in the script you could write:
+ *
+ * $application =& kApplication::Instance();
+ *
+ * or in an object:
+ *
+ * $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 descendant 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.
+ *
+ * Pattern: Singleton
+ *
+ * @static
+ * @return kApplication
+ * @access public
+ */
public static function &Instance()
{
static $instance = false;
- if (!$instance) {
+ if ( !$instance ) {
$class = defined('APPLICATION_CLASS') ? APPLICATION_CLASS : 'kApplication';
$instance = new $class();
$instance->Application =& $instance;
@@ -253,14 +270,14 @@
}
/**
- * Initializes the Application
- *
- * @access public
- * @see kHTTPQuery
- * @see Session
- * @see TemplatesCache
- * @return bool Was Init actually made now or before
- */
+ * Initializes the Application
+ *
+ * @return bool Was Init actually made now or before
+ * @access public
+ * @see kHTTPQuery
+ * @see Session
+ * @see TemplatesCache
+ */
public function Init()
{
if ( $this->InitDone ) {
@@ -398,11 +415,18 @@
return true;
}
- function InitManagers()
+ /**
+ * Performs initialization of manager classes, that can be overridden from unit configs
+ *
+ * @return void
+ * @access public
+ * @throws Exception
+ */
+ public function InitManagers()
{
- if ($this->InitDone) {
+ if ( $this->InitDone ) {
throw new Exception('Duplicate call of ' . __METHOD__, E_USER_ERROR);
- return ;
+ return;
}
$this->UrlManager =& $this->makeClass('kUrlManager');
@@ -420,7 +444,7 @@
* @param string $return_field field value to returns, if not specified, then return all fields
* @return Array
*/
- function findModule($field, $value, $return_field = null)
+ public function findModule($field, $value, $return_field = null)
{
$found = $module_info = false;
@@ -446,9 +470,9 @@
*/
public function refreshModuleInfo()
{
- if (defined('IS_INSTALL') && IS_INSTALL && !$this->TableFound('Modules', true)) {
+ if ( defined('IS_INSTALL') && IS_INSTALL && !$this->TableFound('Modules', true) ) {
$this->registerModuleConstants();
- return ;
+ return;
}
// use makeClass over recallObject, since used before kApplication initialization during installation
@@ -468,12 +492,14 @@
/**
* Checks if passed language id if valid and sets it to primary otherwise
*
+ * @return void
+ * @access public
*/
- function VerifyLanguageId()
+ public function VerifyLanguageId()
{
$language_id = $this->GetVar('m_lang');
- if (!$language_id) {
+ if ( !$language_id ) {
$language_id = 'default';
}
@@ -486,30 +512,32 @@
$lang =& $this->recallObject('lang.current');
/* @var $lang kDBItem */
- if (!$lang->isLoaded() || (!$this->isAdmin && !$lang->GetDBField('Enabled'))) {
- if (!defined('IS_INSTALL')) {
+ if ( !$lang->isLoaded() || (!$this->isAdmin && !$lang->GetDBField('Enabled')) ) {
+ if ( !defined('IS_INSTALL') ) {
$this->ApplicationDie('Unknown or disabled language');
}
}
- $this->SetVar('lang_mode',$lang_mode);
+ $this->SetVar('lang_mode', $lang_mode);
}
/**
* Checks if passed theme id if valid and sets it to primary otherwise
*
+ * @return void
+ * @access public
*/
- function VerifyThemeId()
+ public function VerifyThemeId()
{
- if ($this->isAdmin) {
+ if ( $this->isAdmin ) {
kUtil::safeDefine('THEMES_PATH', '/core/admin_templates');
return;
}
$path = $this->GetFrontThemePath();
- if ($path === false) {
+ if ( $path === false ) {
$this->ApplicationDie('No Primary Theme Selected or Current Theme is Unknown or Disabled');
}
@@ -1081,6 +1109,17 @@
}
/**
+ * Only renders template
+ *
+ * @see kDBEventHandler::_errorNotFound()
+ */
+ public function QuickRun()
+ {
+ $this->InitParser();
+ $this->HTML = $this->ParseBlock(Array ('name' => $this->GetVar('t')));
+ }
+
+ /**
* Performs template parser/cache initialization
*
* @param bool|string $theme_name
@@ -1567,13 +1606,14 @@
}
/**
- * Return ADODB Connection object
- *
- * Returns ADODB Connection object already connected to the project database, configurable in config.php
- * @access public
- * @return kDBConnection
- */
- function &GetADODBConnection()
+ * Return ADODB Connection object
+ *
+ * Returns ADODB Connection object already connected to the project database, configurable in config.php
+ *
+ * @return kDBConnection
+ * @access public
+ */
+ public function &GetADODBConnection()
{
return $this->Conn;
}
@@ -1585,10 +1625,11 @@
* @param bool $pass_params Forces to pass current parser params to this block/template. Use with caution, because you can accidentally pass "block_no_data" parameter.
* @param bool $as_template
* @return string
+ * @access public
*/
- function ParseBlock($params, $pass_params = false, $as_template = false)
+ public function ParseBlock($params, $pass_params = false, $as_template = false)
{
- if (substr($params['name'], 0, 5) == 'html:') {
+ if ( substr($params['name'], 0, 5) == 'html:' ) {
return substr($params['name'], 5);
}
@@ -1600,8 +1641,9 @@
*
* @param string $name
* @return bool
+ * @access public
*/
- function ParserBlockFound($name)
+ public function ParserBlockFound($name)
{
return $this->Parser->blockFound($name);
}
@@ -1611,8 +1653,9 @@
*
* @param Array $params Parameters to pass to template. Reserved parameter "name" used to specify template name.
* @return string
+ * @access public
*/
- function IncludeTemplate($params)
+ public function IncludeTemplate($params)
{
return $this->Parser->IncludeTemplate($params, isset($params['is_silent']) ? 1 : 0);
}
@@ -1660,12 +1703,24 @@
*
* @param Array $params
* @return Array
+ * @access public
*/
- function getPassThroughVariables(&$params)
+ public function getPassThroughVariables(&$params)
{
return $this->UrlManager->getPassThroughVariables($params);
}
+ /**
+ * Builds url
+ *
+ * @param string $t
+ * @param Array $params
+ * @param string $pass
+ * @param bool $pass_events
+ * @param bool $env_var
+ * @return string
+ * @access public
+ */
public function BuildEnv($t, $params, $pass = 'all', $pass_events = false, $env_var = true)
{
return $this->UrlManager->plain->build($t, $params, $pass, $pass_events, $env_var);
@@ -1687,18 +1742,27 @@
return $this->UrlManager->plain->parse($env_var, $pass_name);
}
- function BaseURL($prefix = '', $ssl = null, $add_port = true)
+ /**
+ * Returns base part of all urls, build on website
+ *
+ * @param string $prefix
+ * @param bool $ssl
+ * @param bool $add_port
+ * @return string
+ * @access public
+ */
+ public function BaseURL($prefix = '', $ssl = null, $add_port = true)
{
- if ($ssl === null) {
+ if ( $ssl === null ) {
// stay on same encryption level
return PROTOCOL . SERVER_NAME . ($add_port && defined('PORT') ? ':' . PORT : '') . BASE_PATH . $prefix . '/';
}
- if ($ssl) {
+ if ( $ssl ) {
// going from http:// to https://
$base_url = $this->isAdmin ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$base_url) {
+ if ( !$base_url ) {
$ssl_url = $this->siteDomainField('SSLUrl');
$base_url = $ssl_url !== false ? $ssl_url : $this->ConfigValue('SSL_URL');
}
@@ -1709,48 +1773,58 @@
// going from https:// to http://
$domain = $this->siteDomainField('DomainName');
- if ($domain === false) {
+ if ( $domain === false ) {
$domain = DOMAIN;
}
return 'http://' . $domain . ($add_port && defined('PORT') ? ':' . PORT : '') . BASE_PATH . $prefix . '/';
}
- function Redirect($t = '', $params = Array(), $prefix = '', $index_file = null)
+ /**
+ * Redirects user to url, that's build based on given parameters
+ *
+ * @param string $t
+ * @param Array $params
+ * @param string $prefix
+ * @param string $index_file
+ * @return void
+ * @access public
+ */
+ public function Redirect($t = '', $params = Array(), $prefix = '', $index_file = null)
{
$js_redirect = getArrayValue($params, 'js_redirect');
- if ($t == '' || $t === true) {
+ if ( $t == '' || $t === true ) {
$t = $this->GetVar('t');
}
// pass prefixes and special from previous url
- if (array_key_exists('js_redirect', $params)) {
+ if ( array_key_exists('js_redirect', $params) ) {
unset($params['js_redirect']);
}
// allows to send custom responce code along with redirect header
- if (array_key_exists('response_code', $params)) {
+ if ( array_key_exists('response_code', $params) ) {
$response_code = (int)$params['response_code'];
unset($params['response_code']);
}
else {
$response_code = 302; // Found
}
- if (!array_key_exists('pass', $params)) {
+ if ( !array_key_exists('pass', $params) ) {
$params['pass'] = 'all';
}
- if ($this->GetVar('ajax') == 'yes' && $t == $this->GetVar('t')) {
+ if ( $this->GetVar('ajax') == 'yes' && $t == $this->GetVar('t') ) {
// redirects to the same template as current
$params['ajax'] = 'yes';
}
$params['__URLENCODE__'] = 1;
$location = $this->HREF($t, $prefix, $params, $index_file);
- if ($this->isDebugMode() && (kUtil::constOn('DBG_REDIRECT') || (kUtil::constOn('DBG_RAISE_ON_WARNINGS') && $this->Debugger->WarningCount))) {
+ if ( $this->isDebugMode() && (kUtil::constOn('DBG_REDIRECT') || (kUtil::constOn('DBG_RAISE_ON_WARNINGS') && $this->Debugger->WarningCount)) ) {
$this->Debugger->appendTrace();
echo 'Debug output above !!!
' . "\n";
@@ -1761,7 +1835,7 @@
echo "Proceed to redirect: {$location}
\n";
}
else {
- if ($js_redirect) {
+ if ( $js_redirect ) {
// show "redirect" template instead of redirecting,
// because "Set-Cookie" header won't work, when "Location"
// header is used later
@@ -1773,16 +1847,16 @@
$this->SetVar($name, $value);
}
- return true;
+ return;
}
else {
- if ($this->GetVar('ajax') == 'yes' && $t != $this->GetVar('t')) {
+ if ( $this->GetVar('ajax') == 'yes' && $t != $this->GetVar('t') ) {
// redirection to other then current template during ajax request
kUtil::safeDefine('DBG_SKIP_REPORTING', 1);
echo '#redirect#' . $location;
}
- elseif (headers_sent() != '') {
- // some output occured -> redirect using javascript
+ elseif ( headers_sent() != '' ) {
+ // some output occurred -> redirect using javascript
echo '';
}
else {
@@ -1799,14 +1873,23 @@
$session =& $this->recallObject('Session');
/* @var $session Session */
- $this->HandleEvent( new kEvent('adm:OnBeforeShutdown') );
+ $this->HandleEvent(new kEvent('adm:OnBeforeShutdown'));
$session->SaveData();
ob_end_flush();
exit;
}
- function Phrase($label, $allow_editing = true, $use_admin = false)
+ /**
+ * Returns translation of given label
+ *
+ * @param string $label
+ * @param bool $allow_editing return translation link, when translation is missing on current language
+ * @param bool $use_admin use current Admin Console language to translate phrase
+ * @return string
+ * @access public
+ */
+ public function Phrase($label, $allow_editing = true, $use_admin = false)
{
return $this->Phrases->GetPhrase($label, $allow_editing, $use_admin);
}
@@ -1819,7 +1902,7 @@
* @return string
* @access public
*/
- function ReplaceLanguageTags($text, $force_escape = null)
+ public function ReplaceLanguageTags($text, $force_escape = null)
{
return $this->Phrases->ReplaceLanguageTags($text, $force_escape);
}
@@ -1830,9 +1913,10 @@
* later using "u.current" prefix_special. Also you may
* get user id by getting "u.current_id" variable.
*
- * @access private
+ * @return void
+ * @access protected
*/
- function ValidateLogin()
+ protected function ValidateLogin()
{
$session =& $this->recallObject('Session');
/* @var $session Session */
@@ -1881,8 +1965,10 @@
/**
* Loads current user persistent session data
*
+ * @return void
+ * @access public
*/
- function LoadPersistentVars()
+ public function LoadPersistentVars()
{
$this->Session->LoadPersistentVars();
}
@@ -1892,8 +1978,9 @@
*
* @param string $name
* @return string
+ * @access public
*/
- function ConfigValue($name)
+ public function ConfigValue($name)
{
return $this->cacheManager->ConfigValue($name);
}
@@ -1919,9 +2006,8 @@
* @param Array $params
* @param Array $specific_params
* @access public
- * @author Alex
*/
- function HandleEvent(&$event, $params = null, $specific_params = null)
+ public function HandleEvent(&$event, $params = null, $specific_params = null)
{
if ( isset($params) ) {
$event = new kEvent($params, $specific_params);
@@ -1936,22 +2022,24 @@
* @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
+ * @param Array $dependencies List of classes required for this class functioning
+ * @return void
* @access public
- * @author Alex
*/
- function registerClass($real_class, $file, $pseudo_class = null, $dependecies = Array() )
+ public function registerClass($real_class, $file, $pseudo_class = null, $dependencies = Array() )
{
- $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependecies);
+ $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependencies);
}
/**
* Unregisters existing class from factory
*
* @param string $real_class Real name of class as in class declaration
* @param string $pseudo_class Name under this class object is accessed using getObject method
+ * @return void
+ * @access public
*/
- function unregisterClass($real_class, $pseudo_class = null)
+ public function unregisterClass($real_class, $pseudo_class = null)
{
$this->Factory->unregisterClass($real_class, $pseudo_class);
}
@@ -1962,9 +2050,10 @@
*
* @param string $depended_class
* @param string $class_name
- * @author Alex
+ * @return void
+ * @access public
*/
- function registerDependency($depended_class, $class_name)
+ public function registerDependency($depended_class, $class_name)
{
$this->Factory->registerDependency($depended_class, $class_name);
}
@@ -2015,14 +2104,15 @@
* Allows one TagProcessor tag act as other TagProcessor tag
*
* @param Array $tag_info
- * @author Kostja
+ * @return void
+ * @access public
*/
- function registerAggregateTag($tag_info)
+ public function registerAggregateTag($tag_info)
{
$aggregator =& $this->recallObject('TagsAggregator', 'kArray');
/* @var $aggregator kArray */
- $tag_data = Array(
+ $tag_data = Array (
$tag_info['LocalPrefix'],
$tag_info['LocalTagName'],
getArrayValue($tag_info, 'LocalSpecial')
@@ -2057,8 +2147,9 @@
*
* @param string $prefix
* @return kDBTagProcessor
+ * @access public
*/
- function &recallTagProcessor($prefix)
+ public function &recallTagProcessor($prefix)
{
$this->InitParser(); // because kDBTagProcesor is in NParser dependencies
$result =& $this->recallObject($prefix . '_TagProcessor');
@@ -2069,11 +2160,11 @@
/**
* Checks if object with prefix passes was already created in factory
*
- * @param string $name object presudo_class, prefix
+ * @param string $name object pseudo_class, prefix
* @return bool
- * @author Kostja
+ * @access public
*/
- function hasObject($name)
+ public function hasObject($name)
{
return isset($this->Factory->Storage[$name]);
}
@@ -2082,7 +2173,8 @@
* Removes object from storage by given name
*
* @param string $name Object's name in the Storage
- * @author Kostja
+ * @return void
+ * @access public
*/
public function removeObject($name)
{
@@ -2128,8 +2220,9 @@
*
* @param bool|null $ssl Force ssl link to be build
* @return bool
+ * @access public
*/
- function RewriteURLs($ssl = false)
+ public function RewriteURLs($ssl = false)
{
// case #1,#4:
// we want to create https link from http mode
@@ -2219,11 +2312,12 @@
*
* @param string $prefix_special
* @param string $event_name
+ * @return void
* @access public
*/
- function setEvent($prefix_special, $event_name)
+ public function setEvent($prefix_special, $event_name)
{
- $this->EventManager->setEvent($prefix_special,$event_name);
+ $this->EventManager->setEvent($prefix_special, $event_name);
}
/**
@@ -2233,10 +2327,9 @@
* @param string $msg
* @param string $sql
* @return bool
- * @access private
- * @author Alex
+ * @access public
*/
- function handleSQLError($code, $msg, $sql)
+ public function handleSQLError($code, $msg, $sql)
{
if ( isset($this->Debugger) ) {
$long_error_msg = '' . $msg . ' (' . $code . ')
SQL: ' . $this->Debugger->formatSQL($sql);
@@ -2451,21 +2544,22 @@
*
* @return int
* @access public
- * @author Alex
*/
- function NextResourceId()
+ public function NextResourceId()
{
- $table_name = TABLE_PREFIX.'IdGenerator';
+ $table_name = TABLE_PREFIX . 'IdGenerator';
- $this->Conn->Query('LOCK TABLES '.$table_name.' WRITE');
- $this->Conn->Query('UPDATE '.$table_name.' SET lastid = lastid + 1');
- $id = $this->Conn->GetOne('SELECT lastid FROM '.$table_name);
- if($id === false)
- {
- $this->Conn->Query('INSERT INTO '.$table_name.' (lastid) VALUES (2)');
+ $this->Conn->Query('LOCK TABLES ' . $table_name . ' WRITE');
+ $this->Conn->Query('UPDATE ' . $table_name . ' SET lastid = lastid + 1');
+ $id = $this->Conn->GetOne('SELECT lastid FROM ' . $table_name);
+
+ if ( $id === false ) {
+ $this->Conn->Query('INSERT INTO ' . $table_name . ' (lastid) VALUES (2)');
$id = 2;
}
+
$this->Conn->Query('UNLOCK TABLES');
+
return $id - 1;
}
@@ -2478,12 +2572,12 @@
* @return string
* @access public
*/
- function GetTopmostPrefix($current_prefix, $real_top = false)
+ public function GetTopmostPrefix($current_prefix, $real_top = false)
{
// 1. get genealogical tree of $current_prefix
$prefixes = Array ($current_prefix);
- while ( $parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix') ) {
- if (!$this->prefixRegistred($parent_prefix)) {
+ while ($parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix')) {
+ if ( !$this->prefixRegistred($parent_prefix) ) {
// stop searching, when parent prefix is not registered
break;
}
@@ -2492,14 +2586,14 @@
array_unshift($prefixes, $current_prefix);
}
- if ($real_top) {
+ if ( $real_top ) {
return $current_prefix;
}
// 2. find what if parent is passed
$passed = explode(',', $this->GetVar('all_passed'));
foreach ($prefixes as $a_prefix) {
- if (in_array($a_prefix, $passed)) {
+ if ( in_array($a_prefix, $passed) ) {
return $a_prefix;
}
}
@@ -2514,8 +2608,9 @@
* @param int $to_user_id
* @param array $send_params associative array of direct send params, possible keys: to_email, to_name, from_email, from_name, message, message_text
* @return kEvent
+ * @access public
*/
- function &EmailEventAdmin($email_event_name, $to_user_id = null, $send_params = Array ())
+ public function &EmailEventAdmin($email_event_name, $to_user_id = null, $send_params = Array ())
{
$event =& $this->EmailEvent($email_event_name, EmailEvent::EVENT_TYPE_ADMIN, $to_user_id, $send_params);
@@ -2529,8 +2624,9 @@
* @param int $to_user_id
* @param array $send_params associative array of direct send params, possible keys: to_email, to_name, from_email, from_name, message, message_text
* @return kEvent
+ * @access public
*/
- function &EmailEventUser($email_event_name, $to_user_id = null, $send_params = Array ())
+ public function &EmailEventUser($email_event_name, $to_user_id = null, $send_params = Array ())
{
$event =& $this->EmailEvent($email_event_name, EmailEvent::EVENT_TYPE_FRONTEND, $to_user_id, $send_params);
@@ -2546,8 +2642,9 @@
* @param array $send_params associative array of direct send params,
* possible keys: to_email, to_name, from_email, from_name, message, message_text
* @return kEvent
+ * @access protected
*/
- function &EmailEvent($email_event_name, $email_event_type, $to_user_id = null, $send_params = Array ())
+ protected function &EmailEvent($email_event_name, $email_event_type, $to_user_id = null, $send_params = Array ())
{
$params = Array (
'EmailEventName' => $email_event_name,
@@ -2556,7 +2653,7 @@
'DirectSendParams' => $send_params,
);
- if (array_key_exists('use_special', $send_params)) {
+ if ( array_key_exists('use_special', $send_params) ) {
$event_str = 'emailevents.' . $send_params['use_special'] . ':OnEmailEvent';
}
else {
@@ -2572,8 +2669,9 @@
* Allows to check if user in this session is logged in or not
*
* @return bool
+ * @access public
*/
- function LoggedIn()
+ public function LoggedIn()
{
// no session during expiration process
return is_null($this->Session) ? false : $this->Session->LoggedIn();
@@ -2586,24 +2684,26 @@
* @param int $cat_id category id, current used if not specified
* @param int $type permission type {1 - system, 0 - per category}
* @return int
+ * @access public
*/
- function CheckPermission($name, $type = 1, $cat_id = null)
+ public function CheckPermission($name, $type = 1, $cat_id = null)
{
$perm_helper =& $this->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
return $perm_helper->CheckPermission($name, $type, $cat_id);
}
- /**
+ /**
* Check current admin permissions based on it's group permissions in specified category
*
* @param string $name permission name
* @param int $cat_id category id, current used if not specified
* @param int $type permission type {1 - system, 0 - per category}
* @return int
+ * @access public
*/
- function CheckAdminPermission($name, $type = 1, $cat_id = null)
+ public function CheckAdminPermission($name, $type = 1, $cat_id = null)
{
$perm_helper =& $this->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
@@ -2616,18 +2716,21 @@
*
* @param string $field
* @param mixed $value
+ * @return void
+ * @access public
+ * @todo move to separate module
*/
- function setVisitField($field, $value)
+ public function setVisitField($field, $value)
{
- if ($this->isAdmin || !$this->ConfigValue('UseVisitorTracking')) {
- // admin logins are not registred in visits list
- return ;
+ if ( $this->isAdmin || !$this->ConfigValue('UseVisitorTracking') ) {
+ // admin logins are not registered in visits list
+ return;
}
$visit =& $this->recallObject('visits', null, Array ('raise_warnings' => 0));
/* @var $visit kDBItem */
- if ($visit->isLoaded()) {
+ if ( $visit->isLoaded() ) {
$visit->SetDBField($field, $value);
$visit->Update();
}
@@ -2637,8 +2740,9 @@
* Allows to check if in-portal is installed
*
* @return bool
+ * @access public
*/
- function isInstalled()
+ public function isInstalled()
{
return $this->InitDone && (count($this->ModuleInfo) > 0);
}
@@ -2648,8 +2752,9 @@
*
* @param string $module_name
* @return bool
+ * @access public
*/
- function isModuleEnabled($module_name)
+ public function isModuleEnabled($module_name)
{
return $this->findModule('Name', $module_name) !== false;
}
@@ -2658,12 +2763,14 @@
* Returns Window ID of passed prefix main prefix (in edit mode)
*
* @param string $prefix
- * @return mixed
+ * @return int
+ * @access public
*/
- function GetTopmostWid($prefix)
+ public function GetTopmostWid($prefix)
{
$top_prefix = $this->GetTopmostPrefix($prefix);
- $mode = $this->GetVar($top_prefix.'_mode');
+ $mode = $this->GetVar($top_prefix . '_mode');
+
return $mode != '' ? substr($mode, 1) : '';
}
@@ -2673,27 +2780,42 @@
* @param string $table
* @param mixed $wid
* @return string
+ * @access public
*/
- function GetTempName($table, $wid = '')
+ public function GetTempName($table, $wid = '')
{
return $this->GetTempTablePrefix($wid) . $table;
}
- function GetTempTablePrefix($wid = '')
+ /**
+ * Builds temporary table prefix based on given window id
+ *
+ * @param string $wid
+ * @return string
+ * @access public
+ */
+ public function GetTempTablePrefix($wid = '')
{
- if (preg_match('/prefix:(.*)/', $wid, $regs)) {
+ if ( preg_match('/prefix:(.*)/', $wid, $regs) ) {
$wid = $this->GetTopmostWid($regs[1]);
}
return TABLE_PREFIX . 'ses_' . $this->GetSID() . ($wid ? '_' . $wid : '') . '_edit_';
}
- function IsTempTable($table)
+ /**
+ * Checks if given table is a temporary table
+ *
+ * @param string $table
+ * @return bool
+ * @access public
+ */
+ public function IsTempTable($table)
{
static $cache = Array ();
if ( !array_key_exists($table, $cache) ) {
- $cache[$table] = preg_match('/'.TABLE_PREFIX.'ses_'.$this->GetSID().'(_[\d]+){0,1}_edit_(.*)/',$table);
+ $cache[$table] = preg_match('/' . TABLE_PREFIX . 'ses_' . $this->GetSID() . '(_[\d]+){0,1}_edit_(.*)/', $table);
}
return (bool)$cache[$table];
@@ -2705,8 +2827,9 @@
* @param string $prefix
* @param string $special
* @return bool
+ * @access public
*/
- function IsTempMode($prefix, $special = '')
+ public function IsTempMode($prefix, $special = '')
{
$top_prefix = $this->GetTopmostPrefix($prefix);
@@ -2721,7 +2844,8 @@
$temp_mode = false;
foreach ($var_names as $var_name) {
$value = $this->GetVar($var_name . '_mode');
- if ($value && (substr($value, 0, 1) == 't')) {
+
+ if ( $value && (substr($value, 0, 1) == 't') ) {
$temp_mode = true;
break;
}
@@ -2736,44 +2860,42 @@
* @param string $temp_table
* @return string
*/
- function GetLiveName($temp_table)
+ public function GetLiveName($temp_table)
{
- if( preg_match('/'.TABLE_PREFIX.'ses_'.$this->GetSID().'(_[\d]+){0,1}_edit_(.*)/',$temp_table, $rets) )
- {
+ if ( preg_match('/' . TABLE_PREFIX . 'ses_' . $this->GetSID() . '(_[\d]+){0,1}_edit_(.*)/', $temp_table, $rets) ) {
// cut wid from table end if any
return $rets[2];
}
- else
- {
+ else {
return $temp_table;
}
}
- function CheckProcessors($processors)
+ /**
+ * Stops processing of user request and displays given message
+ *
+ * @param string $message
+ * @access public
+ */
+ public function ApplicationDie($message = '')
{
- foreach ($processors as $a_processor)
- {
- if (!isset($this->CachedProcessors[$a_processor])) {
- $this->CachedProcessors[$a_processor] =& $this->recallObject($a_processor.'_TagProcessor');
- }
- }
- }
+ $message = ob_get_clean() . $message;
- function ApplicationDie($message = '')
- {
- $message = ob_get_clean().$message;
- if ($this->isDebugMode()) {
+ if ( $this->isDebugMode() ) {
$message .= $this->Debugger->printReport(true);
}
echo $this->UseOutputCompression() ? gzencode($message, DBG_COMPRESSION_LEVEL) : $message;
exit;
}
-
- /* moved from MyApplication */
-
- function getUserGroups($user_id)
+ /**
+ * Returns comma-separated list of groups from given user
+ *
+ * @param int $user_id
+ * @return string
+ */
+ public function getUserGroups($user_id)
{
switch ($user_id) {
case USER_ROOT:
@@ -2790,8 +2912,8 @@
WHERE PortalUserId = ' . (int)$user_id;
$res = $this->Conn->GetCol($sql);
- $user_groups = Array( $this->ConfigValue('User_LoggedInGroup') );
- if ($res) {
+ $user_groups = Array ($this->ConfigValue('User_LoggedInGroup'));
+ if ( $res ) {
$user_groups = array_merge($user_groups, $res);
}
@@ -2806,34 +2928,36 @@
* Allows to detect if page is browsed by spider (293 scheduled_tasks supported)
*
* @return bool
+ * @access public
*/
- function IsSpider()
+ /*public function IsSpider()
{
static $is_spider = null;
- if (!isset($is_spider)) {
+ if ( !isset($is_spider) ) {
$user_agent = trim($_SERVER['HTTP_USER_AGENT']);
- $robots = file(FULL_PATH.'/core/robots_list.txt');
+ $robots = file(FULL_PATH . '/core/robots_list.txt');
foreach ($robots as $robot_info) {
$robot_info = explode("\t", $robot_info, 3);
- if ($user_agent == trim($robot_info[2])) {
+ if ( $user_agent == trim($robot_info[2]) ) {
$is_spider = true;
break;
}
}
}
return $is_spider;
- }
+ }*/
/**
- * Allows to detect table's presense in database
+ * Allows to detect table's presence in database
*
* @param string $table_name
* @param bool $force
* @return bool
+ * @access public
*/
- function TableFound($table_name, $force = false)
+ public function TableFound($table_name, $force = false)
{
return $this->Conn->TableFound($table_name, $force);
}
@@ -2843,11 +2967,12 @@
*
* @param string $name counter name
* @param Array $params counter parameters
- * @param string $query_name specify query name directly (don't generate from parmeters)
+ * @param string $query_name specify query name directly (don't generate from parameters)
* @param bool $multiple_results
* @return mixed
+ * @access public
*/
- function getCounter($name, $params = Array (), $query_name = null, $multiple_results = false)
+ public function getCounter($name, $params = Array (), $query_name = null, $multiple_results = false)
{
$count_helper =& $this->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
@@ -2897,12 +3022,13 @@
*
* @param int $category_id
* @return Array
+ * @access public
*/
- function getTreeIndex($category_id)
+ public function getTreeIndex($category_id)
{
$tree_index = $this->getCategoryCache($category_id, 'category_tree');
- if ($tree_index) {
+ if ( $tree_index ) {
$ret = Array ();
list ($ret['TreeLeft'], $ret['TreeRight']) = explode(';', $tree_index);
@@ -2917,8 +3043,9 @@
* Usually replaced category, with ID = 0 in category-related operations.
*
* @return int
+ * @access public
*/
- function getBaseCategory()
+ public function getBaseCategory()
{
// same, what $this->findModule('Name', 'Core', 'RootCat') does
// don't cache while IS_INSTALL, because of kInstallToolkit::createModuleCategory and upgrade
@@ -2956,6 +3083,10 @@
*/
public function setFromCache(&$data)
{
+ $this->Factory->setFromCache($data);
+ $this->UnitConfigReader->setFromCache($data);
+ $this->EventManager->setFromCache($data);
+
$this->ReplacementTemplates = $data['Application.ReplacementTemplates'];
$this->RewriteListeners = $data['Application.RewriteListeners'];
$this->ModuleInfo = $data['Application.ModuleInfo'];
@@ -2970,11 +3101,16 @@
*/
public function getToCache()
{
- return Array (
- 'Application.ReplacementTemplates' => $this->ReplacementTemplates,
- 'Application.RewriteListeners' => $this->RewriteListeners,
- 'Application.ModuleInfo' => $this->ModuleInfo,
- );
+ return array_merge(
+ $this->Factory->getToCache(),
+ $this->UnitConfigReader->getToCache(),
+ $this->EventManager->getToCache(),
+ Array (
+ 'Application.ReplacementTemplates' => $this->ReplacementTemplates,
+ 'Application.RewriteListeners' => $this->RewriteListeners,
+ 'Application.ModuleInfo' => $this->ModuleInfo,
+ )
+ );
}
public function delayUnitProcessing($method, $params)
Index: branches/5.2.x/core/units/languages/languages_event_handler.php
===================================================================
diff -u -r15065 -r15073
--- branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 15065)
+++ branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 15073)
@@ -1,6 +1,6 @@
getObject();
/* @var $object kDBItem */
Index: branches/5.2.x/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r15065 -r15073
--- branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 15065)
+++ branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 15073)
@@ -1,6 +1,6 @@
getPrefixSpecial() . '] in checkItemStatus, leading to "404 Not Found"', E_USER_NOTICE);
- header('HTTP/1.0 404 Not Found');
+ $vars = $this->Application->UrlManager->prepare404();
- while (ob_get_level()) {
- ob_end_clean();
+ foreach ($vars as $var_name => $var_value) {
+ $this->Application->SetVar($var_name, $var_value);
}
- // object is used inside template parsing, so break out any parsing and return error document
- $error_template = $this->Application->ConfigValue('ErrorTemplate');
-
- $themes_helper =& $this->Application->recallObject('ThemesHelper');
- /* @var $themes_helper kThemesHelper */
-
- $this->Application->SetVar('t', $error_template);
- $this->Application->SetVar('m_cat_id', $themes_helper->getPageByTemplate($error_template));
-
// in case if missing item is recalled first from event (not from template)
- $this->Application->InitParser();
- $this->Application->HTML = $this->Application->ParseBlock(Array ('name' => $error_template));
+ $this->Application->QuickRun();
$this->Application->Done();
exit;
}