summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/codeigniter/CodeIgniter.php9
-rw-r--r--system/libraries/Calendar.php11
-rw-r--r--system/libraries/Pagination.php5
-rw-r--r--user_guide/general/alternative_php.html12
-rw-r--r--user_guide/libraries/calendar.html64
-rw-r--r--user_guide/libraries/file_uploading.html5
6 files changed, 65 insertions, 41 deletions
diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php
index 5b3f54ae3..3e2b99dea 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -125,9 +125,16 @@ else
require(BASEPATH.'codeigniter/Base5'.EXT);
}
+// Load the base controller class
load_class('Controller', FALSE);
-require(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
+// Load the local application controller
+// Note: The Router class automatically validates the controller path. If this include fails it
+// means that the default controller in the Routes.php file is not resolving to something valid.
+if ( ! @include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
+{
+ show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
+}
// Set a mark point for benchmarking
$BM->mark('loading_time_base_classes_end');
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 84b096c8b..fdef5dd75 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -45,7 +45,7 @@ class CI_Calendar {
*
* @access public
*/
- function CI_Calendar()
+ function CI_Calendar($config = array())
{
$this->CI =& get_instance();
@@ -55,6 +55,12 @@ class CI_Calendar {
}
$this->local_time = time();
+
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
log_message('debug', "Calendar Class Initialized");
}
@@ -153,6 +159,9 @@ class CI_Calendar {
// "previous" month link
if ($this->show_next_prev == TRUE)
{
+ // Add a trailing slash to the URL if needed
+ $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
+
$adjusted_date = $this->adjust_date($month - 1, $year);
$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
$out .= "\n";
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index c66d570cd..07ad6a683 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -120,8 +120,11 @@ class CI_Pagination {
if ($CI->uri->segment($this->uri_segment) != 0)
{
$this->cur_page = $CI->uri->segment($this->uri_segment);
+
+ // Prep the current page - no funny business!
+ $this->cur_page = preg_replace("/[a-z\-]/", "", $this->cur_page);
}
-
+
if ( ! is_numeric($this->cur_page))
{
$this->cur_page = 0;
diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html
index 888123ed0..2018bf26b 100644
--- a/user_guide/general/alternative_php.html
+++ b/user_guide/general/alternative_php.html
@@ -63,15 +63,21 @@ Alternate PHP Syntax
<h1>Alternate PHP Syntax for View Files</h1>
<p>If you do not utilize Code Igniter's <a href="../libraries/parser.html">template engine</a>, you'll be using pure PHP
-in your View files. To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use PHPs alternative
-syntax for control structures and echo statements. If you are not familiar with this syntax, it allows you to eliminate the braces from your code,
+in your View files. To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use
+PHPs alternative syntax for control structures and short tag echo statements. If you are not familiar with this syntax, it allows you to eliminate the braces from your code,
and eliminate "echo" statements.</p>
-<p class="important"><strong>Note:</strong> If you find that the syntax described in this page does not work on your server it might
+<h2>Automatic Short Tag Support</h2>
+
+<p><strong>Note:</strong> If you find that the syntax described in this page does not work on your server it might
be that "short tags" are disabled in your PHP ini file. Code Igniter will optionally rewrite short tags on-the-fly,
allowing you to use that syntax even if your server doesn't support it. This feature can be enabled in your
<dfn>config/config.php</dfn> file.</p>
+<p class="important">Please note that if you do use this feature, if PHP errors are encountered
+in your <strong>view files</strong>, the error message and line number will not be accurately shown. Instead, all errors
+will be shown as <kbd>eval()</kbd> errors.</p>
+
<h2>Alternative Echos</h2>
diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html
index 03035170d..ff61701aa 100644
--- a/user_guide/libraries/calendar.html
+++ b/user_guide/libraries/calendar.html
@@ -119,19 +119,18 @@ how data passed to your cells is handled so you can pass different types of info
<h2>Setting Display Preferences</h2>
-<p>There are seven preferences you can set to control various aspects of the calendar. Preferences are set using an initialization
-function similar to other classes. Here is an example:
+<p>There are seven preferences you can set to control various aspects of the calendar. Preferences are set by passing an
+array of preferences in the second parameter of the loading function. Here is an example:</p>
-<code>$this->load->library('calendar');<br />
-<br />
+<code>
$prefs = array (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'start_day'&nbsp;&nbsp;&nbsp; => 'saturday',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'month_type'&nbsp;&nbsp; => 'long',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'day_type'&nbsp;&nbsp;&nbsp;&nbsp; => 'short'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
<br />
-$this->calendar->initialize($prefs);<br />
+$this->load->library('calendar', $prefs);<br />
<br />
echo $this->calendar->generate();</code>
@@ -166,6 +165,30 @@ regarding preferences below.</p>
+<h2>Showing Next/Previous Month Links</h2>
+
+<p>To allow your calendar to dynamically increment/decrement via the next/previous links requires that you set up your calendar
+code similar to this example:</p>
+
+
+<code>$this->load->library('calendar');<br />
+<br />
+$prefs = array (<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'show_next_prev'&nbsp;&nbsp;=> TRUE,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'next_prev_url'&nbsp;&nbsp; => 'http://www.your-site.com/index.php/calendar/show/'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo $this->calendar->generate(<var>$this->uri->segment(3)</var>, <var>$this->uri->segment(4)</var>, $prefs);</code>
+
+<p>You'll notice a few things about the above example:</p>
+
+<ul>
+<li>You must set the "show_next_prev" to TRUE.</li>
+<li>You must supply the URL to the controller containing your calendar in the "next_prev_url" preference.</li>
+<li>You must supply the "year" and "month" to the calendar generating function via the URI segments where they appear (Note: The calendar class automatically adds the year/month to the base URL you provide.).</li>
+</ul>
+
+
<h2>Creating a Calendar Template</h2>
@@ -173,7 +196,7 @@ regarding preferences below.</p>
calendar will be placed within a pair of pseudo-variables as shown here:</p>
-<code>$this->load->library('calendar');<br /><br />
+<code>
$prefs['template'] = '<br /><br />
&nbsp;&nbsp;&nbsp;<dfn>{table_open}</dfn><var>&lt;table border="0" cellpadding="0" cellspacing="0"></var><dfn>{/table_open}</dfn><br />
<br />
@@ -206,39 +229,12 @@ $prefs['template'] = '<br /><br />
&nbsp;&nbsp;&nbsp;<dfn>{table_close}</dfn><var>&lt;/table></var><dfn>{/table_close}</dfn><br />
';<br />
<br />
-$this->calendar->initialize($prefs);<br />
+$this->load->library('calendar', $prefs);<br />
<br />
echo $this->calendar->generate();</code>
-<h2>Showing Next/Previous Month Links</h2>
-
-<p>To allow your calendar to dynamically increment/decrement via the next/previous links requires that you set up your calendar
-code similar to this example:</p>
-
-
-<code>$this->load->library('calendar');<br />
-<br />
-$prefs = array (<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'show_next_prev'&nbsp;&nbsp;=> TRUE,<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'next_prev_url'&nbsp;&nbsp; => 'http://www.your-site.com/index.php/calendar/show/'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
-<br />
-$this->calendar->initialize($prefs);<br />
-<br />
-echo $this->calendar->generate(<var>$this->uri->segment(3)</var>, <var>$this->uri->segment(4)</var>);</code>
-
-<p>You'll notice a few things about the above example:</p>
-
-<ul>
-<li>You must set the "show_next_prev" to TRUE.</li>
-<li>You must supply the URL to the controller containing your calendar in the "next_prev_url" preference.</li>
-<li>You must supply the "year" and "month" to the calendar generating function via the URI segments where they appear (Note: The calendar class automatically adds the year/month to the base URL you provide.).</li>
-</ul>
-
-
-
</div>
<!-- END CONTENT -->
diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html
index 6a2317da1..1fa93bf17 100644
--- a/user_guide/libraries/file_uploading.html
+++ b/user_guide/libraries/file_uploading.html
@@ -171,7 +171,7 @@ class Upload extends Controller {
$config['max_width'] = '1024';
$config['max_height'] = '768';
- $this->upload->initialize($config);
+ $this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
@@ -230,6 +230,9 @@ $config['max_size'] = '100';<br />
$config['max_width'] = '1024';<br />
$config['max_height'] = '768';<br />
<br />
+$this->load->library('ftp', $config);<br /><br />
+
+// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:<br />
$this->upload->initialize($config);</code>
<p>The above preferences should be fairly self-explanatory. Below is a table describing all available preferences.</p>