Kohana v3.3.0

This commit is contained in:
Deon George
2013-04-22 14:09:50 +10:00
commit f96694b18f
1280 changed files with 145034 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_300 extends HTTP_Exception_Redirect {
/**
* @var integer HTTP 300 Multiple Choices
*/
protected $_code = 300;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_301 extends HTTP_Exception_Redirect {
/**
* @var integer HTTP 301 Moved Permanently
*/
protected $_code = 301;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_302 extends HTTP_Exception_Redirect {
/**
* @var integer HTTP 302 Found
*/
protected $_code = 302;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_303 extends HTTP_Exception_Redirect {
/**
* @var integer HTTP 303 See Other
*/
protected $_code = 303;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_304 extends HTTP_Exception_Expected {
/**
* @var integer HTTP 304 Not Modified
*/
protected $_code = 304;
}

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_305 extends HTTP_Exception_Expected {
/**
* @var integer HTTP 305 Use Proxy
*/
protected $_code = 305;
/**
* Specifies the proxy to replay this request via
*
* @param string $location URI of the proxy
*/
public function location($uri = NULL)
{
if ($uri === NULL)
return $this->headers('Location');
$this->headers('Location', $uri);
return $this;
}
/**
* Validate this exception contains everything needed to continue.
*
* @throws Kohana_Exception
* @return bool
*/
public function check()
{
if ($location = $this->headers('location') === NULL)
throw new Kohana_Exception('A \'location\' must be specified for a redirect');
if (strpos($location, '://') === FALSE)
throw new Kohana_Exception('An absolute URI to the proxy server must be specified');
return TRUE;
}
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_307 extends HTTP_Exception_Redirect {
/**
* @var integer HTTP 307 Temporary Redirect
*/
protected $_code = 307;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_400 extends HTTP_Exception {
/**
* @var integer HTTP 400 Bad Request
*/
protected $_code = 400;
}

View File

@@ -0,0 +1,38 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_401 extends HTTP_Exception_Expected {
/**
* @var integer HTTP 401 Unauthorized
*/
protected $_code = 401;
/**
* Specifies the WWW-Authenticate challenge.
*
* @param string $challenge WWW-Authenticate challenge (eg `Basic realm="Control Panel"`)
*/
public function authenticate($challenge = NULL)
{
if ($challenge === NULL)
return $this->headers('www-authenticate');
$this->headers('www-authenticate', $challenge);
return $this;
}
/**
* Validate this exception contains everything needed to continue.
*
* @throws Kohana_Exception
* @return bool
*/
public function check()
{
if ($this->headers('www-authenticate') === NULL)
throw new Kohana_Exception('A \'www-authenticate\' header must be specified for a HTTP 401 Unauthorized');
return TRUE;
}
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_402 extends HTTP_Exception {
/**
* @var integer HTTP 402 Payment Required
*/
protected $_code = 402;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_403 extends HTTP_Exception {
/**
* @var integer HTTP 403 Forbidden
*/
protected $_code = 403;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_404 extends HTTP_Exception {
/**
* @var integer HTTP 404 Not Found
*/
protected $_code = 404;
}

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_405 extends HTTP_Exception_Expected {
/**
* @var integer HTTP 405 Method Not Allowed
*/
protected $_code = 405;
/**
* Specifies the list of allowed HTTP methods
*
* @param array $methods List of allowed methods
*/
public function allowed($methods)
{
if (is_array($methods))
{
$methods = implode(',', $methods);
}
$this->headers('allow', $methods);
return $this;
}
/**
* Validate this exception contains everything needed to continue.
*
* @throws Kohana_Exception
* @return bool
*/
public function check()
{
if ($location = $this->headers('allow') === NULL)
throw new Kohana_Exception('A list of allowed methods must be specified');
return TRUE;
}
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_406 extends HTTP_Exception {
/**
* @var integer HTTP 406 Not Acceptable
*/
protected $_code = 406;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_407 extends HTTP_Exception {
/**
* @var integer HTTP 407 Proxy Authentication Required
*/
protected $_code = 407;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_408 extends HTTP_Exception {
/**
* @var integer HTTP 408 Request Timeout
*/
protected $_code = 408;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_409 extends HTTP_Exception {
/**
* @var integer HTTP 409 Conflict
*/
protected $_code = 409;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_410 extends HTTP_Exception {
/**
* @var integer HTTP 410 Gone
*/
protected $_code = 410;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_411 extends HTTP_Exception {
/**
* @var integer HTTP 411 Length Required
*/
protected $_code = 411;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_412 extends HTTP_Exception {
/**
* @var integer HTTP 412 Precondition Failed
*/
protected $_code = 412;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_413 extends HTTP_Exception {
/**
* @var integer HTTP 413 Request Entity Too Large
*/
protected $_code = 413;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_414 extends HTTP_Exception {
/**
* @var integer HTTP 414 Request-URI Too Long
*/
protected $_code = 414;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_415 extends HTTP_Exception {
/**
* @var integer HTTP 415 Unsupported Media Type
*/
protected $_code = 415;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_416 extends HTTP_Exception {
/**
* @var integer HTTP 416 Request Range Not Satisfiable
*/
protected $_code = 416;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_417 extends HTTP_Exception {
/**
* @var integer HTTP 417 Expectation Failed
*/
protected $_code = 417;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_500 extends HTTP_Exception {
/**
* @var integer HTTP 500 Internal Server Error
*/
protected $_code = 500;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_501 extends HTTP_Exception {
/**
* @var integer HTTP 501 Not Implemented
*/
protected $_code = 501;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_502 extends HTTP_Exception {
/**
* @var integer HTTP 502 Bad Gateway
*/
protected $_code = 502;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_503 extends HTTP_Exception {
/**
* @var integer HTTP 503 Service Unavailable
*/
protected $_code = 503;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_504 extends HTTP_Exception {
/**
* @var integer HTTP 504 Gateway Timeout
*/
protected $_code = 504;
}

View File

@@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct script access.');
class Kohana_HTTP_Exception_505 extends HTTP_Exception {
/**
* @var integer HTTP 505 HTTP Version Not Supported
*/
protected $_code = 505;
}

View File

@@ -0,0 +1,82 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* "Expected" HTTP exception class. Used for all [HTTP_Exception]'s where a standard
* Kohana error page should never be shown.
*
* Eg [HTTP_Exception_301], [HTTP_Exception_302] etc
*
* @package Kohana
* @category Exceptions
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception {
/**
* @var Response Response Object
*/
protected $_response;
/**
* Creates a new translated exception.
*
* throw new Kohana_Exception('Something went terrible wrong, :user',
* array(':user' => $user));
*
* @param string $message status message, custom content to display with error
* @param array $variables translation variables
* @return void
*/
public function __construct($message = NULL, array $variables = NULL, Exception $previous = NULL)
{
parent::__construct($message, $variables, $previous);
// Prepare our response object and set the correct status code.
$this->_response = Response::factory()
->status($this->_code);
}
/**
* Gets and sets headers to the [Response].
*
* @see [Response::headers]
* @param mixed $key
* @param string $value
* @return mixed
*/
public function headers($key = NULL, $value = NULL)
{
$result = $this->_response->headers($key, $value);
if ( ! $result instanceof Response)
return $result;
return $this;
}
/**
* Validate this exception contains everything needed to continue.
*
* @throws Kohana_Exception
* @return bool
*/
public function check()
{
return TRUE;
}
/**
* Generate a Response for the current Exception
*
* @uses Kohana_Exception::response()
* @return Response
*/
public function get_response()
{
$this->check();
return $this->_response;
}
} // End Kohana_HTTP_Exception

View File

@@ -0,0 +1,51 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Redirect HTTP exception class. Used for all [HTTP_Exception]'s where the status
* code indicates a redirect.
*
* Eg [HTTP_Exception_301], [HTTP_Exception_302] and most of the other 30x's
*
* @package Kohana
* @category Exceptions
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
abstract class Kohana_HTTP_Exception_Redirect extends HTTP_Exception_Expected {
/**
* Specifies the URI to redirect to.
*
* @param string $location URI of the proxy
*/
public function location($uri = NULL)
{
if ($uri === NULL)
return $this->headers('Location');
if (strpos($uri, '://') === FALSE)
{
// Make the URI into a URL
$uri = URL::site($uri, TRUE, ! empty(Kohana::$index_file));
}
$this->headers('Location', $uri);
return $this;
}
/**
* Validate this exception contains everything needed to continue.
*
* @throws Kohana_Exception
* @return bool
*/
public function check()
{
if ($this->headers('location') === NULL)
throw new Kohana_Exception('A \'location\' must be specified for a redirect');
return TRUE;
}
} // End Kohana_HTTP_Exception_Redirect