Index: trunk/kernel/include/item.php =================================================================== diff -u -N -r3145 -r3162 --- trunk/kernel/include/item.php (.../item.php) (revision 3145) +++ trunk/kernel/include/item.php (.../item.php) (revision 3162) @@ -1112,8 +1112,15 @@ function StripDisallowed($string) { $not_allowed = Array(' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|'); - $string = str_replace($not_allowed, '_', $string); - return preg_replace('/(_+)/', '_', $string); + $string = str_replace($not_allowed, '_', $string); + $string = preg_replace('/(_+)/', '_', $string); + + while( preg_match('/(.*)_([\d]+)$/', $string, $rets) ) + { + $string = $rets[1]; + } + + return $string; } function GenerateFilename() Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r3154 -r3162 --- trunk/core/kernel/application.php (.../application.php) (revision 3154) +++ trunk/core/kernel/application.php (.../application.php) (revision 3162) @@ -70,6 +70,13 @@ var $Phrases; /** + * Modules table content, key - module name + * + * @var Array + */ + var $ModuleInfo = Array(); + + /** * Holds DBConnection * * @var kDBConnection @@ -129,7 +136,7 @@ function Init() { if($this->InitDone) return false; - + if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') ) { $GLOBALS['debugger']->appendMemoryUsage('Application before Init:'); @@ -144,11 +151,17 @@ $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); + $this->Factory = new kFactory(); $this->registerDefaultClasses(); @@ -157,18 +170,22 @@ // 1. to read configs before doing any recallObject (called from "SetDefaultConstants" anyway) $config_reader =& $this->recallObject('kUnitConfigReader'); - $this->VerifyLanguageId(); - $this->VerifyThemeId(); - - if( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 0); - - $this->Phrases = new PhrasesCache( $this->GetVar('m_lang') ); - + // Module items are recalled during url parsing & PhrasesCache is needed already there, + // because it's used in their build events. That's why phrases cache initialization is + // called from httpquery in case when mod_rewrite is used + if( !$this->RewriteURLs() ) + { + $this->Phrases = new PhrasesCache(); + $this->VerifyLanguageId(); + $this->Phrases->Init('phrases'); + $this->VerifyThemeId(); + } + $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->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 0); + + $language =& $this->recallObject( 'lang.current', null, Array('live_table' => true) ); if( !$this->RecallVar('UserGroups') ) { @@ -189,11 +206,6 @@ $GLOBALS['debugger']->profileFinish('kernel4_startup'); } - $cms_on = defined('CMS') && CMS; - $rewrite_on = $this->ConfigValue('UseModRewrite'); - $admin_on = $this->GetVar('admin') || $this->IsAdmin(); - define('MOD_REWRITE', ($rewrite_on || $cms_on) && !$admin_on ? 1 : 0); - $this->InitDone = true; return true; } @@ -207,15 +219,16 @@ $language_id = $this->GetVar('m_lang'); if($language_id) { - $table = $this->getUnitOption('lang','TableName'); - $id_field = $this->getUnitOption('lang','IDField'); + $table = $this->getUnitOption('lang', 'TableName'); + $id_field = $this->getUnitOption('lang', 'IDField'); $language_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table); } - if(!$language_id || !in_array($language_id, $language_ids) ) { + if ( !$language_id || !in_array($language_id, $language_ids) ) + { $def_lang = $this->GetDefaultLanguageId(); - $this->SetVar('m_lang', $def_lang ); - $this->StoreVar('m_lang', $def_lang ); + $this->SetVar('m_lang', $def_lang); + $this->StoreVar('m_lang', $def_lang); } } @@ -228,14 +241,17 @@ $theme_id = $this->GetVar('m_theme'); if($theme_id) { - $table = $this->getUnitOption('theme','TableName'); - $id_field = $this->getUnitOption('theme','IDField'); + $table = $this->getUnitOption('theme', 'TableName'); + $id_field = $this->getUnitOption('theme', 'IDField'); $theme_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table); } - if(!$theme_id || !in_array($theme_id, $theme_ids) ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); + if ( !$theme_id || !in_array($theme_id, $theme_ids) ) + { + $this->SetVar('m_theme', $this->GetDefaultThemeId() ); + } } - + function GetDefaultLanguageId() { static $language_id = 0; @@ -716,7 +732,9 @@ { if(!$t) $t = $this->GetVar('t'); // moved from MainProcessor->T() - if ( $this->IsAdmin() && $prefix == '') $prefix='/admin'; + if( substr($t, -4) == '.tpl' ) $t = substr($t, 0, strlen($t) - 4 ); + + if ( $this->IsAdmin() && $prefix == '') $prefix = '/admin'; if ( $this->IsAdmin() && $prefix == '_FRONT_END_') $prefix = ''; $index_file = isset($index_file) ? $index_file : (defined('INDEX_FILE') ? INDEX_FILE : basename($_SERVER['SCRIPT_NAME'])); @@ -819,7 +837,7 @@ $event_params['url_params'] = $params; $event = new kEvent($pass_element.':BuildEnv', $event_params); $this->HandleEvent($event); - $ret .= '/'.$event->getEventParam('env_string'); + $ret .= '/'.trim( $event->getEventParam('env_string'), '/'); $params = $event->getEventParam('url_params'); // save back unprocessed parameters } $ret = trim($ret, '/').'.html'; @@ -1014,6 +1032,12 @@ function ReplaceLanguageTags($text, $force_escape=null) { // !!!!!!!! + if( !is_object($this->Phrases) ) + { + print_r( debug_backtrace() ); +// $this->Debugger->appendTrace(); + } + return $this->Phrases->ReplaceLanguageTags($text,$force_escape); } Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -N -r3031 -r3162 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3031) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3162) @@ -62,18 +62,32 @@ var $Admin = false; /** + * Description + * + * @var kDBConnection + * @access public + */ + var $Conn; + + /** * Loads info from $_POST, $_GET and * related arrays into common place * * @param string $order * @return HTTPQuery * @access public */ - function HTTPQuery($order='CGPF') + function HTTPQuery($order = 'CGPF') { parent::Params(); + $this->Conn =& $this->Application->GetADODBConnection(); + $this->Order = $order; $this->Admin = $this->Application->IsAdmin(); // better cache this value, not to calculate it each time in foreach + } + + function Init($prefix, $special) + { $this->AddAllVars(); $this->specialsToRemove = $this->Get('remove_specials'); @@ -83,7 +97,7 @@ } ini_set('magic_quotes_gpc', 0); } - + function removeSpecials($array) { $ret = Array(); @@ -116,22 +130,31 @@ $current = $this->Order[$i]; switch ($current) { case 'G': - $this->Get =$this->AddVars($_GET); + $this->Get = $this->AddVars($_GET); $this->processQueryString(); + if( $this->Application->RewriteURLs() ) + { + $this->processRewriteURL(); + } break; + case 'P': $this->Post = $this->AddVars($_POST); $this->convertPostEvents(); break; + case 'C': $this->Cookie = $this->AddVars($_COOKIE); break; + case 'E'; $this->Env = $this->AddVars($_ENV); break; + case 'S'; $this->Server = $this->AddVars($_SERVER); break; + case 'F'; $this->convertFiles(); $this->Files = $this->MergeVars($_FILES, false); //do not strip slashes! @@ -243,6 +266,162 @@ } } + + function processRewriteURL() + { + // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html + + $url = $this->Get('url'); + if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); + + $url_parts = $url ? explode('/', $url) : Array(); + + // set default values + $defaults = Array('t' => '', 'm_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); + foreach ($defaults as $default_key => $default_value) + { + $this->Set($default_key, $default_value); + } + + if(!$url_parts) + { + $this->Application->VerifyLanguageId(); + $this->Application->VerifyThemeId(); + $this->Application->Phrases = new PhrasesCache(); + $this->Application->Phrases->Init('phrases'); +// $this->Get('m_lang') ); + $this->Set('t', $this->getDefaultTemplate('') ); + return false; + } + + $url_part = array_shift($url_parts); + + // match language + $sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; + $language_id = $this->Conn->GetOne($sql); + if($language_id) + { + $this->Set('m_lang', $language_id); + $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing + } + else + { + $this->Application->VerifyLanguageId(); + } + $this->Application->Phrases = new PhrasesCache(); + $this->Application->Phrases->Init('phrases'); + // $this->Get('m_lang') ); + + // match theme + if($url_part) + { + $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; + $theme_id = $this->Conn->GetOne($sql); + if($theme_id) + { + $this->Set('m_theme', $theme_id); + $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing + } + else + { + $this->Application->VerifyThemeId(); + } + } + + // match category + if($url_part) + { + $category_stack = Array(); + $category_found = false; + $category_path = ''; + do + { + $category_path = trim($category_path.'/'.$url_part, '/'); + + if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) + { + $category_path = $rets[1]; + $this->Set('m_cat_page', $rets[2]); + } + + $sql = 'SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE NamedParentPath = '.$this->Conn->qstr($category_path); + array_push($category_stack, $this->Conn->GetOne($sql) ); + $category_found = end($category_stack); + if($category_found) $url_part = array_shift($url_parts); + + }while ($category_found); + + if( count($category_stack) >= 2 ) + { + array_pop($category_stack); // remove last not found category + $category_id = array_pop($category_stack); + if($category_id) + { + $this->Set('m_cat_id', $category_id); + } + } + } + + // match module + if($url_part) + { + foreach ($this->Application->ModuleInfo as $module_name => $module_data) + { + if( trim($module_data['TemplatePath'], '/') == $url_part ) + { + $module_prefix = $module_data['Var']; + break; + } + } + } + + // match template + $template_path = ''; + $template_found = false; + if($url_part) + { + array_unshift($url_parts, $url_part); + $template_parts = $url_parts; + $url_parts = Array(); + do + { + $template_path = implode('/', $template_parts); + + $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); + $template_found = $this->Conn->GetOne($sql); + if(!$template_found) + { + array_unshift( $url_parts, array_pop($template_parts) ); + } + + }while (!$template_found && $template_parts); + } + $this->Set('t', $this->getDefaultTemplate($template_found ? $template_path : '') ); + // pass params left to module + + $passed = Array('m'); + $module_params = Array(); + if($url_parts && isset($module_prefix) ) + { + $passed[] = $module_prefix; + $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) ); + $this->Application->HandleEvent($module_event); + $module_params = Array($module_prefix.'_id' => 0); + } + + $this->Set('passed', implode(',', $passed) ); + $env = $this->Application->BuildEnv( $this->Get('t'), $module_params, implode(',', $passed), false, false ); + $this->Set(ENV_VAR_NAME, $env); + $_REQUEST['env'] = $_GET['env'] = $env; // for capability with old in-portal code + } + + function getDefaultTemplate($t) + { + $t = $this->getTemplateName( trim($t, '/') ); + if (!$t) $t = 'index'; + return trim($t, '/'); + } + /** * Process QueryString only, create * events, ids, based on config @@ -260,7 +439,7 @@ if($env_var) { $sid = $this->Get('sid'); - if (defined('MOD_REWRITE') && MOD_REWRITE && $sid && !$this->Get('admin') ) + if ( $this->Application->RewriteURLs() && $sid && !$this->Get('admin') ) { //$env_var = rtrim($sid.$env_var, '/'); $split_by = defined('INPORTAL_ENV') ? '-' : ':'; @@ -272,7 +451,7 @@ $parts=explode(':',$env_var); - if (defined('MOD_REWRITE') && MOD_REWRITE) $env_var = str_replace('/', ':', $env_var); + if ( $this->Application->RewriteURLs() ) $env_var = str_replace('/', ':', $env_var); if (defined('INPORTAL_ENV')) { $sub_parts = array_shift($parts); @@ -287,24 +466,21 @@ } // Save Template Name - $t=$this->getTemplateName( trim($t, '/') ); - if(!$t) $t='index'; - $this->Set('t', trim($t, '/') ); + $this->Set('t', $this->getDefaultTemplate($t) ); } else { // Save Session ID - $sid=array_shift($parts); - if($sid) $this->Set('sid',$sid); + $sid = array_shift($parts); + if ($sid) $this->Set('sid', $sid); // Save Template Name - $t=$this->getTemplateName( array_shift($parts) ); - if(!$t) $t='index'; - $this->Set('t', trim($t, '/') ); + $t = array_shift($parts); + $this->Set('t', $this->getDefaultTemplate($t) ); } if($parts) { - $query_maps=Array(); + $query_maps = Array(); $event_manger =& $this->Application->recallObject('EventManager'); $passed = Array(); @@ -353,7 +529,7 @@ else { $t=$this->getTemplateName('index'); - $this->Set('t',$t); + $this->Set('t', $t); } } @@ -368,13 +544,15 @@ function getTemplateName($querystring_template) { $t_from_post = $this->Get('t'); - $t= $t_from_post ? $t_from_post : $querystring_template; + $t = $t_from_post ? $t_from_post : $querystring_template; - if ( is_numeric($t) ) { - $t = $this->Application->DB->GetOne('SELECT CONCAT(FilePath, \'/\', FileName) FROM '.TABLE_PREFIX.'ThemeFiles - WHERE FileId = '.$t); + if ( is_numeric($t) ) + { + $t = $this->Conn->GetOne(' SELECT CONCAT(FilePath, \'/\', FileName) + FROM '.TABLE_PREFIX.'ThemeFiles + WHERE FileId = '.$t); } - $t = preg_replace("/\.tpl$/", '', $t); + $t = preg_replace('/\.tpl$/', '', $t); return $t; } Index: trunk/core/kernel/db/dbitem.php =================================================================== diff -u -N -r3088 -r3162 --- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 3088) +++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 3162) @@ -271,7 +271,7 @@ return $this->Clear(); } - if( is_array($id) ) $this->setID( $this->FieldValues[$this->IDField] ); + if( is_array($id) || isset($id_field_name) ) $this->setID( $this->FieldValues[$this->IDField] ); $this->UpdateFormattersSubFields(); // used for updating separate virtual date/time fields from DB timestamp (for example) Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -N -r3150 -r3162 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3150) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3162) @@ -202,8 +202,15 @@ function stripDisallowed($string) { $not_allowed = Array(' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|'); - $string = str_replace($not_allowed, '_', $string); - return preg_replace('/(_+)/', '_', $string); + $string = str_replace($not_allowed, '_', $string); + $string = preg_replace('/(_+)/', '_', $string); + + while( preg_match('/(.*)_([\d]+)$/', $string, $rets) ) + { + $string = $rets[1]; + } + + return $string; } /** Index: trunk/core/kernel/event_handler.php =================================================================== diff -u -N -r3154 -r3162 --- trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 3154) +++ trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 3162) @@ -160,35 +160,86 @@ //otherwise it will use value from get_var } - if(!$query_vars) + if(!$query_vars) return true; + + $processed_params = Array(); + foreach($query_vars as $index => $var_name) { - $event->setEventParam('env_string', ''); - return true; - + //if value passed in params use it, otherwise use current from application + $var_name = $prefix_special.'_'.$var_name; + $processed_params[$var_name] = isset( $url_params[$var_name] ) ? $url_params[$var_name] : $this->Application->GetVar($var_name); + if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] ); } + $ret = ''; + $object =& $event->getObject( Array('skip_autoload' => true) ); + if($processed_params[$prefix_special.'_Page'] > 1) + { + $ret .= $processed_params[$prefix_special.'_Page'].'/'; + } - /*$tmp_string = Array(0 => $prefix_special); - foreach($query_vars as $index => $var_name) + if($processed_params[$prefix_special.'_id']) { - //if value passed in params use it, otherwise use current from application - $var_name = $prefix_special.'_'.$var_name; - $tmp_string[$index] = isset( $url_params[$var_name] ) ? $url_params[$var_name] : $this->Application->GetVar($var_name); - if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] ); + $object->Load( $processed_params[$prefix_special.'_id'] ); + if( $object->isLoaded() ) + { + $filename = $object->GetDBField('Filename'); + $ret .= $filename.'/'; + } } - - $escaped = Array(); - foreach ($tmp_string as $tmp_val) + + if($processed_params[$prefix_special.'_Reviews_Page'] > 1) { - $escaped[] = str_replace( Array('-',':'), Array('\-','\:'), $tmp_val); + $ret = rtrim($ret, '/').'_'.$processed_params[$prefix_special.'_Reviews_Page'].'/'; } - - $portal_env = $this->Application->getUnitOption($event->Prefix, 'PortalStyleEnv'); - $ret .= $portal_env ? array_shift($escaped).array_shift($escaped).'-'.implode('-',$escaped) : implode('-', $escaped);*/ + $event->setEventParam('url_params', $url_params); + $event->setEventParam('env_string', strtolower($ret) ); } + + /** + * Process mod_rewrite url part left after previous parser + * + * @param kEvent $event + */ + function ParseEnv(&$event) + { + // /_ + + $url_parts = $event->getEventParam('url_parts'); + + $ret = ''; + + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $url_part = array_shift($url_parts); + + // match module page + if( is_numeric($url_part) ) + { + $this->Application->SetVar( $event->getPrefixSpecial().'_Page', $url_part); + $url_part = $url_parts ? array_shift($url_parts) : ''; + } + + if(!$url_part) return true; + + // match module reviews page + if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) + { + $url_part = $rets[1]; + $this->Application->SetVar( $event->getPrefixSpecial().'_Reviews_Page', $rets[2]); + } + + // match item's filename + $object->Load($url_part, 'Filename'); + if( $object->isLoaded() ) + { + $this->Application->SetVar( $event->getPrefixSpecial().'_id', $object->GetID() ); + } + + } } Index: trunk/kernel/units/general/cat_dbitem.php =================================================================== diff -u -N -r3150 -r3162 --- trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3150) +++ trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3162) @@ -202,8 +202,15 @@ function stripDisallowed($string) { $not_allowed = Array(' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|'); - $string = str_replace($not_allowed, '_', $string); - return preg_replace('/(_+)/', '_', $string); + $string = str_replace($not_allowed, '_', $string); + $string = preg_replace('/(_+)/', '_', $string); + + while( preg_match('/(.*)_([\d]+)$/', $string, $rets) ) + { + $string = $rets[1]; + } + + return $string; } /** Index: trunk/admin/category/permcacheupdate.php =================================================================== diff -u -N -r677 -r3162 --- trunk/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 677) +++ trunk/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 3162) @@ -208,6 +208,7 @@ if ($data === false) { //If Stack is empty $data['current_id'] = 0; $data['title'] = Array(); + $data['named_path'] = Array(); $this->Stack->Push($data); } @@ -234,6 +235,7 @@ { $next_data = Array(); $next_data['title'] = $data['title']; + $next_data['named_path'] = $data['named_path']; $next_data['current_id'] = $data['children'][$data['current_child']]; //next iteration should process child $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance $next_data['perms']->SetCatId($next_data['current_id']); @@ -251,18 +253,27 @@ } function UpdateCachedPath(&$data) { - $sql='UPDATE '.GetTablePrefix().'Category SET CachedNavbar="'.addslashes(join('>',$data['title'])) .'" WHERE CategoryId = '.$data['current_id']; + $sql = 'UPDATE '.GetTablePrefix().'Category SET CachedNavbar="'.addslashes(join('>',$data['title'])) .'" WHERE CategoryId = '.$data['current_id']; $this->conn->Execute($sql); + + $path = implode('/', $data['named_path'] ); + $sql = 'UPDATE '.GetTablePrefix().'Category SET NamedParentPath = "'.addslashes($path).'" WHERE CategoryId = '.$data['current_id']; + $this->conn->Execute($sql); } + function QueryTitle(&$data) { - $sql = sprintf('SELECT Name FROM '.GetTablePrefix().'Category WHERE CategoryId = %s', + $sql = sprintf('SELECT Name, Filename FROM '.GetTablePrefix().'Category WHERE CategoryId = %s', $data['current_id']); $rs = $this->conn->Execute($sql); if ($rs && !$rs->EOF) + { $data['title'][] = $rs->fields['Name']; + $data['named_path'][] = $rs->fields['Filename']; + } } + function QueryChildren(&$data) { $sql = sprintf('SELECT CategoryId FROM '.GetTablePrefix().'Category WHERE ParentId = %s', Index: trunk/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r3145 -r3162 --- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 3145) +++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 3162) @@ -192,7 +192,7 @@ if($config_found) include_once(FULL_PATH.$filename); } - if($config_found) + if($config_found && isset($config) && $config) { $prefix = $config['Prefix']; Index: trunk/core/units/general/main_event_handler.php =================================================================== diff -u -N -r3154 -r3162 --- trunk/core/units/general/main_event_handler.php (.../main_event_handler.php) (revision 3154) +++ trunk/core/units/general/main_event_handler.php (.../main_event_handler.php) (revision 3162) @@ -42,12 +42,7 @@ //otherwise it will use value from get_var } - if(!$query_vars) - { - $event->setEventParam('env_string', ''); - return true; - - } + if(!$query_vars) return true; $processed_params = Array(); foreach($query_vars as $index => $var_name) @@ -58,6 +53,7 @@ if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] ); } + $ret = ''; $default_language_id = $this->Application->GetDefaultLanguageId(); if( $processed_params['m_lang'] != $default_language_id ) { Index: trunk/core/kernel/languages/phrases_cache.php =================================================================== diff -u -N -r2720 -r3162 --- trunk/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 2720) +++ trunk/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 3162) @@ -18,16 +18,18 @@ var $fromTag = false; - function PhrasesCache($LanguageId=1) + function PhrasesCache() { parent::kBase(); $this->Conn =& $this->Application->GetADODBConnection(); - - $this->Phrases = Array(); - $this->LanguageId = $LanguageId; - $this->LoadPhrases( $this->GetCachedIds() ); } + function Init($prefix, $special = '') + { + $this->LanguageId = $this->Application->GetVar('m_lang'); + $this->LoadPhrases( $this->GetCachedIds() ); + } + function GetCachedIds() { $query = sprintf("SELECT PhraseList FROM %s WHERE Template = %s", Index: trunk/kernel/include/category.php =================================================================== diff -u -N -r3154 -r3162 --- trunk/kernel/include/category.php (.../category.php) (revision 3154) +++ trunk/kernel/include/category.php (.../category.php) (revision 3162) @@ -42,7 +42,14 @@ { $not_allowed = Array(' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|'); $string = str_replace($not_allowed, '_', $string); - return preg_replace('/(_+)/', '_', $string); + $string = preg_replace('/(_+)/', '_', $string); + + while( preg_match('/(.*)_([\d]+)$/', $string, $rets) ) + { + $string = $rets[1]; + } + + return $string; } function GenerateFilename() Index: trunk/kernel/action.php =================================================================== diff -u -N -r3145 -r3162 --- trunk/kernel/action.php (.../action.php) (revision 3145) +++ trunk/kernel/action.php (.../action.php) (revision 3162) @@ -821,8 +821,17 @@ { $original_cats = new clsCatList(); $original_cat = $original_cats->GetItemByField('CategoryId', GetVar('CategoryId')); - if( $original_cat->Get('Name') != stripslashes($_POST['cat_name'] )) - $objSession->SetVariable('PermCache_UpdateRequired', 1); + + $match_fields = Array('Name' => 'cat_name', 'Filename' => 'filename'); + foreach ($match_fields as $db_field => $submit_field) + { + if( $original_cat->Get($db_field) != stripslashes( GetVar($submit_field) ) ) + { + $objSession->SetVariable('PermCache_UpdateRequired', 1); + break; + } + } + unset($original_cat, $original_cats); } else Index: trunk/kernel/units/general/main_event_handler.php =================================================================== diff -u -N -r3154 -r3162 --- trunk/kernel/units/general/main_event_handler.php (.../main_event_handler.php) (revision 3154) +++ trunk/kernel/units/general/main_event_handler.php (.../main_event_handler.php) (revision 3162) @@ -42,12 +42,7 @@ //otherwise it will use value from get_var } - if(!$query_vars) - { - $event->setEventParam('env_string', ''); - return true; - - } + if(!$query_vars) return true; $processed_params = Array(); foreach($query_vars as $index => $var_name) @@ -58,6 +53,7 @@ if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] ); } + $ret = ''; $default_language_id = $this->Application->GetDefaultLanguageId(); if( $processed_params['m_lang'] != $default_language_id ) {