summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-07 05:07:29 +0200
committeradmin <devnull@localhost>2006-10-07 05:07:29 +0200
commitb3ab70bfdce29b570c853ae53e370e54ca39da93 (patch)
treeeb0e40f152d6bd2ad6898d5d367f6aa66972996f /system/libraries
parent8f0a8f693307a6d04b8a50aa11f81041c961adf6 (diff)
Diffstat (limited to 'system/libraries')
-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
6 files changed, 103 insertions, 76 deletions
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);
}
// --------------------------------------------------------------------