Updated a few things
This commit is contained in:
@@ -34,6 +34,7 @@ class Anvil {
|
||||
? $this->config->item('default_controller') : array_shift($uri_array);
|
||||
$start_token = $this->config->item('starting_token');
|
||||
while($start_token-- > 0) { array_shift($uri_array); }
|
||||
$this->request->uri_array = $uri_array;
|
||||
$cc_name = '';
|
||||
if(!file_exists(APP_ROOT.'/controllers/'.$class_name.'_controller.php')) {
|
||||
$class_name = $this->config->item('default_controller');
|
||||
|
@@ -27,6 +27,21 @@ class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function load_helpers($helper=NULL) {
|
||||
$this->load_helper($helper);
|
||||
}
|
||||
public function load_helper($helper=NULL) {
|
||||
// All helpers end with '_helper'
|
||||
if(is_array($helper)) {
|
||||
foreach($helper as $k=>$m) {
|
||||
$helper[$k]=$m."_helper";
|
||||
}
|
||||
} else {
|
||||
$helper.="_helper";
|
||||
}
|
||||
$this->_load_files($helper, "helpers");
|
||||
}
|
||||
|
||||
public function load_models($model=NULL) {
|
||||
$this->load_model($model);
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ class Request {
|
||||
public $server;
|
||||
|
||||
public $uri_array;
|
||||
public $original_uri_array;
|
||||
|
||||
private $_anvil;
|
||||
|
||||
@@ -19,6 +20,7 @@ class Request {
|
||||
public function __construct($a) {
|
||||
$this->_anvil = $a;
|
||||
$this->createFromGlobals();
|
||||
$this->clearFlashdata();
|
||||
}
|
||||
|
||||
public function createFromGlobals() {
|
||||
@@ -32,6 +34,7 @@ class Request {
|
||||
$this->files = $_FILES;
|
||||
$this->server = $_SERVER;
|
||||
$this->uri_array = $this->uriToArray();
|
||||
$this->original_uri_array = $this->uri_array;
|
||||
}
|
||||
|
||||
/** Is this an HTTPS request? */
|
||||
@@ -71,7 +74,11 @@ class Request {
|
||||
}
|
||||
|
||||
public function process_data($index=NULL, $xss_clean=FALSE) {
|
||||
$request_vars = (array)$this->json();
|
||||
if(count($_FILES) > 0) {
|
||||
$request_vars = $_POST;
|
||||
} else {
|
||||
$request_vars = (array)$this->json();
|
||||
}
|
||||
if($index==NULL && !empty($request_vars)) {
|
||||
$post = array();
|
||||
foreach(array_keys($request_vars) as $key) {
|
||||
@@ -115,6 +122,23 @@ class Request {
|
||||
$this->setCookie($key, '', time()-3600*24*365);
|
||||
}
|
||||
|
||||
public function setFlashdata($key, $val) {
|
||||
return $this->setCookie('flashdata_'.$key, $val);
|
||||
}
|
||||
|
||||
public function getFlashdata($key) {
|
||||
if(!isset($this->cookie['flashdata_'.$key])) { return false; }
|
||||
return $this->cookie['flashdata_'.$key];
|
||||
}
|
||||
|
||||
public function clearFlashdata() {
|
||||
foreach($this->cookie as $k => $v) {
|
||||
if(strpos($k, 'flashdata_') !== FALSE) {
|
||||
$this->clearCookie($k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* URI Parsing Functions
|
||||
*/
|
||||
|
@@ -7,6 +7,16 @@ class Response {
|
||||
$this->_anvil = $a;
|
||||
}
|
||||
|
||||
public function badrequest($txt="Bad Request") {
|
||||
header('HTTP/1.0 400 Bad Request');
|
||||
echo $txt;
|
||||
}
|
||||
|
||||
public function notfound($txt="Page Not Found") {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
echo $txt;
|
||||
}
|
||||
|
||||
public function redirect($url) {
|
||||
header('Location: '.$url);
|
||||
}
|
||||
|
Reference in New Issue
Block a user