summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/config/constants.php16
-rw-r--r--system/core/Loader.php6
-rw-r--r--system/helpers/captcha_helper.php3
-rw-r--r--system/language/english/date_lang.php28
-rw-r--r--tests/codeigniter/libraries/Calendar_test.php204
-rw-r--r--tests/mocks/libraries/calendar.php25
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/form_validation.rst1
8 files changed, 256 insertions, 28 deletions
diff --git a/application/config/constants.php b/application/config/constants.php
index d22d2963e..62a18e761 100644
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -52,14 +52,14 @@ define('DIR_WRITE_MODE', 0777);
|
*/
-define('FOPEN_READ', 'rb');
-define('FOPEN_READ_WRITE', 'r+b');
-define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
-define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
-define('FOPEN_WRITE_CREATE', 'ab');
-define('FOPEN_READ_WRITE_CREATE', 'a+b');
-define('FOPEN_WRITE_CREATE_STRICT', 'xb');
-define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
+define('FOPEN_READ', 'rb');
+define('FOPEN_READ_WRITE', 'r+b');
+define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
+define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
+define('FOPEN_WRITE_CREATE', 'ab');
+define('FOPEN_READ_WRITE_CREATE', 'a+b');
+define('FOPEN_WRITE_CREATE_STRICT', 'xb');
+define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/*
|--------------------------------------------------------------------------
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 0d05649ca..89b2028bf 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -779,11 +779,11 @@ class CI_Loader {
$_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
$_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view;
- foreach ($this->_ci_view_paths as $view_file => $cascade)
+ foreach ($this->_ci_view_paths as $_ci_view_file => $cascade)
{
- if (file_exists($view_file.$_ci_file))
+ if (file_exists($_ci_view_file.$_ci_file))
{
- $_ci_path = $view_file.$_ci_file;
+ $_ci_path = $_ci_view_file.$_ci_file;
$file_exists = TRUE;
break;
}
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index a4383c9d3..57ef9e2fa 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -80,8 +80,7 @@ if ( ! function_exists('create_captcha'))
$current_dir = @opendir($img_path);
while ($filename = @readdir($current_dir))
{
- if ($filename !== '.' && $filename !== '..' && $filename !== 'index.html'
- && (str_replace('.jpg', '', $filename) + $expiration) < $now)
+ if (strpos($filename, ".jpg") !== FALSE && (str_replace('.jpg', '', $filename) + $expiration) < $now)
{
@unlink($img_path.$filename);
}
diff --git a/system/language/english/date_lang.php b/system/language/english/date_lang.php
index 229d33d2e..6683e4c69 100644
--- a/system/language/english/date_lang.php
+++ b/system/language/english/date_lang.php
@@ -25,20 +25,20 @@
* @filesource
*/
-$lang['date_year'] = "Year";
-$lang['date_years'] = "Years";
-$lang['date_month'] = "Month";
-$lang['date_months'] = "Months";
-$lang['date_week'] = "Week";
-$lang['date_weeks'] = "Weeks";
-$lang['date_day'] = "Day";
-$lang['date_days'] = "Days";
-$lang['date_hour'] = "Hour";
-$lang['date_hours'] = "Hours";
-$lang['date_minute'] = "Minute";
-$lang['date_minutes'] = "Minutes";
-$lang['date_second'] = "Second";
-$lang['date_seconds'] = "Seconds";
+$lang['date_year'] = 'Year';
+$lang['date_years'] = 'Years';
+$lang['date_month'] = 'Month';
+$lang['date_months'] = 'Months';
+$lang['date_week'] = 'Week';
+$lang['date_weeks'] = 'Weeks';
+$lang['date_day'] = 'Day';
+$lang['date_days'] = 'Days';
+$lang['date_hour'] = 'Hour';
+$lang['date_hours'] = 'Hours';
+$lang['date_minute'] = 'Minute';
+$lang['date_minutes'] = 'Minutes';
+$lang['date_second'] = 'Second';
+$lang['date_seconds'] = 'Seconds';
$lang['UM12'] = '(UTC -12:00) Baker/Howland Island';
$lang['UM11'] = '(UTC -11:00) Niue';
diff --git a/tests/codeigniter/libraries/Calendar_test.php b/tests/codeigniter/libraries/Calendar_test.php
new file mode 100644
index 000000000..95668d70d
--- /dev/null
+++ b/tests/codeigniter/libraries/Calendar_test.php
@@ -0,0 +1,204 @@
+<?php
+
+class Calendar_test extends CI_TestCase {
+
+ function __construct()
+ {
+ $obj = new stdClass;
+ $obj->calendar = new Mock_Libraries_Calendar();
+
+ $this->calendar = $obj->calendar;
+ }
+
+ function test_initialize()
+ {
+ $this->calendar->initialize(array(
+ 'month_type' => 'short',
+ 'start_day' => 'monday'
+ ));
+ $this->assertEquals('short', $this->calendar->month_type);
+ $this->assertEquals('monday', $this->calendar->start_day);
+ }
+
+ /**
+ * @covers Mock_Libraries_Calendar::parse_template
+ */
+ function test_generate()
+ {
+ $no_events = '<table border="0" cellpadding="4" cellspacing="0">
+
+<tr>
+<th colspan="7">September&nbsp;2011</th>
+
+</tr>
+
+<tr>
+<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>
+</tr>
+
+<tr>
+<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>1</td><td>2</td><td>3</td>
+</tr>
+
+<tr>
+<td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
+</tr>
+
+<tr>
+<td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td>
+</tr>
+
+<tr>
+<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
+</tr>
+
+<tr>
+<td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>&nbsp;</td>
+</tr>
+
+</table>';
+
+ $this->assertEquals($no_events, $this->calendar->generate(2011, 9));
+
+ $data = array(
+ 3 => 'http://example.com/news/article/2006/03/',
+ 7 => 'http://example.com/news/article/2006/07/',
+ 13 => 'http://example.com/news/article/2006/13/',
+ 26 => 'http://example.com/news/article/2006/26/'
+ );
+
+ $events = '<table border="0" cellpadding="4" cellspacing="0">
+
+<tr>
+<th colspan="7">September&nbsp;2011</th>
+
+</tr>
+
+<tr>
+<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>
+</tr>
+
+<tr>
+<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>1</td><td>2</td><td><a href="http://example.com/news/article/2006/03/">3</a></td>
+</tr>
+
+<tr>
+<td>4</td><td>5</td><td>6</td><td><a href="http://example.com/news/article/2006/07/">7</a></td><td>8</td><td>9</td><td>10</td>
+</tr>
+
+<tr>
+<td>11</td><td>12</td><td><a href="http://example.com/news/article/2006/13/">13</a></td><td>14</td><td>15</td><td>16</td><td>17</td>
+</tr>
+
+<tr>
+<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
+</tr>
+
+<tr>
+<td>25</td><td><a href="http://example.com/news/article/2006/26/">26</a></td><td>27</td><td>28</td><td>29</td><td>30</td><td>&nbsp;</td>
+</tr>
+
+</table>';
+
+ $this->assertEquals($events, $this->calendar->generate(2011, 9, $data));
+ }
+
+ function test_get_month_name()
+ {
+ $this->calendar->month_type = NULL;
+ $this->assertEquals('January', $this->calendar->get_month_name('01'));
+
+ $this->calendar->month_type = 'short';
+ $this->assertEquals('Jan', $this->calendar->get_month_name('01'));
+ }
+
+ function test_get_day_names()
+ {
+ $this->assertEquals(array(
+ 'Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'
+ ), $this->calendar->get_day_names('long'));
+
+ $this->assertEquals(array(
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat'
+ ), $this->calendar->get_day_names('short'));
+
+ $this->calendar->day_type = NULL;
+
+ $this->assertEquals(array(
+ 'Su',
+ 'Mo',
+ 'Tu',
+ 'We',
+ 'Th',
+ 'Fr',
+ 'Sa'
+ ), $this->calendar->get_day_names());
+ }
+
+ function test_adjust_date()
+ {
+ $this->assertEquals(array('month' => 8, 'year' => 2012), $this->calendar->adjust_date(8, 2012));
+ $this->assertEquals(array('month' => 1, 'year' => 2013), $this->calendar->adjust_date(13, 2012));
+ }
+
+ function test_get_total_days()
+ {
+ $this->assertEquals(0, $this->calendar->get_total_days(13, 2012));
+
+ $this->assertEquals(31, $this->calendar->get_total_days(1, 2012));
+ $this->assertEquals(28, $this->calendar->get_total_days(2, 2011));
+ $this->assertEquals(29, $this->calendar->get_total_days(2, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(3, 2012));
+ $this->assertEquals(30, $this->calendar->get_total_days(4, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(5, 2012));
+ $this->assertEquals(30, $this->calendar->get_total_days(6, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(7, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(8, 2012));
+ $this->assertEquals(30, $this->calendar->get_total_days(9, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(10, 2012));
+ $this->assertEquals(30, $this->calendar->get_total_days(11, 2012));
+ $this->assertEquals(31, $this->calendar->get_total_days(12, 2012));
+ }
+
+ function test_default_template()
+ {
+ $array = array(
+ 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
+ 'heading_row_start' => '<tr>',
+ 'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
+ 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
+ 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
+ 'heading_row_end' => '</tr>',
+ 'week_row_start' => '<tr>',
+ 'week_day_cell' => '<td>{week_day}</td>',
+ 'week_row_end' => '</tr>',
+ 'cal_row_start' => '<tr>',
+ 'cal_cell_start' => '<td>',
+ 'cal_cell_start_today' => '<td>',
+ 'cal_cell_content' => '<a href="{content}">{day}</a>',
+ 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
+ 'cal_cell_no_content' => '{day}',
+ 'cal_cell_no_content_today' => '<strong>{day}</strong>',
+ 'cal_cell_blank' => '&nbsp;',
+ 'cal_cell_end' => '</td>',
+ 'cal_cell_end_today' => '</td>',
+ 'cal_row_end' => '</tr>',
+ 'table_close' => '</table>'
+ );
+
+ $this->assertEquals($array, $this->calendar->default_template());
+ }
+
+} \ No newline at end of file
diff --git a/tests/mocks/libraries/calendar.php b/tests/mocks/libraries/calendar.php
new file mode 100644
index 000000000..8fee5365e
--- /dev/null
+++ b/tests/mocks/libraries/calendar.php
@@ -0,0 +1,25 @@
+<?php
+
+class Mock_Libraries_Calendar extends CI_Calendar {
+
+ public function __construct($config = array())
+ {
+ $this->CI = new stdClass;
+ $this->CI->lang = new Mock_Core_Lang();
+
+ if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
+ {
+ $this->CI->lang->load('calendar');
+ }
+
+ $this->local_time = time();
+
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ log_message('debug', 'Calendar Class Initialized');
+ }
+
+} \ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index eb4f1e762..578e60ec0 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -337,6 +337,7 @@ Bug fixes for 3.0
- Fixed a bug (#1613) - :doc:`Form Helper <helpers/form_helper>` functions ``form_multiselect()``, ``form_dropdown()`` didn't properly handle empty array option groups.
- Fixed a bug (#1605) - :doc:`Pagination Library <libraries/pagination>` produced incorrect *previous* and *next* link values.
- Fixed a bug in SQLSRV's ``affected_rows()`` method where an erroneous function name was used.
+- Fixed a bug (#1000) - Change syntax of $view_file to $_ci_view_file to prevent being overwritten by application.
Version 2.1.2
=============
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 3bcad7ba6..39f787402 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -884,7 +884,6 @@ Rule Parameter Description
0, 1, 2, 3, etc.
**is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural
number, but not zero: 1, 2, 3, etc.
-**is_unique** Yes Returns FALSE if the form element is not unique in a database table. is_unique[table.field]
**valid_email** No Returns FALSE if the form element does not contain a valid email address.
**valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email.
**valid_ip** No Returns FALSE if the supplied IP is not valid.