summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-08-26 21:28:37 +0200
committeradmin <devnull@localhost>2006-08-26 21:28:37 +0200
commitb071bb5a92aade551345a495fb13f5678f3978d0 (patch)
tree803575f71b327ad5782206331d82bf5c6dfc0cc0
parente07fbb376a741e21e69a182eada322c4d3b7e62e (diff)
-rw-r--r--system/application/config/config.php2
-rw-r--r--system/application/config/routes.php3
-rw-r--r--system/codeigniter/CodeIgniter.php6
-rw-r--r--system/codeigniter/Common.php3
-rw-r--r--system/drivers/DB_mssql.php2
-rw-r--r--system/drivers/DB_mysql.php2
-rw-r--r--system/drivers/DB_mysqli.php2
-rw-r--r--system/drivers/DB_odbc.php2
-rw-r--r--system/drivers/DB_postgre.php8
-rw-r--r--system/drivers/DB_sqlite.php2
-rw-r--r--system/helpers/form_helper.php2
-rw-r--r--system/helpers/url_helper.php4
-rw-r--r--system/libraries/Calendar.php2
-rw-r--r--system/libraries/Loader.php2
-rw-r--r--system/libraries/Router.php45
-rw-r--r--system/libraries/URI.php14
-rw-r--r--user_guide/general/changelog.html16
-rw-r--r--user_guide/general/controllers.html20
-rw-r--r--user_guide/general/routing.html2
-rw-r--r--user_guide/helpers/form_helper.html10
-rw-r--r--user_guide/helpers/url_helper.html6
-rw-r--r--user_guide/libraries/database/active_record.html2
22 files changed, 96 insertions, 61 deletions
diff --git a/system/application/config/config.php b/system/application/config/config.php
index 0b4f33f41..c33bda37c 100644
--- a/system/application/config/config.php
+++ b/system/application/config/config.php
@@ -37,6 +37,8 @@ $config['index_page'] = "index.php";
| 'auto' Default - auto detects
| 'path_info' Uses the PATH_INFO
| 'query_string' Uses the QUERY_STRING
+| 'orig_path_info' Uses the ORIG_PATH_INFO
+| 'request_uri' Uses the REQUEST_URI
|
*/
$config['uri_protocol'] = "auto";
diff --git a/system/application/config/routes.php b/system/application/config/routes.php
index 5167f7569..dc8a32d01 100644
--- a/system/application/config/routes.php
+++ b/system/application/config/routes.php
@@ -45,7 +45,8 @@ $route['scaffolding_trigger'] = "scaffolding";
// Define your own routes below -------------------------------------------
+$route['products/([a-z]+)/(\d+)'] = "bamo/$1/a$2";
+
-$route['products\/([a-z]+)\/(\d+)'] = "$1/a$2";
?> \ No newline at end of file
diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php
index de7f89af2..872f4c049 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -27,7 +27,7 @@
* @link http://www.codeigniter.com/user_guide/
*/
-define('APPVER', '1.4');
+define('APPVER', '1.4.0');
/*
* ------------------------------------------------------
@@ -122,7 +122,7 @@ $LANG =& _load_class('CI_Language');
*
*/
-_load_class('CI_Loader');
+_load_class('CI_Loader', FALSE);
if (floor(phpversion()) < 5)
{
@@ -133,7 +133,7 @@ else
require(BASEPATH.'codeigniter/Base5'.EXT);
}
-_load_class('CI_Controller');
+_load_class('CI_Controller', FALSE);
require(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index 2ec1c3d38..4879e7099 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -63,11 +63,10 @@ function &_load_class($class, $instantiate = TRUE)
}
else
{
- $objects[$class] = TRUE;
+ $objects[$class] = FALSE;
}
}
-
return $objects[$class];
}
diff --git a/system/drivers/DB_mssql.php b/system/drivers/DB_mssql.php
index 6156ec3c9..48d1929e3 100644
--- a/system/drivers/DB_mssql.php
+++ b/system/drivers/DB_mssql.php
@@ -93,7 +93,7 @@ class CI_DB_mssql extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
return $sql;
}
diff --git a/system/drivers/DB_mysql.php b/system/drivers/DB_mysql.php
index 18c080b21..82e677a1a 100644
--- a/system/drivers/DB_mysql.php
+++ b/system/drivers/DB_mysql.php
@@ -100,7 +100,7 @@ class CI_DB_mysql extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
// the query so that it returns the number of affected rows
diff --git a/system/drivers/DB_mysqli.php b/system/drivers/DB_mysqli.php
index f8cb19dbe..32c4c0f89 100644
--- a/system/drivers/DB_mysqli.php
+++ b/system/drivers/DB_mysqli.php
@@ -102,7 +102,7 @@ class CI_DB_mysqli extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
// the query so that it returns the number of affected rows
diff --git a/system/drivers/DB_odbc.php b/system/drivers/DB_odbc.php
index fac44904b..50f39accd 100644
--- a/system/drivers/DB_odbc.php
+++ b/system/drivers/DB_odbc.php
@@ -94,7 +94,7 @@ class CI_DB_odbc extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
return $sql;
}
diff --git a/system/drivers/DB_postgre.php b/system/drivers/DB_postgre.php
index 01d4b3df0..3829b04af 100644
--- a/system/drivers/DB_postgre.php
+++ b/system/drivers/DB_postgre.php
@@ -94,7 +94,7 @@ class CI_DB_postgre extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
return $sql;
}
@@ -174,7 +174,7 @@ class CI_DB_postgre extends CI_DB {
if ($table == '')
return '0';
- $query = $this->query("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
+ $query = $this->query("SELECT COUNT(*) AS numrows FROM ".$this->dbprefix.$table."");
if ($query->num_rows() == 0)
return '0';
@@ -225,7 +225,7 @@ class CI_DB_postgre extends CI_DB {
{
if (stristr($table, '.'))
{
- $table = preg_replace("/\./", "`.`", $table);
+ $table = preg_replace("/\./", ".", $table);
}
return $table;
@@ -432,7 +432,7 @@ class CI_DB_postgre_result extends CI_DB_result {
$F->name = pg_field_name($this->result_id, $i);
$F->type = pg_field_type($this->result_id, $i);
$F->max_length = pg_field_size($this->result_id, $i);
- $F->primary_key = 0;
+ $F->primary_key = $i == 0;
$F->default = '';
$retval[] = $F;
diff --git a/system/drivers/DB_sqlite.php b/system/drivers/DB_sqlite.php
index 6428dd5bb..1192e6dc7 100644
--- a/system/drivers/DB_sqlite.php
+++ b/system/drivers/DB_sqlite.php
@@ -115,7 +115,7 @@ class CI_DB_sqlite extends CI_DB {
* @param string an SQL query
* @return string
*/
- function &_prep_query($sql)
+ function _prep_query($sql)
{
return $sql;
}
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index f82ad01a0..d4e45a0af 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -326,7 +326,7 @@ function form_close($extra = '')
*/
function form_prep($str = '')
{
- if ($str == '')
+ if ($str === '')
{
return '';
}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index d2d2a5985..03d6c3b2c 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -90,7 +90,7 @@ function index_page()
*/
function anchor($uri = '', $title = '', $attributes = '')
{
- $site_url = site_url($uri);
+ $site_url = ( ! preg_match('!^\w+://!i', $uri)) ? site_url($uri) : $uri;
if ($title == '')
{
@@ -128,7 +128,7 @@ function anchor($uri = '', $title = '', $attributes = '')
*/
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
- $site_url = site_url($uri);
+ $site_url = ( ! preg_match('!^\w+://!i', $uri)) ? site_url($uri) : $uri;
if ($title == '')
{
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 013f06796..b77dd1b6f 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -263,7 +263,7 @@ class CI_Calendar {
}
else
{
- $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_novermber', '12' => 'cal_december');
+ $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
}
$month = $month_names[$month];
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index e2467fa64..3d2501fc0 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -478,7 +478,7 @@ class CI_Loader {
if ($path == '')
{
$ext = pathinfo($view, PATHINFO_EXTENSION);
- $file = ($ext == '') ? $view.EXT : $view;
+ $file = ($ext != EXT) ? $view.EXT : $view;
$path = $this->view_path.$file;
}
else
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 678145458..b28ead953 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -87,25 +87,31 @@ class CI_Router {
// Fetch the URI string Depending on the server,
// the URI will be available in one of two globals
- switch ($this->config->item('uri_protocol'))
+ if ($this->config->item('uri_protocol') == 'auto')
{
- case 'path_info' : $this->uri_string = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
- break;
- case 'query_string' : $this->uri_string = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
- break;
- default :
- $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
-
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $this->uri_string = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
- }
- break;
+ $path_info = getenv('PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ $this->uri_string = $path_info;
+ }
+ else
+ {
+ $path_info = getenv('ORIG_PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ $this->uri_string = $path_info;
+ }
+ else
+ {
+ $this->uri_string = getenv('QUERY_STRING');
+ }
+ }
+ }
+ else
+ {
+ $this->uri_string = getenv(strtoupper($this->config->item('uri_protocol')));
}
+
// Is there a URI string? If not, the default controller specified
// by the admin in the "routes" file will be shown.
@@ -291,10 +297,7 @@ class CI_Router {
// Loop through the route array looking for wildcards
foreach (array_slice($this->routes, 1) as $key => $val)
- {
- if (count(explode('/', $key)) != $num)
- continue;
-
+ {
// Convert wildcards to RegEx
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index 4c2fa9c7f..c5fd4625b 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -28,7 +28,7 @@
*/
class CI_URI {
- var $uri;
+ var $router;
var $keyval = array();
/**
@@ -42,7 +42,7 @@ class CI_URI {
*/
function CI_URI()
{
- $this->uri =& _load_class('CI_Router');
+ $this->router =& _load_class('CI_Router');
log_message('debug', "URI Class Initialized");
}
@@ -60,7 +60,7 @@ class CI_URI {
*/
function segment($n, $no_result = FALSE)
{
- return ( ! isset($this->uri->segments[$n])) ? $no_result : $this->uri->segments[$n];
+ return ( ! isset($this->router->segments[$n])) ? $no_result : $this->router->segments[$n];
}
// --------------------------------------------------------------------
@@ -196,7 +196,7 @@ class CI_URI {
$leading = '/';
$trailing = '/';
}
- return ( ! isset($this->uri->segments[$n])) ? '' : $leading.$this->uri->segments[$n].$trailing;
+ return ( ! isset($this->router->segments[$n])) ? '' : $leading.$this->router->segments[$n].$trailing;
}
// --------------------------------------------------------------------
@@ -209,7 +209,7 @@ class CI_URI {
*/
function segment_array()
{
- return $this->uri->segments;
+ return $this->router->segments;
}
// --------------------------------------------------------------------
@@ -222,7 +222,7 @@ class CI_URI {
*/
function total_segments()
{
- return count($this->uri->segments);
+ return count($this->router->segments);
}
// --------------------------------------------------------------------
@@ -235,7 +235,7 @@ class CI_URI {
*/
function uri_string()
{
- return $this->uri->uri_string;
+ return $this->router->uri_string;
}
}
diff --git a/user_guide/general/changelog.html b/user_guide/general/changelog.html
index 5f3b86904..5721bc866 100644
--- a/user_guide/general/changelog.html
+++ b/user_guide/general/changelog.html
@@ -69,20 +69,28 @@ Change Log
<ul>
<li>Added <a href="hooks.html">Hooks</a> feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.</li>
+<li>Added the ability to organize controller files <a href="controllers.html">into sub-folders</a>. Kudos to Marco for <a href="http://www.codeigniter.com/forums/viewthread/627/">suggesting</a> this (and the next two) feature.</li>
+<li>Added regular expressions support for <a href="routing.html">routing rules</a>.</li>
<li>Added the ability to <a href="core_classes.html">replace core system classes</a> with your own classes.</li>
<li>Added support for % character in URL.</li>
-<li>Added the ability to organize <a href="controllers.html">controller</a> files into sub-folders.
-<li>Updated the <a href="routing.html">Routing feature</a> to accept regular expressions within routing rules.</li>
+<li>Added the ability to supply full URLs using the <dfn>anchor()</dfn> helper function.</li>
<li>Moved the MIME type array out of the Upload class and into its own file in the applications/comfig/ folder.</li>
+<li>Tweaked the URI Protocol code to allow more options so that URLs will work more reliably in different environments.</li>
<li>Removed a strtolower() call that was changing URL segments to lower case.</li>
+<li>Removed some references that were interfering with PHP 4.4.1 compatibility.</li>
+<li>Removed backticks from Postgre class since these are not needed.</li>
<li>Deprecated the hash() function due to a naming conflict with a native PHP function with the same name. Please use dohash() instead.</li>
-<li>Fixed a MS SQL issue.</li>
<li>Fixed an issue when removing GET variables.</li>
<li>Fixed <a href="http://www.codeigniter.com/forums/viewthread/773/">this</a> router bug.</li>
<li>Fixed a bug that was preventing multiple discreet database calls.</li>
<li>Fixed a bug in which loading a language file was producing a "file contains no data" message.</li>
<li>Fixed a session bug caused by the XSS Filtering feature inadvertently changing the case of certain words.</li>
-<li>Removed backticks from Postgre class since these are not needed.</li>
+<li>Fixed some missing prefixes when using the database prefix feature.</li>
+<li>Fixed a bug that was causing the Loader class to incorrectly identify the file extension.</li>
+<li>Fixed a typo in the Calendar class (cal_november).</li>
+<li>Fixed an evaluation bug in the database initialization function.</li>
+<li>Fixed some MS SQL bugs.</li>
+<li>Fixed some doc typos.</li>
</ul>
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html
index 648298eb0..b45b5aef7 100644
--- a/user_guide/general/controllers.html
+++ b/user_guide/general/controllers.html
@@ -71,6 +71,7 @@ Controllers
<li><a href="#functions">Functions</a></li>
<li><a href="#private">Private Functions</a></li>
<li><a href="#default">Defining a Default Controller</a></li>
+<li><a href="#subfolders">Organizing Controllers into Sub-folders</a></li>
<li><a href="#constructors">Class Constructors</a></li>
<li><a href="#reserved">Reserved Function Names</a></li>
</ul>
@@ -204,6 +205,25 @@ your <dfn>application/config/routes.php</dfn> file and set this variable:</p>
specifying any URI segments you'll see your Hello World message by default.</p>
+<a name="subfolders"></a>
+<h2>Organizing Your Controllers into Sub-folders</h2>
+
+<p>If you are building a large application you might find it convenient to organize your controllers into sub-folders. Code Igniter permits you to do this.</p>
+
+<p>Simply create folders within your <dfn>application/controllers</dfn> directory and place your controller classes within them.</p>
+
+<p><strong>Note:</strong>&nbsp; When using this feature the first segment or your URI must specify the folder. For example, lets say you have a controller
+located here:</p>
+
+<code>application/controllers/<kbd>products</kbd>/shoes.php</code>
+
+<p>To call the above controller your URI will look something like this:</p>
+
+<code>www.your-site.com/index.php/products/shoes/123</code>
+
+<p>Code Igniter also permits you to remap your URIs using its <a href="routing.html">URI Routing</a> feature.
+
+
<a name="constructors"></a>
<h2>Class Constructors</h2>
diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html
index 977698b9f..e5dac6808 100644
--- a/user_guide/general/routing.html
+++ b/user_guide/general/routing.html
@@ -138,7 +138,7 @@ Higher routes will always take precedence over lower ones.</p>
<p>A typical RegEx route might look something like this:</p>
-<code>$route['products\/([a-z]+)\/(\d+)'] = "$1/id_$2";</code>
+<code>$route['products/([a-z]+)/(\d+)'] = "$1/id_$2";</code>
<p>In the above example, a URI similar to <dfn>products/shirts/123</dfn> would instead call the <dfn>shirts</dfn> controller class and the <dfn>id_123</dfn> function.</p>
diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html
index 8593f81d9..f38d4ada1 100644
--- a/user_guide/helpers/form_helper.html
+++ b/user_guide/helpers/form_helper.html
@@ -208,7 +208,7 @@ value you wish to be selected. Example:
<code>$options = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'small'&nbsp;&nbsp;=> 'Small Shirt',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'med'&nbsp;&nbsp;&nbsp;&nbsp;=> 'Medium Shirt',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;large'&nbsp;&nbsp; => 'Large Shirt',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'large'&nbsp;&nbsp; => 'Large Shirt',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'xlarge' => 'Extra Large Shirt',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
<br />
@@ -217,10 +217,10 @@ echo form_dropdown('shirts', $options, 'large');<br />
// Would produce:<br /><br />
&lt;select name="shirts"><br />
-&lt;option value="small">Small Shirt</option><br />
-&lt;option value="med">Medium Shirt</option><br />
-&lt;option value="large" selected>Large Shirt</option><br />
-&lt;option value="xlarge">Extra Large Shirt</option><br />
+&lt;option value="small">Small Shirt&lt;/option><br />
+&lt;option value="med">Medium Shirt&lt;/option><br />
+&lt;option value="large" selected>Large Shirt&lt;/option><br />
+&lt;option value="xlarge">Extra Large Shirt&lt;/option><br />
&lt;/select></code>
diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html
index a8f5c14d6..2b5b354cc 100644
--- a/user_guide/helpers/url_helper.html
+++ b/user_guide/helpers/url_helper.html
@@ -117,8 +117,10 @@ echo site_url($segments);</code>
<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code>
<p>The first parameter can contain any segments you wish appended to the URL. As with the <dfn>site_url()</dfn> function above,
-segments can be a string or an array. Note: Do not include the base URL. It will be built as specified in your config file. Include
-only the URI segments you wish appended to the URL.</p>
+segments can be a string or an array.</p>
+
+<p><strong>Note:</strong>&nbsp; If you are building links that are internal to your application do not include the base URL (http://...). This
+will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL.</p>
<p>The second segment is the text you would like the link to say. If you leave it blank, the URL will be used.</p>
diff --git a/user_guide/libraries/database/active_record.html b/user_guide/libraries/database/active_record.html
index 8fc3b8131..6e5d6126a 100644
--- a/user_guide/libraries/database/active_record.html
+++ b/user_guide/libraries/database/active_record.html
@@ -557,7 +557,7 @@ You can optionally pass this information directly into the update function as a
<p>Generates a delete SQL string and runs the query.</p>
<code>
-$this->db->delete('mytable', array('id', $id));
+$this->db->delete('mytable', array('id' => $id));
<br /><br />
// Produces:<br />
// DELETE FROM mytable <br />