From 88a8ad187b13b36d6120eae2344fe16c3a76219d Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 7 Oct 2006 03:16:32 +0000 Subject: --- system/database/DB.php | 7 +++---- system/database/DB_driver.php | 8 ++++---- system/database/DB_utility.php | 21 ++++++++++----------- system/libraries/Controller.php | 2 +- system/libraries/Email.php | 6 +++--- system/libraries/Encrypt.php | 4 ++-- system/libraries/Image_lib.php | 8 ++++---- system/libraries/Language.php | 4 ++-- system/libraries/Model.php | 8 ++++---- system/libraries/Output.php | 24 ++++++++++++------------ system/libraries/Pagination.php | 6 +++--- system/libraries/Parser.php | 6 +++--- system/libraries/Profiler.php | 4 +--- system/libraries/Unit.php | 12 ++++++------ system/libraries/Upload.php | 12 ++++++------ system/libraries/Xmlrpc.php | 12 ++++++------ system/libraries/Xmlrpcs.php | 4 ++-- user_guide/general/ancillary_classes.html | 12 ++++++------ user_guide/general/creating_libraries.html | 12 ++++++------ 19 files changed, 84 insertions(+), 88 deletions(-) diff --git a/system/database/DB.php b/system/database/DB.php index f7476a68e..62237440f 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -24,8 +24,6 @@ */ function DB($params = '', $return = FALSE, $active_record = FALSE) { - $obj =& get_instance(); - // Do we even need to load the database class? if (class_exists('CI_DB') AND $return == FALSE AND $active_record == FALSE) { @@ -92,8 +90,9 @@ function DB($params = '', $return = FALSE, $active_record = FALSE) { return $DB; } - - $obj->db =& $DB; + + $CI =& get_instance(); + $CI->db =& $DB; } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b89ebbf8d..c8a00b7b1 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -165,13 +165,13 @@ class CI_DB_driver { * @return string */ function load_utilities() - { - $obj =& get_instance(); - + { require_once(BASEPATH.'database/DB_utility'.EXT); require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_utility'.EXT); $class = 'CI_DB_'.$this->dbdriver.'_utility'; - $obj->dbutil = new $class(); + + $CI =& get_instance(); + $CI->dbutil = new $class(); } // -------------------------------------------------------------------- diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 433056ff0..64d67db41 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -36,8 +36,8 @@ class CI_DB_utility { function CI_DB_utility() { // Assign the main database object to $this->db - $obj =& get_instance(); - $this->db =& $obj->db; + $CI =& get_instance(); + $this->CI =& $obj->db; log_message('debug', "Database Utility Class Initialized"); } @@ -286,8 +286,8 @@ class CI_DB_utility { extract($params); // Load the xml helper - $obj =& get_instance(); - $obj->load->helper('xml'); + $CI =& get_instance(); + $CI->load->helper('xml'); // Generate the result $xml = "<{$root}/>".$newline; @@ -391,10 +391,7 @@ class CI_DB_utility { } // ------------------------------------------------------ - - // Grab the super object - $obj =& get_instance(); - + // Was a Gzip file requested? if ($prefs['format'] == 'gzip') { @@ -427,9 +424,11 @@ class CI_DB_utility { } // Load the Zip class and output it - $obj->load->library('zip'); - $obj->zip->add_data($prefs['filename'], $this->_backup($prefs)); - return $obj->zip->get_zip(); + + $CI =& get_instance(); + $CI->load->library('zip'); + $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); + return $CI->zip->get_zip(); } } diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php index 58bec841e..4b9e3e960 100644 --- a/system/libraries/Controller.php +++ b/system/libraries/Controller.php @@ -102,7 +102,7 @@ class Controller extends CI_Base { * Run Scaffolding * * @access private - * @return voikd + * @return void */ function _ci_scaffolding() { diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 99de17414..23f7fe456 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1629,10 +1629,10 @@ class CI_Email { */ function _set_error_message($msg, $val = '') { - $obj =& get_instance(); - $obj->lang->load('email'); + $CI =& get_instance(); + $CI->lang->load('email'); - if (FALSE === ($line = $obj->lang->line($msg))) + if (FALSE === ($line = $CI->lang->line($msg))) { $this->_debug_msg[] = str_replace('%s', $val, $msg)."
"; } diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 537b1ab20..2a1de6f37 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -66,8 +66,8 @@ class CI_Encrypt { return $this->encryption_key; } - $obj =& get_instance(); - $key = $obj->config->item('encryption_key'); + $CI =& get_instance(); + $key = $CI->config->item('encryption_key'); if ($key === FALSE) { diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index ca1d7478b..79b2f9c1c 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1503,22 +1503,22 @@ class CI_Image_lib { */ function set_error($msg) { - $obj =& get_instance(); - $obj->lang->load('imglib'); + $CI =& get_instance(); + $CI->lang->load('imglib'); if (is_array($msg)) { foreach ($msg as $val) { - $msg = ($obj->lang->line($val) == FALSE) ? $val : $obj->lang->line($val); + $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); } } else { - $msg = ($obj->lang->line($msg) == FALSE) ? $msg : $obj->lang->line($msg); + $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message('error', $msg); } diff --git a/system/libraries/Language.php b/system/libraries/Language.php index dabfd4145..00e2fb7e8 100644 --- a/system/libraries/Language.php +++ b/system/libraries/Language.php @@ -61,8 +61,8 @@ class CI_Language { if ($idiom == '') { - $obj =& get_instance(); - $deft_lang = $obj->config->item('language'); + $CI =& get_instance(); + $deft_lang = $CI->config->item('language'); $idiom = ($deft_lang == '') ? 'english' : $deft_lang; } diff --git a/system/libraries/Model.php b/system/libraries/Model.php index 55c995636..46f0367cb 100644 --- a/system/libraries/Model.php +++ b/system/libraries/Model.php @@ -49,18 +49,18 @@ class Model { */ function _assign_libraries($use_reference = TRUE) { - $obj =& get_instance(); - foreach (get_object_vars($obj) as $key => $var) + $CI =& get_instance(); + foreach (get_object_vars($CI) as $key => $var) { if (is_object($var) AND ! isset($this->$key)) { if ($use_reference === TRUE) { - $this->$key =& $obj->$key; + $this->$key =& $CI->$key; } else { - $this->$key = $obj->$key; + $this->$key = $CI->$key; } } } diff --git a/system/libraries/Output.php b/system/libraries/Output.php index 4ab5dd23c..507beab59 100644 --- a/system/libraries/Output.php +++ b/system/libraries/Output.php @@ -135,7 +135,7 @@ class CI_Output { */ function _display($output = '') { - // Note: We use globals because we can't use $obj =& get_instance() + // Note: We use globals because we can't use $CI =& get_instance() // since this function is sometimes called by the caching mechanism, // which happens before the CI super object is available. global $BM, $CFG; @@ -207,25 +207,25 @@ class CI_Output { // -------------------------------------------------------------------- // Grab the super object. We'll need it in a moment... - $obj =& get_instance(); + $CI =& get_instance(); // Do we need to generate profile data? // If so, load the Profile class and run it. if ($this->enable_profiler == TRUE) { - $obj->load->library('profiler'); + $CI->load->library('profiler'); // If the output data contains closing and tags // we will remove them and add them back after we insert the profile data if (preg_match("|.*?|is", $output)) { $output = preg_replace("|.*?|is", '', $output); - $output .= $obj->profiler->run(); + $output .= $CI->profiler->run(); $output .= ''; } else { - $output .= $obj->profiler->run(); + $output .= $CI->profiler->run(); } } @@ -233,9 +233,9 @@ class CI_Output { // Does the controller contain a function named _output()? // If so send the output there. Otherwise, echo it. - if (method_exists($obj, '_output')) + if (method_exists($CI, '_output')) { - $obj->_output($output); + $CI->_output($output); } else { @@ -256,8 +256,8 @@ class CI_Output { */ function _write_cache($output) { - $obj =& get_instance(); - $path = $obj->config->item('cache_path'); + $CI =& get_instance(); + $path = $CI->config->item('cache_path'); $cache_path = ($path == '') ? BASEPATH.'cache/' : $path; @@ -266,9 +266,9 @@ class CI_Output { return; } - $uri = $obj->config->item('base_url'). - $obj->config->item('index_page'). - $obj->uri->uri_string(); + $uri = $CI->config->item('base_url'). + $CI->config->item('index_page'). + $CI->uri->uri_string(); $cache_path .= md5($uri); diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 867d214fc..efbe6c27f 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -122,10 +122,10 @@ class CI_Pagination { } // Determine the current page number. - $obj =& get_instance(); - if ($obj->uri->segment($this->uri_segment) != 0) + $CI =& get_instance(); + if ($CI->uri->segment($this->uri_segment) != 0) { - $this->cur_page = $obj->uri->segment($this->uri_segment); + $this->cur_page = $CI->uri->segment($this->uri_segment); } if ( ! is_numeric($this->cur_page)) diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 42e78b0ee..a0c9dab9e 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -44,8 +44,8 @@ class CI_Parser { */ function parse($template, $data, $return = FALSE) { - $obj =& get_instance(); - $template = $obj->load->view($template, $data, TRUE); + $CI =& get_instance(); + $template = $CI->load->view($template, $data, TRUE); if ($template == '') { @@ -66,7 +66,7 @@ class CI_Parser { if ($return == FALSE) { - $obj->output->final_output = $template; + $CI->output->final_output = $template; } return $template; diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index d91f23193..3370c9113 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -173,9 +173,7 @@ class CI_Profiler { * @return string */ function run($output = '') - { - $obj =& get_instance(); - + { $output = '
'; $output .= "
"; diff --git a/system/libraries/Unit.php b/system/libraries/Unit.php index 0df78c253..6573f4269 100644 --- a/system/libraries/Unit.php +++ b/system/libraries/Unit.php @@ -171,8 +171,8 @@ class CI_Unit { */ function result($results = array()) { - $obj =& get_instance(); - $obj->load->language('unit_test'); + $CI =& get_instance(); + $CI->load->language('unit_test'); if (count($results) == 0) { @@ -189,20 +189,20 @@ class CI_Unit { { foreach ($val as $k => $v) { - if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$v)))) + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v)))) { $v = $line; } - $temp[$obj->lang->line('ut_'.$k)] = $v; + $temp[$CI->lang->line('ut_'.$k)] = $v; } } else { - if (FALSE !== ($line = $obj->lang->line(strtolower('ut_'.$val)))) + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) { $val = $line; } - $temp[$obj->lang->line('ut_'.$key)] = $val; + $temp[$CI->lang->line('ut_'.$key)] = $val; } } diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 37fccdfd8..13fa8acdf 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -684,8 +684,8 @@ class CI_Upload { $data = fread($fp, filesize($file)); - $obj =& get_instance(); - $data = $obj->input->xss_clean($data); + $CI =& get_instance(); + $data = $CI->input->xss_clean($data); fwrite($fp, $data); flock($fp, LOCK_UN); @@ -703,21 +703,21 @@ class CI_Upload { */ function set_error($msg) { - $obj =& get_instance(); - $obj->lang->load('upload'); + $CI =& get_instance(); + $CI->lang->load('upload'); if (is_array($msg)) { foreach ($msg as $val) { - $msg = ($obj->lang->line($val) == FALSE) ? $val : $obj->lang->line($val); + $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); } } else { - $msg = ($obj->lang->line($msg) == FALSE) ? $msg : $obj->lang->line($msg); + $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message('error', $msg); } diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 4cb16f74e..0a3dedae1 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -493,7 +493,7 @@ class XML_RPC_Response function decode($array=FALSE) { - $obj =& get_instance(); + $CI =& get_instance(); if ($array !== FALSE && is_array($array)) { @@ -505,7 +505,7 @@ class XML_RPC_Response } else { - $array[$key] = $obj->input->xss_clean($array[$key]); + $array[$key] = $CI->input->xss_clean($array[$key]); } } @@ -521,7 +521,7 @@ class XML_RPC_Response } else { - $result = $obj->input->xss_clean($result); + $result = $CI->input->xss_clean($result); } } @@ -1107,7 +1107,7 @@ class XML_RPC_Message extends CI_Xmlrpc function output_parameters($array=FALSE) { - $obj =& get_instance(); + $CI =& get_instance(); if ($array !== FALSE && is_array($array)) { @@ -1119,7 +1119,7 @@ class XML_RPC_Message extends CI_Xmlrpc } else { - $array[$key] = $obj->input->xss_clean($array[$key]); + $array[$key] = $CI->input->xss_clean($array[$key]); } } @@ -1139,7 +1139,7 @@ class XML_RPC_Message extends CI_Xmlrpc } else { - $parameters[] = $obj->input->xss_clean($a_param); + $parameters[] = $CI->input->xss_clean($a_param); } } } diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index b47104857..e4d3cffde 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -318,8 +318,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc } else { - $obj =& get_instance(); - return $obj->$method_parts['1']($m); + $CI =& get_instance(); + return $CI->$method_parts['1']($m); //$class = new $method_parts['0']; //return $class->$method_parts['1']($m); //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html index 86e210f3f..f7c4a8697 100644 --- a/user_guide/general/ancillary_classes.html +++ b/user_guide/general/ancillary_classes.html @@ -86,21 +86,21 @@ If you would like to use Code Igniter's classes from within your own custom clas

First, assign the Code Igniter object to a variable:

-$obj =& get_instance(); +$CI =& get_instance();

Once you've assigned the object to a variable, you'll use that variable instead of $this:

-$obj =& get_instance();

-$obj->load->helper('url');
-$obj->load->library('session');
-$obj->config->item('base_url');
+$CI =& get_instance();

+$CI->load->helper('url');
+$CI->load->library('session');
+$CI->config->item('base_url');
etc.

Note: You'll notice that the above get_instance() function is being passed by reference:

-$obj =& get_instance(); +$CI =& get_instance();

This is very important. Assigning by reference allows you to use the original Code Igniter object rather than creating a copy of it.

diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index e2a57f02a..b73bfb888 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -184,21 +184,21 @@ If you would like to use Code Igniter's classes from within your own custom clas

First, assign the Code Igniter object to a variable:

-$obj =& get_instance(); +$CI =& get_instance();

Once you've assigned the object to a variable, you'll use that variable instead of $this:

-$obj =& get_instance();

-$obj->load->helper('url');
-$obj->load->library('session');
-$obj->config->item('base_url');
+$CI =& get_instance();

+$CI->load->helper('url');
+$CI->load->library('session');
+$CI->config->item('base_url');
etc.

Note: You'll notice that the above get_instance() function is being passed by reference:

-$obj =& get_instance(); +$CI =& get_instance();

This is very important. Assigning by reference allows you to use the original Code Igniter object rather than creating a copy of it.

-- cgit v1.2.3-24-g4f1b