blob: 668ac0954b3f6019efc8d45bbc2d98202e7f71b5 [file] [log] [blame]
Derek Jones37f4b9c2011-07-01 17:56:50 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Router Class
20 *
21 * Parses URIs and determines routing
22 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @author ExpressionEngine Dev Team
26 * @category Libraries
27 * @link http://codeigniter.com/user_guide/general/routing.html
28 */
29class CI_Router {
30
Barry Mienydd671972010-10-04 16:33:58 +020031 var $config;
32 var $routes = array();
Derek Allard2067d1a2008-11-13 22:59:24 +000033 var $error_routes = array();
34 var $class = '';
35 var $method = 'index';
36 var $directory = '';
Derek Allard2067d1a2008-11-13 22:59:24 +000037 var $default_controller;
Barry Mienydd671972010-10-04 16:33:58 +020038
Derek Allard2067d1a2008-11-13 22:59:24 +000039 /**
40 * Constructor
41 *
42 * Runs the route mapping function.
43 */
Greg Akera9263282010-11-10 15:26:43 -060044 function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000045 {
Derek Jonesc7738402010-03-02 13:55:13 -060046 $this->config =& load_class('Config', 'core');
47 $this->uri =& load_class('URI', 'core');
Derek Allard2067d1a2008-11-13 22:59:24 +000048 log_message('debug', "Router Class Initialized");
49 }
Barry Mienydd671972010-10-04 16:33:58 +020050
Derek Allard2067d1a2008-11-13 22:59:24 +000051 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020052
Derek Allard2067d1a2008-11-13 22:59:24 +000053 /**
54 * Set the route mapping
55 *
56 * This function determines what should be served based on the URI request,
57 * as well as any "routes" that have been set in the routing config file.
58 *
59 * @access private
60 * @return void
61 */
62 function _set_routing()
Barry Mienydd671972010-10-04 16:33:58 +020063 {
Derek Jones37f4b9c2011-07-01 17:56:50 -050064 // Are query strings enabled in the config file? Normally CI doesn't utilize query strings
Barry Mienydd671972010-10-04 16:33:58 +020065 // since URI segments are more search-engine friendly, but they can optionally be used.
Derek Jonesc7738402010-03-02 13:55:13 -060066 // If this feature is enabled, we will gather the directory/class/method a little differently
67 $segments = array();
Derek Allard2067d1a2008-11-13 22:59:24 +000068 if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
69 {
Derek Jonesc7738402010-03-02 13:55:13 -060070 if (isset($_GET[$this->config->item('directory_trigger')]))
71 {
72 $this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
73 $segments[] = $this->fetch_directory();
74 }
Barry Mienydd671972010-10-04 16:33:58 +020075
Derek Jonesc7738402010-03-02 13:55:13 -060076 if (isset($_GET[$this->config->item('controller_trigger')]))
77 {
78 $this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
79 $segments[] = $this->fetch_class();
80 }
Barry Mienydd671972010-10-04 16:33:58 +020081
Derek Allard2067d1a2008-11-13 22:59:24 +000082 if (isset($_GET[$this->config->item('function_trigger')]))
83 {
84 $this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
Derek Jonesc7738402010-03-02 13:55:13 -060085 $segments[] = $this->fetch_method();
Derek Allard2067d1a2008-11-13 22:59:24 +000086 }
Derek Allard2067d1a2008-11-13 22:59:24 +000087 }
Barry Mienydd671972010-10-04 16:33:58 +020088
Derek Allard2067d1a2008-11-13 22:59:24 +000089 // Load the routes.php file.
Greg Aker3a746652011-04-19 10:59:47 -050090 if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
bubbafoley0ea04142011-03-17 14:55:41 -050091 {
Greg Aker3a746652011-04-19 10:59:47 -050092 include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
bubbafoley0ea04142011-03-17 14:55:41 -050093 }
Greg Aker3a746652011-04-19 10:59:47 -050094 elseif (is_file(APPPATH.'config/routes.php'))
bubbafoley0ea04142011-03-17 14:55:41 -050095 {
Greg Aker3a746652011-04-19 10:59:47 -050096 include(APPPATH.'config/routes.php');
bubbafoley0ea04142011-03-17 14:55:41 -050097 }
Derek Jones37f4b9c2011-07-01 17:56:50 -050098
Derek Allard2067d1a2008-11-13 22:59:24 +000099 $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
100 unset($route);
Barry Mienydd671972010-10-04 16:33:58 +0200101
Derek Allard2067d1a2008-11-13 22:59:24 +0000102 // Set the default controller so we can display it in the event
103 // the URI doesn't correlated to a valid controller.
Barry Mienydd671972010-10-04 16:33:58 +0200104 $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
105
Derek Jones37f4b9c2011-07-01 17:56:50 -0500106 // Were there any query string segments? If so, we'll validate them and bail out since we're done.
Derek Jonesc7738402010-03-02 13:55:13 -0600107 if (count($segments) > 0)
108 {
109 return $this->_validate_request($segments);
110 }
Barry Mienydd671972010-10-04 16:33:58 +0200111
Derek Allard2067d1a2008-11-13 22:59:24 +0000112 // Fetch the complete URI string
113 $this->uri->_fetch_uri_string();
Barry Mienydd671972010-10-04 16:33:58 +0200114
Derek Allard2067d1a2008-11-13 22:59:24 +0000115 // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
116 if ($this->uri->uri_string == '')
117 {
Derek Jonesc7738402010-03-02 13:55:13 -0600118 return $this->_set_default_controller();
Derek Allard2067d1a2008-11-13 22:59:24 +0000119 }
Barry Mienydd671972010-10-04 16:33:58 +0200120
Derek Allard2067d1a2008-11-13 22:59:24 +0000121 // Do we need to remove the URL suffix?
122 $this->uri->_remove_url_suffix();
Barry Mienydd671972010-10-04 16:33:58 +0200123
Derek Allard2067d1a2008-11-13 22:59:24 +0000124 // Compile the segments into an array
125 $this->uri->_explode_segments();
Barry Mienydd671972010-10-04 16:33:58 +0200126
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 // Parse any custom routing that may exist
Barry Mienydd671972010-10-04 16:33:58 +0200128 $this->_parse_routes();
129
Derek Allard2067d1a2008-11-13 22:59:24 +0000130 // Re-index the segment array so that it starts with 1 rather than 0
131 $this->uri->_reindex_segments();
132 }
Derek Jonesc7738402010-03-02 13:55:13 -0600133
134 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200135
Derek Jonesc7738402010-03-02 13:55:13 -0600136 /**
137 * Set the default controller
138 *
139 * @access private
140 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200141 */
Derek Jonesc7738402010-03-02 13:55:13 -0600142 function _set_default_controller()
143 {
144 if ($this->default_controller === FALSE)
145 {
146 show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
147 }
148 // Is the method being specified?
149 if (strpos($this->default_controller, '/') !== FALSE)
150 {
151 $x = explode('/', $this->default_controller);
Barry Mienydd671972010-10-04 16:33:58 +0200152
Derek Jonesc7738402010-03-02 13:55:13 -0600153 $this->set_class($x[0]);
154 $this->set_method($x[1]);
Pascal Kriete790ebf32010-12-15 10:53:35 -0500155 $this->_set_request($x);
Barry Mienydd671972010-10-04 16:33:58 +0200156 }
Derek Jonesc7738402010-03-02 13:55:13 -0600157 else
158 {
159 $this->set_class($this->default_controller);
160 $this->set_method('index');
161 $this->_set_request(array($this->default_controller, 'index'));
162 }
Barry Mienydd671972010-10-04 16:33:58 +0200163
Derek Jonesc7738402010-03-02 13:55:13 -0600164 // re-index the routed segments array so it starts with 1 rather than 0
165 $this->uri->_reindex_segments();
Barry Mienydd671972010-10-04 16:33:58 +0200166
Derek Jonesc7738402010-03-02 13:55:13 -0600167 log_message('debug', "No URI present. Default controller set.");
168 }
Barry Mienydd671972010-10-04 16:33:58 +0200169
Derek Allard2067d1a2008-11-13 22:59:24 +0000170 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200171
Derek Allard2067d1a2008-11-13 22:59:24 +0000172 /**
173 * Set the Route
174 *
175 * This function takes an array of URI segments as
176 * input, and sets the current class/method
177 *
178 * @access private
179 * @param array
180 * @param bool
181 * @return void
182 */
183 function _set_request($segments = array())
Barry Mienydd671972010-10-04 16:33:58 +0200184 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000185 $segments = $this->_validate_request($segments);
Barry Mienydd671972010-10-04 16:33:58 +0200186
Derek Allard2067d1a2008-11-13 22:59:24 +0000187 if (count($segments) == 0)
188 {
Derek Jonesc7738402010-03-02 13:55:13 -0600189 return $this->_set_default_controller();
Derek Allard2067d1a2008-11-13 22:59:24 +0000190 }
Barry Mienydd671972010-10-04 16:33:58 +0200191
Derek Allard2067d1a2008-11-13 22:59:24 +0000192 $this->set_class($segments[0]);
Barry Mienydd671972010-10-04 16:33:58 +0200193
Derek Allard2067d1a2008-11-13 22:59:24 +0000194 if (isset($segments[1]))
195 {
Derek Jonesc7738402010-03-02 13:55:13 -0600196 // A standard method request
197 $this->set_method($segments[1]);
Derek Allard2067d1a2008-11-13 22:59:24 +0000198 }
199 else
200 {
201 // This lets the "routed" segment array identify that the default
202 // index method is being used.
203 $segments[1] = 'index';
204 }
Barry Mienydd671972010-10-04 16:33:58 +0200205
Derek Allard2067d1a2008-11-13 22:59:24 +0000206 // Update our "routed" segment array to contain the segments.
207 // Note: If there is no custom routing, this array will be
208 // identical to $this->uri->segments
209 $this->uri->rsegments = $segments;
210 }
Barry Mienydd671972010-10-04 16:33:58 +0200211
Derek Allard2067d1a2008-11-13 22:59:24 +0000212 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200213
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500215 * Validates the supplied segments. Attempts to determine the path to
Derek Allard2067d1a2008-11-13 22:59:24 +0000216 * the controller.
217 *
218 * @access private
219 * @param array
220 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200221 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000222 function _validate_request($segments)
223 {
Derek Jonesc7738402010-03-02 13:55:13 -0600224 if (count($segments) == 0)
225 {
226 return $segments;
227 }
Barry Mienydd671972010-10-04 16:33:58 +0200228
Derek Allard2067d1a2008-11-13 22:59:24 +0000229 // Does the requested controller exist in the root folder?
Greg Aker3a746652011-04-19 10:59:47 -0500230 if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000231 {
232 return $segments;
233 }
Barry Mienydd671972010-10-04 16:33:58 +0200234
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 // Is the controller in a sub-folder?
236 if (is_dir(APPPATH.'controllers/'.$segments[0]))
Derek Jonesc7738402010-03-02 13:55:13 -0600237 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000238 // Set the directory and remove it from the segment array
239 $this->set_directory($segments[0]);
240 $segments = array_slice($segments, 1);
Barry Mienydd671972010-10-04 16:33:58 +0200241
Derek Allard2067d1a2008-11-13 22:59:24 +0000242 if (count($segments) > 0)
243 {
244 // Does the requested controller exist in the sub-folder?
Greg Aker3a746652011-04-19 10:59:47 -0500245 if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000246 {
Shane Pearson664a9352011-08-10 16:02:32 -0500247 if ( ! empty($this->routes['404_override']))
248 {
249 $x = explode('/', $this->routes['404_override']);
250
251 $this->set_directory('');
252 $this->set_class($x[0]);
253 $this->set_method(isset($x[1]) ? $x[1] : 'index');
254
255 return $x;
256 }
257 else
258 {
259 show_404($this->fetch_directory().$segments[0]);
260 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000261 }
262 }
263 else
264 {
Derek Jonesc7738402010-03-02 13:55:13 -0600265 // Is the method being specified in the route?
266 if (strpos($this->default_controller, '/') !== FALSE)
267 {
268 $x = explode('/', $this->default_controller);
Barry Mienydd671972010-10-04 16:33:58 +0200269
Derek Jonesc7738402010-03-02 13:55:13 -0600270 $this->set_class($x[0]);
271 $this->set_method($x[1]);
Barry Mienydd671972010-10-04 16:33:58 +0200272 }
Derek Jonesc7738402010-03-02 13:55:13 -0600273 else
274 {
275 $this->set_class($this->default_controller);
276 $this->set_method('index');
277 }
Barry Mienydd671972010-10-04 16:33:58 +0200278
Derek Allard2067d1a2008-11-13 22:59:24 +0000279 // Does the default controller exist in the sub-folder?
Greg Aker3a746652011-04-19 10:59:47 -0500280 if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000281 {
282 $this->directory = '';
283 return array();
284 }
Barry Mienydd671972010-10-04 16:33:58 +0200285
Derek Allard2067d1a2008-11-13 22:59:24 +0000286 }
Barry Mienydd671972010-10-04 16:33:58 +0200287
Derek Allard2067d1a2008-11-13 22:59:24 +0000288 return $segments;
289 }
Barry Mienydd671972010-10-04 16:33:58 +0200290
291
Derek Jonesc7738402010-03-02 13:55:13 -0600292 // If we've gotten this far it means that the URI does not correlate to a valid
Derek Jones37f4b9c2011-07-01 17:56:50 -0500293 // controller class. We will now see if there is an override
Eric Barnesc5bf6162011-01-30 21:17:11 -0500294 if ( ! empty($this->routes['404_override']))
Derek Jonesc7738402010-03-02 13:55:13 -0600295 {
Phil Sturgeon23174a62010-12-15 15:18:16 +0000296 $x = explode('/', $this->routes['404_override']);
Barry Mienydd671972010-10-04 16:33:58 +0200297
Phil Sturgeon23174a62010-12-15 15:18:16 +0000298 $this->set_class($x[0]);
299 $this->set_method(isset($x[1]) ? $x[1] : 'index');
Barry Mienydd671972010-10-04 16:33:58 +0200300
Phil Sturgeon23174a62010-12-15 15:18:16 +0000301 return $x;
Derek Jonesc7738402010-03-02 13:55:13 -0600302 }
Barry Mienydd671972010-10-04 16:33:58 +0200303
Phil Sturgeon23174a62010-12-15 15:18:16 +0000304
Derek Jonesc7738402010-03-02 13:55:13 -0600305 // Nothing else to do at this point but show a 404
Barry Mienydd671972010-10-04 16:33:58 +0200306 show_404($segments[0]);
Derek Allard2067d1a2008-11-13 22:59:24 +0000307 }
Barry Mienydd671972010-10-04 16:33:58 +0200308
Derek Allard2067d1a2008-11-13 22:59:24 +0000309 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200310
Derek Allard2067d1a2008-11-13 22:59:24 +0000311 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500312 * Parse Routes
Derek Allard2067d1a2008-11-13 22:59:24 +0000313 *
314 * This function matches any routes that may exist in
315 * the config/routes.php file against the URI to
316 * determine if the class/method need to be remapped.
317 *
318 * @access private
319 * @return void
320 */
321 function _parse_routes()
322 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000323 // Turn the segment array into a URI string
324 $uri = implode('/', $this->uri->segments);
Barry Mienydd671972010-10-04 16:33:58 +0200325
Derek Jones37f4b9c2011-07-01 17:56:50 -0500326 // Is there a literal match? If so we're done
Derek Allard2067d1a2008-11-13 22:59:24 +0000327 if (isset($this->routes[$uri]))
328 {
Derek Jonesc7738402010-03-02 13:55:13 -0600329 return $this->_set_request(explode('/', $this->routes[$uri]));
Derek Allard2067d1a2008-11-13 22:59:24 +0000330 }
Barry Mienydd671972010-10-04 16:33:58 +0200331
Derek Allard2067d1a2008-11-13 22:59:24 +0000332 // Loop through the route array looking for wild-cards
333 foreach ($this->routes as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200334 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000335 // Convert wild-cards to RegEx
336 $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
Derek Jonesc7738402010-03-02 13:55:13 -0600337
Derek Allard2067d1a2008-11-13 22:59:24 +0000338 // Does the RegEx match?
339 if (preg_match('#^'.$key.'$#', $uri))
Derek Jonesc7738402010-03-02 13:55:13 -0600340 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000341 // Do we have a back-reference?
342 if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
343 {
344 $val = preg_replace('#^'.$key.'$#', $val, $uri);
345 }
Barry Mienydd671972010-10-04 16:33:58 +0200346
347 return $this->_set_request(explode('/', $val));
Derek Allard2067d1a2008-11-13 22:59:24 +0000348 }
349 }
350
351 // If we got this far it means we didn't encounter a
352 // matching route so we'll set the site default route
353 $this->_set_request($this->uri->segments);
354 }
355
356 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200357
Derek Allard2067d1a2008-11-13 22:59:24 +0000358 /**
359 * Set the class name
360 *
361 * @access public
362 * @param string
363 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200364 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000365 function set_class($class)
366 {
Derek Jones2615e412010-10-06 17:51:16 -0500367 $this->class = str_replace(array('/', '.'), '', $class);
Derek Allard2067d1a2008-11-13 22:59:24 +0000368 }
Barry Mienydd671972010-10-04 16:33:58 +0200369
Derek Allard2067d1a2008-11-13 22:59:24 +0000370 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200371
Derek Allard2067d1a2008-11-13 22:59:24 +0000372 /**
373 * Fetch the current class
374 *
375 * @access public
376 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200377 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 function fetch_class()
379 {
380 return $this->class;
381 }
Barry Mienydd671972010-10-04 16:33:58 +0200382
Derek Allard2067d1a2008-11-13 22:59:24 +0000383 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200384
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500386 * Set the method name
Derek Allard2067d1a2008-11-13 22:59:24 +0000387 *
388 * @access public
389 * @param string
390 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200391 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000392 function set_method($method)
393 {
394 $this->method = $method;
395 }
396
397 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200398
Derek Allard2067d1a2008-11-13 22:59:24 +0000399 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500400 * Fetch the current method
Derek Allard2067d1a2008-11-13 22:59:24 +0000401 *
402 * @access public
403 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200404 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000405 function fetch_method()
406 {
407 if ($this->method == $this->fetch_class())
408 {
409 return 'index';
410 }
411
412 return $this->method;
413 }
414
415 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200416
Derek Allard2067d1a2008-11-13 22:59:24 +0000417 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500418 * Set the directory name
Derek Allard2067d1a2008-11-13 22:59:24 +0000419 *
420 * @access public
421 * @param string
422 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200423 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000424 function set_directory($dir)
425 {
Derek Jones2615e412010-10-06 17:51:16 -0500426 $this->directory = str_replace(array('/', '.'), '', $dir).'/';
Derek Allard2067d1a2008-11-13 22:59:24 +0000427 }
428
429 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200430
Derek Allard2067d1a2008-11-13 22:59:24 +0000431 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500432 * Fetch the sub-directory (if any) that contains the requested controller class
Derek Allard2067d1a2008-11-13 22:59:24 +0000433 *
434 * @access public
435 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200436 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000437 function fetch_directory()
438 {
439 return $this->directory;
440 }
441
Derek Jonesc7738402010-03-02 13:55:13 -0600442 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200443
Derek Jonesc7738402010-03-02 13:55:13 -0600444 /**
Derek Jones37f4b9c2011-07-01 17:56:50 -0500445 * Set the controller overrides
Derek Jonesc7738402010-03-02 13:55:13 -0600446 *
447 * @access public
448 * @param array
449 * @return null
Barry Mienydd671972010-10-04 16:33:58 +0200450 */
Derek Jonesc7738402010-03-02 13:55:13 -0600451 function _set_overrides($routing)
452 {
453 if ( ! is_array($routing))
454 {
455 return;
456 }
Barry Mienydd671972010-10-04 16:33:58 +0200457
Derek Jonesc7738402010-03-02 13:55:13 -0600458 if (isset($routing['directory']))
459 {
460 $this->set_directory($routing['directory']);
461 }
Barry Mienydd671972010-10-04 16:33:58 +0200462
Derek Jonesc7738402010-03-02 13:55:13 -0600463 if (isset($routing['controller']) AND $routing['controller'] != '')
464 {
465 $this->set_class($routing['controller']);
466 }
Barry Mienydd671972010-10-04 16:33:58 +0200467
Derek Jonesc7738402010-03-02 13:55:13 -0600468 if (isset($routing['function']))
469 {
470 $routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
471 $this->set_method($routing['function']);
472 }
473 }
474
475
Derek Allard2067d1a2008-11-13 22:59:24 +0000476}
477// END Router Class
478
479/* End of file Router.php */
Derek Jonesc68dfbf2010-03-02 12:59:23 -0600480/* Location: ./system/core/Router.php */