getPrefixSpecial(); $url_params = $event->getEventParam('url_params'); $pass_events = $event->getEventParam('pass_events'); $query_vars = $this->Application->getUnitOption($event->Prefix, 'QueryString'); $event_key = array_search('event', $query_vars); if ($event_key) { // pass through event of this prefix unset($query_vars[$event_key]); } if (!getArrayValue($url_params, $prefix_special.'_event')) { // if empty event, then remove it from url unset( $url_params[$prefix_special.'_event'] ); } //if pass events is off and event is not implicity passed 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) { //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 = ''; // topic 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); if ($template == $item_template || strtolower($template) == '__default__') { unset($url_params['t']); } $ret .= $processed_params[$prefix_special.'_id'].'/'; } if($processed_params[$prefix_special.'_Page'] > 1) { if ($processed_params[$prefix_special.'_Page']) $ret = rtrim($ret, '/'); $ret .= '_'.$processed_params[$prefix_special.'_Page'].'/'; } // post if($processed_params[$prefix_special.'_post_id']) { $ret .= $processed_params[$prefix_special.'_post_id'].'/'; } if($processed_params[$prefix_special.'_Post_Page'] > 1) { if ($processed_params[$prefix_special.'_post_id']) $ret = rtrim($ret, '/'); $ret .= '_'.$processed_params[$prefix_special.'_Post_Page'].'/'; } // private message if($processed_params[$prefix_special.'_pm_id']) { $ret .= 'pm_'.$processed_params[$prefix_special.'_pm_id'].'/'; } if($processed_params[$prefix_special.'_pm_Page'] > 1) { if ($processed_params[$prefix_special.'_pm_id']) $ret = rtrim($ret, '/'); $ret .= '_'.$processed_params[$prefix_special.'_pm_Page'].'/'; } $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'); $defaults = Array('id' => 0, 'Page' => 1, 'Reviews_Page' => 1, 'post_id' => 0, 'Post_Page' => 1, 'pm_id' => 0, 'pm_Page' => 1); foreach ($defaults as $var_name => $var_value) { $this->Application->SetVar($event->getPrefixSpecial().'_'.$var_name, $var_value); } if (!$url_parts) { return false; } $ret = ''; $url_part = array_shift($url_parts); if($url_part && substr($url_part,0,3) != 'pm_') { // match topic page if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) { $url_part = $rets[1]; $this->Application->SetVar( $event->getPrefixSpecial().'_Page', $rets[2]); } if (is_numeric($url_part)) { // match topic id (we don't use names here) $this->Application->SetVar($event->getPrefixSpecial().'_id', $url_part); $url_part = $url_parts ? array_shift($url_parts) : ''; } } if($url_part && substr($url_part,0,3) != 'pm_') { // match post page if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) { $url_part = $rets[1]; $this->Application->SetVar( $event->getPrefixSpecial().'_Post_Page', $rets[2]); } if (is_numeric($url_part)) { // match post id $this->Application->SetVar($event->getPrefixSpecial().'_post_id', $url_part); $url_part = $url_parts ? array_shift($url_parts) : ''; } } if($url_part && substr($url_part,0,3) == 'pm_') { $url_part = substr($url_part, 3, strlen($url_part) ); // match private message page if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) { $url_part = $rets[1]; $this->Application->SetVar( $event->getPrefixSpecial().'_pm_Page', $rets[2]); } if (is_numeric($url_part)) { // match private message id $this->Application->SetVar($event->getPrefixSpecial().'_pm_id', $url_part); $url_part = $url_parts ? array_shift($url_parts) : ''; } } if ($url_part) { array_unshift($url_parts, $url_part); } $event->setEventParam('url_parts', $url_parts); } /** * Lock or unlock topic * * @param kEvent $event */ function OnToggleLock(&$event) { $object =& $event->getObject(); $new_type = $object->GetDBField('TopicType') ? 0 : 1; $object->SetDBField('TopicType', $new_type); $object->Update(); } } ?>