parseExtensions() public static method

For example, http://example.com/posts.rss would yield a file extension of "rss". The file extension itself is made available in the controller as $this->params['ext'], and is used by the RequestHandler component to automatically switch to alternate layouts and templates, and load helpers corresponding to the given content, i.e. RssHelper. Switching layouts and helpers requires that the chosen extension has a defined mime type in CakeResponse A list of valid extension can be passed to this method, i.e. Router::parseExtensions('rss', 'xml'); If no parameters are given, anything after the first . (dot) after the last / in the URL will be parsed, excluding querystring parameters (i.e. ?q=...).
See also: RequestHandler::startup()
public static parseExtensions ( ) : void
return void
Esempio n. 1
0
 public function startTest($method)
 {
     parent::startTest($method);
     Router::parseExtensions('json');
     $this->Pages =& new TestPagesController();
     $this->Pages->__construct();
     $this->Pages->constructClasses();
     $this->testController = $this->Pages;
 }
 public function startTest($method)
 {
     parent::startTest($method);
     Router::parseExtensions('json');
     $this->loadFixtures('AppSetting', 'User');
     $this->AppSettings =& new TestAppSettingsController();
     $this->AppSettings->__construct();
     $this->AppSettings->constructClasses();
     $this->AppSettings->setReturnValue('isAuthorized', true);
     $this->testController = $this->AppSettings;
 }
 /**
  * AssetDispatcher should not 404 extensions that could be handled
  * by Routing.
  *
  * @return void
  */
 public function testNoHandleRoutedExtension()
 {
     $filter = new AssetDispatcher();
     $response = $this->getMock('CakeResponse', array('_sendHeader'));
     Configure::write('Asset.filter', array('js' => '', 'css' => ''));
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::RESET);
     Router::parseExtensions('json');
     Router::connect('/test_plugin/api/v1/:action', array('controller' => 'api'));
     CakePlugin::load('TestPlugin');
     $request = new CakeRequest('test_plugin/api/v1/forwarding.json');
     $event = new CakeEvent('DispatcherTest', $this, compact('request', 'response'));
     $this->assertNull($filter->beforeDispatch($event));
     $this->assertFalse($event->isStopped(), 'Events for routed extensions should not be stopped');
 }
Esempio n. 4
0
 public function startTest($method)
 {
     parent::startTest($method);
     Router::parseExtensions('json');
     $this->loadFixtures('Involvement', 'Date');
     $this->Dates =& new TestDatesController();
     $this->Dates->__construct();
     $this->Dates->constructClasses();
     $this->Dates->Notifier->QueueEmail = new MockDatesQueueEmailComponent();
     $this->Dates->Notifier->QueueEmail->enabled = true;
     $this->Dates->Notifier->QueueEmail->initialize($this->Dates);
     $this->Dates->Notifier->QueueEmail->setReturnValue('_smtp', true);
     $this->Dates->Notifier->QueueEmail->setReturnValue('_mail', true);
     $this->Dates->setReturnValue('isAuthorized', true);
     $this->testController = $this->Dates;
 }
 function startTest($method)
 {
     Router::reload();
     $this->c = new TestControllerForSearchPaginationComponentTestCase();
     // set 'ext' parameter
     if (preg_match('/parseExtensions/i', $method)) {
         Router::parseExtensions();
     }
     $this->c->params = Router::parse($this->url);
     // always set 'url' parameter
     if (!isset($this->c->params['url'])) {
         $this->c->params['url'] = array();
     }
     $this->c->params['url']['url'] = $this->url;
     $this->s = new SearchPaginationComponent();
     $this->s->initialize($this->c);
 }
Esempio n. 6
0
 public function startTest($method)
 {
     parent::startTest($method);
     Router::parseExtensions('csv', 'print');
     // necessary fixtures
     $this->loadFixtures('User', 'Roster', 'Ministry', 'Involvement', 'Campus', 'InvolvementType');
     $this->Reports = new TestReportsController();
     $this->Reports->__construct();
     $this->Reports->constructClasses();
     $this->Reports->Notifier->QueueEmail = new MockReportsQueueEmailComponent();
     $this->Reports->Notifier->QueueEmail->enabled = true;
     $this->Reports->Notifier->QueueEmail->initialize($this->Reports);
     $this->Reports->Notifier->QueueEmail->setReturnValue('_smtp', true);
     $this->Reports->Notifier->QueueEmail->setReturnValue('_mail', true);
     $this->Reports->setReturnValue('isAuthorized', true);
     $this->testController = $this->Reports;
 }
Esempio n. 7
0
//Router::connect('/whitelists/admin_add/*', array('controller' => 'whitelists', 'action' => 'add', 'admin' => true));
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'));
//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');
/**
 * 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';
Esempio n. 8
0
 * Redistributions of files must retain the above copyright notice.
 *
 * @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('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * 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';
Router::parseExtensions("pdf");
Router::parseExtensions("json");
Esempio n. 9
0
 /**
  * test that requests with a trailing dot don't loose the do.
  *
  * @return void
  */
 function testParsingWithTrailingPeriodAndParseExtensions()
 {
     Router::reload();
     Router::parseExtensions('json');
     $result = Router::parse('/posts/view/something.');
     $this->assertEqual($result['pass'][0], 'something.', 'Period was chopped off %s');
     $result = Router::parse('/posts/view/something. . .');
     $this->assertEqual($result['pass'][0], 'something. . .', 'Period was chopped off %s');
 }
Esempio n. 10
0
 * different URLs to chosen controllers and their actions (functions).
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @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
 */
Router::parseExtensions('html', 'rss', 'json', 'csv');
/**
 * 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('/feed', array('controller' => 'poles', 'action' => 'equipage'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/', array('controller' => 'poles', 'action' => 'equipage'));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/:controller/:id', array('action' => 'view'), array('pass' => array('id'), 'id' => '[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}'));
/**
Esempio n. 11
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
 */
/*
    Router::resourceMap( array(
        array( 'action' => 'index_api', 'method' => 'GET', 'id' => false ),
        array( 'action' => 'view_api', 'method' => 'GET', 'id' => true ),
        array( 'action' => 'add_api', 'method' => 'POST', 'id' => false),
        array( 'action' => 'edit_api', 'method' => 'PUT', 'id' => true ),
        array( 'action' => 'delete_api', 'method' => 'DELETE', 'id' => true ),
    ));*/
Router::mapResources('api');
Router::parseExtensions('json');
/**
 * 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'));
/*
* MANEJO DE EMBARCACIONES
*/
Router::connect('/api/ships/person/:id', array('controller' => 'api', '[method]' => 'GET', 'action' => 'person_ships'), array('pass' => array('id'), 'id' => '[EV][0-9]+'));
Router::connect('/api/ships/person', array('controller' => 'api', '[method]' => array('POST', 'PUT', 'DELETE'), 'action' => 'NotAllow'));
Router::connect('/api/ships', array('controller' => 'api', '[method]' => 'POST', 'action' => 'add_ship'));
Router::connect('/api/ships', array('controller' => 'api', '[method]' => 'DELETE', 'action' => 'disable_ship'));
Router::connect('/api/ships', array('controller' => 'api', '[method]' => array('PUT', 'GET'), 'action' => 'NotAllow'));
/*
 * 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: 7945 $
 * @modifiedby    $LastChangedBy: gwoo $
 * @lastmodified  $Date: 2008-12-19 13:16:01 +1100 (Fri, 19 Dec 2008) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
Router::parseExtensions('rss', 'json');
/**
 * 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.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/p/:slug-:id', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('id'), 'id' => $UUID));
$controllers = array_map(array('Inflector', 'underscore'), Configure::listObjects('controller'));
Router::connect('/:controller', array(), array('controller' => join('|', $controllers)));
Router::connect('/:username', array('controller' => 'users', 'action' => 'view'), array('pass', array('username')));
Esempio n. 13
0
<?php

/**
 * pHKapa routes file
 *
 * PHP 5
 *
 * @category Controller
 * @package  pHKapa.app.Config
 * @version  V1
 * @author   Paulo Homem <*****@*****.**>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://phkapa.net
 */
/*if (file_exists(TMP.'installed.txt')) {
    // the routes for when the application has been installed
    //echo "installed";
} else {
    //echo "install";
    Router::connect('/:controler/:action', array('controller' => 'install'));
}*/
Router::parseExtensions('pdf');
Router::parseExtensions('csv');
Esempio n. 14
0
 * WordPress
 */
CroogoRouter::connect('/calculo/frete.html', array('controller' => 'produtos', 'action' => 'frete'));
/**
 * Corrige links de versões antigas como a estrutura
 * WordPress
 */
CroogoRouter::connect('/calcular-frete/*', array('controller' => 'urls', 'action' => 'url'));
// Botao calculo frete antigo
CroogoRouter::connect('/frete/*', array('controller' => 'produtos', 'action' => 'frete'));
/**
 * BOTOES
 * no WordPress existia uma estrutura na raiz
 * onde havia o diretório botoes na raiz
 */
CroogoRouter::connect('/botoes/*', array('controller' => 'urls', 'action' => 'botoes'));
/**
 * Rastreamento
 * Corrige links de versões antigas como a estrutura 
 * WordPress
 */
//CroogoRouter::connect( '/rastreamento/rastrear-pedido.html', array( 'controller' => 'codigos', 'action' => 'add' ) );
/**
 * API Rest
 */
//Router::mapResources( 'Produtos', array('prefix' => '/api/') );
Router::mapResources('Produtos');
Router::mapResources('Codigos');
Router::mapResources('Avisos');
Router::parseExtensions('xml', 'html', 'pdf');
Esempio n. 15
0
<?php

/* SVN FILE: $Id$ */
/**
 * @copyright		Copyright 2008, Passion Mansion, Inc.
 * @version			$Revision$
 * @modifiedby 		$LastChangedBy$
 * @lastmodified	$Date$
 */
Router::parseExtensions('rss', 'xml', 'html');
// Default
Router::connect('/', array('controller' => 'default', 'action' => 'index'));
// Blocked
Router::connect('/blocked', array('controller' => 'pages', 'action' => 'display', 'blocked'));
// Product View
Router::connect('/p/view', array('controller' => 'product', 'action' => 'index'));
Router::connect('/p', array('controller' => 'product', 'action' => 'index'));
Router::connect('/p/*', array('controller' => 'product', 'action' => 'view'));
Router::connect('/c/*', array('controller' => 'category', 'action' => 'view'));
Router::connect('/product_info/*', array('controller' => 'product', 'action' => 'view'));
Router::connect('/cart/add_country/*', array('controller' => 'cart', 'action' => 'add_country'));
Router::connect('/cart/add/*', array('controller' => 'cart', 'action' => 'add'));
Router::connect('/cart', array('controller' => 'cart', 'action' => 'index'));
// Custom Error Message
Router::connect('/404', array('controller' => 'pages', 'action' => 'display', 'error'));
Router::connect('/error/*', array('controller' => 'pages', 'action' => 'display', 'error'));
Router::connect('/docs/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/sitemap', array('controller' => 'sitemaps', 'action' => 'index', 'url' => array('ext' => 'xml')));
Esempio n. 16
0
<?php

Router::parseExtensions('html', 'json');
Router::connect('/', array('controller' => 'User', 'action' => 'login'));
Router::connect('/user_:id', array('controller' => 'User', 'action' => 'view'), array('pass' => array('id'), 'id' => '[0-9A-Za-z]+'));
Router::connect('/group_:id', array('controller' => 'Group', 'action' => 'view'), array('pass' => array('id'), 'id' => '[0-9A-Za-z]+'));
Router::connect('/Mytime', array('controller' => 'Timeline', 'action' => 'index'));
Router::connect('/Planet', array('controller' => 'Timeline', 'action' => 'planet'));
//Router::connect('/apiv1/:action', array('plugin'=>'Api','controller' => 'Apiv1', ));
Router::connect('/apiv1/*', array('plugin' => 'Api', 'controller' => 'Apiv1', 'action' => 'index'));
Router::connect('/admin', array('admin' => true, 'controller' => 'Dashboard', 'action' => 'index'));
Router::connect('/admin/login', array('admin' => true, 'controller' => 'user', 'action' => 'login'));
Router::connect('/admin/logout', array('admin' => true, 'controller' => 'user', 'action' => 'logout'));
//Router::connect('/admin', array('admin' => true, 'controller' => 'dashboard', 'action' => 'index'));
Router::connect('/apiv2/*', array('plugin' => 'Apiv2', 'controller' => 'Apiv2', 'action' => 'index'));
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
Esempio n. 17
0
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, 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       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
Router::parseExtensions('pdf', 'xml', 'json');
/**
 * 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' => 'surveys', 'action' => 'index'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * Load all plugin routes.  See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
Esempio n. 18
0
<?php

/**
 * Routes file
 *
 * @copyright     Copyright 2010, *ROCK*HARBOR
 * @link          http://rockharbor.org *ROCK*HARBOR
 * @package       core
 * @subpackage    core.config
 */
/**
 * Extensions to redirect views/layouts
 */
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));
Esempio n. 19
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('plugin' => '', 'controller' => 'cabinets', 'action' => 'login'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::parseExtensions('pdf');
App::uses('SlugRoute', 'Usermgmt.routes');
Router::connect('/:slug', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'viewProfile'), array('routeClass' => 'SlugRoute'));
Router::connect('/login/*', array('plugin' => '', 'controller' => 'cabinets', 'action' => 'login'));
Router::connect('/logout', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'logout'));
Router::connect('/forgotPassword', array('controller' => 'cabinets', 'action' => 'forgot_password'));
Router::connect('/emailVerification', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'emailVerification'));
Router::connect('/activatePassword/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'activatePassword'));
Router::connect('/register', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'register'));
Router::connect('/changePassword', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'changePassword'));
Router::connect('/changeUserPassword/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'changeUserPassword'));
Router::connect('/addUser', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'addUser'));
Router::connect('/editUser/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'editUser'));
Router::connect('/logoutUser/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'logoutUser'));
Router::connect('/viewUser/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'viewUser'));
Router::connect('/userVerification/*', array('plugin' => 'usermgmt', 'controller' => 'users', 'action' => 'userVerification'));
 /**
  * Test that a type mismatch doesn't incorrectly set the ext
  *
  * @return void
  */
 public function testInitializeContentTypeAndExtensionMismatch()
 {
     $this->assertNull($this->RequestHandler->ext);
     $extensions = Router::extensions();
     Router::parseExtensions('xml');
     $this->Controller->request = $this->getMock('CakeRequest');
     $this->Controller->request->expects($this->any())->method('accepts')->will($this->returnValue(array('application/json')));
     $this->RequestHandler->initialize($this->Controller);
     $this->assertNull($this->RequestHandler->ext);
     call_user_func_array(array('Router', 'parseExtensions'), $extensions);
 }
Esempio n. 21
0
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, 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       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
Router::parseExtensions('rss', 'pdf', 'xml');
/**
 * Here, we are connecting '/' (base path) to controller called 'Posts',
 * its action called 'index'.
 */
Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
Router::connect('/post/:slug', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug')));
Router::connect('/page/:slug', array('controller' => 'pages', 'action' => 'view'), array('pass' => array('slug')));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
//Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * Load all plugin routes.  See the CakePlugin documentation on 
 * how to customize the loading of plugin routes.
 */
 function testExtension()
 {
     Router::parseExtensions('csv');
     $vars = $this->ExtendedTestCase->testAction('/dummies/dummy_action/test.csv');
     $this->assertEqual($this->Dummies->params['url']['ext'], 'csv');
 }
Esempio n. 23
0
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @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('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * 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.
 */
Router::mapResources(array('posts', 'client'));
Router::parseExtensions('json', 'xml');
require CAKE . 'Config' . DS . 'routes.php';
Esempio n. 24
0
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, 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       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'));
/**
 * Load all plugin routes.  See the CakePlugin documentation on 
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
Router::parseExtensions();
/**
 * Load the CakePHP default routes. Remove this if you do not want to use
 * the built-in default routes.
 */
require CAKE . 'Config' . DS . 'routes.php';
Esempio n. 25
0
 /**
  * Test that extensions work with Router::reverse()
  *
  * @return void
  */
 public function testReverseWithExtension()
 {
     Router::parseExtensions('json');
     $request = new CakeRequest('/posts/view/1.json');
     $request->addParams(array('controller' => 'posts', 'action' => 'view', 'pass' => array(1), 'named' => array(), 'ext' => 'json'));
     $request->query = array();
     $result = Router::reverse($request);
     $expected = '/posts/view/1.json';
     $this->assertEquals($expected, $result);
 }
Esempio n. 26
0
Router::connect('/', array('controller' => 'pages', 'action' => 'index'));
Router::connect('/login', array('controller' => 'Pages', 'action' => 'login'));
Router::connect('/sing_up', array('controller' => 'Pages', 'action' => 'sing_up'));
Router::connect('/comfirm/:code', array('controller' => 'Pages', 'action' => 'comfirm'), array('pass' => array('code')));
Router::connect('/admin', array('controller' => 'ProductCategories', 'action' => 'index', 'admin' => true));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
//Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'home'));
/*
	rewrite url frontend
*/
/* product detail */
Router::connect('/lien-he/', array('controller' => 'Pages', 'action' => 'contact'));
Router::connect('/san-pham/:product_code', array('controller' => 'Pages', 'action' => 'detail', array('pass' => array('code'), 'code' => '[a-z A-Z 0-9]+')));
Router::connect('/tin-tuc/:lisnews', array('controller' => 'Pages', 'action' => 'lisnews', array('pass' => array('code'), 'code' => '[a-z A-Z 0-9]+')));
Router::connect('/detailnews/:detailnews', array('controller' => 'Pages', 'action' => 'detailnews', array('pass' => array('code'), 'code' => '[a-z A-Z 0-9]+')));
Router::connect('/danh-muc/:cate_code', array('controller' => 'Pages', 'action' => 'lists', array('pass' => array('code'), 'code' => '[a-z A-Z 0-9]+')));
Router::connect('/:page_code', array('controller' => 'Pages', 'action' => 'info', array('pass' => array('page_code'), 'page_code' => '[a-z A-Z 0-9 %_-]+')));
// Router::connect('/dat-hang.html', array('controller' => 'Pages', 'action' => 'add_cart'));
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
Router::parseExtensions('html', 'rss');
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';
Esempio n. 27
0
 * to use (in this case, /app/View/Pages/home.ctp)...
 */
// Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/', array('controller' => 'slides', 'action' => 'index'));
/*
 * ...and connect the rest of 'Pages' controller's URLs.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * API routing
 */
Router::connect('/api/v1/slides/*', array('controller' => 'api_v1', 'action' => 'get_slides'));
Router::connect('/api/v1/slide/:id', array('controller' => 'api_v1', 'action' => 'get_slide_by_id'), array('id' => '[0-9]+'));
Router::connect('/api/v1/slide/:id/transcript', array('controller' => 'api_v1', 'action' => 'get_transcript_by_id'), array('id' => '[0-9]+'));
Router::connect('/api/v1/user/:id', array('controller' => 'api_v1', 'action' => 'get_user_by_user_id'), array('id' => '[0-9]+'));
Router::connect('/api/v1/user/:id/slides', array('controller' => 'api_v1', 'action' => 'get_slides_by_user_id'), array('id' => '[0-9]+'));
// Router::connect('/api/v1/:action/*', array('controller' => 'api_v1'));
/*
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();
/*
 * Activate rss
 */
Router::parseExtensions('rss');
/**
 * 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';
Esempio n. 28
0
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, 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       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Parse common extensions...
 */
Router::parseExtensions('json', 'xml', 'rss', 'ajax');
/**
 * 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. or use plate add page_route
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * short routes for login/logout admin false to prevent issues sometimes
 */
Router::connect('/login', array('admin' => false, 'controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('admin' => false, 'controller' => 'users', 'action' => 'logout'));
Esempio n. 29
0
 /**
  * testExtensionParsing method
  *
  * @access public
  * @return void
  */
 function testExtensionParsing()
 {
     Router::parseExtensions();
     $result = Router::parse('/posts.rss');
     $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'index', 'url' => array('ext' => 'rss'), 'pass' => array(), 'named' => array());
     $this->assertEqual($result, $expected);
     $result = Router::parse('/posts/view/1.rss');
     $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'pass' => array('1'), 'named' => array(), 'url' => array('ext' => 'rss'), 'named' => array());
     $this->assertEqual($result, $expected);
     $result = Router::parse('/posts/view/1.rss?query=test');
     $this->assertEqual($result, $expected);
     $result = Router::parse('/posts/view/1.atom');
     $expected['url'] = array('ext' => 'atom');
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::parseExtensions('rss', 'xml');
     $result = Router::parse('/posts.xml');
     $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'index', 'url' => array('ext' => 'xml'), 'pass' => array(), 'named' => array());
     $this->assertEqual($result, $expected);
     $result = Router::parse('/posts.atom?hello=goodbye');
     $expected = array('plugin' => null, 'controller' => 'posts.atom', 'action' => 'index', 'pass' => array(), 'named' => array(), 'url' => array('ext' => 'html'));
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::parseExtensions();
     $result = $this->router->__parseExtension('/posts.atom');
     $expected = array('ext' => 'atom', 'url' => '/posts');
     $this->assertEqual($result, $expected);
     Router::reload();
     Router::connect('/controller/action', array('controller' => 'controller', 'action' => 'action', 'url' => array('ext' => 'rss')));
     $result = Router::parse('/controller/action');
     $expected = array('controller' => 'controller', 'action' => 'action', 'plugin' => null, 'url' => array('ext' => 'rss'), 'named' => array(), 'pass' => array());
     $this->assertEqual($result, $expected);
 }
Esempio n. 30
0
<?php

#App::import('Lib', 'super_router');
require_once APP . 'libs' . DS . 'super_router.php';
#SuperRouter::plugins();
#if (!isInstalled()) {
#	SuperRouter::connect('/', array('plugin' => 'install', 'controller' => 'wizard'));
#}
// Basic
SuperRouter::connect('/admin', array('admin' => true, 'controller' => 'dashboard'));
// Pages
SuperRouter::connect('/', array('controller' => 'pages', 'action' => 'home', 'home'));
#SuperRouter::connect('/pages/*', array('controller' => 'pages', 'action' => 'view'));
SuperRouter::connect('/contact', array('controller' => 'pages', 'action' => 'contact'));
// Users
SuperRouter::connect('/register', array('controller' => 'users', 'action' => 'register'));
SuperRouter::connect('/login', array('controller' => 'users', 'action' => 'login'));
SuperRouter::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
SuperRouter::connect('/recover', array('controller' => 'users', 'action' => 'recover'));
Router::parseExtensions('xml', 'json', 'csv');