Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

routes.php

By: a guest on Dec 14th, 2010  |  syntax: PHP  |  size: 3.16 KB  |  views: 76  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /**
  3.  * Routes configuration
  4.  *
  5.  * In this file, you set up routes to your controllers and their actions.
  6.  * Routes are very important mechanism that allows you to freely connect
  7.  * different urls to chosen controllers and their actions (functions).
  8.  *
  9.  * PHP versions 4 and 5
  10.  *
  11.  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  12.  * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  13.  *
  14.  * Licensed under The MIT License
  15.  * Redistributions of files must retain the above copyright notice.
  16.  *
  17.  * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  18.  * @link          http://cakephp.org CakePHP(tm) Project
  19.  * @package       cake
  20.  * @subpackage    cake.app.config
  21.  * @since         CakePHP(tm) v 0.2.9
  22.  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  23.  */
  24. /**
  25.  * Here, we are connecting '/' (base path) to controller called 'Pages',
  26.  * its action called 'display', and we pass a param to select the view file
  27.  * to use (in this case, /app/views/pages/home.ctp)...
  28.  */
  29.         Router::parseExtensions('rss', 'mrss');
  30.  
  31.         $regex = array(
  32.                 'lang' => '[a-z]{2}',
  33.                 'slug' => '[a-z0-9-]+');
  34.  
  35.         Router::connect('/', array('controller' => 'pages', 'action' => 'home'));
  36.         Router::connect('/:lang', array('controller' => 'pages', 'action' => 'home'), array('lang' => $regex['lang'], 'pass' => array('lang')));
  37.         Router::connect('/admin', array('controller' => 'pages', 'action' => 'index', 'admin' => true));
  38.  
  39.         Router::connect('/actions/*', array('controller' => 'pages', 'action' => 'dispatcher'));
  40.        
  41.        
  42.         // BLOG
  43.         Router::connect('/blog/*', array('controller' => 'posts', 'action' => 'view'));
  44.        
  45.         // NEWS
  46.         Router::connect('/news.rss', array('controller' => 'posts', 'action' => 'index', 'ext' => 'rss'));
  47.         Router::connect('/news/*', array('controller' => 'posts', 'action' => 'index'));
  48.         Router::connect('/:lang/posts/*', array('controller' => 'posts', 'action' => 'index'));
  49.        
  50.         // PAGES
  51.         Router::connect('/page/*', array('controller' => 'posts', 'action' => 'view', 'type' => 'page'));
  52.         Router::connect('/pages', array('controller' => 'posts', 'action' => 'index', 'type' => 'page'));
  53.        
  54.         Router::connect('/admin/pages/add', array('controller' => 'posts', 'action' => 'add', 'type' => 'page', 'admin' => true));
  55.         Router::connect('/admin/pages/edit/*', array('controller' => 'posts', 'action' => 'edit', 'type' => 'page', 'admin' => true));
  56.         Router::connect('/admin/pages/*', array('controller' => 'posts', 'action' => 'index', 'type' => 'page', 'admin' => true));
  57.        
  58.         // RELEASES
  59.         Router::connect('/release/:slug', array('controller' => 'releases', 'action' => 'view'), array('slug' => $regex['slug'], 'pass' => array('slug')));
  60.         Router::connect('/:lang/release/:slug',
  61.                 array('controller' => 'releases', 'action' => 'view'),
  62.                 array(
  63.                         'lang' => $regex['lang'],
  64.                         'slug' => $regex['slug'],
  65.                         'pass' => array('slug', 'lang'))
  66.         );
  67.        
  68.         // ARTISTS
  69.         Router::connect('/artist/*', array('controller' => 'artists', 'action' => 'view', 'admin' => false));
  70.        
  71.         // FITXERS
  72.         Router::connect('/files/download/*', array('controller' => 'fitxers', 'action' => 'download'));