Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r3215 -r3220 --- trunk/core/kernel/application.php (.../application.php) (revision 3215) +++ trunk/core/kernel/application.php (.../application.php) (revision 3220) @@ -406,9 +406,7 @@ { $table = $this->getUnitOption($prefix, 'TableName'); $id_field = $this->getUnitOption($prefix, 'IDField'); - $sql = 'SELECT '.$field.' - FROM '.$table.' - WHERE '.$id_field.' = '.$this->DB->qstr($id); + $sql = 'SELECT '.$field.' FROM '.$table.' WHERE '.$id_field.' = '.$this->DB->qstr($id); $filename = $this->DB->GetOne($sql); $filenames_cache->Set($prefix.'_'.$id, $filename); } Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -N -r3215 -r3220 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3215) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3220) @@ -377,12 +377,15 @@ $category_found = end($category_stack); if($category_found) $url_part = array_shift($url_parts); - }while ($category_found); + }while ($category_found && $url_part); if( count($category_stack) >= 2 ) { - array_pop($category_stack); // remove last not found category - $category_id = array_pop($category_stack); + $category_id = array_pop($category_stack); // remove last not found category + if($category_id === false) + { + $category_id = array_pop($category_stack); + } if($category_id) { $this->Set('m_cat_id', $category_id); Index: trunk/core/kernel/event_handler.php =================================================================== diff -u -N -r3214 -r3220 --- trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 3214) +++ trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 3220) @@ -236,9 +236,10 @@ $db =& $this->Application->GetADODBConnection(); $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); - $sql = 'SELECT '.$id_field.' - FROM '.$table.' - WHERE Filename = '.$db->qstr($url_part); + $sql = 'SELECT item_table.'.$id_field.' + FROM '.$table.' item_table + LEFT JOIN '.TABLE_PREFIX.'CategoryItems cat_items ON item_table.ResourceId = cat_items.ItemResourceId + WHERE (item_table.Filename = '.$db->qstr($url_part).') AND (cat_items.CategoryId = '.$this->Application->GetVar('m_cat_id').')'; $item_id = $db->GetOne($sql); if($item_id !== false) { Index: trunk/kernel/include/category.php =================================================================== diff -u -N -r3179 -r3220 --- trunk/kernel/include/category.php (.../category.php) (revision 3179) +++ trunk/kernel/include/category.php (.../category.php) (revision 3220) @@ -46,13 +46,18 @@ $string = str_replace($not_allowed, '_', $string); $string = preg_replace('/(_+)/', '_', $string); + $string = $this->checkAutoFilename($string); + return $string; + } + + function checkAutoFilename($string) + { while( preg_match('/(.*)_([\d]+)$/', $string, $rets) ) { $string = $rets[1]; } - - return $string; + return $string; } function GenerateFilename()