Ejemplo n.º 1
0
 /**
  * Attempts to match the routing path.
  * See {@link XenForo_Route_Interface} for further details.
  *
  * @param string Routing path
  * @param Zend_Controller_Request_Http Request object
  * @param XenForo_Router Routing object
  *
  * @return false XenForo_RouteMatch
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     list($prefix) = explode('/', $routePath);
     if ($prefix === '') {
         return false;
     }
     $delimQuoted = preg_quote(XenForo_Application::URL_ID_DELIMITER);
     $extension = '';
     $xenOptions = XenForo_Application::get('options');
     if ($xenOptions->th_shorterRoutes_extension) {
         $extension = preg_quote('.' . $xenOptions->th_shorterRoutes_extension);
     }
     if (!preg_match('#^([^' . $delimQuoted . '^/]*' . $delimQuoted . ')?([a-zA-Z]+)([0-9]+)' . $extension . '#', $prefix, $matches)) {
         return false;
     }
     $title = $matches[1];
     $shorterPrefix = $matches[2];
     $integer = $matches[3];
     if ($shorterPrefix == 'f') {
         $routeClass = XenForo_Link::getPrefixHandlerClassName($this->_routeType, 'forums');
     } elseif ($shorterPrefix == 't') {
         $routeClass = XenForo_Link::getPrefixHandlerClassName($this->_routeType, 'threads');
     } else {
         return false;
     }
     if (!$routeClass) {
         return false;
     }
     $newRoutePath = $title . $integer . '/' . substr($routePath, strlen($prefix) + 1);
     return $this->_loadAndRunSubRule($routeClass, $newRoutePath, $request, $router);
 }
Ejemplo n.º 2
0
 /**
  * Attempts to match the routing path. See {@link XenForo_Route_Interface} for further details.
  *
  * @param string Routing path
  * @param Zend_Controller_Request_Http Request object
  * @param XenForo_Router Routing object
  *
  * @return false|XenForo_RouteMatch
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     list($prefix) = explode('/', $routePath);
     if ($prefix === '') {
         return false;
     }
     if (preg_match('#[^a-zA-Z0-9_-]#', $prefix)) {
         return false;
     }
     $routeClass = XenForo_Link::getPrefixHandlerClassName($this->_routeType, $prefix);
     if (!$routeClass) {
         return false;
     }
     $newRoutePath = substr($routePath, strlen($prefix) + 1);
     if (!is_string($newRoutePath)) {
         $newRoutePath = '';
     }
     return $this->_loadAndRunSubRule($routeClass, $newRoutePath, $request, $router);
 }