Index: trunk/core/kernel/event_handler.php =================================================================== diff -u -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() ); + } + + } }