connectNamed() public static method

Do not parse any named parameters: Router::connectNamed(false); Parse only default parameters used for CakePHP's pagination: Router::connectNamed(false, array('default' => true)); Parse only the page parameter if its value is a number: Router::connectNamed(array('page' => '[\d]+'), array('default' => false, 'greedy' => false)); Parse only the page parameter no matter what. Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); Parse only the page parameter if the current action is 'index'. Router::connectNamed( array('page' => array('action' => 'index')), array('default' => false, 'greedy' => false) ); Parse only the page parameter if the current action is 'index' and the controller is 'pages'. Router::connectNamed( array('page' => array('action' => 'index', 'controller' => 'pages')), array('default' => false, 'greedy' => false) ); ### Options - greedy Setting this to true will make Router parse all named params. Setting it to false will parse only the connected named params. - default Set this to true to merge in the default set of named parameters. - reset Set to true to clear existing rules and start fresh. - separator Change the string used to separate the key & value in a named parameter. Defaults to :
public static connectNamed ( array $named, array $options = [] ) : array
$named array A list of named parameters. Key value pairs are accepted where values are either regex strings to match, or arrays as seen above.
$options array Allows to control all settings: separator, greedy, reset, default
return array
Exemplo n.º 1
0
 /**
  * undocumented function
  *
  * @return void
  */
 function index()
 {
     $this->set('disableNav', true);
     Router::connectNamed(array('type', 'page'));
     if (empty($this->passedArgs['type'])) {
         $this->passedArgs['type'] = 'public';
         $projects = $this->Project->User->groups($this->Auth->user('id'));
         if (!empty($projects)) {
             $this->Session->write('Auth.User.ProjectPermission', $projects);
             $this->passedArgs['type'] = null;
             $this->paginate['conditions'] = array('Project.id' => array_keys($projects));
             $this->paginate['order'] = 'Project.private DESC, Project.url ASC';
         }
     }
     if (!empty($this->passedArgs['type'])) {
         $this->paginate['conditions'] = array('Project.private' => 0, 'Project.active' => 1, 'Project.approved' => 1);
         if ($this->passedArgs['type'] == 'forks') {
             $this->paginate['conditions']['Project.fork !='] = null;
             $this->paginate['order'] = 'Project.url ASC';
         } else {
             if ($this->passedArgs['type'] == 'public') {
                 $this->paginate['conditions']['Project.fork ='] = null;
                 $this->paginate['order'] = 'Project.url ASC';
             }
         }
     }
     if (User::get('id') == 1) {
         unset($this->paginate['conditions']);
         $this->paginate['order'] = 'Project.private ASC, Project.url ASC';
     }
     $this->Project->recursive = 0;
     $projects = $this->paginate();
     $this->set('projects', $projects);
     $this->set('rssFeed', array('controller' => 'projects'));
 }
Exemplo n.º 2
0
 /**
  * undocumented function
  *
  * @param string $controller
  * @param string $options
  * @return void
  */
 function initialize($controller, $options)
 {
     $this->params = $_GET;
     unset($this->params['url']);
     if (!empty($options['keys'])) {
         $this->keys($options['keys']);
     }
     if (!empty($options['connect'])) {
         Router::connectNamed($options['connect']);
     } else {
         Router::connectNamed($this->keys);
     }
     if (!empty($options['count'])) {
         $this->enabled = count($this->params) >= $options['count'] ? true : false;
     } else {
         $this->enabled = count($this->params) >= count($this->keys) ? true : false;
     }
     if (!empty($options['actions'])) {
         $this->allowedActions = $options['actions'];
     }
     if (!$this->enabled) {
         foreach ($this->keys as $key) {
             if (isset($controller->params['named'][$key])) {
                 if (strpos($controller->params['named'][$key], ',') !== false) {
                     $controller->data[$controller->modelClass][$key] = explode(',', $controller->params['named'][$key]);
                 } else {
                     $controller->data[$controller->modelClass][$key] = $controller->params['named'][$key];
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * undocumented function
  *
  * @return void
  */
 function index()
 {
     Router::connectNamed(array('type', 'page'));
     if (empty($this->paginate['conditions'])) {
         $this->paginate['conditions'] = array('Timeline.project_id' => $this->Project->id);
     }
     if (!empty($this->passedArgs['type'])) {
         $this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
     } else {
         if ($this->action !== 'forks') {
             $this->passedArgs['type'] = null;
         }
     }
     $this->Timeline->recursive = 0;
     $this->set('timeline', $this->paginate());
     $this->set('rssFeed', array('controller' => 'timeline'));
 }
Exemplo n.º 4
0
 /**
  * undocumented function
  *
  * @return void
  */
 function index()
 {
     Router::connectNamed(array('page', 'type'));
     $this->set('rssFeed', array('controller' => 'dashboard', 'action' => 'feed'));
     extract($this->Project->User->projects($this->Auth->user('id')));
     if (empty($ids)) {
         return;
     }
     $this->paginate['conditions']['Timeline.project_id'] = $ids;
     if (!empty($this->passedArgs['type'])) {
         $this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
     } else {
         if ($this->action !== 'forks') {
             $this->passedArgs['type'] = null;
         }
     }
     $this->set('timeline', $this->paginate('Timeline'));
 }
 function index($id = null)
 {
     if (!isset($this->params['type'])) {
         $this->cakeError('error404');
     }
     $extraArgsForPaging['type'] = $this->paginate[0] = $this->params['type'];
     if (isset($id)) {
         $this->paginate['conditions']['id'] = $id;
     }
     foreach ($this->passedArgs as $arg => $value) {
         if (in_array($arg, $this->conditionsByType[$this->params['type']])) {
             $this->paginate['conditions'][$arg] = $value;
         }
     }
     if (!empty($this->paginate['conditions'])) {
         Router::connectNamed(array_keys($this->paginate['conditions']), array('default' => true));
     }
     $users = $this->paginate();
     $this->set(compact('users', 'extraArgsForPaging'));
 }
Exemplo n.º 6
0
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']);
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connectNamed(false);
Router::connect('/pages/api', ['controller' => 'api']);
Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']);
Router::connect('/spectra', ['controller' => 'reports', 'action' => 'index']);
Router::connect('/compounds', ['controller' => 'substances', 'action' => 'index']);
Router::connect('/compounds/:action/*', ['controller' => 'substances']);
Router::connect('/splashes', ['controller' => 'reports', 'action' => 'splashes']);
Router::connect('/spectra/:action/*', ['controller' => 'reports']);
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
Exemplo n.º 7
0
 */
Router::parseExtensions('json', 'csv', 'print');
/**
 * Bring in custom routing libraries
 */
App::import('Lib', array('Slugger.routes/SluggableRoute'));
/**
 * Static routes
 */
Router::connect('/', array('controller' => 'profiles', 'action' => 'view'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/pages/phrase/*', array('controller' => 'pages', 'action' => 'phrase'));
Router::connect('/pages/message/*', array('controller' => 'pages', 'action' => 'message'));
/**
 * Custom routes
 */
Router::connectNamed(array('User', 'Ministry', 'Involvement', 'Campus', 'model'), array('defaults' => true));
Router::connect('/involvements/:action/*', array('controller' => 'involvements'), array('routeClass' => 'SluggableRoute', 'models' => array('Involvement'), 'prependPk' => true));
Router::connect('/ministries/:action/*', array('controller' => 'ministries'), array('routeClass' => 'SluggableRoute', 'models' => array('Ministry'), 'prependPk' => true));
Router::connect('/campuses/:action/*', array('controller' => 'campuses'), array('routeClass' => 'SluggableRoute', 'models' => array('Campus'), 'prependPk' => true));
Router::connect('/:controller/:action/*', array(), array('routeClass' => 'SluggableRoute', 'models' => array('User'), 'controller' => 'users|profiles', 'prependPk' => true));
/*
 * Asset Compress
 */
Router::connect('/css_cache/*', array('plugin' => 'asset_compress', 'controller' => 'css_files', 'action' => 'get'));
Router::connect('/js_cache/*', array('plugin' => 'asset_compress', 'controller' => 'js_files', 'action' => 'get'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Exemplo n.º 8
0
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app.config
 * @since         CakePHP(tm) v 0.2.9
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/*次の設定はdocomo携帯でのセッション管理のための設定*/
Router::connectNamed(array(), array('argSeparator' => '~'));
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/views/pages/home.ctp)...
 */
Router::connect('/', array('controller' => 'users', 'action' => 'index'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/cake/users/', array('controller' => 'users', 'action' => 'index'));
Router::connect('/cake/twitters/', array('controller' => 'twitters', 'action' => 'index'));
Exemplo n.º 9
0
 /**
  * Ensure that keys at named parameters are urldecoded
  *
  * @return void
  */
 public function testParseNamedKeyUrlDecode()
 {
     Router::connectNamed(true);
     $route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
     // checking /post/index/user[0]:a/user[1]:b
     $result = $route->parse('/posts/index/user%5B0%5D:a/user%5B1%5D:b');
     $this->assertArrayHasKey('user', $result['named']);
     $this->assertEquals(array('a', 'b'), $result['named']['user']);
     // checking /post/index/user[]:a/user[]:b
     $result = $route->parse('/posts/index/user%5B%5D:a/user%5B%5D:b');
     $this->assertArrayHasKey('user', $result['named']);
     $this->assertEquals(array('a', 'b'), $result['named']['user']);
 }
Exemplo n.º 10
0
 /**
  * testNamedArgsUrlParsing method
  *
  * @access public
  * @return void
  */
 function testNamedArgsUrlParsing()
 {
     $Router =& Router::getInstance();
     Router::reload();
     $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
     $expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     $result = Router::connectNamed(false);
     $this->assertEqual(array_keys($result['rules']), array());
     $this->assertFalse($result['greedy']);
     $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
     $expected = array('pass' => array('param1:value1:1', 'param2:value2:3', 'param:value'), 'named' => array(), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     $result = Router::connectNamed(true);
     $this->assertEqual(array_keys($result['rules']), $Router->named['default']);
     $this->assertTrue($result['greedy']);
     Router::reload();
     Router::connectNamed(array('param1' => 'not-matching'));
     $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
     $expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connect('/foo/:action/*', array('controller' => 'bar'), array('named' => array('param1' => array('action' => 'index')), 'greedy' => true));
     $result = Router::parse('/foo/index/param1:value1:1/param2:value2:3/param:value');
     $expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'bar', 'action' => 'index', 'plugin' => null);
     $this->assertEqual($result, $expected);
     $result = Router::parse('/foo/view/param1:value1:1/param2:value2:3/param:value');
     $expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'bar', 'action' => 'view', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connectNamed(array('param1' => '[\\d]', 'param2' => '[a-z]', 'param3' => '[\\d]'));
     $result = Router::parse('/controller/action/param1:1/param2:2/param3:3');
     $expected = array('pass' => array('param2:2'), 'named' => array('param1' => '1', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connectNamed(array('param1' => '[\\d]', 'param2' => true, 'param3' => '[\\d]'));
     $result = Router::parse('/controller/action/param1:1/param2:2/param3:3');
     $expected = array('pass' => array(), 'named' => array('param1' => '1', 'param2' => '2', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connectNamed(array('param1' => 'value[\\d]+:[\\d]+'), array('greedy' => false));
     $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param3:value');
     $expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar'), array('named' => array('param1' => 'value[\\d]:[\\d]')));
     Router::connectNamed(array(), array('greedy' => false));
     $result = Router::parse('/foo/param1:value1:1/param2:value2:3/param3:value');
     $expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null);
     $this->assertEqual($result, $expected);
 }
Exemplo n.º 11
0
    App::uses('PluginShortRoute', 'Routing/Route');
    foreach ($plugins as $key => $value) {
        $plugins[$key] = Inflector::underscore($value);
    }
    $pluginPattern = implode('|', $plugins);
    $match = array('plugin' => $pluginPattern, 'defaultRoute' => true);
    $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true);
    foreach ($prefixes as $prefix) {
        $params = array('prefix' => $prefix, $prefix => true);
        $indexParams = $params + array('action' => 'index');
        Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams);
        Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match);
        Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match);
    }
    Router::connect('/:plugin', array('action' => 'index'), $shortParams);
    Router::connect('/:plugin/:controller', array('action' => 'index'), $match);
    Router::connect('/:plugin/:controller/:action/*', array(), $match);
}
foreach ($prefixes as $prefix) {
    $params = array('prefix' => $prefix, $prefix => true);
    $indexParams = $params + array('action' => 'index');
    Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => true));
    Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => true));
}
Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => true));
Router::connect('/:controller/:action/*', array(), array('defaultRoute' => true));
$namedConfig = Router::namedConfig();
if ($namedConfig['rules'] === false) {
    Router::connectNamed(true);
}
unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, $pluginPattern, $plugins, $key, $value);
Exemplo n.º 12
0
 * PHP versions 4 and 5
 *
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app.config
 * @since         CakePHP(tm) v 0.2.9
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
include_once ROOT . '/app/plugins/spark_plug/config/routes.php';
Router::connect('/', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'register'));
Router::connect('/admin', array('controller' => 'homepage', 'action' => 'index', "admin" => true));
Router::connect('/admin/login', array('controller' => 'users', 'action' => 'login', "admin" => true));
Router::connect('/downloads/*', array('controller' => 'downloads', 'action' => 'file'));
Router::connect('/websites/:action/*', array('controller' => 'websites'));
Router::connect('/company_files/:action/*', array('controller' => 'company_files'));
Router::connect('/customers/:action/*', array('controller' => 'customers'));
Router::connect('/products/:action/*', array('controller' => 'products'));
Router::connect('/payments/:action/*', array('controller' => 'payments'));
Router::connectNamed(array('page'));
Router::connect('/:slug/*', array('controller' => 'websites', 'action' => 'view'), array('pass' => array('slug')));
Exemplo n.º 13
0
 */
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
//Main site routes: dashboard, profile, culture, search
Router::connect('/dashboard', array('controller' => 'users', 'action' => 'dashboard'));
Router::connect('/profile', array('controller' => 'users', 'action' => 'profile'));
Router::connect('/culture', array('controller' => 'users', 'action' => 'culture'));
Router::connect('/search', array('controller' => 'users', 'action' => 'search'));
Router::connect('/privacy', array('controller' => 'users', 'action' => 'privacy'));
Router::connect('/settings', array('controller' => 'users', 'action' => 'settings'));
Router::connect('/register', array('controller' => 'users', 'action' => 'register'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/for/*', array('controller' => 'positions', 'action' => 'view'));
//change the url for users to "with" so fitin.today/with/<userhash> and the userhash can be personalized for a price
Router::connectNamed(array('url'));
Router::connect('/with/:url', array('controller' => 'employers', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/hire/:url', array('controller' => 'applicants', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/at/:url', array('controller' => 'companies', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/under/:url', array('controller' => 'employers', 'action' => 'under'), array('pass' => array("url")));
Router::connect('/confirm', array('controller' => 'users', 'action' => 'confirm'));
Router::connect('/confirm/:url', array('controller' => 'requests', 'action' => 'confirm'), array('pass' => array("url")));
Router::connect('/passwordReset', array('controller' => 'users', 'action' => 'passwordReset'));
Router::connect('/passwordReset/:url', array('controller' => 'requests', 'action' => 'passwordReset'), array('pass' => array("url")));
//referral url
Router::connect('/join/:url', array('controller' => 'users', 'action' => 'join', array('url')));
Router::connect('/admin/users', array('controller' => 'users', 'action' => 'index'));
Router::connect('/admin/culture', array('controller' => 'cultureQuestions', 'action' => 'index'));
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
Exemplo n.º 14
0
Router::connect('/bostad/*', array('controller' => 'object_items', 'action' => 'bostad'));
Router::connectNamed(array('print'));
/*	Router::connect('/objekt/*', array('controller' => 'object_items', 'action' => 'view')); */
Router::connect('/bilder/*', array('controller' => 'object_items', 'action' => 'images'));
/*	Router::connect('/o/*', array('controller' => 'object_items', 'action' => 'view', 'short' => true));  */
Router::connect('/hemnet/*', array('controller' => 'object_items', 'action' => 'view', 'layout' => 'hemnet'));
Router::connectNamed(array('types', 'areas', 'rooms', 'size', 'price', 'page', 'sort', 'direction', 'map'));
Router::connect('/sok/*', array('controller' => 'object_items', 'action' => 'search'));
// Pages
Router::connect('/kopa', array('controller' => 'pages', 'action' => 'kopa'));
Router::connect('/salja', array('controller' => 'pages', 'action' => 'salja'));
Router::connect('/omraden', array('controller' => 'pages', 'action' => 'omraden'));
Router::connect('/videos', array('controller' => 'pages', 'action' => 'videos'));
Router::connectNamed(array('page'));
Router::connect('/omrade/:name/*', array('controller' => 'pages', 'action' => 'omrade'), array('pass' => array('name')));
Router::connectNamed(array('types', 'areas', 'rooms', 'size', 'price', 'page', 'sort', 'direction', 'map'));
Router::connect('/medarbetare/objekt/*', array('controller' => 'pages', 'action' => 'medarbetare_objekt'));
Router::connect('/medarbetare/*', array('controller' => 'pages', 'action' => 'medarbetare'));
Router::connect('/tjanster', array('controller' => 'pages', 'action' => 'tjanster'));
Router::connect('/om', array('controller' => 'pages', 'action' => 'om'));
Router::connect('/partners/:category', array('controller' => 'pages', 'action' => 'partners'));
Router::connect('/partners', array('controller' => 'pages', 'action' => 'partners'));
Router::connect('/portfolio', array('controller' => 'pages', 'action' => 'portfolio'));
Router::connect('/portfolio/:category', array('controller' => 'pages', 'action' => 'portfolio'));
Router::connect('/aktiviteter', array('controller' => 'pages', 'action' => 'aktiviteter'));
Router::connect('/referenser', array('controller' => 'pages', 'action' => 'referenser'));
Router::connect('/jobba_hos_m2', array('controller' => 'pages', 'action' => 'jobba_hos_m2'));
Router::connect('/kontakta', array('controller' => 'pages', 'action' => 'kontakta'));
Router::connect('/video/*', array('controller' => 'videos', 'action' => 'video'));
Router::connect('/film/medarbetare/*', array('controller' => 'videos', 'action' => 'broker_video'));
Router::connect('/fastpris', array('controller' => 'pages', 'action' => 'fastpris'));
Exemplo n.º 15
0
 /**
  * undocumented function
  *
  * @return void
  */
 function admin_index()
 {
     Router::connectNamed(array('page', 'type'));
     $projects = $this->Project->forks();
     array_unshift($projects, $this->Project->id);
     $this->paginate['conditions']['Timeline.project_id'] = $projects;
     if (!empty($this->passedArgs['type'])) {
         $this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
     } else {
         if ($this->action !== 'forks') {
             $this->passedArgs['type'] = null;
         }
     }
     $this->set('timeline', $this->paginate('Timeline'));
 }
Exemplo n.º 16
0
Router::connect('/whitelists/admin_index/*', array('controller' => 'whitelists', 'action' => 'index', 'admin' => true));
//Router::connect('/whitelists/admin_edit/*', array('controller' => 'whitelists', 'action' => 'edit', 'admin' => true));
//Router::connect('/whitelists/admin_delete/*', array('controller' => 'whitelists', 'action' => 'delete', 'admin' => true));
//	Router::connect('/regexp/admin_index/*', array('controller' => 'regexp', 'action' => 'index', 'admin' => true));
Router::connect('/users/admin_index/*', array('controller' => 'users', 'action' => 'index', 'admin' => true));
Router::connect('/roles/admin_index/*', array('controller' => 'roles', 'action' => 'index', 'admin' => true));
Router::connect('/logs/admin_search/*', array('controller' => 'logs', 'action' => 'search', 'admin' => true));
//	Router::connect('/roles/admin_add/*', array('controller' => 'roles', 'action' => 'add', 'admin' => true));
//	Router::connect('/roles/admin_edit/*', array('controller' => 'roles', 'action' => 'edit', 'admin' => true));
Router::connect('/logs/admin_index/*', array('controller' => 'logs', 'action' => 'index', 'admin' => true));
//	Router::connect('/logs/admin_search/*', array('controller' => 'logs', 'action' => 'search', 'admin' => true));
//	Router::connect('/admin/users/terms', array('controller' => 'users', 'action' => 'terms'));
//Router::connect('/admin/users/login', array('controller' => 'users', 'action' => 'login', 'admin' => false));
//Router::connect('/admin/users/routeafterlogin', array('controller' => 'users', 'action' => 'routeafterlogin'));
//	Router::connect('/admin/users/edit/:id', array('controller' => 'users', 'action' => 'edit'), array('pass' => array('field', 'id')));
//	Router::connect('/admin/users/view/:id', array('controller' => 'users', 'action' => 'view'), array('pass' => array('field', 'id')));
//	Router::connect('/:controller/:field/:newValue/:oldValue', array('action' => 'call'), array('pass' => array('field', 'newValue', 'oldValue')));
// Activate REST
Router::mapResources(array('events', 'attributes'));
Router::parseExtensions('xml', 'json');
Router::connectNamed(array('attributesPage' => array('controller' => 'events', 'action' => 'view')));
/**
 * Load all plugin routes.  See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
require CAKE . 'Config' . DS . 'routes.php';
Exemplo n.º 17
0
 * @copyright	  Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link		  http://cakephp.org CakePHP(tm) Project
 * @package		  cake
 * @subpackage	  cake.app.config
 * @since		  CakePHP(tm) v 0.2.9
 * @license		  MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
// enable rss extensions
Router::parseExtensions('rss');
// Use Cake's new router class.  Import the helper libs and use them
App::import('Lib', 'routes/HomeRoute');
App::import('Lib', 'routes/SlugRoute');
Router::connectNamed(array('page'));
Router::connectNamed(array('query'));
Router::connectNamed(array('root'));
Router::connectNamed(array('slug'));
foreach (App::objects('plugin') as $plugin) {
    App::import('Plugin', Inflector::classify("{$plugin}_routes"), array('file' => Inflector::underscore($plugin) . DS . 'config' . DS . 'routes.php'));
}
// FIXES ACO table
Router::connect('/fix', array('controller' => 'users', 'action' => 'fix'));
// Home page
// If the first one returns true (the user is logged in) then rediret to news
Router::connect('/', array('controller' => 'news', 'action' => 'news'), array('routeClass' => 'HomeRoute'));
// False, redirect to signup page
Router::connect('/', array('controller' => 'pages', 'action' => 'home'));
// Site pages
// Signup, Login/logout and password reset
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/signup/*', array('controller' => 'users', 'action' => 'signup'));
Exemplo n.º 18
0
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connectNamed(array('passed'));
Router::connect('/q/*', array('controller' => 'kodaks', 'action' => 'develop'));
Router::connect('/git/*', array('controller' => 'gits', 'action' => 'exec'));
Router::connect('/mysql/*', array('controller' => 'mysql', 'action' => 'exec'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
//Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::mapResources(array('users', 'galleries', 'albums', 'photos', 'galleries_albums', 'albums_photos'));
Router::parseExtensions();
/**
 * Load all plugin routes.  See the CakePlugin documentation on 
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
Exemplo n.º 19
0
$agentAlias = Configure::read('BcRequest.agentAlias');
$agentPrefix = Configure::read('BcRequest.agentPrefix');
$authPrefixes = Configure::read('BcAuthPrefix');
if (BC_INSTALLED && !$isUpdater && !$isMaintenance) {
    $pluginMatch = array();
    $plugins = CakePlugin::loaded();
    if ($plugins) {
        foreach ($plugins as $key => $value) {
            $plugins[$key] = Inflector::underscore($value);
        }
        $pluginMatch = array('plugin' => implode('|', $plugins));
    }
    /**
     * 名前付きパラメータを追加 
     */
    Router::connectNamed(array('sortmode', 'num', 'page', 'sort', 'direction'));
    /**
     * プラグインルーティング
     */
    CakePlugin::routes();
    /**
     * プラグイン判定 & プラグイン名の書き換え
     * 
     * DBに登録したデータを元にURLのプラグイン名部分を書き換える。
     * 一つのプラグインで二つのコンテンツを設置した場合に利用する。
     * あらかじめ、plugin_contentsテーブルに、URLに使う名前とコンテンツを特定する。
     * プラグインごとの一意のキー[content_id]を保存しておく。
     *
     * content_idをコントローラーで取得するには、$plugins_controllerのcontentIdプロパティを利用する。
     * Router::connectの引数として値を与えると、$this->Html->linkなどで、
     * Routerを利用する際にマッチしなくなりURLがデフォルトのプラグイン名となるので注意
Exemplo n.º 20
0
    App::uses('PluginShortRoute', 'Routing/Route');
    foreach ($plugins as $key => $value) {
        $plugins[$key] = Inflector::underscore($value);
    }
    $pluginPattern = implode('|', $plugins);
    $match = array('plugin' => $pluginPattern, 'defaultRoute' => TRUE);
    $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => TRUE);
    foreach ($prefixes as $prefix) {
        $params = array('prefix' => $prefix, $prefix => TRUE);
        $indexParams = $params + array('action' => 'index');
        Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams);
        Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match);
        Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match);
    }
    Router::connect('/:plugin', array('action' => 'index'), $shortParams);
    Router::connect('/:plugin/:controller', array('action' => 'index'), $match);
    Router::connect('/:plugin/:controller/:action/*', array(), $match);
}
foreach ($prefixes as $prefix) {
    $params = array('prefix' => $prefix, $prefix => TRUE);
    $indexParams = $params + array('action' => 'index');
    Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => TRUE));
    Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => TRUE));
}
Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => TRUE));
Router::connect('/:controller/:action/*', array(), array('defaultRoute' => TRUE));
$namedConfig = Router::namedConfig();
if ($namedConfig['rules'] === FALSE) {
    Router::connectNamed(TRUE);
}
unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, $pluginPattern, $plugins, $key, $value);
Exemplo n.º 21
0
/**
 * test match() with greedy routes, named parameters and passed args.
 *
 * @return void
 */
	public function testMatchWithNamedParametersAndPassedArgs() {
		Router::connectNamed(true);

		$route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
		$result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1));
		$this->assertEqual($result, '/posts/index/page:1');

		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5));
		$this->assertEqual($result, '/posts/view/5');

		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 0));
		$this->assertEqual($result, '/posts/view/0');

		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, '0'));
		$this->assertEqual($result, '/posts/view/0');

		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title'));
		$this->assertEqual($result, '/posts/view/5/page:1/limit:20/order:title');


		$route = new CakeRoute('/test2/*', array('controller' => 'pages', 'action' => 'display', 2));
		$result = $route->match(array('controller' => 'pages', 'action' => 'display', 1));
		$this->assertFalse($result);

		$result = $route->match(array('controller' => 'pages', 'action' => 'display', 2, 'something'));
		$this->assertEqual($result, '/test2/something');

		$result = $route->match(array('controller' => 'pages', 'action' => 'display', 5, 'something'));
		$this->assertFalse($result);
	}
Exemplo n.º 22
0
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/views/pages/home.ctp)...
 */
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
$defaultPath = true;
foreach (array('my_properties', 'my_pgproperties', 'post', 'my_evaluateproperties', 'my_requirements') as $value) {
    if (strstr($_GET['url'], $value)) {
        $defaultPath = false;
    }
}
if (strstr($_GET['url'], 'contact_us')) {
    Router::connect('/', array('controller' => 'pages', 'action' => 'contact_us'));
} else {
    Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'view'));
}
//Router::connect('/contact_us/*', array('controller' => 'pages', 'action' => 'contact_us'));
Router::connect('/admin', array('controller' => 'admins', 'action' => 'index', "admin" => 1));
if ($defaultPath) {
    Router::connect('/properties/:property_slug', array('controller' => 'properties', 'action' => 'viewproperty'));
    Router::connect('/pg_properties/:property_slug', array('controller' => 'pg_properties', 'action' => 'viewpgproperty'));
    Router::connect('/evaluate_properties/:property_slug', array('controller' => 'evaluate_properties', 'action' => 'viewevaluateproperty'));
    Router::connect('/requirements/:requirement_slug', array('controller' => 'requirements', 'action' => 'viewrequirementproperty'));
}
Router::connectNamed(array('type'));
Exemplo n.º 23
0
 /**
  * Connect named arguments
  *
  * @param array $data
  * @param array $exclude
  * @return void
  */
 public function connectNamed($data = null, array $exclude = array())
 {
     if (!isset($data)) {
         $data = $this->controller->passedArgs;
     }
     if (!is_array($data)) {
         return;
     }
     foreach ($data as $key => $value) {
         if (!is_numeric($key) && !in_array($key, $exclude)) {
             Router::connectNamed(array($key));
         }
     }
 }
Exemplo n.º 24
0
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright (c) 2006, Cake Software Foundation, Inc.
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
 * @package       cake
 * @subpackage    cake.app.config
 * @since         CakePHP v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
$defaultLang = Configure::read('Languages.default');
if (!empty($fromUrl)) {
    if (strpos($fromUrl, 'admin') === 0) {
        Router::connectNamed(true);
    } else {
        Router::connectNamed(array('node', 'user', 'language', 'status', 'query', 'collection'), array('default' => true));
    }
}
Router::parseExtensions('rss', 'xml', 'ajax');
/**
 * Forward css and js requests to the asset serve funciton
 */
Router::connect('/:mediaType/*', array('plugin' => 'mi_asset', 'controller' => 'asset', 'action' => 'serve'), array('mediaType' => '(css|js)'));
// Legacy
Router::connect('/chapter/*', array('controller' => 'redirect', 'action' => 'process', 'chapter'));
Router::connect('/appendix/*', array('controller' => 'redirect', 'action' => 'process', 'appendix'));
// Router::connect('/:section/*', array('controller' => 'redirect', 'action' => 'process'), array('pass' => array('section'), 'section' => 'chapter|index'));
// missing images
Router::connect('/img/*', array('controller' => 'attachments', 'action' => 'view'), array('lang' => $defaultLang));
$routes = array(array('/', array('controller' => 'nodes', 'action' => 'index'), array()), array('/comments/:id/*', array('controller' => 'comments', 'action' => 'index'), array('pass' => array('id'), 'id' => '[0-9]+')), array('/comments/:action/*', array('controller' => 'comments', 'action' => 'index'), array()), array('/add/*', array('controller' => 'nodes', 'action' => 'add'), array()), array('/compare/*', array('controller' => 'nodes', 'action' => 'compare'), array()), array('/complete/*', array('controller' => 'nodes', 'action' => 'complete'), array()), array('/edit/*', array('controller' => 'nodes', 'action' => 'edit'), array()), array('/history/*', array('controller' => 'nodes', 'action' => 'history'), array()), array('/stats/*', array('controller' => 'nodes', 'action' => 'stats'), array()), array('/toc/*', array('controller' => 'nodes', 'action' => 'toc'), array()), array('/todo/*', array('controller' => 'nodes', 'action' => 'todo'), array()), array('/view/*', array('controller' => 'nodes', 'action' => 'view'), array()), array('/search/*', array('controller' => 'revisions', 'action' => 'search', 'collection' => 2), array()), array('/changes/:action/*', array('controller' => 'changes', 'action' => 'index'), array()), array('/nodes/:action/*', array('controller' => 'nodes', 'action' => 'index'), array()), array('/revisions/:action/*', array('controller' => 'revisions', 'action' => 'index'), array()), array('/users/:action/*', array('plugin' => 'users', 'controller' => 'users', 'action' => 'index'), array()), array('/admin/users/:action/*', array('prefix' => 'admin', 'plugin' => 'users', 'controller' => 'users', 'action' => 'index', 'admin' => true), array()), array('/admin', array('controller' => 'revisions', 'action' => 'pending', 'admin' => true), array()), array('/admin/:controller/:action/*', array('controller' => 'revisions', 'action' => 'pending', 'admin' => true), array()), array('/:controller/:action/*', array('controller' => 'nodes', 'action' => 'index'), array()));
foreach ($routes as $route) {
Exemplo n.º 25
0
 /**
  * test newer style automatically generated prefix routes.
  *
  * @return void
  */
 public function testUrlGenerationWithAutoPrefixes()
 {
     Configure::write('Routing.prefixes', array('protected'));
     Router::reload();
     Router::parse('/');
     $request = new CakeRequest();
     Router::setRequestInfo($request->addParams(array('plugin' => null, 'controller' => 'images', 'action' => 'index', 'prefix' => null, 'protected' => false, 'url' => array('url' => 'images/index')))->addPaths(array('base' => '', 'here' => '/images/index', 'webroot' => '/')));
     $result = Router::url(array('controller' => 'images', 'action' => 'add'));
     $expected = '/images/add';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true));
     $expected = '/protected/images/add';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('action' => 'edit', 1));
     $expected = '/images/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true));
     $expected = '/protected/images/protectededit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1));
     $expected = '/others/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/others/edit/1';
     $this->assertEquals($expected, $result);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1));
     $expected = '/protected/others/edit/1/page:1';
     $this->assertEquals($expected, $result);
     Router::connectNamed(array('random'));
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value'));
     $expected = '/protected/others/edit/1/random:my-value';
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 26
0
<?php

Router::connectNamed(array('lang'));
Router::connect('/admin/users/:action', array('controller' => 'users', 'admin' => true));
Router::connect('/admin/blog', array('controller' => 'blogs', 'admin' => true));
Router::connect('/admin/blog/:action/*', array('controller' => 'blogs', 'admin' => true));
Router::connect('/admin/service/:action/*', array('controller' => 'services', 'admin' => true));
Router::connect('/admin', array('controller' => 'services', 'action' => 'index', 'admin' => true));
Router::connect('/', array('controller' => 'main', 'action' => 'index'));
Router::connect('/services/*', array('controller' => 'services', 'action' => 'index'));
Router::connect('/page/*', array('controller' => 'pages', 'action' => 'index'));
Router::connect('/blog', array('controller' => 'blogs', 'action' => 'index'));
Router::connect('/blog/*', array('controller' => 'blogs', 'action' => 'view'));
Router::connect('/news', array('controller' => 'news', 'action' => 'index'));
Router::connect('/news/*', array('controller' => 'news', 'action' => 'view'));
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
Exemplo n.º 27
0
 /**
  * testUrlGenerationWithPrefixes method
  *
  * @access public
  * @return void
  */
 function testUrlGenerationWithPrefixes()
 {
     Router::reload();
     Router::connect('/protected/:controller/:action/*', array('controller' => 'users', 'action' => 'index', 'prefix' => 'protected', 'protected' => true));
     Router::parse('/');
     Router::setRequestInfo(array(array('plugin' => null, 'controller' => 'images', 'action' => 'index', 'pass' => array(), 'prefix' => null, 'admin' => false, 'form' => array(), 'url' => array('url' => 'images/index')), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => '/images/index', 'webroot' => '/')));
     $result = Router::url(array('controller' => 'images', 'action' => 'add'));
     $expected = '/images/add';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true));
     $expected = '/protected/images/add';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('action' => 'edit', 1));
     $expected = '/images/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/images/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1));
     $expected = '/others/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true));
     $expected = '/protected/others/edit/1';
     $this->assertEqual($result, $expected);
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1));
     $expected = '/protected/others/edit/1/page:1';
     $this->assertEqual($result, $expected);
     Router::connectNamed(array('random'));
     $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value'));
     $expected = '/protected/others/edit/1/random:my-value';
     $this->assertEqual($result, $expected);
 }
Exemplo n.º 28
0
 /**
  * Ensure that named parameters are urldecoded
  *
  * @return void
  */
 public function testParseNamedParametersUrlDecode()
 {
     Router::connectNamed(true);
     $route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
     $result = $route->parse('/posts/index/page:%CE%98');
     $this->assertEquals('Θ', $result['named']['page']);
     $result = $route->parse('/posts/index/page[]:%CE%98');
     $this->assertEquals('Θ', $result['named']['page'][0]);
     $result = $route->parse('/posts/index/something%20else/page[]:%CE%98');
     $this->assertEquals('Θ', $result['named']['page'][0]);
     $this->assertEquals('something else', $result['pass'][0]);
 }