Index: branches/RC/core/kernel/event_handler.php =================================================================== diff -u -N -r11546 -r11838 --- branches/RC/core/kernel/event_handler.php (.../event_handler.php) (revision 11546) +++ branches/RC/core/kernel/event_handler.php (.../event_handler.php) (revision 11838) @@ -188,17 +188,15 @@ } //if pass events is off and event is not implicity passed - if ( !$pass_events && !isset($url_params[$prefix_special.'_event']) ) - { + if ( !$pass_events && !isset($url_params[$prefix_special.'_event']) ) { unset($url_params[$prefix_special.'_event']); // remove event from url if requested //otherwise it will use value from get_var } if(!$query_vars) return true; $processed_params = Array(); - foreach($query_vars as $index => $var_name) - { + foreach($query_vars as $index => $var_name) { //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); @@ -207,11 +205,6 @@ $ret = ''; - /*if($processed_params[$prefix_special.'_Page'] > 1 && !$processed_params[$prefix_special.'_id']) - { - $ret .= $processed_params[$prefix_special.'_Page'].'/'; - }*/ - if (!$processed_params[$prefix_special.'_id']) { if ($processed_params[$prefix_special.'_Page'] == 1) { // when printing "items" from category, there is 1st page -> nothing from "item prefix" in url @@ -224,14 +217,18 @@ } if ($processed_params[$prefix_special.'_id']) { - // this allows to fill 3 cache records with one query (see this method for details) $category_id = isset($url_params['m_cat_id']) ? $url_params['m_cat_id'] : $this->Application->GetVar('m_cat_id'); $category_filename = $this->Application->getFilename('c', $category_id); // if template is also item template of category, then remove template $template = getArrayValue($url_params, 't'); - $item_template = $this->Application->getCache('item_templates', $category_id); + + $mod_rw_helper =& $this->Application->recallObject('ModRewriteHelper'); + /* @var $mod_rw_helper kModRewriteHelper */ + + $item_template = $mod_rw_helper->GetItemTemplate($category_id, $event->Prefix); + if ($template == $item_template || strtolower($template) == '__default__') { unset($url_params['t']); } @@ -241,12 +238,6 @@ if($filename !== false) $ret .= $filename.'/'; } - if( getArrayValue($processed_params, $prefix_special.'_Reviews_Page') > 1) - { - if($processed_params[$prefix_special.'_id']) $ret = rtrim($ret, '/'); - $ret .= '_'.$processed_params[$prefix_special.'_Reviews_Page'].'/'; - } - $event->setEventParam('url_params', $url_params); $event->setEventParam('env_string', mb_strtolower($ret) ); } @@ -258,15 +249,17 @@ */ function ParseEnv(&$event) { - // /_ + // / $url_parts = $event->getEventParam('url_parts'); + $vars = $event->getEventParam('vars'); - $defaults = Array('id' => 0, 'Page' => 1, 'Reviews_Page' => 1); - foreach ($defaults as $var_name => $var_value) - { + $defaults = Array('id' => 0, 'Page' => 1); + foreach ($defaults as $var_name => $var_value) { $this->Application->SetVar($event->getPrefixSpecial().'_'.$var_name, $var_value); + $vars[$event->getPrefixSpecial().'_'.$var_name] = $var_value; } + if (!$url_parts) { // $event->status = erFAIL; return false; @@ -276,9 +269,9 @@ $url_part = array_shift($url_parts); // match module page - if( is_numeric($url_part) ) - { + if ( is_numeric($url_part) ) { $this->Application->SetVar( $event->getPrefixSpecial().'_Page', $url_part); + $vars[$event->getPrefixSpecial().'_Page'] = $url_part; $url_part = $url_parts ? array_shift($url_parts) : ''; } @@ -288,37 +281,29 @@ 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 $db =& $this->Application->GetADODBConnection(); $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); - - $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) - { + if ($item_id !== false) { $this->Application->SetVar($event->getPrefixSpecial().'_id', $item_id); + $vars[$event->getPrefixSpecial().'_id'] = $item_id; } - elseif ($url_part !== 'index') // otherwise category/index.html is parsed as /index.tpl - { + elseif ($url_part !== 'index') { + // otherwise category/index.html is parsed as /index.tpl array_unshift($url_parts, $url_part); $event->status = erFAIL; } $event->setEventParam('url_parts', $url_parts); + $event->setEventParam('vars', $vars); } /**