<?php

class Dark_vB4Redir_Route_Prefix_Forums extends XFCP_Dark_vB4Redir_Route_Prefix_Forums implements XenForo_Route_Interface 
{
	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
	{
		
		if(!preg_match('/\w+\.([0-9]+)\/?/', $routePath))
		{
			if(preg_match('/^([0-9]+)(?:-[^\/]+)/', $routePath, $matches) && count($matches) >= 1){	
				$importModel = XenForo_Model::create('XenForo_Model_Import');
				$target = XenForo_Link::buildPublicLink('forums', array('node_id' => $importModel->mapNodeId($matches[1])));
				$response = new Zend_Controller_Response_Http();
				$response->setRedirect(XenForo_Link::convertUriToAbsoluteUri($target), 301);
				$response->sendResponse();
				exit;
			}
		}
		
		if($this instanceof XFCP_Dark_vB4Redir_Route_Prefix_Forums)
			return parent::match($routePath, $request, $router);	
	}
}