Index: branches/5.2.x/core/kernel/session/session_storage.php =================================================================== diff -u -N -r14811 -r14995 --- branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14811) +++ branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14995) @@ -1,7 +1,7 @@ Session->RecallVar('user_id'); - if ($user_id == USER_GUEST || $user_id === false) { + if ( $user_id == USER_GUEST || $user_id === false ) { // -2 (when not logged in), false (when after u:OnLogout event) $this->Session->StoreVar($var_name, $var_value, $optional); - return ; + return; } $this->PersistentVars[$var_name] = $var_value; - $key_clause = 'PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name); + $key_clause = 'PortalUserId = ' . $user_id . ' AND VariableName = ' . $this->Conn->qstr($var_name); $sql = 'SELECT VariableName - FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE '.$key_clause; + FROM ' . TABLE_PREFIX . 'PersistantSessionData + WHERE ' . $key_clause; $record_found = $this->Conn->GetOne($sql); $fields_hash = Array ( @@ -380,11 +382,11 @@ 'VariableValue' => $var_value, ); - if ($record_found) { - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'PersistantSessionData', $key_clause); + if ( $record_found ) { + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'PersistantSessionData', $key_clause); } else { - $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PersistantSessionData'); + $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'PersistantSessionData'); } } @@ -394,46 +396,58 @@ * @param string $var_name * @param mixed $default * @return mixed + * @access public */ - function RecallPersistentVar($var_name, $default = false) + public function RecallPersistentVar($var_name, $default = false) { - if ($this->Session->RecallVar('user_id') == USER_GUEST) { - if ($default == ALLOW_DEFAULT_SETTINGS) { + if ( $this->Session->RecallVar('user_id') == USER_GUEST ) { + if ( $default == ALLOW_DEFAULT_SETTINGS ) { $default = null; } + return $this->Session->RecallVar($var_name, $default); } - if (array_key_exists($var_name, $this->PersistentVars)) { + if ( array_key_exists($var_name, $this->PersistentVars) ) { return $this->PersistentVars[$var_name]; } - elseif ($default == ALLOW_DEFAULT_SETTINGS) { + elseif ( $default == ALLOW_DEFAULT_SETTINGS ) { $default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId'); - if (!$default_user_id) { + + if ( !$default_user_id ) { $default_user_id = USER_ROOT; } + $sql = 'SELECT VariableValue, VariableName - FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE VariableName = '.$this->Conn->qstr($var_name).' AND PortalUserId = '.$default_user_id; + FROM ' . TABLE_PREFIX . 'PersistantSessionData + WHERE VariableName = ' . $this->Conn->qstr($var_name) . ' AND PortalUserId = ' . $default_user_id; $value = $this->Conn->GetOne($sql); $this->PersistentVars[$var_name] = $value; - if ($value !== false) { + + if ( $value !== false ) { $this->StorePersistentVar($var_name, $value); //storing it, so next time we don't load default user setting } + return $value; } - else { - return $default; - } + + return $default; } + /** + * Removes variable from persistent session + * + * @param string $var_name + * @return void + * @access public + */ function RemovePersistentVar($var_name) { unset($this->PersistentVars[$var_name]); $user_id = $this->Session->RecallVar('user_id'); - if ($user_id == USER_GUEST || $user_id === false) { + if ( $user_id == USER_GUEST || $user_id === false ) { // -2 (when not logged in), false (when after u:OnLogout event) $this->Session->RemoveVar($var_name); } Index: branches/5.2.x/core/kernel/session/session.php =================================================================== diff -u -N -r14879 -r14995 --- branches/5.2.x/core/kernel/session/session.php (.../session.php) (revision 14879) +++ branches/5.2.x/core/kernel/session/session.php (.../session.php) (revision 14995) @@ -1,6 +1,6 @@ Data->Set($name, $value); - if ($optional) { + if ( $optional ) { // make variable optional, also remember optional value $this->OptionalData[$name] = $value; } - elseif (!$optional && array_key_exists($name, $this->OptionalData)) { - if ($this->OptionalData[$name] == $value) { + elseif ( !$optional && array_key_exists($name, $this->OptionalData) ) { + if ( $this->OptionalData[$name] == $value ) { // same value as optional -> don't remove optional mark - return ; + return; } // make variable non-optional unset($this->OptionalData[$name]); } } - function StorePersistentVar($name, $value, $optional = false) + /** + * Stores variable to persistent session + * + * @param string $name + * @param mixed $value + * @param bool $optional + * @return void + * @access public + */ + public function StorePersistentVar($name, $value, $optional = false) { $this->Storage->StorePersistentVar($name, $value, $optional); } @@ -934,53 +955,98 @@ $this->Storage->LoadPersistentVars(); } - function StoreVarDefault($name, $value, $optional=false) + /** + * Stores default value for session variable + * + * @param string $name + * @param string $value + * @param bool $optional + * @return void + * @access public + * @see Session::RecallVar() + * @see Session::StoreVar() + */ + public function StoreVarDefault($name, $value, $optional = false) { $tmp = $this->RecallVar($name); - if($tmp === false || $tmp == '') - { + + if ( $tmp === false || $tmp == '' ) { $this->StoreVar($name, $value, $optional); } } - function RecallVar($name, $default = false) + /** + * Returns session variable value + * + * Return value of $var variable stored in Session. An optional default value could be passed as second parameter. + * + * @param string $name Variable name + * @param mixed $default Default value to return if no $var variable found in session + * @return mixed + * @access public + */ + public function RecallVar($name, $default = false) { $ret = $this->Data->Get($name); + return ($ret === false) ? $default : $ret; } - function RecallPersistentVar($name, $default = false) + /** + * Returns variable value from persistent session + * + * @param string $name + * @param mixed $default + * @return mixed + * @access public + */ + public function RecallPersistentVar($name, $default = false) { return $this->Storage->RecallPersistentVar($name, $default); } - - function RemoveVar($name) + /** + * Deletes Session variable + * + * @param string $var + * @return void + * @access public + */ + public function RemoveVar($name) { $this->Storage->RemoveFromData($name); $this->Data->Remove($name); } - function RemovePersistentVar($name) + /** + * Removes variable from persistent session + * + * @param string $name + * @return void + * @access public + */ + public function RemovePersistentVar($name) { - return $this->Storage->RemovePersistentVar($name); + $this->Storage->RemovePersistentVar($name); } /** - * Ignores session varible value set before + * Ignores session variable value set before * * @param string $name + * @return void + * @access public */ - function RestoreVar($name) + public function RestoreVar($name) { $value = $this->Storage->GetFromData($name, '__missing__'); - if ($value === '__missing__') { + if ( $value === '__missing__' ) { // there is nothing to restore (maybe session was not saved), look in optional variable values $value = array_key_exists($name, $this->OptionalData) ? $this->OptionalData[$name] : false; } - return $this->StoreVar($name, $value); + $this->StoreVar($name, $value); } function GetField($var_name, $default = false) Index: branches/5.2.x/core/kernel/managers/cache_manager.php =================================================================== diff -u -N -r14941 -r14995 --- branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 14941) +++ branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 14995) @@ -1,6 +1,6 @@ _Params[$name]); } Index: branches/5.2.x/core/kernel/application.php =================================================================== diff -u -N -r14994 -r14995 --- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 14994) +++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 14995) @@ -1,6 +1,6 @@ ModuleInfo as $module_name => $module_info) { + $found = $module_info = false; + + foreach ($this->ModuleInfo as $module_info) { if ( strtolower($module_info[$field]) == strtolower($value) ) { $found = true; break; @@ -515,7 +516,14 @@ kUtil::safeDefine('THEMES_PATH', $path); } - function GetFrontThemePath($force=0) + /** + * Returns relative path to current front-end theme + * + * @param bool $force + * @return string + * @access public + */ + public function GetFrontThemePath($force = false) { static $path = null; @@ -525,12 +533,12 @@ $theme_id = $this->GetVar('m_theme'); if ( !$theme_id ) { -// $theme_id = $this->GetDefaultThemeId(1); //1 to force front-end mode! - $theme_id = 'default'; + $theme_id = 'default'; // $this->GetDefaultThemeId(1); // 1 to force front-end mode! } $this->SetVar('m_theme', $theme_id); $this->SetVar('theme.current_id', $theme_id); // KOSTJA: this is to fool theme' getPassedID + $theme =& $this->recallObject('theme.current'); /* @var $theme ThemeItem */ @@ -544,12 +552,19 @@ return $path; } - function GetDefaultLanguageId($init = false) + /** + * Returns primary front/admin language id + * + * @param bool $init + * @return int + * @access public + */ + public function GetDefaultLanguageId($init = false) { $cache_key = 'primary_language_info[%LangSerial%]'; $language_info = $this->getCache($cache_key); - if ($language_info === false) { + if ( $language_info === false ) { // cache primary language info first $table = $this->getUnitOption('lang', 'TableName'); $id_field = $this->getUnitOption('lang', 'IDField'); @@ -560,53 +575,60 @@ WHERE (AdminInterfaceLang = 1 OR PrimaryLang = 1) AND (Enabled = 1)'; $language_info = $this->Conn->GetCol($sql, 'LanguageKey'); - if ($language_info !== false) { + if ( $language_info !== false ) { $this->setCache($cache_key, $language_info); } } $language_key = ($this->isAdmin && $init) || count($language_info) == 1 ? 'Admin' : 'Front'; - if (array_key_exists($language_key, $language_info) && $language_info[$language_key] > 0) { + if ( array_key_exists($language_key, $language_info) && $language_info[$language_key] > 0 ) { // get from cache return $language_info[$language_key]; } $language_id = $language_info && array_key_exists($language_key, $language_info) ? $language_info[$language_key] : false; - if (!$language_id && defined('IS_INSTALL') && IS_INSTALL) { + if ( !$language_id && defined('IS_INSTALL') && IS_INSTALL ) { $language_id = 1; } return $language_id; } - function GetDefaultThemeId($force_front=0) + /** + * Returns front-end primary theme id (even, when called from admin console) + * + * @param bool $force_front + * @return int + * @access public + */ + public function GetDefaultThemeId($force_front = false) { static $theme_id = 0; - if ($theme_id > 0) { + if ( $theme_id > 0 ) { return $theme_id; } - if (kUtil::constOn('DBG_FORCE_THEME')) { + if ( kUtil::constOn('DBG_FORCE_THEME') ) { $theme_id = DBG_FORCE_THEME; } - elseif (!$force_front && $this->isAdmin) { + elseif ( !$force_front && $this->isAdmin ) { $theme_id = 999; } else { $cache_key = 'primary_theme[%ThemeSerial%]'; $theme_id = $this->getCache($cache_key); - if ($theme_id === false) { + if ( $theme_id === false ) { $this->Conn->nextQueryCachable = true; $sql = 'SELECT ' . $this->getUnitOption('theme', 'IDField') . ' FROM ' . $this->getUnitOption('theme', 'TableName') . ' WHERE (PrimaryTheme = 1) AND (Enabled = 1)'; $theme_id = $this->Conn->GetOne($sql); - if ($theme_id !== false) { + if ( $theme_id !== false ) { $this->setCache($cache_key, $theme_id); } } @@ -619,14 +641,16 @@ * Returns site primary currency ISO code * * @return string + * @access public + * @todo Move into In-Commerce */ - function GetPrimaryCurrency() + public function GetPrimaryCurrency() { $cache_key = 'primary_currency[%CurrSerial%][%SiteDomainSerial%]:' . $this->siteDomainField('DomainId'); $currency_iso = $this->getCache($cache_key); - if ($currency_iso === false) { - if ($this->isModuleEnabled('In-Commerce')) { + if ( $currency_iso === false ) { + if ( $this->isModuleEnabled('In-Commerce') ) { $this->Conn->nextQueryCachable = true; $currency_id = $this->siteDomainField('PrimaryCurrencyId'); @@ -651,34 +675,37 @@ * @param string $field * @param bool $formatted * @param string $format + * @return mixed + * @todo Move into separate module */ - function siteDomainField($field, $formatted = false, $format = null) + public function siteDomainField($field, $formatted = false, $format = null) { - if ($this->isAdmin) { + if ( $this->isAdmin ) { // don't apply any filtering in administrative console return false; } - if (!$this->siteDomain) { + if ( !$this->siteDomain ) { $this->siteDomain =& $this->recallObject('site-domain.current'); /* @var $site_domain kDBItem */ } - if ($this->siteDomain->isLoaded()) { + if ( $this->siteDomain->isLoaded() ) { return $formatted ? $this->siteDomain->GetField($field, $format) : $this->siteDomain->GetDBField($field); } return false; } /** - * Registers default classes such as ItemController, GridController and LoginController - * - * Called automatically while initializing Application - * @access private - * @return void - */ - function RegisterDefaultClasses() + * Registers default classes such as kDBEventHandler, kUrlManager + * + * Called automatically while initializing kApplication + * + * @return void + * @access public + */ + public function RegisterDefaultClasses() { $this->registerClass('kHelper', KERNEL_PATH . '/kbase.php'); $this->registerClass('kMultipleFilter', KERNEL_PATH . '/utility/filters.php'); @@ -741,13 +768,19 @@ $this->registerClass('kModulesHelper', KERNEL_PATH . self::MODULE_HELPER_PATH, 'ModulesHelper'); } - function RegisterDefaultBuildEvents() + /** + * Registers default build events + * + * @return void + * @access protected + */ + protected function RegisterDefaultBuildEvents() { $this->EventManager->registerBuildEvent('kTempTablesHandler', 'OnTempHandlerBuild'); } /** - * Returns cached category informaton by given cache name. All given category + * Returns cached category information by given cache name. All given category * information is recached, when at least one of 4 caches is missing. * * @param int $category_id @@ -778,6 +811,7 @@ * @param string $prefix * @param int $id ID (value of IDField) or ForeignKeyField:ID * @param bool $increment + * @return string * @access public */ public function incrementCacheSerial($prefix, $id = null, $increment = true) @@ -803,8 +837,9 @@ * Adds new value to cache $cache_name and identified by key $key * * @param int $key key name to add to cache - * @param mixed $value value of chached record + * @param mixed $value value of cached record * @param int $expiration when value expires (0 - doesn't expire) + * @return bool * @access public */ public function setCache($key, $value, $expiration = 0) @@ -818,6 +853,8 @@ * @param string $name * @param int $mode * @param int $max_rebuilding_time + * @return void + * @access public */ public function rebuildCache($name, $mode = null, $max_rebuilding_time = 0) { @@ -828,6 +865,7 @@ * Deletes key from cache * * @param string $key + * @return void * @access public */ public function deleteCache($key) @@ -838,6 +876,7 @@ /** * Reset's all memory cache at once * + * @return void * @access public */ public function resetCache() @@ -864,6 +903,7 @@ * @param string $name * @param mixed $value * @param int|bool $expiration + * @return void * @access public */ public function setDBCache($name, $value, $expiration = false) @@ -877,6 +917,8 @@ * @param string $name * @param int $mode * @param int $max_rebuilding_time + * @return void + * @access public */ public function rebuildDBCache($name, $mode = null, $max_rebuilding_time = 0) { @@ -887,6 +929,7 @@ * Deletes key from database cache * * @param string $name + * @return void * @access public */ public function deleteDBCache($name) @@ -898,8 +941,9 @@ * Registers each module specific constants if any found * * @return bool + * @access protected */ - function registerModuleConstants() + protected function registerModuleConstants() { if ( file_exists(KERNEL_PATH . '/constants.php') ) { kUtil::includeOnce(KERNEL_PATH . '/constants.php'); @@ -923,6 +967,7 @@ /** * Performs redirect to hard maintenance template * + * @return void * @access public */ public function redirectToMaintenance() @@ -937,14 +982,15 @@ } /** - * Actually runs the parser against current template and stores parsing result - * - * This method gets t variable passed to the script, loads the template given in t variable and - * parses it. The result is store in {@link $this->HTML} property. - * @access public - * @return void - */ - function Run() + * Actually runs the parser against current template and stores parsing result + * + * This method gets 't' variable passed to the script, loads the template given in 't' variable and + * parses it. The result is store in {@link $this->HTML} property. + * + * @return void + * @access public + */ + public function Run() { // process maintenance mode redirect: begin $maintenance_mode = $this->getMaintenanceMode(); @@ -973,16 +1019,16 @@ if ( $this->isAdminUser ) { // for permission checking in events & templates - $this->LinkVar('module'); // for common configuration templates - $this->LinkVar('module_key'); // for common search templates - $this->LinkVar('section'); // for common configuration templates + $this->LinkVar('module'); // for common configuration templates + $this->LinkVar('module_key'); // for common search templates + $this->LinkVar('section'); // for common configuration templates - if ($this->GetVar('m_opener') == 'p') { - $this->LinkVar('main_prefix'); // window prefix, that opened selector - $this->LinkVar('dst_field'); // field to set value choosed in selector + if ( $this->GetVar('m_opener') == 'p' ) { + $this->LinkVar('main_prefix'); // window prefix, that opened selector + $this->LinkVar('dst_field'); // field to set value choosed in selector } - if ($this->GetVar('ajax') == 'yes' && !$this->GetVar('debug_ajax')) { + if ( $this->GetVar('ajax') == 'yes' && !$this->GetVar('debug_ajax') ) { // hide debug output from ajax requests automatically kUtil::safeDefine('DBG_SKIP_REPORTING', 1); // safeDefine, because debugger also defines it } @@ -1034,9 +1080,16 @@ } } - function InitParser($theme_name = false) + /** + * Performs template parser/cache initialization + * + * @param bool|string $theme_name + * @return void + * @access public + */ + public function InitParser($theme_name = false) { - if( !is_object($this->Parser) ) { + if ( !is_object($this->Parser) ) { $this->Parser =& $this->recallObject('NParser'); $this->TemplatesCache =& $this->recallObject('TemplatesCache'); } @@ -1045,13 +1098,14 @@ } /** - * Send the parser results to browser - * - * Actually send everything stored in {@link $this->HTML}, to the browser by echoing it. - * @access public - * @return void - */ - function Done() + * Send the parser results to browser + * + * Actually send everything stored in {@link $this->HTML}, to the browser by echoing it. + * + * @return void + * @access public + */ + public function Done() { $this->HandleEvent(new kEvent('adm:OnBeforeShutdown')); @@ -1108,8 +1162,10 @@ /** * Stores script execution statistics to database * + * @return void + * @access protected */ - function _storeStatistics() + protected function _storeStatistics() { global $start; @@ -1118,10 +1174,10 @@ $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'StatisticsCapture - WHERE TemplateName = ' . $this->Conn->qstr( $this->GetVar('t') ); + WHERE TemplateName = ' . $this->Conn->qstr($this->GetVar('t')); $data = $this->Conn->GetRow($sql); - if ($data) { + if ( $data ) { $this->_updateAverageStatistics($data, 'ScriptTime', $script_time); $this->_updateAverageStatistics($data, 'SqlTime', $query_statistics['time']); $this->_updateAverageStatistics($data, 'SqlCount', $query_statistics['count']); @@ -1148,21 +1204,31 @@ * @param Array $data * @param string $field_prefix * @param float $current_value + * @return void + * @access protected */ - function _updateAverageStatistics(&$data, $field_prefix, $current_value) + protected function _updateAverageStatistics(&$data, $field_prefix, $current_value) { $data[$field_prefix . 'Avg'] = (($data['Hits'] * $data[$field_prefix . 'Avg']) + $current_value) / ($data['Hits'] + 1); - if ($current_value < $data[$field_prefix . 'Min']) { + if ( $current_value < $data[$field_prefix . 'Min'] ) { $data[$field_prefix . 'Min'] = $current_value; } - if ($current_value > $data[$field_prefix . 'Max']) { + if ( $current_value > $data[$field_prefix . 'Max'] ) { $data[$field_prefix . 'Max'] = $current_value; } } - function logSlowQuery($slow_sql, $time) + /** + * Remembers slow query SQL and execution time into log + * + * @param string $slow_sql + * @param int $time + * @return void + * @access public + */ + public function logSlowQuery($slow_sql, $time) { $query_crc = crc32($slow_sql); @@ -1171,7 +1237,7 @@ WHERE QueryCrc = ' . $query_crc; $data = $this->Conn->Query($sql, null, true); - if ($data) { + if ( $data ) { $this->_updateAverageStatistics($data, 'Time', $time); $template_names = explode(',', $data['TemplateNames']); @@ -1198,11 +1264,12 @@ /** * Checks if output compression options is available * - * @return string + * @return bool + * @access protected */ - function UseOutputCompression() + protected function UseOutputCompression() { - if (kUtil::constOn('IS_INSTALL') || kUtil::constOn('DBG_ZEND_PRESENT') || kUtil::constOn('SKIP_OUT_COMPRESSION')) { + if ( kUtil::constOn('IS_INSTALL') || kUtil::constOn('DBG_ZEND_PRESENT') || kUtil::constOn('SKIP_OUT_COMPRESSION') ) { return false; } @@ -1212,19 +1279,27 @@ // Facade /** - * Returns current session id (SID) - * @access public - * @return int - */ - function GetSID() + * Returns current session id (SID) + * + * @return int + * @access public + */ + public function GetSID() { $session =& $this->recallObject('Session'); /* @var $session Session */ return $session->GetID(); } - function DestroySession() + /** + * Destroys current session + * + * @return void + * @access public + * @see UserHelper::logoutUser() + */ + public function DestroySession() { $session =& $this->recallObject('Session'); /* @var $session Session */ @@ -1237,7 +1312,6 @@ * * @param string $name Name of variable to retrieve * @param mixed $default default value returned in case if variable not present - * * @return mixed * @access public */ @@ -1252,7 +1326,6 @@ * @param string $name Name of variable to retrieve * @param string $type Get/Post/Cookie * @param mixed $default default value returned in case if variable not present - * * @return mixed * @access public */ @@ -1265,29 +1338,29 @@ } /** - * Returns ALL variables passed to the script as GET/POST/COOKIE - * - * @access public - * @return array - */ - function GetVars() + * Returns ALL variables passed to the script as GET/POST/COOKIE + * + * @return Array + * @access public + * @deprecated + */ + public function GetVars() { return $this->HttpQuery->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 - * 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.
- * - * This method is formerly known as $this->Session->SetProperty. - * @param string $var Variable name to set - * @param mixed $val Variable value - * @access public - * @return void - */ + * 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 + * 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.
+ * + * @param string $var Variable name to set + * @param mixed $val Variable value + * @return void + * @access public + */ public function SetVar($var,$val) { $this->HttpQuery->Set($var, $val); @@ -1297,55 +1370,76 @@ * Deletes kHTTPQuery variable * * @param string $var - * @todo think about method name + * @return void + * @todo Think about method name */ - function DeleteVar($var) + public function DeleteVar($var) { - return $this->HttpQuery->Remove($var); + $this->HttpQuery->Remove($var); } /** * Deletes Session variable * * @param string $var + * @return void + * @access public */ - function RemoveVar($var) + public function RemoveVar($var) { - return $this->Session->RemoveVar($var); + $this->Session->RemoveVar($var); } - function RemovePersistentVar($var) + /** + * Removes variable from persistent session + * + * @param string $var + * @return void + * @access public + */ + public function RemovePersistentVar($var) { - return $this->Session->RemovePersistentVar($var); + $this->Session->RemovePersistentVar($var); } /** * Restores Session variable to it's db version * * @param string $var + * @return void + * @access public */ - function RestoreVar($var) + public function RestoreVar($var) { - return $this->Session->RestoreVar($var); + $this->Session->RestoreVar($var); } /** - * Returns session variable value - * - * Return value of $var variable stored in Session. An optional default value could be passed as second parameter. - * - * @see SimpleSession - * @access public - * @param string $var Variable name - * @param mixed $default Default value to return if no $var variable found in session - * @return mixed - */ - function RecallVar($var,$default=false) + * Returns session variable value + * + * Return value of $var variable stored in Session. An optional default value could be passed as second parameter. + * + * @param string $var Variable name + * @param mixed $default Default value to return if no $var variable found in session + * @return mixed + * @access public + * @see Session::RecallVar() + */ + public function RecallVar($var,$default=false) { return $this->Session->RecallVar($var,$default); } - function RecallPersistentVar($var, $default = false) + /** + * Returns variable value from persistent session + * + * @param string $var + * @param mixed $default + * @return mixed + * @access public + * @see Session::RecallPersistentVar() + */ + public function RecallPersistentVar($var, $default = false) { return $this->Session->RecallPersistentVar($var, $default); } @@ -1358,45 +1452,75 @@ * @param string $var Variable name * @param mixed $val Variable value * @param bool $optional - * @see kApplication::RecallVar() + * @return void * @access public + * @see kApplication::RecallVar() */ - function StoreVar($var, $val, $optional = false) + public function StoreVar($var, $val, $optional = false) { $session =& $this->recallObject('Session'); + /* @var $session Session */ + $this->Session->StoreVar($var, $val, $optional); } - function StorePersistentVar($var, $val, $optional = false) + /** + * Stores variable to persistent session + * + * @param string $var + * @param mixed $val + * @param bool $optional + * @return void + * @access public + */ + public function StorePersistentVar($var, $val, $optional = false) { $this->Session->StorePersistentVar($var, $val, $optional); } - function StoreVarDefault($var, $val, $optional=false) + /** + * Stores default value for session variable + * + * @param string $var + * @param string $val + * @param bool $optional + * @return void + * @access public + * @see Session::RecallVar() + * @see Session::StoreVar() + */ + public function StoreVarDefault($var, $val, $optional = false) { $session =& $this->recallObject('Session'); + /* @var $session Session */ + $this->Session->StoreVarDefault($var, $val, $optional); } /** - * 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 - - * 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 - * @param string $var HTTP Query (GPC) variable name - * @param mixed $ses_var Session variable name - * @param mixed $default Default variable value - * @param bool $optional - */ - function LinkVar($var, $ses_var = null, $default = '', $optional = false) + * 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 - + * 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 + * + * @param string $var HTTP Query (GPC) variable name + * @param mixed $ses_var Session variable name + * @param mixed $default Default variable value + * @param bool $optional + * @return void + * @access public + */ + public function LinkVar($var, $ses_var = null, $default = '', $optional = false) { - if (!isset($ses_var)) $ses_var = $var; - if ($this->GetVar($var) !== false) { + if ( !isset($ses_var) ) { + $ses_var = $var; + } + + if ( $this->GetVar($var) !== false ) { $this->StoreVar($ses_var, $this->GetVar($var), $optional); } else { @@ -1405,25 +1529,36 @@ } /** - * 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 - * - * @see LinkVar - * @access public - * @param string $var HTTP Query (GPC) variable name - * @param mixed $ses_var Session variable name - * @param mixed $default Default variable value - * @return mixed - */ - function GetLinkedVar($var, $ses_var = null, $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 + * + * @param string $var HTTP Query (GPC) variable name + * @param mixed $ses_var Session variable name + * @param mixed $default Default variable value + * @return mixed + * @access public + * @see LinkVar + */ + public function GetLinkedVar($var, $ses_var = null, $default = '') { $this->LinkVar($var, $ses_var, $default); + return $this->GetVar($var); } - function ProcessParsedTag($prefix, $tag, $params) + /** + * Renders given tag and returns it's output + * + * @param string $prefix + * @param string $tag + * @param Array $params + * @return mixed + * @access public + * @see kApplication::InitParser() + */ + public function ProcessParsedTag($prefix, $tag, $params) { $processor = $this->Parser->GetProcessor($prefix); /* @var $processor kDBTagProcessor */ Index: branches/5.2.x/core/kernel/processors/tag_processor.php =================================================================== diff -u -N -r14628 -r14995 --- branches/5.2.x/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 14628) +++ branches/5.2.x/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 14995) @@ -1,6 +1,6 @@ Application->isDebugMode()) { - $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix); + if ( method_exists($this, $Method) ) { + if ( defined('DEBUG_MODE') && defined('DBG_SHOW_TAGS') && DBG_SHOW_TAGS && $this->Application->isDebugMode() ) { + $this->Application->Debugger->appendHTML('Processing PreParsed Tag ' . $Method . ' in ' . $this->Prefix); } - list ($prefix_only, ) = explode('.', $prefix); + list ($prefix_only,) = explode('.', $prefix); $this->Application->Parser->PrefixesInUse[$prefix_only] = 1; $cache_key = ''; $backup_prefix = $this->Prefix; $backup_special = $this->Special; - if ($this->Application->Parser->CachingEnabled && array_key_exists('cache_timeout', $params)) { + if ( $this->Application->Parser->CachingEnabled && array_key_exists('cache_timeout', $params) ) { // individual tag caching $cache_key = $this->FormCacheKey($tag, $params, $prefix); $res = $this->Application->Parser->getCache($cache_key); - if ($res !== false) { + if ( $res !== false ) { return $res; } } @@ -115,7 +115,7 @@ $flag_values = $this->PreparePostProcess($params); // pass_params for non ParseBlock tags :) - if ($flag_values['pass_params']) { + if ( $flag_values['pass_params'] ) { $params = array_merge($this->Application->Parser->Params, $params); } @@ -125,7 +125,7 @@ $ret = $this->PostProcess($ret, $flag_values); - if ($this->Application->Parser->CachingEnabled && $flag_values['cache_timeout']) { + if ( $this->Application->Parser->CachingEnabled && $flag_values['cache_timeout'] ) { $this->Application->Parser->setCache($cache_key, $ret, (int)$flag_values['cache_timeout']); } @@ -134,7 +134,7 @@ else { list ($ret, $tag_found) = $this->processAggregatedTag($tag, $params, $prefix, $file, $line); - if ($tag_found) { + if ( $tag_found ) { return $ret; }