diff options
-rw-r--r-- | system/libraries/Loader.php | 29 | ||||
-rw-r--r-- | system/libraries/User_agent.php | 3 | ||||
-rw-r--r-- | user_guide/libraries/loader.html | 38 | ||||
-rw-r--r-- | user_guide/libraries/table.html | 9 |
4 files changed, 42 insertions, 37 deletions
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php index 05ee93959..452e39dfa 100644 --- a/system/libraries/Loader.php +++ b/system/libraries/Loader.php @@ -65,15 +65,15 @@ class CI_Loader { * * @access public * @param string the name of the class - * @param mixed any initialization parameters + * @param sring the optional class variable name to assign the library to * @return void */ - function library($class, $param = NULL) + function library($class, $varname = NULL) { if ($class == '') return; - $this->_ci_load_class($class, $param); + $this->_ci_load_class($class, $varname); $this->_ci_assign_to_models(); } @@ -595,7 +595,7 @@ class CI_Loader { * @param mixed any additional parameters * @return void */ - function _ci_load_class($class, $params = NULL) + function _ci_load_class($class, $varname = NULL) { // Prep the class name $class = strtolower(str_replace(EXT, '', $class)); @@ -627,7 +627,7 @@ class CI_Loader { } } - return $this->_ci_init_class($filename, 'MY_', $params); + return $this->_ci_init_class($filename, 'MY_', $varname); } // Lets search for the requested library file and load it. @@ -642,7 +642,7 @@ class CI_Loader { if (file_exists($path.'libraries/'.$filename.EXT)) { include_once($path.'libraries/'.$filename.EXT); - return $this->_ci_init_class($filename, '', $params); + return $this->_ci_init_class($filename, '', $varname); } } } @@ -662,15 +662,12 @@ class CI_Loader { * @param string * @return null */ - function _ci_init_class($class, $prefix = '', $config = NULL) + function _ci_init_class($class, $prefix = '', $varname = NULL) { // Is there an associated config file for this class? - if ($config == NULL) + if (file_exists(APPPATH.'config/'.$class.EXT)) { - if (file_exists(APPPATH.'config/'.$class.EXT)) - { - include_once(APPPATH.'config/'.$class.EXT); - } + include_once(APPPATH.'config/'.$class.EXT); } if ($prefix == '') @@ -682,17 +679,17 @@ class CI_Loader { $name = $prefix.$class; } - $varname = ( ! isset($remap[$class])) ? $class : $remap[$class]; - $varname = strtolower($varname); + $classvar = ( ! is_null($varname)) ? $varname : strtolower($class); + // Instantiate the class if ($config !== NULL) { - $this->CI->$varname = new $name($config); + $this->CI->$classvar = new $name($config); } else { - $this->CI->$varname = new $name; + $this->CI->$classvar = new $name; } } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 21162388a..39e12327f 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -113,8 +113,7 @@ class CI_User_agent { unset($robots); $return = TRUE; } - - + return $return; } diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index b8da7aaf2..b93d5fa79 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -72,6 +72,29 @@ Loader Class +<h2>$this->load->library('<var>class_name</var>')</h2>
+
+<p>This function is used to load core classes. Where <var>class_name</var> is the name of the class you want to load.
+Note: We use the terms "class" and "library" interchangeably.</p>
+
+<p>For example, if you would like to send email with Code Igniter, the first step is to load the email class within your controller:</p>
+
+<code>$this->load->library('email');</code>
+
+<p>Once loaded, the library will be ready for use, using <kbd>$this->email-></kbd><samp><em>some_function</em>()</samp>.
+
+Each library is described in detail in its own page, so please read theinformation regarding each one you would like to use.</p>
+
+<p>If you would like your libraries assigned to a different variable name then the default you can specify the name in the second paramter:</p>
+
+<code>
+$this->load->library('email', 'E'); // Assigns the email object to "E"<br />
+<br />
+<kbd>$this->E-></kbd><samp><em>some_function</em>()</samp>
+</code>
+
+
+
<h2>$this->load->view('<var>file_name</var>', <samp>$data</samp>, <kbd>true/false</kbd>)</h2>
<p>This function is used to load your View files. If you haven't read the <a href="../general/views.html">Views</a> section of the
@@ -92,21 +115,6 @@ to your browser. Remember to assign it to a variable if you wan the data return <code>$string = $this->load->view('<var>myfile</var>', '', <kbd>true</kbd>);</code>
-
-<h2>$this->load->library('<var>class_name</var>')</h2>
-
-<p>This function is used to load core classes. Where <var>class_name</var> is the name of the class you want to load.
-Note: We use the terms "class" and "library" interchangeably.</p>
-
-<p>For example, if you would like to send email with Code Igniter, the first step is to load the email class within your controller:</p>
-
-<code>$this->load->library('email');</code>
-
-<p>Once loaded, the library will be ready for use. Each library is described in detail in its own page, so please read the
-information regarding each one you would like to use.</p>
-
-
-
<h2>$this->load->database('<var>options</var>', <kbd>true/false</kbd>)</h2>
<p>This function lets you load the database class. The two parameters are <strong>optional</strong>. Please see the
diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html index e80e53fd7..61b5ce82f 100644 --- a/user_guide/libraries/table.html +++ b/user_guide/libraries/table.html @@ -76,7 +76,8 @@ HTML Table Class <h2>Examples</h2>
<p>Here is an example showing how you can create a table from a multi-dimensional array.
-Note that the first array index will become the table heading.</p>
+Note that the first array index will become the table heading (or you can set your own headings using the
+<dfn>set_heading()</dfn> function described in the function reference below).</p>
<code>
$this->load->library('table');<br />
@@ -92,8 +93,8 @@ echo $this->table->generate($data); </code>
<p>Here is an example of a table created from a database query result. The table class will automatically generate the
-headings based on the table names. Or you can set your own headings using the <dfn>set_heading()</dfn> function described
-in the function reference below.</p>
+headings based on the table names (or you can set your own headings using the <dfn>set_heading()</dfn> function described
+in the function reference below).</p>
<code>
$this->load->library('table');<br />
@@ -164,7 +165,7 @@ $tmpl = array (<br /> $this->table->set_template($tmpl);
</code>
-<p class="important">You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each
+<p class="important"><strong>Note:</strong> You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each
iteration of the row data.</p>
<p>You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements.
|