summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/codeigniter/CodeIgniter.php24
-rw-r--r--system/database/DB_cache.php46
-rw-r--r--system/libraries/Calendar.php14
-rw-r--r--system/libraries/Controller.php46
-rw-r--r--system/libraries/Loader.php3
-rw-r--r--system/libraries/Profiler.php28
-rw-r--r--system/libraries/Session.php71
-rw-r--r--system/libraries/Validation.php17
-rw-r--r--system/scaffolding/Scaffolding.php85
9 files changed, 173 insertions, 161 deletions
diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php
index a237e8a0a..63ae45864 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -173,32 +173,15 @@ $EXT->_call_hook('pre_controller');
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
+// Instantiate the Controller
$CI = new $class();
+// Is this a scaffolding request?
if ($RTR->scaffolding_request === TRUE)
{
if ($EXT->_call_hook('scaffolding_override') === FALSE)
{
- if ($CI->_ci_scaffolding === FALSE OR $CI->_ci_scaff_table === FALSE)
- {
- show_404('Scaffolding unavailable');
- }
-
- if ( ! class_exists('Scaffolding'))
- {
- if ( ! in_array($CI->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE))
- {
- $method = 'view';
- }
- else
- {
- $method = $CI->uri->segment(3);
- }
-
- require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
- $scaff = new Scaffolding($CI->_ci_scaff_table);
- $scaff->$method();
- }
+ $CI->_ci_scaffolding();
}
}
else
@@ -210,6 +193,7 @@ else
*/
$EXT->_call_hook('post_controller_constructor');
+ // Is there a "remap" function?
if (method_exists($CI, '_remap'))
{
$CI->_remap($method);
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index bb2b47b7b..081b56584 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -24,7 +24,7 @@
*/
class CI_DB_Cache {
- var $obj;
+ var $CI;
/**
* Constructor
@@ -34,10 +34,10 @@ class CI_DB_Cache {
*/
function CI_DB_Cache()
{
- // Assign the main CI object to $this->obj
+ // Assign the main CI object to $this->CI
// and load the file helper since we use it a lot
- $this->obj =& get_instance();
- $this->obj->load->helper('file');
+ $this->CI =& get_instance();
+ $this->CI->load->helper('file');
}
// --------------------------------------------------------------------
@@ -53,12 +53,12 @@ class CI_DB_Cache {
{
if ($path == '')
{
- if ($this->obj->db->cachedir == '')
+ if ($this->CI->db->cachedir == '')
{
- return $this->obj->db->cache_off();
+ return $this->CI->db->cache_off();
}
- $path = $this->obj->db->cachedir;
+ $path = $this->CI->db->cachedir;
}
// Add a trailing slash to the path if needed
@@ -66,16 +66,16 @@ class CI_DB_Cache {
if ( ! is_dir($path) OR ! is_writable($path))
{
- if ($this->obj->db->db_debug)
+ if ($this->CI->db->db_debug)
{
- return $this->obj->db->display_error('db_invalid_cache_path');
+ return $this->CI->db->display_error('db_invalid_cache_path');
}
// If the path is wrong we'll turn off caching
- return $this->obj->db->cache_off();
+ return $this->CI->db->cache_off();
}
- $this->obj->db->cachedir = $path;
+ $this->CI->db->cachedir = $path;
return TRUE;
}
@@ -94,15 +94,15 @@ class CI_DB_Cache {
{
if ( ! $this->check_path())
{
- return $this->obj->db->cache_off();
+ return $this->CI->db->cache_off();
}
- $uri = ($this->obj->uri->segment(1) == FALSE) ? 'default.' : $this->obj->uri->segment(1).'.';
- $uri .= ($this->obj->uri->segment(2) == FALSE) ? 'index' : $this->obj->uri->segment(2);
+ $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'.';
+ $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
$filepath = $uri.'/'.md5($sql);
- if (FALSE === ($cachedata = read_file($this->obj->db->cachedir.$filepath)))
+ if (FALSE === ($cachedata = read_file($this->CI->db->cachedir.$filepath)))
{
return FALSE;
}
@@ -122,13 +122,13 @@ class CI_DB_Cache {
{
if ( ! $this->check_path())
{
- return $this->obj->db->cache_off();
+ return $this->CI->db->cache_off();
}
- $uri = ($this->obj->uri->segment(1) == FALSE) ? 'default.' : $this->obj->uri->segment(1).'.';
- $uri .= ($this->obj->uri->segment(2) == FALSE) ? 'index' : $this->obj->uri->segment(2);
+ $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'.';
+ $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
- $dir_path = $this->obj->db->cachedir.$uri.'/';
+ $dir_path = $this->CI->db->cachedir.$uri.'/';
$filename = md5($sql);
@@ -163,15 +163,15 @@ class CI_DB_Cache {
{
if ($segment_one == '')
{
- $segment_one = ($this->obj->uri->segment(1) == FALSE) ? 'default' : $this->obj->uri->segment(2);
+ $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(2);
}
if ($segment_two == '')
{
- $segment_two = ($this->obj->uri->segment(2) == FALSE) ? 'index' : $this->obj->uri->segment(2);
+ $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
}
- $dir_path = $this->obj->db->cachedir.md5($segment_one.'.'.$segment_two).'/';
+ $dir_path = $this->CI->db->cachedir.md5($segment_one.'.'.$segment_two).'/';
delete_files($dir_path, TRUE);
}
@@ -186,7 +186,7 @@ class CI_DB_Cache {
*/
function delete_all()
{
- delete_files($this->obj->db->cachedir, TRUE);
+ delete_files($this->CI->db->cachedir, TRUE);
}
}
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 8cf151703..3cbbbfe6d 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -28,8 +28,8 @@
*/
class CI_Calendar {
+ var $CI;
var $lang;
- var $obj;
var $local_time;
var $template = '';
var $start_day = 'sunday';
@@ -47,10 +47,10 @@ class CI_Calendar {
*/
function CI_Calendar()
{
- $this->obj =& get_instance();
- if ( ! in_array('calendar_lang'.EXT, $this->obj->lang->is_loaded, TRUE))
+ $this->CI =& get_instance();
+ if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
{
- $this->obj->lang->load('calendar');
+ $this->CI->lang->load('calendar');
}
$this->local_time = time();
@@ -268,12 +268,12 @@ class CI_Calendar {
$month = $month_names[$month];
- if ($this->obj->lang->line($month) === FALSE)
+ if ($this->CI->lang->line($month) === FALSE)
{
return ucfirst(str_replace('cal_', '', $month));
}
- return $this->obj->lang->line($month);
+ return $this->CI->lang->line($month);
}
// END get_month_name()
@@ -310,7 +310,7 @@ class CI_Calendar {
$days = array();
foreach ($day_names as $val)
{
- $days[] = ($this->obj->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->obj->lang->line('cal_'.$val);
+ $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
}
return $days;
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 88b49a9e6..58bec841e 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -40,9 +40,7 @@ class Controller extends CI_Base {
function Controller()
{
parent::CI_Base();
-
$this->_ci_initialize();
-
log_message('debug', "Controller Class Initialized");
}
@@ -62,22 +60,28 @@ class Controller extends CI_Base {
// Assign all the class objects that were instantiated by the
// front controller to local class variables so that CI can be
// run as one big super object.
- foreach (array('Config', 'Input', 'Benchmark', 'URI', 'Output') as $val)
+ $classes = array(
+ 'config' => 'Config',
+ 'input' => 'Input',
+ 'benchmark' => 'Benchmark',
+ 'uri' => 'URI',
+ 'output' => 'Output',
+ 'lang' => 'Language'
+ );
+
+ foreach ($classes as $var => $class)
{
- $class = strtolower($val);
- $this->$class =& _load_class($val);
+ $this->$var =& _load_class($class);
}
- $this->lang =& _load_class('Language');
-
- // In PHP 4 the Controller class is a child of CI_Loader.
- // In PHP 5 we run it as its own class.
+
+ // In PHP 5 the Controller class is run as a discreet
+ // class. In PHP 4 it extends the Controller
if (floor(phpversion()) >= 5)
{
$this->load = new CI_Loader();
}
-
// Load everything specified in the autoload.php file
$this->load->_ci_autoloader();
@@ -92,6 +96,28 @@ class Controller extends CI_Base {
}
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Run Scaffolding
+ *
+ * @access private
+ * @return voikd
+ */
+ function _ci_scaffolding()
+ {
+ if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
+ {
+ show_404('Scaffolding unavailable');
+ }
+
+ $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
+
+ require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
+ $scaff = new Scaffolding($this->_ci_scaff_table);
+ $scaff->$method();
+ }
+
}
// END _Controller class
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index f823d95e8..90dc0f140 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -31,12 +31,11 @@ class CI_Loader {
var $CI;
var $ob_level;
var $cached_vars = array();
+ var $models = array();
var $helpers = array();
var $plugins = array();
var $scripts = array();
- var $languages = array();
var $view_path = '';
- var $models = array();
/**
* Constructor
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 6142267bb..d91f23193 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -32,12 +32,12 @@
*/
class CI_Profiler {
- var $obj;
+ var $CI;
function CI_Profiler()
{
- $this->obj =& get_instance();
- $this->obj->load->language('profiler');
+ $this->CI =& get_instance();
+ $this->CI->load->language('profiler');
}
// --------------------------------------------------------------------
@@ -56,15 +56,15 @@ class CI_Profiler {
function _compile_benchmarks()
{
$profile = array();
- foreach ($this->obj->benchmark->marker as $key => $val)
+ foreach ($this->CI->benchmark->marker as $key => $val)
{
// We match the "end" marker so that the list ends
// up in the order that it was defined
if (preg_match("/(.+?)_end/i", $key, $match))
{
- if (isset($this->obj->benchmark->marker[$match[1].'_end']) AND isset($this->obj->benchmark->marker[$match[1].'_start']))
+ if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start']))
{
- $profile[$match[1]] = $this->obj->benchmark->elapsed_time($match[1].'_start', $key);
+ $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
}
}
}
@@ -76,7 +76,7 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset style="border:1px solid #990000;padding:6px 10px 10px 10px;margin:0 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#990000;">&nbsp;&nbsp;'.$this->obj->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#990000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
$output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
@@ -100,22 +100,22 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->obj->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
$output .= "\n";
if ( ! class_exists('CI_DB_driver'))
{
- $output .= "<div style='color:#0000FF;font-weight:normal;padding:4px 0 0 0;'>".$this->obj->lang->line('profiler_no_db')."</div>";
+ $output .= "<div style='color:#0000FF;font-weight:normal;padding:4px 0 0 0;'>".$this->CI->lang->line('profiler_no_db')."</div>";
}
else
{
- if (count($this->obj->db->queries) == 0)
+ if (count($this->CI->db->queries) == 0)
{
- $output .= "<div style='color:#0000FF;font-weight:normal;padding:4px 0 4px 0;'>".$this->obj->lang->line('profiler_no_queries')."</div>";
+ $output .= "<div style='color:#0000FF;font-weight:normal;padding:4px 0 4px 0;'>".$this->CI->lang->line('profiler_no_queries')."</div>";
}
else
{
- foreach ($this->obj->db->queries as $val)
+ foreach ($this->CI->db->queries as $val)
{
$output .= '<div style="padding:3px;margin:12px 0 12px 0;background-color:#ddd;color:#000">';
$output .= $val;
@@ -136,12 +136,12 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
- $output .= '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->obj->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
+ $output .= '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
$output .= "\n";
if (count($_POST) == 0)
{
- $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->obj->lang->line('profiler_no_post')."</div>";
+ $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>";
}
else
{
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 28e469da7..16f373fd0 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -26,6 +26,7 @@
*/
class CI_Session {
+ var $CI;
var $now;
var $encryption = TRUE;
var $use_database = FALSE;
@@ -34,7 +35,7 @@ class CI_Session {
var $sess_cookie = 'ci_session';
var $userdata = array();
var $gc_probability = 5;
- var $object;
+
/**
@@ -45,7 +46,7 @@ class CI_Session {
*/
function CI_Session()
{
- $this->object =& get_instance();
+ $this->CI =& get_instance();
log_message('debug', "Session Class Initialized");
$this->sess_run();
@@ -73,7 +74,7 @@ class CI_Session {
* "last_visit" times based on each user's locale.
*
*/
- if (strtolower($this->object->config->item('time_reference')) == 'gmt')
+ if (strtolower($this->CI->config->item('time_reference')) == 'gmt')
{
$now = time();
$this->now = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
@@ -97,13 +98,13 @@ class CI_Session {
* two years from now.
*
*/
- $expiration = $this->object->config->item('sess_expiration');
+ $expiration = $this->CI->config->item('sess_expiration');
if (is_numeric($expiration))
{
if ($expiration > 0)
{
- $this->sess_length = $this->object->config->item('sess_expiration');
+ $this->sess_length = $this->CI->config->item('sess_expiration');
}
else
{
@@ -112,25 +113,25 @@ class CI_Session {
}
// Do we need encryption?
- $this->encryption = $this->object->config->item('sess_encrypt_cookie');
+ $this->encryption = $this->CI->config->item('sess_encrypt_cookie');
if ($this->encryption == TRUE)
{
- $this->object->load->library('encrypt');
+ $this->CI->load->library('encrypt');
}
// Are we using a database?
- if ($this->object->config->item('sess_use_database') === TRUE AND $this->object->config->item('sess_table_name') != '')
+ if ($this->CI->config->item('sess_use_database') === TRUE AND $this->CI->config->item('sess_table_name') != '')
{
$this->use_database = TRUE;
- $this->session_table = $this->object->config->item('sess_table_name');
- $this->object->load->database();
+ $this->session_table = $this->CI->config->item('sess_table_name');
+ $this->CI->load->database();
}
// Set the cookie name
- if ($this->object->config->item('sess_cookie_name') != FALSE)
+ if ($this->CI->config->item('sess_cookie_name') != FALSE)
{
- $this->sess_cookie = $this->object->config->item('cookie_prefix').$this->object->config->item('sess_cookie_name');
+ $this->sess_cookie = $this->CI->config->item('cookie_prefix').$this->CI->config->item('sess_cookie_name');
}
/*
@@ -172,7 +173,7 @@ class CI_Session {
function sess_read()
{
// Fetch the cookie
- $session = $this->object->input->cookie($this->sess_cookie);
+ $session = $this->CI->input->cookie($this->sess_cookie);
if ($session === FALSE)
{
@@ -183,7 +184,7 @@ class CI_Session {
// Decrypt and unserialize the data
if ($this->encryption == TRUE)
{
- $session = $this->object->encrypt->decode($session);
+ $session = $this->CI->encrypt->decode($session);
}
$session = @unserialize($this->strip_slashes($session));
@@ -202,14 +203,14 @@ class CI_Session {
}
// Does the IP Match?
- if ($this->object->config->item('sess_match_ip') == TRUE AND $session['ip_address'] != $this->object->input->ip_address())
+ if ($this->CI->config->item('sess_match_ip') == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
{
$this->sess_destroy();
return FALSE;
}
// Does the User Agent Match?
- if ($this->object->config->item('sess_match_useragent') == TRUE AND $session['user_agent'] != substr($this->object->input->user_agent(), 0, 50))
+ if ($this->CI->config->item('sess_match_useragent') == TRUE AND $session['user_agent'] != substr($this->CI->input->user_agent(), 0, 50))
{
$this->sess_destroy();
return FALSE;
@@ -218,19 +219,19 @@ class CI_Session {
// Is there a corresponding session in the DB?
if ($this->use_database === TRUE)
{
- $this->object->db->where('session_id', $session['session_id']);
+ $this->CI->db->where('session_id', $session['session_id']);
- if ($this->object->config->item('sess_match_ip') == TRUE)
+ if ($this->CI->config->item('sess_match_ip') == TRUE)
{
- $this->object->db->where('ip_address', $session['ip_address']);
+ $this->CI->db->where('ip_address', $session['ip_address']);
}
- if ($this->object->config->item('sess_match_useragent') == TRUE)
+ if ($this->CI->config->item('sess_match_useragent') == TRUE)
{
- $this->object->db->where('user_agent', $session['user_agent']);
+ $this->CI->db->where('user_agent', $session['user_agent']);
}
- $query = $this->object->db->get($this->session_table);
+ $query = $this->CI->db->get($this->session_table);
if ($query->num_rows() == 0)
{
@@ -242,8 +243,8 @@ class CI_Session {
$row = $query->row();
if (($row->last_activity + $this->sess_length) < $this->now)
{
- $this->object->db->where('session_id', $session['session_id']);
- $this->object->db->delete($this->session_table);
+ $this->CI->db->where('session_id', $session['session_id']);
+ $this->CI->db->delete($this->session_table);
$this->sess_destroy();
return FALSE;
}
@@ -272,15 +273,15 @@ class CI_Session {
if ($this->encryption == TRUE)
{
- $cookie_data = $this->object->encrypt->encode($cookie_data);
+ $cookie_data = $this->CI->encrypt->encode($cookie_data);
}
setcookie(
$this->sess_cookie,
$cookie_data,
$this->sess_length + $this->now,
- $this->object->config->item('cookie_path'),
- $this->object->config->item('cookie_domain'),
+ $this->CI->config->item('cookie_path'),
+ $this->CI->config->item('cookie_domain'),
0
);
}
@@ -304,8 +305,8 @@ class CI_Session {
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
- 'ip_address' => $this->object->input->ip_address(),
- 'user_agent' => substr($this->object->input->user_agent(), 0, 50),
+ 'ip_address' => $this->CI->input->ip_address(),
+ 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
'last_activity' => $this->now
);
@@ -313,7 +314,7 @@ class CI_Session {
// Save the session in the DB if needed
if ($this->use_database === TRUE)
{
- $this->object->db->query($this->object->db->insert_string($this->session_table, $this->userdata));
+ $this->CI->db->query($this->CI->db->insert_string($this->session_table, $this->userdata));
}
// Write the cookie
@@ -342,7 +343,7 @@ class CI_Session {
// Update the session in the DB if needed
if ($this->use_database === TRUE)
{
- $this->object->db->query($this->object->db->update_string($this->session_table, array('last_activity' => $this->now), array('session_id' => $this->userdata['session_id'])));
+ $this->CI->db->query($this->CI->db->update_string($this->session_table, array('last_activity' => $this->now), array('session_id' => $this->userdata['session_id'])));
}
// Write the cookie
@@ -364,8 +365,8 @@ class CI_Session {
$this->sess_cookie,
addslashes(serialize(array())),
($this->now - 31500000),
- $this->object->config->item('cookie_path'),
- $this->object->config->item('cookie_domain'),
+ $this->CI->config->item('cookie_path'),
+ $this->CI->config->item('cookie_domain'),
0
);
}
@@ -389,8 +390,8 @@ class CI_Session {
{
$expire = $this->now - $this->sess_length;
- $this->object->db->where("last_activity < {$expire}");
- $this->object->db->delete($this->session_table);
+ $this->CI->db->where("last_activity < {$expire}");
+ $this->CI->db->delete($this->session_table);
log_message('debug', 'Session garbage collection performed.');
}
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index ff5970837..5322be0e9 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -26,6 +26,7 @@
*/
class CI_Validation {
+ var $CI;
var $error_string = '';
var $_error_array = array();
var $_rules = array();
@@ -35,7 +36,7 @@ class CI_Validation {
var $_safe_form_data = FALSE;
var $_error_prefix = '<p>';
var $_error_suffix = '</p>';
- var $obj;
+
/**
@@ -44,7 +45,7 @@ class CI_Validation {
*/
function CI_Validation()
{
- $this->obj =& get_instance();
+ $this->CI =& get_instance();
log_message('debug', "Validation Class Initialized");
}
@@ -185,7 +186,7 @@ class CI_Validation {
}
// Load the language file containing error messages
- $this->obj->lang->load('validation');
+ $this->CI->lang->load('validation');
// Cycle through the rules and test for errors
foreach ($this->_rules as $field => $rules)
@@ -217,7 +218,7 @@ class CI_Validation {
{
if ( ! isset($this->_error_messages['isset']))
{
- if (FALSE === ($line = $this->obj->lang->line('isset')))
+ if (FALSE === ($line = $this->CI->lang->line('isset')))
{
$line = 'The field was not set';
}
@@ -267,12 +268,12 @@ class CI_Validation {
// Call the function that corresponds to the rule
if ($callback === TRUE)
{
- if ( ! method_exists($this->obj, $rule))
+ if ( ! method_exists($this->CI, $rule))
{
continue;
}
- $result = $this->obj->$rule($_POST[$field], $param);
+ $result = $this->CI->$rule($_POST[$field], $param);
// If the field isn't required and we just processed a callback we'll move on...
if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE)
@@ -309,7 +310,7 @@ class CI_Validation {
{
if ( ! isset($this->_error_messages[$rule]))
{
- if (FALSE === ($line = $this->obj->lang->line($rule)))
+ if (FALSE === ($line = $this->CI->lang->line($rule)))
{
$line = 'Unable to access an error message corresponding to your field name.';
}
@@ -698,7 +699,7 @@ class CI_Validation {
*/
function xss_clean($str)
{
- $_POST[$this->_current_field] = $this->obj->input->xss_clean($str);
+ $_POST[$this->_current_field] = $this->CI->input->xss_clean($str);
}
// --------------------------------------------------------------------
diff --git a/system/scaffolding/Scaffolding.php b/system/scaffolding/Scaffolding.php
index 9059ec15a..c046d228f 100644
--- a/system/scaffolding/Scaffolding.php
+++ b/system/scaffolding/Scaffolding.php
@@ -27,25 +27,25 @@
*/
class Scaffolding {
+ var $CI;
var $current_table;
var $base_url = '';
var $lang = array();
function Scaffolding($db_table)
{
- $obj =& get_instance();
- foreach (get_object_vars($obj) as $key => $var)
- {
- if (is_object($var))
- {
- $this->$key =& $obj->$key;
- }
- }
+ $this->CI =& get_instance();
+
+ $this->CI->load->database("", FALSE, TRUE);
+ $this->CI->load->library('pagination');
+
+ // Turn off caching
+ $this->CI->db->cache_off();
/**
* Set the current table name
* This is done when initializing scaffolding:
- * $this->_ci_init_scaffolding('table_name')
+ * $this->load->scaffolding('table_name')
*
*/
$this->current_table = $db_table;
@@ -55,28 +55,29 @@ class Scaffolding {
* We'll manually override the "view" path so that
* the load->view function knows where to look.
*/
- $this->load->_ci_set_view_path(BASEPATH.'scaffolding/views/');
+
+ $this->CI->load->view_path = BASEPATH.'scaffolding/views/';
// Set the base URL
- $this->base_url = $this->config->site_url().'/'.$this->uri->segment(1).$this->uri->slash_segment(2, 'both');
- $this->base_uri = $this->uri->segment(1).$this->uri->slash_segment(2, 'leading');
+ $this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');
+ $this->base_uri = $this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'leading');
// Set a few globals
$data = array(
- 'image_url' => $this->config->system_url().'scaffolding/images/',
+ 'image_url' => $this->CI->config->system_url().'scaffolding/images/',
'base_uri' => $this->base_uri,
'base_url' => $this->base_url,
'title' => $this->current_table
);
- $this->load->vars($data);
+ $this->CI->load->vars($data);
// Load the language file and create variables
- $this->lang = $this->load->language('scaffolding', '', TRUE);
- $this->load->vars($this->lang);
+ $this->lang = $this->CI->load->language('scaffolding', '', TRUE);
+ $this->CI->load->vars($this->lang);
// Load the helper files we plan to use
- $this->load->helper(array('url', 'form'));
+ $this->CI->load->helper(array('url', 'form'));
log_message('debug', 'Scaffolding Class Initialized');
@@ -97,11 +98,11 @@ class Scaffolding {
{
$data = array(
'title' => ( ! isset($this->lang['scaff_add'])) ? 'Add Data' : $this->lang['scaff_add'],
- 'fields' => $this->db->field_data($this->current_table),
+ 'fields' => $this->CI->db->field_data($this->current_table),
'action' => $this->base_uri.'/insert'
);
- $this->load->view('add', $data);
+ $this->CI->load->view('add', $data);
}
// --------------------------------------------------------------------
@@ -114,7 +115,7 @@ class Scaffolding {
*/
function insert()
{
- if ($this->db->insert($this->current_table, $_POST) === FALSE)
+ if ($this->CI->db->insert($this->current_table, $_POST) === FALSE)
{
$this->add();
}
@@ -138,28 +139,28 @@ class Scaffolding {
function view()
{
// Fetch the total number of DB rows
- $total_rows = $this->db->count_all($this->current_table);
+ $total_rows = $this->CI->db->count_all($this->current_table);
if ($total_rows < 1)
{
- return $this->load->view('no_data');
+ return $this->CI->load->view('no_data');
}
// Set the query limit/offset
$per_page = 20;
- $offset = $this->uri->segment(4, 0);
+ $offset = $this->CI->uri->segment(4, 0);
// Run the query
- $query = $this->db->get($this->current_table, $per_page, $offset);
+ $query = $this->CI->db->get($this->current_table, $per_page, $offset);
// Now let's get the field names
- $fields = $this->db->field_names($this->current_table);
+ $fields = $this->CI->db->field_names($this->current_table);
// We assume that the column in the first position is the primary field.
$primary = current($fields);
// Pagination!
- $this->pagination->initialize(
+ $this->CI->pagination->initialize(
array(
'base_url' => $this->base_url.'/view',
'total_rows' => $total_rows,
@@ -175,10 +176,10 @@ class Scaffolding {
'query' => $query,
'fields' => $fields,
'primary' => $primary,
- 'paginate' => $this->pagination->create_links()
+ 'paginate' => $this->CI->pagination->create_links()
);
- $this->load->view('view', $data);
+ $this->CI->load->view('view', $data);
}
// --------------------------------------------------------------------
@@ -194,25 +195,25 @@ class Scaffolding {
*/
function edit()
{
- if (FALSE === ($id = $this->uri->segment(4)))
+ if (FALSE === ($id = $this->CI->uri->segment(4)))
{
return $this->view();
}
// Fetch the primary field name
- $primary = $this->db->primary($this->current_table);
+ $primary = $this->CI->db->primary($this->current_table);
// Run the query
- $query = $this->db->getwhere($this->current_table, array($primary => $id));
+ $query = $this->CI->db->getwhere($this->current_table, array($primary => $id));
$data = array(
'title' => ( ! isset($this->lang['scaff_edit'])) ? 'Edit Data' : $this->lang['scaff_edit'],
'fields' => $query->field_data(),
'query' => $query->row(),
- 'action' => $this->base_uri.'/update/'.$this->uri->segment(4)
+ 'action' => $this->base_uri.'/update/'.$this->CI->uri->segment(4)
);
- $this->load->view('edit', $data);
+ $this->CI->load->view('edit', $data);
}
// --------------------------------------------------------------------
@@ -226,10 +227,10 @@ class Scaffolding {
function update()
{
// Fetch the primary key
- $primary = $this->db->primary($this->current_table);
+ $primary = $this->CI->db->primary($this->current_table);
// Now do the query
- $this->db->update($this->current_table, $_POST, array($primary => $this->uri->segment(4)));
+ $this->CI->db->update($this->current_table, $_POST, array($primary => $this->CI->uri->segment(4)));
redirect($this->base_uri.'/view/');
}
@@ -246,21 +247,21 @@ class Scaffolding {
{
if ( ! isset($this->lang['scaff_del_confirm']))
{
- $message = 'Are you sure you want to delete the following row: '.$this->uri->segment(4);
+ $message = 'Are you sure you want to delete the following row: '.$this->CI->uri->segment(4);
}
else
{
- $message = $this->lang['scaff_del_confirm'].' '.$this->uri->segment(4);
+ $message = $this->lang['scaff_del_confirm'].' '.$this->CI->uri->segment(4);
}
$data = array(
'title' => ( ! isset($this->lang['scaff_delete'])) ? 'Delete Data' : $this->lang['scaff_delete'],
'message' => $message,
'no' => anchor(array($this->base_uri, 'view'), ( ! isset($this->lang['scaff_no'])) ? 'No' : $this->lang['scaff_no']),
- 'yes' => anchor(array($this->base_uri, 'do_delete', $this->uri->segment(4)), ( ! isset($this->lang['scaff_yes'])) ? 'Yes' : $this->lang['scaff_yes'])
+ 'yes' => anchor(array($this->base_uri, 'do_delete', $this->CI->uri->segment(4)), ( ! isset($this->lang['scaff_yes'])) ? 'Yes' : $this->lang['scaff_yes'])
);
- $this->load->view('delete', $data);
+ $this->CI->load->view('delete', $data);
}
// --------------------------------------------------------------------
@@ -274,11 +275,11 @@ class Scaffolding {
function do_delete()
{
// Fetch the primary key
- $primary = $this->db->primary($this->current_table);
+ $primary = $this->CI->db->primary($this->current_table);
// Now do the query
- $this->db->where($primary, $this->uri->segment(4));
- $this->db->delete($this->current_table);
+ $this->CI->db->where($primary, $this->CI->uri->segment(4));
+ $this->CI->db->delete($this->current_table);
header("Refresh:0;url=".site_url(array($this->base_uri, 'view')));
exit;