function defineRoutes()
 {
     // Login route
     Router::map('auth_login_frosso', 'sso-login', array('controller' => 'frosso_auth', 'action' => 'login'));
     // Admin Route
     Router::map('auth_login_frosso_admin', 'admin/login-frosso-config', array('controller' => 'frosso_auth_admin'));
 }
Exemple #2
0
 /**
  * Resource map
  *
  * @param string $path
  * @param string $namespace
  * @param array  $excepts
  * @throws \InvalidArgumentException
  */
 public function resource($path, $namespace, $excepts = array())
 {
     foreach ($this->injectors['resource'] as $type => $opt) {
         if (in_array($type, $excepts)) {
             continue;
         }
         $this->router->map($path . (!empty($opt[1]) ? '/' . $opt[1] : ''), $namespace . '\\' . (!empty($opt[2]) ? $opt[2] : ucfirst($type)), $opt[0]);
     }
 }
 function defineRoutes()
 {
     // Hijacked Route
     Router::map('project_tasks', 'projects/:project_slug/tasks', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'index'));
     // Single task
     // Servono perch� se viene salvato un task tra i preferiti, viene caricata la view dei tasks di default, senza il responsabile
     Router::map('project_task', 'projects/:project_slug/tasks/:task_id', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'view'), array('task_id' => Router::MATCH_ID));
     Router::map('project_task_edit', 'projects/:project_slug/tasks/:task_id/edit', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'edit'), array('task_id' => Router::MATCH_ID));
     Router::map('frosso_tasks_tab_route', 'projects/:project_slug/tasks-old', array('controller' => 'tasks', 'action' => 'index', 'module' => TASKS_MODULE));
 }
Exemple #4
0
 /**
  * @expectedException \RuntimeException
  */
 public function testPathForRouteNotExists()
 {
     $methods = ['GET'];
     $pattern = '/hello/{first}/{last}';
     $callable = function ($request, $response, $args) {
         echo sprintf('Hello %s %s', $args['first'], $args['last']);
     };
     $route = $this->router->map($methods, $pattern, $callable);
     $route->setName('foo');
     $this->router->pathFor('bar', ['first' => 'josh', 'last' => 'lockhart']);
 }
Exemple #5
0
 public static function load(Router $router, $resource, FileLocator $fileLocator)
 {
     $path = $fileLocator->locate($resource);
     $content = self::loadFile($path);
     // empty file
     if (null === $content) {
         return;
     }
     foreach ($content as $key => $val) {
         $router->map($val["methods"], $val["route"], $val["target"], $key);
     }
 }
Exemple #6
0
 /**
  * Adds a new route
  * @param string $method The HTTP method (GET/POST)
  * @param string $route The route
  * @param mixed $title Either the title of the page or a closure (same as $function)
  * @param Closure $function The code to run
  * @return void
  */
 public function add($method, $route, $title, $function = null)
 {
     if ($function === null) {
         $function = $title;
         $class = explode('@', $function);
         $class_name = $this->framework->getNameSpace() . '\\Controllers\\' . $class[0];
         $object = new $class_name($this, $this->framework);
         $function = array($object, $class[1]);
         $title = null;
     }
     $name = $this->sanitize_function($route);
     $this->routes[$name] = array('method' => strtoupper($method), 'route' => $route, 'title' => $title, 'function' => $function);
     $this->router->map(strtoupper($method), $route, $function, $name);
 }
Exemple #7
0
 /**
      * Figure out where the user is trying to get to and route them to the appropriate controller/action.
 //剖析網址的規則, 取得 Controller/Action
 */
 public function router()
 {
     $r = new Router();
     // Configure the routes, where the user should go when they access the
     // specified URL structures. Default controller and action is set in the config.php file.
     $r->map('/', array('controller' => ROUTER_DEFAULT_CONTROLLER, 'action' => ROUTER_DEFAULT_ACTION));
     // Load instructions for basic routing and send the user on their way!
     $r->default_routes();
     $r->execute();
     // Extracting info about where the user is headed, in order to match the
     // URL with the correct controllers/actions.
     $controller = $r->controller;
     $model = $r->controller_name;
     $action = $r->action;
     $id = $r->id;
     $params = $r->params;
     // Returns an array(...)
     $matched = $r->route_found;
     // Bool, where True is if a route was found.
     if ($matched) {
         // If going to a site page, treat it in special manner, otherwise load
         // the appropriate controller/action and pass in the variables and
         // parameters specified by the URL.
         $controller_file = BASE_DIR . "/controller/{$controller}.php";
         if ($controller == "site") {
             $site = new Site();
             $site->login();
             $site->home();
         } elseif (file_exists($controller_file)) {
             include_once $controller_file;
             $site = new Site();
             $site->login();
             ${$controller} = new $model();
             if (method_exists(${$controller}, $action)) {
                 ${$controller}->controller['controller'] = $controller;
                 ${$controller}->controller['action'] = $action;
                 ${$controller}->id = $id;
                 ${$controller}->params = $params;
                 ${$controller}->{$action}();
             } else {
                 Site::load_page('error');
             }
         } else {
             Site::load_page('error');
         }
     } else {
         Site::home();
     }
 }
 function defineRoutes()
 {
     // Reports
     Router::map('frosso_estimated_cost_report', 'reports/frosso-ecr', array('controller' => 'frosso_estimated_cost_reports', 'action' => 'index'));
     Router::map('frosso_estimated_cost_report_run', 'reports/frosso-ecr-run', array('controller' => 'frosso_estimated_cost_reports', 'action' => 'form_run'));
     Router::map('frosso_testing_route', 'reports/frosso-test', array('controller' => 'frosso_testing', 'action' => 'index'));
     Router::map('frosso_ec_set_milestone_percent', 'projects/:project_slug/milestones/:milestone_id/percent/set', array('controller' => 'milestones_tracking', 'action' => 'set_percent'));
     // Hijacked Routes
     Router::map('project_milestones', 'projects/:project_slug/milestones', array('controller' => 'milestones_tracking', 'action' => 'index'));
     Router::map('project_milestone', 'projects/:project_slug/milestones/:milestone_id', array('controller' => 'milestones_tracking', 'action' => 'view'), array('milestone_id' => Router::MATCH_ID));
     Router::map('project_milestones_add', 'projects/:project_slug/milestones/add', array('controller' => 'milestones_tracking', 'action' => 'add'));
     Router::map('project_milestone_edit', 'projects/:project_slug/milestones/:milestone_id/edit', array('controller' => 'milestones_tracking', 'action' => 'edit'), array('milestone_id' => Router::MATCH_ID));
     Router::map('project_object_update_milestone', 'projects/:project_slug/objects/:object_id/update-milestone', array('controller' => 'milestones_tracking', 'action' => 'update_milestone'), array('object_id' => Router::MATCH_ID));
     // Tracking
     if (AngieApplication::isModuleLoaded('tracking')) {
         // prefisso, url, nome controller, nome modulo, parametri extra
         AngieApplication::getModule('tracking')->defineTrackingRoutesFor('project_milestone', 'projects/:project_slug/milestones/:milestone_id', 'milestones_tracking', FROSSO_EC_MODULE, array('milestone_id' => Router::MATCH_ID));
     }
     // if
 }
 /**
  * Figure out where the user is trying to get to and route them to the
  * appropriate controller/action.
  */
 function router()
 {
     // Create a new Router instance.
     $r = new Router();
     // Configure the routes, where the user should go when they access the
     // specified URL structures. Default controller and action is set in the
     // config.php file.
     $r->map('/', array('controller' => ROUTER_DEFAULT_CONTROLLER, 'action' => ROUTER_DEFAULT_ACTION));
     $r->map('/user', array('controller' => 'user', 'action' => 'index'));
     $r->map('/login', array('controller' => 'user', 'action' => 'login'));
     $r->map('/logout', array('controller' => 'user', 'action' => 'logout'));
     $r->map('/signup', array('controller' => 'user', 'action' => 'register'));
     $r->map('/users/:id', array('controller' => 'users'), array('id' => '[\\d]{1,8}'));
     // Load instructions for basic routing and send the user on their way!
     $r->default_routes();
     $r->execute();
     // Extracting info about where the user is headed, in order to match the
     // URL with the correct controllers/actions.
     $controller = $r->controller;
     $model = $r->controller_name;
     $action = $r->action;
     $id = $r->id;
     $params = $r->params;
     // Returns an array(...)
     $matched = $r->route_found;
     // Bool, where True is if a route was found.
     if ($matched) {
         // If going to a site page, treat it in special manner, otherwise load
         // the appropriate controller/action and pass in the variables and
         // parameters specified by the URL.
         if ($controller == "site") {
             $site = new Site();
             $site->load_page($action);
         } elseif (file_exists(LIB_DIR . '/controllers/' . $controller . '.php')) {
             ${$controller} = new $model();
             if (method_exists(${$controller}, $action)) {
                 ${$controller}->{$action}($id, $params[0], $params[1]);
             } else {
                 Site::load_page('error');
             }
         } else {
             Site::load_page('error');
         }
     } else {
         Site::load_page('home');
     }
 }
 /**
  * Define module routes
  */
 function defineRoutes()
 {
     Router::map('add_git_repository', '/projects/:project_slug/repositories/add-git', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_repo'));
     Router::map('project_repositories', '/projects/:project_slug/repositories', array('controller' => 'project_tracking_gitolite', 'action' => 'index'));
     Router::map('repository_history', '/projects/:project_slug/repositories/:project_source_repository_id', array('controller' => 'project_tracking_gitolite', 'action' => 'history'), array('project_source_repository_id' => Router::MATCH_ID));
     Router::map('project_project_source_repository', '/projects/:project_slug/repositories/:project_source_repository_id', array('controller' => 'project_tracking_gitolite', 'action' => 'history'), array('project_source_repository_id' => Router::MATCH_ID));
     Router::map('get_public_keys', 'people/:company_id/users/:user_id/public-keys', array('controller' => 'ac_gitolite', 'action' => 'getpublickeys'));
     Router::map('add_public_keys', 'people/:company_id/users/:user_id/add-public-keys', array('controller' => 'ac_gitolite', 'action' => 'add_public_keys'));
     Router::map('remove_key', 'people/:company_id/users/:user_id/delete-keys/:key_id', array('controller' => 'ac_gitolite', 'action' => 'remove_key'));
     Router::map('gitolite_admin', 'admin/gitolite_admin', array('controller' => 'ac_gitolite_admin', 'action' => 'index'));
     Router::map('gitolite_admin_change', 'admin/change_gitolite_setings', array('controller' => 'ac_gitolite_admin', 'action' => 'gitolite_admin'));
     Router::map('gitolite_test_connection', 'admin/test_connection', array('controller' => 'ac_gitolite_admin', 'action' => 'test_connection'));
     Router::map('edit_git_repository', '/projects/:project_slug/repositories/:project_source_repository_id/edit-git', array('controller' => 'project_tracking_gitolite', 'action' => 'edit_git_repo'));
     Router::map('deleted_gitolite_repo', '/projects/:project_slug/repositories/:project_source_repository_id/delete-repo', array('controller' => 'project_tracking_gitolite', 'action' => 'delete_gitolite_repository'));
     Router::map('add_gitolite_steps', '/projects/:project_slug/repositories/:project_source_repository_id/action/:action/params/:params', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_repo'));
     Router::map('delele_repo_url', 'admin/gitolite_admin/delete', array('controller' => 'ac_gitolite_admin', 'action' => 'delete_repo'));
     Router::map('need_help_path', 'admin/gitolite_admin/help', array('controller' => 'ac_gitolite_admin', 'action' => 'need_help'));
     Router::map('repository_update', '/projects/:project_slug/repositories/:project_source_repository_id/update', array('controller' => 'project_tracking_gitolite', 'action' => 'update'), array('project_source_repository_id' => Router::MATCH_ID));
     Router::map('add_remote_git', '/projects/:project_slug/repositories/add-remote-git', array('controller' => 'project_tracking_gitolite', 'action' => 'add_remote_git_repo'));
     Router::map('save_admin_settings', 'admin/save_admin_settings', array('controller' => 'ac_gitolite_admin', 'action' => 'save_admin_settings'));
     Router::map('check_user_exists', 'admin/check_user_exists', array('controller' => 'ac_gitolite_admin', 'action' => 'check_user_exists'));
     Router::map('map_users', 'admin/map_users', array('controller' => 'ac_gitolite_admin', 'action' => 'map_conf_user'));
     Router::map('map_repos', 'admin/map_repos', array('controller' => 'ac_gitolite_admin', 'action' => 'map_conf_repos'));
     Router::map('render_after_clone', 'admin/render_after_clone', array('controller' => 'ac_gitolite_admin', 'action' => 'render_after_clone_conf'));
     Router::map('admin_source', '/admin/tools/source', array('controller' => 'ac_gitolite_source', 'action' => 'index'));
     Router::map('admin_source_git_repository_delete', '/admin/tools/source/git-repositories/:source_repository_id/delete-new', array('controller' => 'ac_gitolite_source', 'action' => 'delete_git'), array('source_repository_id' => Router::MATCH_ID));
     Router::map('clone_source_git_repository', '/admin/tools/source/clone-gitolite', array('controller' => 'ac_gitolite_source', 'action' => 'clone_source_git_repository'));
     Router::map('repository_add_existing', '/projects/:project_slug/repositories/add-existing', array('controller' => 'project_tracking_gitolite', 'action' => 'add_existing'));
     Router::map('add_source_gitolite_repository', '/admin/tools/source/add-gitolite-repo', array('controller' => 'ac_gitolite_source', 'action' => 'add_source_gitolite_repository'));
     Router::map('add_hooks_git', '/projects/:project_slug/repositories/:project_source_repository_id/add-git-hook', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_hooks'), array('project_source_repository_id' => Router::MATCH_ID));
     Router::map('test_hooks_url', '/projects/:project_slug/repositories/:project_source_repository_id/test-hooks-url', array('controller' => 'project_tracking_gitolite', 'action' => 'test_hooks_url'), array('project_source_repository_id' => Router::MATCH_ID));
     Router::map('hookcall', 'hookcall', array('controller' => 'ac_gitolite_hooks', 'action' => 'hooks_call'));
     Router::map('add_ftp_conn', '/projects/:project_slug/repositories/:project_source_repository_id/add-ftp-details', array('controller' => 'project_tracking_gitolite', 'action' => 'add_ftp_connections'));
     Router::map('test_ftp_conn', '/projects/:project_slug/repositories/:project_source_repository_id/test-ftp-details', array('controller' => 'project_tracking_gitolite', 'action' => 'test_ftp_connection'));
     //Router::map('map_repos', '/projects/:project_slug/repositories/map-remote-git', array('controller'=>'project_tracking_gitolite', 'action'=>'map_conf_repos'), array('project_slug'=>Router::MATCH_SLUG));
 }
Exemple #11
0
  
  $r->match("/artist/:artist")->to(array("controller" => "application", "action" => "show"))->name("artist");
  
  $r->match("/book(/:id)")->to(array("controller" => "application", "action" => "show"))->name("show_book");
  
  $r->match("/user/profile")->to(array("controller" => "application", "action" => "profile"))->name("user_profile");
  
  $r->match("/app/:action")->to(array("controller" => "application"))->name("app");
  $r->match("/app/:action.:format")->to(array("controller" => "application"));
  
  $r->match("/:controller/:action(/:id)")->to();
});
*/
Router::map(function ($r) {
    $r->root("/", array("controller" => "application", "action" => "show"));
    $r->the_name_format("/the_name/:action.:format", array("controller" => "application"));
    $r->api_recent("/api/recent.:format", array("controller" => "application", "action" => "api_recent"));
    $r->the_name("/the_name", array("controller" => "application", "action" => "the_name"));
    $r->session_set("/artist/session_set", array("controller" => "application", "action" => "session_set"));
    $r->redirect("/artist/redirect", array("controller" => "application", "action" => "redirect"));
    $r->flash_example("/artist/flash_example", array("controller" => "application", "action" => "flash_example"));
    $r->flash_show("/artist/flash_show", array("controller" => "application", "action" => "flash_show"));
    $r->my_layout("/artist/my_layout", array("controller" => "application", "action" => "my_layout"));
    $r->html_form("/artist/html_form", array("controller" => "application", "action" => "html_form"));
    $r->artist("/artist/:artist", array("controller" => "application", "action" => "show"));
    $r->show_book("/book(/:id)", array("controller" => "application", "action" => "show"));
    $r->user_profile("/user/profile", array("controller" => "application", "action" => "profile"));
    $r->app("/app/:action", array("controller" => "application"));
    $r->connect("/app/:action.:format", array("controller" => "application"));
    $r->connect("/:controller/:action(/:id)");
});
<?php

require 'Router.php';
require 'Route.php';
$router = new Router();
$router->setBasePath('/PHP-Router');
$router->map('/', 'someController:indexAction', array('methods' => 'GET'));
$router->map('/users/', 'users#create', array('methods' => 'POST', 'name' => 'users_create'));
$router->map('/users/:id/edit/', 'users#edit', array('methods' => 'GET', 'name' => 'users_edit', 'filters' => array('id' => '(\\d+)')));
$router->map('/contact/', array('controller' => 'someController', 'action' => 'contactAction'), array('name' => 'contact'));
$router->map('/blog/:slug', array('c' => 'BlogController', 'a' => 'showAction'));
// capture rest of URL in "path" parameter (including forward slashes)
$router->map('/site-section/:path', 'some#target', array('filters' => array('path' => '(.*)')));
$route = $router->matchCurrentRequest();
?>
<h3>Current URL & HTTP method would route to: </h3>
<?php 
if ($route) {
    ?>
	<strong>Target:</strong>
	<pre><?php 
    var_dump($route->getTarget());
    ?>
</pre>

	<strong>Parameters:</strong>
	<pre><?php 
    var_dump($route->getParameters());
    ?>
</pre>
<?php 
Exemple #13
0
include 'php/fs/dml.flatfs.class.inc.php';
include 'web_framework/router.class.php';
include 'php/reporter.php';
include 'php/mappers/usermapper.php';
include 'php/models/user.class.php';
include 'php/mappers/foldermapper.php';
include 'php/models/folder.class.php';
include 'php/mappers/filemapper.php';
include 'php/models/file.class.php';
/* This is the front-end controller */
$rout_r = new Router();
$rout_r->map('GET', '/', function () {
    global $GLOBALS;
    session_start();
    if (!isset($_SESSION['userID'])) {
        $tpl_engine = $GLOBALS['tpl_engine'];
        $tpl_engine->__set_filetpl('index.html', NULL);
        $tpl_engine->render();
    }
    header("Location:" . $GLOBALS["url"] . "/control-panel/");
});
$rout_r->map('GET', '/control-panel/', function () {
    session_start();
    if (isset($_SESSION['userID'])) {
        global $GLOBALS;
        $tpl_engine = $GLOBALS['tpl_engine'];
        $db = new MySqlDAO();
        $userMapper = new UserMapper($db);
        $user = $userMapper->findById($_SESSION['userID']);
        $tpl_engine->__set_filetpl('main.html', array('user' => $user->getUserName()));
        $tpl_engine->render();
    } else {
$feide = new Dataporten($feide_config);
//  http://altorouter.com
require_once $BASE . '/lib/router.class.php';
$router = new Router();
// $router->addMatchTypes(array('userlist' => '[0-9A-Za-z\[\]@.,%]++'));
$router->setBasePath($API_BASE_PATH);
// Relay API
require_once $BASE . '/lib/relay.class.php';
$relay_config = json_decode(file_get_contents($RELAY_CONFIG_PATH), true);
$relay = new Relay($relay_config);
// ---------------------- DEFINE ROUTES ----------------------
/**
 * GET all REST routes
 */
$router->map('GET', '/', function () {
    global $router;
    Response::result($router->getRoutes());
}, 'Routes listing');
/**
 * GET TechSmith Relay version
 */
$router->map('GET', '/version/', function () {
    global $relay;
    Response::result($relay->getRelayVersion());
}, 'TechSmith Relay version');
/**
 * GET Template
 *
 * $router->map('GET', '/PATH/[i:iD]/status/', function ($iD) {
 * global $dataporten;
 * Response::result(array('status' => true, 'data' => $dataporten->SOME_FUNCTION($iD)));
 * }, 'DESCRIPTION OF ROUTE');
Exemple #15
0
$dataporten_config = json_decode(file_get_contents($DATAPORTEN_CONFIG_PATH), true);
$dataporten = new Dataporten($dataporten_config);
//  http://altorouter.com
require_once $BASE . '/lib/router.class.php';
$router = new Router();
$router->setBasePath($API_BASE_PATH);
// Proxy API to Adobe Connect
require_once $BASE . '/lib/adobeconnect.class.php';
$adobe_config = json_decode(file_get_contents($ADOBE_CONNECT_CONFIG_PATH), true);
$connect = new AdobeConnect($adobe_config);
// ---------------------- DEFINE ROUTES ----------------------
/**
 * GET all REST routes
 */
$router->map('GET', '/', function () {
    global $router;
    Response::result(array('status' => true, 'routes' => $router->getRoutes()));
}, 'Routes listing');
/**
 * GET Adobe Connect version
 */
$router->map('GET', '/version/', function () {
    global $connect;
    Response::result($connect->getConnectVersion());
}, 'Adobe Connect version');
/**
 * Get all subfolders for Shared Meetings/{$orgFolderName}
 */
$router->map('GET', '/folder/[a:org]/nav/', function ($orgFolderName) {
    verifyOrgAccess($orgFolderName);
    global $connect;
    Response::result($connect->getOrgFolderNav($orgFolderName));
Exemple #16
0
<?php

$router = new Router();
// create router instance
$router->map('/', array('controller' => 'home'));
// Repositories
// Completed
$router->map('/:project', array('controller' => 'projects', 'action' => 'show', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/tree', array('controller' => 'projects', 'action' => 'show', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/tree/:branch', array('controller' => 'projects', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+'));
// Completed
$router->map('/:project/tree/:branch/:filepath', array('controller' => 'projects', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/branch_redirect', array('controller' => 'projects', 'action' => 'branch_redirect'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/commit/:commit', array('controller' => 'commits', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'commit' => '[\\w]+'));
// Completed
$router->map('/:project/commits', array('controller' => 'commits', 'action' => 'index', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/commits/:branch', array('controller' => 'commits', 'action' => 'index'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+'));
//Files
$router->map('/:project/blob/:branch/:filepath', array('controller' => 'projects', 'action' => 'blob'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/raw/:branch/:filepath', array('controller' => 'projects', 'action' => 'raw'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/blame/:branch/:filepath', array('controller' => 'projects', 'action' => 'blame'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/download/:branch/:filepath', array('controller' => 'projects', 'action' => 'download'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->default_routes();
$router->execute();
<?php

require_once 'environment.default.php';
session_start();
include 'lib/redis/RedisClient.php';
include 'lib/redis/Redis.php';
include 'Router.php';
include 'controllers/ApplicationController.php';
include 'controllers/RedisController.php';
include 'controllers/iRedisType.php';
include 'bootstrap.php';
// http://blog.sosedoff.com/2009/07/04/simpe-php-url-routing-controller/
$r = new Router();
// create router instance
$r->map('/search', array('controller' => 'search', 'action' => 'index'));
$r->map('/', array('controller' => 'home'));
$r->default_routes();
$r->execute();
$class_name = $r->controller_name . 'Controller';
$path_to_controller = 'controllers/' . $class_name . '.php';
if (is_file($path_to_controller)) {
    require_once $path_to_controller;
} else {
    echo '<div class="error">Controller not found!</div>';
    exit;
}
$dispatch = new $class_name();
if (!method_exists($dispatch, $r->action)) {
    echo '<div class="error">Action <b>' . $r->action . '</b> not specified in <b>' . $r->controller_name . 'Controller</b></div>';
    exit;
} else {
Exemple #18
0
 private function getRequestedMethodValidity($requestedMethod, $routeRuleMethod, $expected)
 {
     $_SERVER['REQUEST_METHOD'] = $requestedMethod;
     $_SERVER['REQUEST_URI'] = PATH . '/tests.php/news/';
     $router = new Router(true);
     $router->map($routeRuleMethod, '/news/', function () {
         return Adapter::invokeAdapter('News', 'addNews');
     });
     $actual = json_decode($router->match(), true);
     $testStatus = $this->getStatus($expected, $actual);
     return $testStatus;
 }
 function defineRoutes()
 {
     Router::map('frosso_testing_route', 'frosso-test', array('controller' => 'frosso_testing', 'action' => 'index'));
 }
 function defineRoutes()
 {
     Router::map('frosso_gc_route', 'projects/:project_slug/frosso-gc', array('controller' => 'frosso_gantt_chart', 'action' => 'index'));
 }
Exemple #21
0
<?php

require 'mvc/Router.inc.php';
$router = new Router();
// Set controller to 404 to block access to an action via a particular URL
// Sync
if ($_SERVER['HTTP_HOST'] == Z_CONFIG::$SYNC_DOMAIN) {
    $router->map('/', array('controller' => 'Sync', 'action' => 'index'));
    $router->map('/:action', array('controller' => 'Sync'));
} else {
    $router->map('/', array('controller' => 'Api', 'action' => 'noop', 'extra' => array('allowHTTP' => true)));
    // Groups
    $router->map('/groups/i:objectGroupID', array('controller' => 'Groups'));
    $router->map('/groups/i:scopeObjectID/users/i:objectID', array('controller' => 'Groups', 'action' => 'groupUsers'));
    // Top-level objects
    $router->map('/users/i:objectUserID/publications/items/top', ['controller' => 'Items', 'extra' => ['subset' => 'top', 'publications' => true]]);
    $router->map('/users/i:objectUserID/:controller/top', array('extra' => array('subset' => 'top')));
    $router->map('/groups/i:objectGroupID/:controller/top', array('extra' => array('subset' => 'top')));
    // Attachment files
    $router->map('/users/i:objectUserID/laststoragesync', array('controller' => 'Storage', 'action' => 'laststoragesync', 'extra' => array('auth' => true)));
    $router->map('/users/i:objectUserID/publications/laststoragesync', ['controller' => 'Storage', 'action' => 'laststoragesync', 'extra' => ['auth' => true, 'publications' => true]]);
    $router->map('/groups/i:objectGroupID/laststoragesync', array('controller' => 'Storage', 'action' => 'laststoragesync', 'extra' => array('auth' => true)));
    $router->map('/users/i:objectUserID/storageadmin', array('controller' => 'Storage', 'action' => 'storageadmin'));
    $router->map('/storagepurge', array('controller' => 'Storage', 'action' => 'storagepurge'));
    $router->map('/users/i:objectUserID/removestoragefiles', array('controller' => 'Storage', 'action' => 'removestoragefiles', 'extra' => array('allowHTTP' => true)));
    $router->map('/users/i:objectUserID/items/:objectKey/file', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true)));
    $router->map('/users/i:objectUserID/items/:objectKey/file/view', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true, 'view' => true)));
    $router->map('/users/i:objectUserID/publications/items/:objectKey/file', ['controller' => 'Items', 'extra' => ['allowHTTP' => true, 'file' => true, 'publications' => true]]);
    $router->map('/users/i:objectUserID/publications/items/:objectKey/file/view', ['controller' => 'Items', 'extra' => ['allowHTTP' => true, 'file' => true, 'view' => true, 'publications' => true]]);
    $router->map('/groups/i:objectGroupID/items/:objectKey/file', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true)));
    $router->map('/groups/i:objectGroupID/items/:objectKey/file/view', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true, 'view' => true)));
Exemple #22
0
<?php

require 'fleet/autoload.php';
$route = new Router();
$view = new View();
$route->map('/blog/(\\w+)/page/(\\d+)', function ($category, $page) use($view) {
    $view->render('test.php', array('title' => 'Blog Application', 'category' => $category, 'page' => $page));
});
$route->run();
 function defineRoutes()
 {
     //overwriten route activecollab/[versione]/modules/tasks/TasksModule.class.php
     Router::map('milestone_tasks', 'projects/:project_slug/milestones/:milestone_id/tasks', array('controller' => 'frosso_milestone_task_assignee', 'action' => 'index'), array('milestone_id' => Router::MATCH_ID));
 }
Exemple #24
0
 /**
  * Resource map
  *
  * @param string $path
  * @param string $namespace
  */
 public function resource($path, $namespace)
 {
     foreach ($this->injectors['resource'] as $type => $opt) {
         $this->router->map($path . (!empty($opt[1]) ? '/' . $opt[1] : ''), $namespace . '\\' . (!empty($opt[2]) ? $opt[2] : ucfirst($type)), $opt[0]);
     }
 }
 /**
  * Define module routes
  */
 function defineRoutes()
 {
     // Timer routes
     Router::map('timer', 'timer', array('controller' => 'timer', 'action' => 'index'));
 }
Exemple #26
0
<?php

require_once 'init.php';
$router = new Router();
$router->map('GET', '', function () {
    loadSmarty();
    show_page('index', 'Home');
});
$router->map('GET', '/news/:id', function ($id) {
    return Adapter::invokeAdapter('News', 'obtaionNews', array('id' => $id));
});
$router->map('GET', '/news/', function () {
    return Adapter::invokeAdapter('News', 'obtaionNews');
});
$router->map('POST', '/news/:id', function ($id) {
    return Adapter::invokeAdapter('News', 'editNews', array('id' => $id));
});
$router->map('POST', '/news/', function () {
    return Adapter::invokeAdapter('News', 'addNews');
});
$router->map('DELETE', '/news/:id', function ($id) {
    return Adapter::invokeAdapter('News', 'deleteNews', array('id' => $id));
});
$router->map('GET', '/users/:userId/', function ($userId) {
    return Adapter::invokeAdapter('Users', 'getUser', array('userId' => $userId));
});
$router->map('GET', '/users/:userId/comments/[:commentId]', function ($userId, $commentId = 0) {
    return Adapter::invokeAdapter('Users', 'getUserComments', array('userId' => $userId, 'commentId' => $commentId));
});
echo $router->match();
 * Serves image tiles, UTFgrid tiles and TileJson definitions 
 * from MBTiles files (as used by TileMill). (Partly) implements
 * the Tile Map Services Specification.
 *
 * Originally based on https://github.com/Zverik/mbtiles-php, 
 * but refactored and extended.
 *
 * @author E. Akerboom (github@infostreams.net)
 * @version 1.1
 * @license LGPL
 */
header('Access-Control-Allow-Origin: *');
$_identifier = '[\\w\\d_-\\s]+';
$_number = '\\d+';
$r = new Router();
$r->map("", array("controller" => "serverinfo", "action" => "hello"));
$r->map("root.xml", array("controller" => "TileMapService", "action" => "root"));
$r->map("1.0.0", array("controller" => "TileMapService", "action" => "service"));
$r->map("1.0.0/:layer", array("controller" => "TileMapService", "action" => "resource"), array("layer" => $_identifier));
$r->map("1.0.0/:layer/:z/:x/:y.:ext", array("controller" => "maptile", "action" => "serveTmsTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(png|jpg|jpeg|json)"));
$r->map(":layer/:z/:x/:y.:ext", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(png|jpg|jpeg|json)"));
$r->map(":layer/:z/:x/:y.:ext\\?:argument=:callback", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer/:z/:x/:y.grid.:ext", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer/:z/:x/:y.grid.:ext\\?:argument=:callback", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer.tilejson", array("controller" => "maptile", "action" => "tilejson"), array("layer" => $_identifier));
$r->map(":layer.tilejsonp\\?:argument=:callback", array("controller" => "maptile", "action" => "tilejson"), array("layer" => $_identifier, "argument" => $_identifier, "callback" => $_identifier));
$r->run();
class BaseClass
{
    protected $layer;
    protected $db;
Exemple #28
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/Resume/app/core/init.php";
//Initialize
var_dump($_SERVER['DOCUMENT_ROOT']);
\Connection::setIP("1.12.1");
//Spoof IP for testing purposes
$User = false;
try {
    if (Session::exists(Config::get("session/session_name"))) {
        $User = new User(Session::get(Config::get("session/session_name")));
    }
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    $User = false;
}
$Visitor = new Visitor();
$Visitor->initialize();
//Should make these routes external
Router::map('/', array('_controller' => 'controllers\\index::create'));
Router::map('/login', array('_controller' => 'controllers\\authenticate\\login::create'));
Router::map('/logout', array('_controller' => 'controllers\\authenticate\\logout::create'));
Router::map('/register', array('_controller' => 'controllers\\authenticate\\register::create'));
Router::dispatch();
Exemple #29
0
 /**
  * Router::cacheNamedRoute should throw na exception if named Route
  * with same name already exists.
  */
 public function testNamedRouteWithExistingName()
 {
     $this->setExpectedException('RuntimeException');
     $request = new Request();
     $router = new Router($request);
     $route1 = $router->map('/foo/bar', function () {
     }, 'GET');
     $route2 = $router->map('/foo/bar/2', function () {
     }, 'GET');
     $router->cacheNamedRoute('bar', $route1);
     $router->cacheNamedRoute('bar', $route2);
 }
Exemple #30
0
$feide = new Dataporten($dataporten_config);
//  http://altorouter.com
require_once $BASE . '/lib/router.class.php';
$router = new Router();
// $router->addMatchTypes(array('userlist' => '[0-9A-Za-z\[\]@.,%]++'));
$router->setBasePath($API_BASE_PATH);
// Proxy API to Adobe Connect
require_once $BASE . '/lib/adobeconnect.class.php';
$adobe_config = json_decode(file_get_contents($ADOBE_CONNECT_CONFIG_PATH), true);
$connect = new AdobeConnect($adobe_config);
// ---------------------- DEFINE ROUTES ----------------------
/**
 * GET all REST routes
 */
$router->map('GET', '/', function () {
    global $router;
    Response::result($router->getRoutes());
}, 'Routes listing');
/**
 * GET Adobe Connect version
 */
$router->map('GET', '/version/', function () {
    global $connect;
    Response::result($connect->getConnectVersion());
}, 'Adobe Connect version');
/**
 * GET Template
 *
$router->map('GET', '/PATH/[i:iD]/status/', function ($iD) {
	global $connect;
	Response::result(array('status' => true, 'data' => $connect->SOME_FUNCTION($iD)));
}, 'DESCRIPTION OF ROUTE');