示例#1
0
 /**
  * Attempts to match the routing path. See {@link XenForo_Route_Interface} for further details.
  *
  * @param string $routePath Routing path
  * @param Zend_Controller_Request_Http $request Request object
  * @param XenForo_Router $router Routing object
  *
  * @return XenForo_RouteMatch|bool
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     if (!XenForo_Application::isRegistered('routeFiltersIn')) {
         return false;
     }
     $filters = XenForo_Application::get('routeFiltersIn');
     if (!$filters) {
         return false;
     }
     foreach ($filters as $filter) {
         if (isset($filter['match_regex'])) {
             $from = $filter['match_regex'];
             $to = $filter['match_replace'];
         } else {
             list($from, $to) = XenForo_Link::translateRouteFilterToRegex(urldecode($filter['replace_route']), urldecode($filter['find_route']));
         }
         $newRoutePath = preg_replace($from, $to, $routePath);
         if ($newRoutePath != $routePath) {
             $match = $router->getRouteMatch();
             $match->setModifiedRoutePath($newRoutePath);
             return $match;
         }
     }
     return false;
 }
示例#2
0
 /**
  *
  * @see XenForo_Route_Prefix_Forums::buildLink()
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if (isset($data['social_forum_id'])) {
         if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) {
             $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray();
         } else {
             $socialForum = $data;
         }
         $class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix');
         $router = new $class();
         $link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams);
         if (XenForo_Application::isRegistered('routeFiltersOut')) {
             $routeFilters = XenForo_Application::get('routeFiltersOut');
             if (isset($routeFilters['social-forums'])) {
                 foreach ($routeFilters['social-forums'] as $filter) {
                     if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) {
                         list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']);
                         $newLink = preg_replace($from, $to, $link);
                     } else {
                         $newLink = $link;
                     }
                     if ($newLink != $link) {
                         $link = $newLink;
                         break;
                     }
                 }
             }
         }
         return $link;
     }
     return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
 }
示例#3
0
 public function getRouteFiltersForCache()
 {
     $results = $this->_getDb()->query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM xf_route_filter\r\n\t\t\tWHERE route_type = 'public' AND enabled = 1\r\n\t\t\tORDER BY LENGTH(replace_route) DESC\r\n\t\t");
     $in = array();
     while ($res = $results->fetch()) {
         list($from, $to) = XenForo_Link::translateRouteFilterToRegex(urldecode($res['replace_route']), urldecode($res['find_route']));
         $in[$res['route_filter_id']] = array('match_regex' => $from, 'match_replace' => $to);
     }
     $results = $this->_getDb()->query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM xf_route_filter\r\n\t\t\tWHERE route_type = 'public'\r\n\t\t\t\tAND enabled = 1\r\n\t\t\t\tAND url_to_route_only = 0\r\n\t\t\tORDER BY prefix, LENGTH(find_route) DESC\r\n\t\t");
     $out = array();
     while ($res = $results->fetch()) {
         list($from, $to) = XenForo_Link::translateRouteFilterToRegex($res['find_route'], $res['replace_route']);
         $out[$res['prefix']][$res['route_filter_id']] = array('match_regex' => $from, 'match_replace' => $to);
     }
     return array('in' => $in, 'out' => $out);
 }