2009-02-24 09:17:28 +02:00
|
|
|
<?php defined('SYSPATH') or die('No direct script access.');
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Request and response wrapper.
|
|
|
|
*
|
2009-03-20 23:58:10 +02:00
|
|
|
* @package Kohana
|
2009-02-28 13:39:01 +02:00
|
|
|
* @author Kohana Team
|
|
|
|
* @copyright (c) 2008-2009 Kohana Team
|
|
|
|
* @license http://kohanaphp.com/license.html
|
|
|
|
*/
|
2009-02-24 09:17:28 +02:00
|
|
|
class Request_Core {
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// HTTP status codes and messages
|
|
|
|
protected static $messages = array(
|
|
|
|
// Informational 1xx
|
|
|
|
100 => 'Continue',
|
|
|
|
101 => 'Switching Protocols',
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Success 2xx
|
|
|
|
200 => 'OK',
|
|
|
|
201 => 'Created',
|
|
|
|
202 => 'Accepted',
|
|
|
|
203 => 'Non-Authoritative Information',
|
|
|
|
204 => 'No Content',
|
|
|
|
205 => 'Reset Content',
|
|
|
|
206 => 'Partial Content',
|
|
|
|
|
|
|
|
// Redirection 3xx
|
|
|
|
300 => 'Multiple Choices',
|
|
|
|
301 => 'Moved Permanently',
|
|
|
|
302 => 'Found', // 1.1
|
|
|
|
303 => 'See Other',
|
|
|
|
304 => 'Not Modified',
|
|
|
|
305 => 'Use Proxy',
|
|
|
|
// 306 is deprecated but reserved
|
|
|
|
307 => 'Temporary Redirect',
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Client Error 4xx
|
|
|
|
400 => 'Bad Request',
|
|
|
|
401 => 'Unauthorized',
|
|
|
|
402 => 'Payment Required',
|
|
|
|
403 => 'Forbidden',
|
|
|
|
404 => 'Not Found',
|
|
|
|
405 => 'Method Not Allowed',
|
|
|
|
406 => 'Not Acceptable',
|
|
|
|
407 => 'Proxy Authentication Required',
|
|
|
|
408 => 'Request Timeout',
|
|
|
|
409 => 'Conflict',
|
|
|
|
410 => 'Gone',
|
|
|
|
411 => 'Length Required',
|
|
|
|
412 => 'Precondition Failed',
|
|
|
|
413 => 'Request Entity Too Large',
|
|
|
|
414 => 'Request-URI Too Long',
|
|
|
|
415 => 'Unsupported Media Type',
|
|
|
|
416 => 'Requested Range Not Satisfiable',
|
|
|
|
417 => 'Expectation Failed',
|
|
|
|
|
|
|
|
// Server Error 5xx
|
|
|
|
500 => 'Internal Server Error',
|
|
|
|
501 => 'Not Implemented',
|
|
|
|
502 => 'Bad Gateway',
|
|
|
|
503 => 'Service Unavailable',
|
|
|
|
504 => 'Gateway Timeout',
|
|
|
|
505 => 'HTTP Version Not Supported',
|
|
|
|
509 => 'Bandwidth Limit Exceeded'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Main request instance
|
2009-02-24 09:17:28 +02:00
|
|
|
protected static $_instance;
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Main request singleton instance. If no URI is provided, the URI will
|
|
|
|
* be automatically detected using PATH_INFO, REQUEST_URI, or PHP_SELF.
|
|
|
|
*
|
|
|
|
* @param string URI of the request
|
|
|
|
* @return Request
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public static function instance( & $uri = FALSE)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
|
|
|
if (Request::$_instance === NULL)
|
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
// Create the initial request parameters
|
|
|
|
$params = array('method' => 'GET', 'get' => NULL, 'post' => NULL);
|
|
|
|
|
|
|
|
if (Kohana::$is_cli)
|
|
|
|
{
|
|
|
|
// Get the command line options
|
|
|
|
$options = cli::options('uri', 'method', 'get', 'post');
|
|
|
|
|
|
|
|
if (isset($options['uri']))
|
|
|
|
{
|
|
|
|
// Use the specified URI
|
|
|
|
$uri = $options['uri'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($options['method']))
|
|
|
|
{
|
|
|
|
// Request method specified
|
|
|
|
$params['method'] = $options['method'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($options['get']))
|
|
|
|
{
|
|
|
|
// GET data specified
|
|
|
|
parse_str($options['get'], $params['get']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($options['post']))
|
|
|
|
{
|
|
|
|
// POST data specified
|
|
|
|
parse_str($options['post'], $params['post']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isset($_SERVER['REQUEST_METHOD']))
|
|
|
|
{
|
|
|
|
// Use the server request method
|
|
|
|
$params['method'] = $_SERVER['REQUEST_METHOD'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($params['method'] !== 'GET' AND $params['method'] !== 'POST')
|
|
|
|
{
|
|
|
|
// Methods besides GET and POST do not properly parse the form-encoded
|
|
|
|
// query string into the $_POST array, so we do it manually.
|
|
|
|
parse_str(file_get_contents('php://input'), $params['post']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($uri === FALSE)
|
2009-02-28 13:39:01 +02:00
|
|
|
{
|
|
|
|
if (isset($_SERVER['PATH_INFO']))
|
|
|
|
{
|
|
|
|
// PATH_INFO is most realiable way to handle routing, as it
|
|
|
|
// does not include the document root or index file
|
|
|
|
$uri = $_SERVER['PATH_INFO'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// REQUEST_URI and PHP_SELF both provide the full path,
|
|
|
|
// including the document root and index file
|
|
|
|
if (isset($_SERVER['REQUEST_URI']))
|
|
|
|
{
|
|
|
|
$uri = $_SERVER['REQUEST_URI'];
|
|
|
|
}
|
|
|
|
elseif (isset($_SERVER['PHP_SELF']))
|
|
|
|
{
|
|
|
|
$uri = $_SERVER['PHP_SELF'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SERVER['SCRIPT_NAME']) AND strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
|
|
|
|
{
|
|
|
|
// Remove the document root and index file from the URI
|
|
|
|
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-24 09:17:28 +02:00
|
|
|
// Create the instance singleton
|
2009-04-10 01:01:40 +03:00
|
|
|
Request::$_instance = new Request($uri, $params);
|
2009-02-24 09:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Request::$_instance;
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Creates a new request object for the given URI. Global GET and POST data
|
|
|
|
* can be overloaded.
|
|
|
|
*
|
|
|
|
* @chainable
|
|
|
|
* @param string URI of the request
|
|
|
|
* @param array overloaded GET data
|
|
|
|
* @param array overloaded POST data
|
|
|
|
* @return Request
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public static function factory($uri, array $params = NULL)
|
2009-02-28 13:39:01 +02:00
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
return new Request($uri, $params);
|
2009-02-28 13:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var object route used for this request
|
|
|
|
*/
|
2009-02-24 09:17:28 +02:00
|
|
|
public $route;
|
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
/**
|
|
|
|
* @var string request method type (GET, POST, PUT, etc)
|
|
|
|
*/
|
|
|
|
public $method = 'GET';
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* @var decimal HTTP version (1.0, 1.1)
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public $version = 1.1;
|
2009-02-28 13:39:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var integer HTTP response code (200, 404, 500, etc)
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public $status = 200;
|
2009-02-28 13:39:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string response body
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public $response;
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* @var array headers to send with the response body
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public $headers = array('content-type' => 'text/html; charset=utf-8');
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-04-21 06:24:05 +03:00
|
|
|
/**
|
|
|
|
* @var string controller directory
|
|
|
|
*/
|
|
|
|
public $directory = '';
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* @var string controller to be executed
|
|
|
|
*/
|
|
|
|
public $controller;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string action to be executed in the controller
|
|
|
|
*/
|
|
|
|
public $action;
|
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
/**
|
|
|
|
* @var string the URI of the request
|
|
|
|
*/
|
|
|
|
public $uri;
|
2009-02-28 13:39:01 +02:00
|
|
|
|
|
|
|
// Parameters extracted from the route
|
2009-02-24 09:17:28 +02:00
|
|
|
protected $_params;
|
2009-02-28 13:39:01 +02:00
|
|
|
|
|
|
|
// Request GET and POST data
|
2009-02-24 09:17:28 +02:00
|
|
|
protected $_get;
|
|
|
|
protected $_post;
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Creates a new request object for the given URI. Global GET and POST data
|
2009-04-10 01:01:40 +03:00
|
|
|
* can be overloaded by setting "get" and "post" in the parameters.
|
2009-02-28 13:39:01 +02:00
|
|
|
*
|
|
|
|
* @param string URI of the request
|
2009-04-10 01:01:40 +03:00
|
|
|
* @param array request parameters
|
2009-02-28 13:39:01 +02:00
|
|
|
* @return void
|
2009-04-10 01:01:40 +03:00
|
|
|
* @throws Kohana_Exception if no route matches the URI
|
2009-02-28 13:39:01 +02:00
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public function __construct($uri, array $params = NULL)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
if (isset($params['method']))
|
|
|
|
{
|
|
|
|
// Set the request method
|
|
|
|
$this->method = strtoupper($params['method']);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load GET data
|
|
|
|
$this->_get = isset($params['get']) ? $params['get'] : $_GET;
|
|
|
|
|
|
|
|
// Load POST data
|
|
|
|
$this->_post = isset($params['post']) ? $params['post'] : $_POST;
|
2009-03-23 17:40:14 +02:00
|
|
|
|
2009-02-24 09:17:28 +02:00
|
|
|
// Remove trailing slashes from the URI
|
|
|
|
$uri = trim($uri, '/');
|
|
|
|
|
|
|
|
// Load routes
|
|
|
|
$routes = Route::all();
|
|
|
|
|
|
|
|
foreach ($routes as $name => $route)
|
|
|
|
{
|
|
|
|
if ($params = $route->matches($uri))
|
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
// Store the URI
|
|
|
|
$this->uri = $uri;
|
|
|
|
|
|
|
|
// Store the matching route
|
2009-02-24 09:17:28 +02:00
|
|
|
$this->route = $route;
|
|
|
|
|
2009-04-21 06:24:05 +03:00
|
|
|
if (isset($params['directory']))
|
|
|
|
{
|
|
|
|
// Controllers are in a sub-directory
|
|
|
|
$this->directory = $params['directory'];
|
|
|
|
}
|
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
// Store the controller and action
|
2009-02-28 13:39:01 +02:00
|
|
|
$this->controller = $params['controller'];
|
|
|
|
$this->action = $params['action'];
|
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
// These are accessible as public vars and can be overloaded
|
2009-04-21 06:24:05 +03:00
|
|
|
unset($params['controller'], $params['action'], $params['directory']);
|
2009-02-28 13:39:01 +02:00
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
// Params cannot be changed once matched
|
2009-02-24 09:17:28 +02:00
|
|
|
$this->_params = $params;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-10 01:01:40 +03:00
|
|
|
throw new Kohana_Exception('Unable to find a route to handle :uri', array(':uri' => $uri));
|
2009-03-23 17:40:14 +02:00
|
|
|
}
|
|
|
|
|
2009-04-21 06:24:52 +03:00
|
|
|
/**
|
|
|
|
* Generates a complete URL for the current route.
|
|
|
|
*
|
|
|
|
* @param array additional route parameters
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function url(array $params = NULL)
|
|
|
|
{
|
|
|
|
return Kohana::$base_url.$this->uri($params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a relative URI for the current route.
|
|
|
|
*
|
|
|
|
* @param array additional route parameters
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function uri(array $params = NULL)
|
|
|
|
{
|
|
|
|
if ( ! isset($params['controller']))
|
|
|
|
{
|
|
|
|
// Add the current controller
|
|
|
|
$params['controller'] = $this->controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! isset($params['action']))
|
|
|
|
{
|
|
|
|
// Add the current action
|
|
|
|
$params['action'] = $this->action;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->route->uri($params);
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Retrieves a value from the route parameters.
|
|
|
|
*
|
|
|
|
* @param string key of the value
|
|
|
|
* @param mixed default value if the key is not set
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public function param($key = NULL, $default = NULL)
|
2009-02-28 13:39:01 +02:00
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
if ($key === NULL)
|
|
|
|
{
|
|
|
|
// Return the full array
|
|
|
|
return $this->_params;
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
return isset($this->_params[$key]) ? $this->_params[$key] : $default;
|
2009-02-24 09:17:28 +02:00
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Retrieves a value from GET data.
|
|
|
|
*
|
|
|
|
* @param string key of the value
|
|
|
|
* @param mixed default value if the key is not set
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public function get($key = NULL, $default = NULL)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
if ($key === NULL)
|
|
|
|
{
|
|
|
|
// Return the full array
|
|
|
|
return $this->_get;
|
|
|
|
}
|
|
|
|
|
2009-02-24 09:17:28 +02:00
|
|
|
return isset($this->_get[$key]) ? $this->_get[$key] : $default;
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Retrieves a value from POST data.
|
|
|
|
*
|
|
|
|
* @param string key of the value
|
|
|
|
* @param mixed default value if the key is not set
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2009-04-10 01:01:40 +03:00
|
|
|
public function post($key = NULL, $default = NULL)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
2009-04-10 01:01:40 +03:00
|
|
|
if ($key === NULL)
|
|
|
|
{
|
|
|
|
// Return the full array
|
|
|
|
return $this->_post;
|
|
|
|
}
|
|
|
|
|
2009-02-24 09:17:28 +02:00
|
|
|
return isset($this->_post[$key]) ? $this->_post[$key] : $default;
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Gets an named header.
|
|
|
|
*
|
|
|
|
* @param string header name
|
|
|
|
* @return string header value
|
|
|
|
* @return FALSE if no header is found
|
|
|
|
*/
|
|
|
|
public function get_header($name)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
2009-02-28 13:39:01 +02:00
|
|
|
// The header name is always stored lowercase
|
|
|
|
$name = strtolower($name);
|
|
|
|
|
|
|
|
return isset($this->headers[$name]) ? $this->headers[$name] : FALSE;
|
2009-02-24 09:17:28 +02:00
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
/**
|
|
|
|
* Sets an named header.
|
|
|
|
*
|
|
|
|
* @param string header name
|
|
|
|
* @param string header value
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function set_header($name, $value)
|
2009-02-24 09:17:28 +02:00
|
|
|
{
|
2009-02-28 13:39:01 +02:00
|
|
|
// The header name is always stored lowercase
|
|
|
|
$name = strtolower($name);
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Add the header to the list
|
|
|
|
$this->headers[$name] = $value;
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets an unnamed header. Raw headers cannot be retrieved with get_header!
|
|
|
|
*
|
|
|
|
* @param string header string
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function set_raw_header($value)
|
|
|
|
{
|
|
|
|
$this->headers[] = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a named header.
|
|
|
|
*
|
|
|
|
* @param string header name
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function delete_header($name)
|
|
|
|
{
|
|
|
|
// The header name is always stored lowercase
|
|
|
|
$name = strtolower($name);
|
|
|
|
|
|
|
|
// Remove the header from the list
|
|
|
|
unset($this->_headers[$name]);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends the response status and all set headers.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function send_headers()
|
|
|
|
{
|
|
|
|
// Get the status message
|
|
|
|
$message = Request::$messages[$this->status];
|
|
|
|
|
|
|
|
// Send the HTTP status message
|
|
|
|
header("HTTP/{$this->version} {$this->status} {$message}", TRUE, $this->status);
|
|
|
|
|
|
|
|
foreach ($this->headers as $name => $value)
|
|
|
|
{
|
|
|
|
if (is_string($name))
|
|
|
|
{
|
|
|
|
// Convert the header name to Title-Case, to match RFC spec
|
|
|
|
$name = str_replace('-', ' ', $name);
|
|
|
|
$name = str_replace(' ', '-', ucwords($name));
|
|
|
|
|
|
|
|
// Combine the name and value to make a raw header
|
|
|
|
$value = "{$name}: {$value}";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send the raw header
|
|
|
|
header($value, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes the request, executing the controller. Before the routed action
|
|
|
|
* is run, the before() method will be called, which allows the controller
|
|
|
|
* to overload the action based on the request parameters. After the action
|
|
|
|
* is run, the after() method will be called, for post-processing.
|
|
|
|
*
|
|
|
|
* By default, the output from the controller is captured and returned, and
|
|
|
|
* no headers are sent.
|
|
|
|
*
|
|
|
|
* @param boolean capture the output and return it
|
|
|
|
* @return string for captured output
|
|
|
|
* @return void for displayed output
|
|
|
|
*/
|
|
|
|
public function execute($capture = TRUE)
|
|
|
|
{
|
2009-04-21 06:24:05 +03:00
|
|
|
if (empty($this->directory))
|
|
|
|
{
|
|
|
|
// There is no controller prefix
|
|
|
|
$prefix = '';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Make the directory name into a class prefix
|
|
|
|
$prefix = str_replace(array('\\', '/'), '_', trim($this->directory, '/')).'_';
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Set the controller class name
|
2009-04-21 06:24:05 +03:00
|
|
|
$controller = 'controller_'.$prefix.$this->controller;
|
2009-02-24 09:17:28 +02:00
|
|
|
|
|
|
|
// Load the controller
|
|
|
|
$controller = new $controller($this);
|
|
|
|
|
|
|
|
// A new action is about to be run
|
2009-04-10 01:01:40 +03:00
|
|
|
$controller->before($this->method);
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Set the action name after running before() to allow the controller
|
|
|
|
// to change the action based on the current parameters
|
|
|
|
$action = 'action_'.$this->action;
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Execute the action
|
|
|
|
$controller->$action();
|
|
|
|
|
|
|
|
// The action has been run
|
2009-04-10 01:01:40 +03:00
|
|
|
$controller->after($this->method);
|
2009-02-28 13:39:01 +02:00
|
|
|
|
|
|
|
if ($capture === TRUE)
|
|
|
|
return $this->response;
|
|
|
|
|
|
|
|
// Send the headers
|
|
|
|
$this->send_headers();
|
2009-02-24 09:17:28 +02:00
|
|
|
|
2009-02-28 13:39:01 +02:00
|
|
|
// Send the response
|
2009-02-24 09:17:28 +02:00
|
|
|
echo $this->response;
|
|
|
|
}
|
|
|
|
|
2009-03-02 02:06:44 +02:00
|
|
|
} // End Request
|