Example #1
0
/**
 * 
 * @param PCRouter $router
 */
function addCompatibilityRoutes($router) {
    //aggiungo ajax

    $categoriesRoute = new PCRouterRoute("/ajax/PCAjaxCategoriesController.php", "categories", "PCAjaxCategoriesController");
    $categoriesRoute->addSubroute(new PCRouterSubroute("all", "allAction"));
    $categoriesRoute->setType(PCRequest::TYPE_AJAX);
    $router->addRoute($categoriesRoute, PCRequest::TYPE_WEB);

//aggiungo user-ajax

    $userAjaxRoute = new PCRouterRoute("/ajax/PCAjaxUsersController.php", "usersajax", "PCAjaxUsersController");
    $userAjaxRoute->addSubroute(new PCRouterSubroute("login", "loginAction"));
    $userAjaxRoute->addSubroute(new PCRouterSubroute("repass", "handleRepassAction"));
    $userAjaxRoute->addSubroute(new PCRouterSubroute("register", "registerAction", PCRequest::HTTP_METHOD_POST));
    $userAjaxRoute->addSubroute(new PCRouterSubroute("contact", "contactAction", PCRequest::HTTP_METHOD_POST));
    $userAjaxRoute->addSubroute(new PCRouterSubroute("changepwd", "changePasswordAction", PCRequest::HTTP_METHOD_POST));
    $userAjaxRoute->setType(PCRequest::TYPE_AJAX);
    $router->addRoute($userAjaxRoute, PCRequest::TYPE_WEB);


    $sitesAjax = new PCRouterRoute("/ajax/PCAjaxSitesController.php", "sitesajax", "PCAjaxSitesController");
    $sitesAjax->addSubroute(new PCRouterSubroute('url', 'getSiteByURLAction'));
    $sitesAjax->addSubroute(new PCRouterSubroute('review', 'getSiteReviewsAction'));
    $sitesAjax->addSubroute(new PCRouterSubroute('add', 'addReviewAction', PCRequest::HTTP_METHOD_POST));
    $sitesAjax->addSubroute(new PCRouterSubroute('reportspam', 'reportSpamAction', PCRequest::HTTP_METHOD_POST));
    $sitesAjax->setType(PCRequest::TYPE_AJAX);
    $router->addRoute($sitesAjax, PCRequest::TYPE_WEB);
}
Example #2
0
 /**
  * returns the correct subroute for this request
  * @param PCRouterRoute $route
  * @param string $actionName 
  * @return PCRouterSubroute the correct subroute for this request
  */
 private function getSubrouteForRequest($route, $actionName)
 {
     $actionName = strtolower($actionName);
     return $route->getSubroute($actionName);
 }