summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--application/config/config.php4
-rw-r--r--application/config/routes.php4
-rw-r--r--application/config/smileys.php64
-rw-r--r--application/config/user_agents.php3
-rw-r--r--contributing.md2
-rw-r--r--system/core/CodeIgniter.php4
-rw-r--r--system/core/Config.php16
-rw-r--r--system/core/Input.php41
-rw-r--r--system/core/Output.php4
-rw-r--r--system/core/Router.php43
-rw-r--r--system/core/URI.php122
-rw-r--r--system/core/Utf8.php4
-rw-r--r--system/database/DB.php7
-rw-r--r--system/database/DB_driver.php78
-rw-r--r--system/database/DB_forge.php36
-rw-r--r--system/database/DB_utility.php14
-rw-r--r--system/database/drivers/mssql/mssql_driver.php14
-rw-r--r--system/database/drivers/mysql/mysql_driver.php57
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php20
-rw-r--r--system/database/drivers/postgre/postgre_driver.php20
-rw-r--r--system/helpers/date_helper.php40
-rw-r--r--system/helpers/download_helper.php38
-rw-r--r--system/helpers/email_helper.php84
-rw-r--r--system/helpers/file_helper.php20
-rw-r--r--system/helpers/form_helper.php19
-rw-r--r--system/helpers/html_helper.php61
-rw-r--r--system/helpers/inflector_helper.php39
-rw-r--r--system/helpers/security_helper.php24
-rw-r--r--system/helpers/smiley_helper.php255
-rw-r--r--system/helpers/string_helper.php47
-rw-r--r--system/helpers/url_helper.php2
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php18
-rw-r--r--system/libraries/Cache/drivers/Cache_redis.php102
-rw-r--r--system/libraries/Cart.php567
-rw-r--r--system/libraries/Email.php4
-rw-r--r--system/libraries/Form_validation.php45
-rw-r--r--system/libraries/Javascript.php856
-rw-r--r--system/libraries/Javascript/Jquery.php1076
-rw-r--r--system/libraries/Javascript/index.html11
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php72
-rw-r--r--system/libraries/Table.php1
-rw-r--r--system/libraries/Upload.php4
-rw-r--r--tests/codeigniter/core/Config_test.php9
-rw-r--r--tests/codeigniter/database/DB_driver_test.php2
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php100
-rw-r--r--tests/codeigniter/helpers/email_helper_test.php24
-rw-r--r--tests/codeigniter/helpers/file_helper_test.php15
-rw-r--r--tests/codeigniter/helpers/form_helper_test.php16
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php42
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php19
-rw-r--r--tests/codeigniter/helpers/security_helper_test.php26
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php32
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php20
-rw-r--r--tests/mocks/autoloader.php1
-rw-r--r--user_guide_src/source/changelog.rst128
-rw-r--r--user_guide_src/source/conf.py4
-rw-r--r--user_guide_src/source/database/db_driver_reference.rst12
-rw-r--r--user_guide_src/source/helpers/date_helper.rst39
-rw-r--r--user_guide_src/source/helpers/download_helper.rst17
-rw-r--r--user_guide_src/source/helpers/email_helper.rst75
-rw-r--r--user_guide_src/source/helpers/file_helper.rst28
-rw-r--r--user_guide_src/source/helpers/form_helper.rst17
-rw-r--r--user_guide_src/source/helpers/html_helper.rst62
-rw-r--r--user_guide_src/source/helpers/inflector_helper.rst18
-rw-r--r--user_guide_src/source/helpers/security_helper.rst27
-rw-r--r--user_guide_src/source/helpers/smiley_helper.rst169
-rw-r--r--user_guide_src/source/helpers/string_helper.rst37
-rw-r--r--user_guide_src/source/images/smile.gifbin1156 -> 0 bytes
-rw-r--r--user_guide_src/source/installation/downloads.rst3
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst37
-rw-r--r--user_guide_src/source/installation/upgrade_310.rst2
-rw-r--r--user_guide_src/source/installation/upgrade_320.rst158
-rw-r--r--user_guide_src/source/installation/upgrading.rst1
-rw-r--r--user_guide_src/source/libraries/caching.rst2
-rw-r--r--user_guide_src/source/libraries/cart.rst398
-rw-r--r--user_guide_src/source/libraries/config.rst11
-rw-r--r--user_guide_src/source/libraries/email.rst4
-rw-r--r--user_guide_src/source/libraries/form_validation.rst4
-rw-r--r--user_guide_src/source/libraries/image_lib.rst4
-rw-r--r--user_guide_src/source/libraries/input.rst19
-rw-r--r--user_guide_src/source/libraries/javascript.rst322
-rw-r--r--user_guide_src/source/libraries/table.rst10
83 files changed, 780 insertions, 5078 deletions
diff --git a/.travis.yml b/.travis.yml
index ba2d6b31d..334cb614f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,6 @@
language: php
php:
- - 5.3
- 5.4
- 5.5
- 5.6
@@ -30,7 +29,6 @@ script: phpunit -d zend.enable_gc=0 -d date.timezone=UTC --coverage-text --confi
matrix:
allow_failures:
- - php: 5.3
- php: hhvm
- php: 7.1
exclude:
diff --git a/application/config/config.php b/application/config/config.php
index 10315220e..c088e80c0 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -63,6 +63,8 @@ $config['uri_protocol'] = 'REQUEST_URI';
| For more information please see the user guide:
|
| https://codeigniter.com/user_guide/general/urls.html
+|
+| Note: This option is ignored for CLI requests.
*/
$config['url_suffix'] = '';
@@ -157,6 +159,8 @@ $config['composer_autoload'] = FALSE;
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
+| Note: This option is ignored for CLI requests.
+|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
diff --git a/application/config/routes.php b/application/config/routes.php
index 1b45740d7..8ebf62bfa 100644
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -43,8 +43,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
-| When you set this option to TRUE, it will replace ALL dashes in the
-| controller and method URI segments.
+| When you set this option to TRUE, it will replace ALL dashes with
+| underscores in the controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
diff --git a/application/config/smileys.php b/application/config/smileys.php
deleted file mode 100644
index abf9a898d..000000000
--- a/application/config/smileys.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/*
-| -------------------------------------------------------------------
-| SMILEYS
-| -------------------------------------------------------------------
-| This file contains an array of smileys for use with the emoticon helper.
-| Individual images can be used to replace multiple smileys. For example:
-| :-) and :) use the same image replacement.
-|
-| Please see user guide for more info:
-| https://codeigniter.com/user_guide/helpers/smiley_helper.html
-|
-*/
-$smileys = array(
-
-// smiley image name width height alt
-
- ':-)' => array('grin.gif', '19', '19', 'grin'),
- ':lol:' => array('lol.gif', '19', '19', 'LOL'),
- ':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
- ':)' => array('smile.gif', '19', '19', 'smile'),
- ';-)' => array('wink.gif', '19', '19', 'wink'),
- ';)' => array('wink.gif', '19', '19', 'wink'),
- ':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
- ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
- ':-S' => array('confused.gif', '19', '19', 'confused'),
- ':wow:' => array('surprise.gif', '19', '19', 'surprised'),
- ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
- ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
- '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
- ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
- ':P' => array('raspberry.gif', '19', '19', 'raspberry'),
- ':blank:' => array('blank.gif', '19', '19', 'blank stare'),
- ':long:' => array('longface.gif', '19', '19', 'long face'),
- ':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
- ':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
- ':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
- '8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
- ':down:' => array('downer.gif', '19', '19', 'downer'),
- ':red:' => array('embarrassed.gif', '19', '19', 'red face'),
- ':sick:' => array('sick.gif', '19', '19', 'sick'),
- ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
- ':-/' => array('hmm.gif', '19', '19', 'hmmm'),
- '>:(' => array('mad.gif', '19', '19', 'mad'),
- ':mad:' => array('mad.gif', '19', '19', 'mad'),
- '>:-(' => array('angry.gif', '19', '19', 'angry'),
- ':angry:' => array('angry.gif', '19', '19', 'angry'),
- ':zip:' => array('zip.gif', '19', '19', 'zipper'),
- ':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
- ':ahhh:' => array('shock.gif', '19', '19', 'shock'),
- ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
- ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
- ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
- ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
- ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
- ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
- ':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
- ':snake:' => array('snake.gif', '19', '19', 'snake'),
- ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
- ':question:' => array('question.gif', '19', '19', 'question')
-
-);
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 798086b65..1359bbea9 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -87,7 +87,8 @@ $browsers = array(
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
- 'Ubuntu' => 'Ubuntu Web Browser'
+ 'Ubuntu' => 'Ubuntu Web Browser',
+ 'Vivaldi' => 'Vivaldi'
);
$mobiles = array(
diff --git a/contributing.md b/contributing.md
index 2037e0424..10b89b1db 100644
--- a/contributing.md
+++ b/contributing.md
@@ -29,7 +29,7 @@ If you change anything that requires a change to documentation then you will nee
### Compatibility
-CodeIgniter recommends PHP 5.4 or newer to be used, but it should be
+CodeIgniter recommends PHP 5.5 or newer to be used, but it should be
compatible with PHP 5.2.4 so all code supplied must stick to this
requirement. If PHP 5.3 (and above) functions or features are used then
there must be a fallback for PHP 5.2.4.
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index c9cb5c89f..97cac90ad 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -55,7 +55,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @var string
*
*/
- const CI_VERSION = '3.1.3-dev';
+ const CI_VERSION = '3.2.0-dev';
/*
* ------------------------------------------------------
@@ -301,7 +301,7 @@ if ( ! is_php('5.4'))
* Instantiate the URI class
* ------------------------------------------------------
*/
- $URI =& load_class('URI', 'core');
+ $URI =& load_class('URI', 'core', $CFG);
/*
* ------------------------------------------------------
diff --git a/system/core/Config.php b/system/core/Config.php
index 9fd3e4a7d..6704a0a7e 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -169,7 +169,7 @@ class CI_Config {
$this->is_loaded[] = $file_path;
$config = NULL;
$loaded = TRUE;
- log_message('debug', 'Config file loaded: '.$file_path);
+ log_message('info', 'Config file loaded: '.$file_path);
}
}
@@ -351,20 +351,6 @@ class CI_Config {
// --------------------------------------------------------------------
/**
- * System URL
- *
- * @deprecated 3.0.0 Encourages insecure practices
- * @return string
- */
- public function system_url()
- {
- $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
- return $this->slash_item('base_url').end($x).'/';
- }
-
- // --------------------------------------------------------------------
-
- /**
* Set a config file item
*
* @param string $item Config item key
diff --git a/system/core/Input.php b/system/core/Input.php
index 24fe8a9cc..ec57cd448 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -67,15 +67,6 @@ class CI_Input {
protected $_allow_get_array = TRUE;
/**
- * Standardize new lines flag
- *
- * If set to TRUE, then newlines are standardized.
- *
- * @var bool
- */
- protected $_standardize_newlines;
-
- /**
* Enable XSS flag
*
* Determines whether the XSS filter is always active when
@@ -140,7 +131,6 @@ class CI_Input {
$this->_allow_get_array = (config_item('allow_get_array') === TRUE);
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
- $this->_standardize_newlines = (bool) config_item('standardize_newlines');
$this->security =& load_class('Security', 'core');
@@ -159,6 +149,13 @@ class CI_Input {
$this->security->csrf_verify();
}
+ if ( ! empty($_POST) && config_item('standardize_newlines') === TRUE)
+ {
+ array_walk_recursive($_POST, function(&$value) {
+ $value = preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $value);
+ });
+ }
+
log_message('info', 'Input Class Initialized');
}
@@ -595,7 +592,6 @@ class CI_Input {
*
* - Unsets $_GET data, if query strings are not enabled
* - Cleans POST, COOKIE and SERVER data
- * - Standardizes newline characters to PHP_EOL
*
* @return void
*/
@@ -653,7 +649,7 @@ class CI_Input {
// Sanitize PHP_SELF
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
- log_message('debug', 'Global POST, GET and COOKIE data sanitized');
+ log_message('info', 'Global POST, GET and COOKIE data sanitized');
}
// --------------------------------------------------------------------
@@ -698,12 +694,6 @@ class CI_Input {
// Remove control characters
$str = remove_invisible_characters($str, FALSE);
- // Standardize newlines if needed
- if ($this->_standardize_newlines === TRUE)
- {
- return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
- }
-
return $str;
}
@@ -841,21 +831,6 @@ class CI_Input {
// --------------------------------------------------------------------
/**
- * Is CLI request?
- *
- * Test to see if a request was made from the command line.
- *
- * @deprecated 3.0.0 Use is_cli() instead
- * @return bool
- */
- public function is_cli_request()
- {
- return is_cli();
- }
-
- // --------------------------------------------------------------------
-
- /**
* Get Request Method
*
* Return the request method
diff --git a/system/core/Output.php b/system/core/Output.php
index 57c78ab19..94a6340e7 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -502,7 +502,7 @@ class CI_Output {
echo $output;
log_message('info', 'Final output sent to browser');
- log_message('debug', 'Total execution time: '.$elapsed);
+ log_message('info', 'Total execution time: '.$elapsed);
return;
}
@@ -539,7 +539,7 @@ class CI_Output {
}
log_message('info', 'Final output sent to browser');
- log_message('debug', 'Total execution time: '.$elapsed);
+ log_message('info', 'Total execution time: '.$elapsed);
}
// --------------------------------------------------------------------
diff --git a/system/core/Router.php b/system/core/Router.php
index 045d36687..42d0e2952 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -439,19 +439,6 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the current class
- *
- * @deprecated 3.0.0 Read the 'class' property instead
- * @return string
- */
- public function fetch_class()
- {
- return $this->class;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Set method name
*
* @param string $method Method name
@@ -465,19 +452,6 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the current method
- *
- * @deprecated 3.0.0 Read the 'method' property instead
- * @return string
- */
- public function fetch_method()
- {
- return $this->method;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Set directory name
*
* @param string $dir Directory name
@@ -495,21 +469,4 @@ class CI_Router {
$this->directory .= str_replace('.', '', trim($dir, '/')).'/';
}
}
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch directory
- *
- * Feches the sub-directory (if any) that contains the requested
- * controller class.
- *
- * @deprecated 3.0.0 Read the 'directory' property instead
- * @return string
- */
- public function fetch_directory()
- {
- return $this->directory;
- }
-
}
diff --git a/system/core/URI.php b/system/core/URI.php
index 544f6c85f..7f07bfe1e 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -96,45 +96,40 @@ class CI_URI {
*
* @return void
*/
- public function __construct()
+ public function __construct(CI_Config $config)
{
- $this->config =& load_class('Config', 'core');
+ $this->config = $config;
+ // If it's a CLI request, ignore the configuration
+ if (is_cli())
+ {
+ $this->_set_uri_string($this->_parse_argv(), TRUE);
+ }
// If query strings are enabled, we don't need to parse any segments.
- // However, they don't make sense under CLI.
- if (is_cli() OR $this->config->item('enable_query_strings') !== TRUE)
+ elseif ($this->config->item('enable_query_strings') !== TRUE)
{
$this->_permitted_uri_chars = $this->config->item('permitted_uri_chars');
+ $protocol = $this->config->item('uri_protocol');
+ empty($protocol) && $protocol = 'REQUEST_URI';
- // If it's a CLI request, ignore the configuration
- if (is_cli())
+ switch ($protocol)
{
- $uri = $this->_parse_argv();
+ case 'AUTO': // For BC purposes only
+ case 'REQUEST_URI':
+ $uri = $this->_parse_request_uri();
+ break;
+ case 'QUERY_STRING':
+ $uri = $this->_parse_query_string();
+ break;
+ case 'PATH_INFO':
+ default:
+ $uri = isset($_SERVER[$protocol])
+ ? $_SERVER[$protocol]
+ : $this->_parse_request_uri();
+ break;
}
- else
- {
- $protocol = $this->config->item('uri_protocol');
- empty($protocol) && $protocol = 'REQUEST_URI';
- switch ($protocol)
- {
- case 'AUTO': // For BC purposes only
- case 'REQUEST_URI':
- $uri = $this->_parse_request_uri();
- break;
- case 'QUERY_STRING':
- $uri = $this->_parse_query_string();
- break;
- case 'PATH_INFO':
- default:
- $uri = isset($_SERVER[$protocol])
- ? $_SERVER[$protocol]
- : $this->_parse_request_uri();
- break;
- }
- }
-
- $this->_set_uri_string($uri);
+ $this->_set_uri_string($uri, FALSE);
}
log_message('info', 'URI Class Initialized');
@@ -145,43 +140,66 @@ class CI_URI {
/**
* Set URI String
*
- * @param string $str
+ * @param string $str Input URI string
+ * @param bool $is_cli Whether the input comes from CLI
* @return void
*/
- protected function _set_uri_string($str)
+ protected function _set_uri_string($str, $is_cli = FALSE)
{
- // Filter out control characters and trim slashes
- $this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
-
- if ($this->uri_string !== '')
+ // CLI requests have a bit simpler logic
+ if ($is_cli)
{
- // Remove the URL suffix, if present
- if (($suffix = (string) $this->config->item('url_suffix')) !== '')
+ if (($this->uri_string = trim($str, '/')) === '')
{
- $slen = strlen($suffix);
-
- if (substr($this->uri_string, -$slen) === $suffix)
- {
- $this->uri_string = substr($this->uri_string, 0, -$slen);
- }
+ return;
}
$this->segments[0] = NULL;
- // Populate the segments array
- foreach (explode('/', trim($this->uri_string, '/')) as $val)
+ foreach (explode('/', $this->uri_string) as $segment)
{
- $val = trim($val);
- // Filter segments for security
- $this->filter_uri($val);
-
- if ($val !== '')
+ if (($segment = trim($segment)) !== '')
{
- $this->segments[] = $val;
+ $this->segments[] = $segment;
}
}
unset($this->segments[0]);
+ return;
+ }
+
+ // Filter out control characters and trim slashes
+ $this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
+
+ if ($this->uri_string === '')
+ {
+ return;
}
+
+ // Remove the URL suffix, if present
+ if (($suffix = (string) $this->config->item('url_suffix')) !== '')
+ {
+ $slen = strlen($suffix);
+
+ if (substr($this->uri_string, -$slen) === $suffix)
+ {
+ $this->uri_string = substr($this->uri_string, 0, -$slen);
+ }
+ }
+
+ $this->segments[0] = NULL;
+ foreach (explode('/', trim($this->uri_string, '/')) as $segment)
+ {
+ $segment = trim($segment);
+ // Filter segments for security
+ $this->filter_uri($segment);
+
+ if ($segment !== '')
+ {
+ $this->segments[] = $segment;
+ }
+ }
+
+ unset($this->segments[0]);
}
// --------------------------------------------------------------------
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index f2f42e6ca..93c611675 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -66,12 +66,12 @@ class CI_Utf8 {
)
{
define('UTF8_ENABLED', TRUE);
- log_message('debug', 'UTF-8 Support Enabled');
+ log_message('info', 'UTF-8 Support Enabled');
}
else
{
define('UTF8_ENABLED', FALSE);
- log_message('debug', 'UTF-8 Support Disabled');
+ log_message('info', 'UTF-8 Support Disabled');
}
log_message('info', 'Utf8 Class Initialized');
diff --git a/system/database/DB.php b/system/database/DB.php
index b4b7767e8..37dfdd632 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -82,7 +82,7 @@ function &DB($params = '', $query_builder_override = NULL)
}
}
- if ( ! isset($db) OR count($db) === 0)
+ if (empty($db))
{
show_error('No database connection settings were found in the database config file.');
}
@@ -192,10 +192,13 @@ function &DB($params = '', $query_builder_override = NULL)
// Load the DB driver
$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
-
file_exists($driver_file) OR show_error('Invalid DB driver');
require_once($driver_file);
+ // Load the result classes as well
+ require_once(BASEPATH.'database/DB_result.php');
+ require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_result.php');
+
// Instantiate the DB adapter
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 151340596..c142a1354 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -380,7 +380,8 @@ abstract class CI_DB_driver {
/**
* Initialize Database Settings
*
- * @return bool
+ * @return void
+ * @throws RuntimeException In case of failure
*/
public function initialize()
{
@@ -392,7 +393,7 @@ abstract class CI_DB_driver {
*/
if ($this->conn_id)
{
- return TRUE;
+ return;
}
// ----------------------------------------------------------------
@@ -429,19 +430,9 @@ abstract class CI_DB_driver {
// We still don't have a connection?
if ( ! $this->conn_id)
{
- log_message('error', 'Unable to connect to the database');
-
- if ($this->db_debug)
- {
- $this->display_error('db_unable_to_connect');
- }
-
- return FALSE;
+ throw new RuntimeException('Unable to connect to the database.');
}
}
-
- // Now we set the character set and that's all
- return $this->db_set_charset($this->char_set);
}
// --------------------------------------------------------------------
@@ -517,31 +508,6 @@ abstract class CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string
- * @return bool
- */
- public function db_set_charset($charset)
- {
- if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset))
- {
- log_message('error', 'Unable to set database connection charset: '.$charset);
-
- if ($this->db_debug)
- {
- $this->display_error('db_unable_to_set_charset', $charset);
- }
-
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* The name of the platform in use (mysql, mssql, etc...)
*
* @return string
@@ -634,7 +600,6 @@ abstract class CI_DB_driver {
// cached query if it exists
if ($this->cache_on === TRUE && $return_object === TRUE && $this->_cache_init())
{
- $this->load_rdriver();
if (FALSE !== ($cache = $this->CACHE->read($sql)))
{
return $cache;
@@ -718,9 +683,9 @@ abstract class CI_DB_driver {
return TRUE;
}
- // Load and instantiate the result driver
- $driver = $this->load_rdriver();
- $RES = new $driver($this);
+ // Instantiate the driver-specific result class
+ $driver = 'CI_DB_'.$this->dbdriver.'_result';
+ $RES = new $driver($this);
// Is query caching enabled? If so, we'll serialize the
// result object and save it to a cache file.
@@ -750,26 +715,6 @@ abstract class CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Load the result drivers
- *
- * @return string the name of the result class
- */
- public function load_rdriver()
- {
- $driver = 'CI_DB_'.$this->dbdriver.'_result';
-
- if ( ! class_exists($driver, FALSE))
- {
- require_once(BASEPATH.'database/DB_result.php');
- require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
- }
-
- return $driver;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Simple Query
* This is a simplified version of the query() function. Internally
* we only use it when running transaction commands since they do
@@ -780,14 +725,7 @@ abstract class CI_DB_driver {
*/
public function simple_query($sql)
{
- if ( ! $this->conn_id)
- {
- if ( ! $this->initialize())
- {
- return FALSE;
- }
- }
-
+ empty($this->conn_id) && $this->initialize();
return $this->_execute($sql);
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index ed6f4b672..9add5cab7 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -894,21 +894,33 @@ abstract class CI_DB_forge {
return;
}
- if (array_key_exists('DEFAULT', $attributes))
+ if ( ! array_key_exists('DEFAULT', $attributes))
{
- if ($attributes['DEFAULT'] === NULL)
- {
- $field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
+ return;
+ }
- // Override the NULL attribute if that's our default
- $attributes['NULL'] = TRUE;
- $field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
- }
- else
- {
- $field['default'] = $this->_default.$this->db->escape($attributes['DEFAULT']);
- }
+ if ($attributes['DEFAULT'] === NULL)
+ {
+ $field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
+
+ // Override the NULL attribute if that's our default
+ $attributes['NULL'] = TRUE;
+ $field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
+ return;
}
+
+ // White-list CURRENT_TIMESTAMP & similar (e.g. Oracle has stuff like SYSTIMESTAMP) defaults for date/time fields
+ if (
+ isset($attributes['TYPE'])
+ && (stripos($attributes['TYPE'], 'time') !== FALSE OR stripos($attributes['TYPE'], 'date') !== FALSE)
+ && (stripos($attributes['DEFAULT'], 'time') !== FALSE OR stripos($attributes['DEFAULT'], 'date') !== FALSE)
+ )
+ {
+ $field['default'] = $this->_default.$attributes['DEFAULT'];
+ return;
+ }
+
+ $field['default'] = $this->_default.$this->db->escape($attributes['DEFAULT']);
}
// --------------------------------------------------------------------
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 70528286c..49cd301df 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -235,13 +235,8 @@ abstract class CI_DB_utility {
* @param string $enclosure Enclosure (default: ")
* @return string
*/
- public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
+ public function csv_from_result(CI_DB_result $query, $delim = ',', $newline = "\n", $enclosure = '"')
{
- if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
- {
- show_error('You must submit a valid result object');
- }
-
$out = '';
// First generate the headings from the table column names
foreach ($query->list_fields() as $name)
@@ -274,13 +269,8 @@ abstract class CI_DB_utility {
* @param array $params Any preferences
* @return string
*/
- public function xml_from_result($query, $params = array())
+ public function xml_from_result(CI_DB_result $query, $params = array())
{
- if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
- {
- show_error('You must submit a valid result object');
- }
-
// Set our default values
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
{
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 66d7572e4..76f58564b 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -108,6 +108,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
public function db_connect($persistent = FALSE)
{
+ ini_set('mssql.charset', $this->char_set);
$this->conn_id = ($persistent)
? mssql_pconnect($this->hostname, $this->username, $this->password)
: mssql_connect($this->hostname, $this->username, $this->password);
@@ -249,19 +250,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return (ini_set('mssql.charset', $charset) !== FALSE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @return string
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 7804dda58..70b4f68ba 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -147,29 +147,41 @@ class CI_DB_mysql_driver extends CI_DB {
: FALSE;
}
- if (isset($this->stricton) && is_resource($this->conn_id))
+ if (is_resource($this->conn_id))
{
- if ($this->stricton)
+ if ( ! mysql_set_charset($this->char_set, $this->conn_id))
{
- $this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ $this->close();
+ return ($this->db->debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
}
- else
+
+ if (isset($this->stricton))
{
- $this->simple_query(
- 'SET SESSION sql_mode =
- REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
- @@sql_mode,
- "STRICT_ALL_TABLES,", ""),
- ",STRICT_ALL_TABLES", ""),
- "STRICT_ALL_TABLES", ""),
- "STRICT_TRANS_TABLES,", ""),
- ",STRICT_TRANS_TABLES", ""),
- "STRICT_TRANS_TABLES", "")'
- );
+ if ($this->stricton)
+ {
+ $this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
+ }
+ else
+ {
+ $this->simple_query(
+ 'SET SESSION sql_mode =
+ REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
+ @@sql_mode,
+ "STRICT_ALL_TABLES,", ""),
+ ",STRICT_ALL_TABLES", ""),
+ "STRICT_ALL_TABLES", ""),
+ "STRICT_TRANS_TABLES,", ""),
+ ",STRICT_TRANS_TABLES", ""),
+ "STRICT_TRANS_TABLES", "")'
+ );
+ }
}
+
+ return $this->conn_id;
}
- return $this->conn_id;
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -218,19 +230,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return mysql_set_charset($charset, $this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 4a14eea93..cf931a351 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -213,6 +213,13 @@ class CI_DB_mysqli_driver extends CI_DB {
return ($this->db->db_debug) ? $this->db->display_error($message, '', TRUE) : FALSE;
}
+ if ( ! $this->_mysqli->set_charset($this->char_set))
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ $this->_mysqli->close();
+ return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
+ }
+
return $this->_mysqli;
}
@@ -265,19 +272,6 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return $this->conn_id->set_charset($charset);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 51916fcc1..5cc6a421c 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -163,6 +163,13 @@ class CI_DB_postgre_driver extends CI_DB {
return FALSE;
}
+ if (pg_set_client_encoding($this->conn_id, $this->char_set) !== 0)
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ pg_close($this->conn_id);
+ return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
+ }
+
empty($this->schema) OR $this->simple_query('SET search_path TO '.$this->schema.',public');
}
@@ -190,19 +197,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return (pg_set_client_encoding($this->conn_id, $charset) === 0);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 0606a4562..1f8e319ca 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -122,46 +122,6 @@ if ( ! function_exists('mdate'))
// ------------------------------------------------------------------------
-if ( ! function_exists('standard_date'))
-{
- /**
- * Standard Date
- *
- * Returns a date formatted according to the submitted standard.
- *
- * As of PHP 5.2, the DateTime extension provides constants that
- * serve for the exact same purpose and are used with date().
- *
- * @todo Remove in version 3.1+.
- * @deprecated 3.0.0 Use PHP's native date() instead.
- * @link http://www.php.net/manual/en/class.datetime.php#datetime.constants.types
- *
- * @example date(DATE_RFC822, now()); // default
- * @example date(DATE_W3C, $time); // a different format and time
- *
- * @param string $fmt = 'DATE_RFC822' the chosen format
- * @param int $time = NULL Unix timestamp
- * @return string
- */
- function standard_date($fmt = 'DATE_RFC822', $time = NULL)
- {
- if (empty($time))
- {
- $time = now();
- }
-
- // Procedural style pre-defined constants from the DateTime extension
- if (strpos($fmt, 'DATE_') !== 0 OR defined($fmt) === FALSE)
- {
- return FALSE;
- }
-
- return date(constant($fmt), $time);
- }
-}
-
-// ------------------------------------------------------------------------
-
if ( ! function_exists('timespan'))
{
/**
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index a6463dfd7..9619c61b1 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -56,7 +56,7 @@ if ( ! function_exists('force_download'))
*
* Generates headers that force a download to happen
*
- * @param string filename
+ * @param mixed filename (or an array of local file path => destination filename)
* @param mixed the data to be downloaded
* @param bool whether to try and send the actual file MIME type
* @return void
@@ -69,14 +69,38 @@ if ( ! function_exists('force_download'))
}
elseif ($data === NULL)
{
- if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
+ // Is $filename an array as ['local source path' => 'destination filename']?
+ if (is_array($filename))
{
- return;
+ if (count($filename) !== 1)
+ {
+ return;
+ }
+
+ $filepath = key($filename);
+ $filename = current($filename);
+
+ if (is_int($filepath))
+ {
+ return;
+ }
+
+ if ( ! @is_file($filepath) OR ($filesize = @filesize($filepath)) === FALSE)
+ {
+ return;
+ }
+ }
+ else
+ {
+ if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
+ {
+ return;
+ }
+
+ $filepath = $filename;
+ $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
+ $filename = end($filename);
}
-
- $filepath = $filename;
- $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
- $filename = end($filename);
}
else
{
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
deleted file mode 100644
index 35944fc7b..000000000
--- a/system/helpers/email_helper.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 1.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * CodeIgniter Email Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author EllisLab Dev Team
- * @link https://codeigniter.com/user_guide/helpers/email_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('valid_email'))
-{
- /**
- * Validate email address
- *
- * @deprecated 3.0.0 Use PHP's filter_var() instead
- * @param string $email
- * @return bool
- */
- function valid_email($email)
- {
- return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('send_email'))
-{
- /**
- * Send an email
- *
- * @deprecated 3.0.0 Use PHP's mail() instead
- * @param string $recipient
- * @param string $subject
- * @param string $message
- * @return bool
- */
- function send_email($recipient, $subject, $message)
- {
- return mail($recipient, $subject, $message);
- }
-}
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 3cb36a551..484bf3228 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -49,26 +49,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
// ------------------------------------------------------------------------
-if ( ! function_exists('read_file'))
-{
- /**
- * Read File
- *
- * Opens the file specified in the path and returns it as a string.
- *
- * @todo Remove in version 3.1+.
- * @deprecated 3.0.0 It is now just an alias for PHP's native file_get_contents().
- * @param string $file Path to file
- * @return string File contents
- */
- function read_file($file)
- {
- return @file_get_contents($file);
- }
-}
-
-// ------------------------------------------------------------------------
-
if ( ! function_exists('write_file'))
{
/**
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index aa7379f77..9756437ae 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -653,25 +653,6 @@ if ( ! function_exists('form_close'))
// ------------------------------------------------------------------------
-if ( ! function_exists('form_prep'))
-{
- /**
- * Form Prep
- *
- * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
- *
- * @deprecated 3.0.0 An alias for html_escape()
- * @param string|string[] $str Value to escape
- * @return string|string[] Escaped values
- */
- function form_prep($str)
- {
- return html_escape($str, TRUE);
- }
-}
-
-// ------------------------------------------------------------------------
-
if ( ! function_exists('set_value'))
{
/**
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index fdc463fca..22ef39c2e 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -229,7 +229,7 @@ if ( ! function_exists('doctype'))
* @param string type The doctype to be generated
* @return string
*/
- function doctype($type = 'xhtml1-strict')
+ function doctype($type = 'html5')
{
static $doctypes;
@@ -360,51 +360,32 @@ if ( ! function_exists('meta'))
$name = array($name);
}
+ $allowed_types = array('charset', 'http-equiv', 'name', 'property');
$str = '';
foreach ($name as $meta)
{
- $type = (isset($meta['type']) && $meta['type'] !== 'name') ? 'http-equiv' : 'name';
- $name = isset($meta['name']) ? $meta['name'] : '';
- $content = isset($meta['content']) ? $meta['content'] : '';
- $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
+ // This is to preserve BC with pre-3.1 versions where only
+ // 'http-equiv' (default) and 'name' were supported.
+ if (isset($meta['type']))
+ {
+ if ($meta['type'] === 'equiv')
+ {
+ $meta['type'] === 'http-equiv';
+ }
+ elseif ( ! in_array($meta['type'], $allowed_types, TRUE))
+ {
+ $meta['type'] = 'name';
+ }
+ }
- $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
+ $type = isset($meta['type']) ? $meta['type'] : 'name';
+ $name = isset($meta['name']) ? $meta['name'] : '';
+ $content = isset($meta['content']) ? $meta['content'] : '';
+ $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
+
+ $str .= '<meta '.$type.'="'.$name.($type === 'charset' ? '' : '" content="'.$content).'" />'.$newline;
}
return $str;
}
}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('br'))
-{
- /**
- * Generates HTML BR tags based on number supplied
- *
- * @deprecated 3.0.0 Use str_repeat() instead
- * @param int $count Number of times to repeat the tag
- * @return string
- */
- function br($count = 1)
- {
- return str_repeat('<br />', $count);
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('nbs'))
-{
- /**
- * Generates non-breaking space entities based on number supplied
- *
- * @deprecated 3.0.0 Use str_repeat() instead
- * @param int
- * @return string
- */
- function nbs($num = 1)
- {
- return str_repeat('&nbsp;', $num);
- }
-}
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index f54dac019..f14f57c54 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -273,3 +273,42 @@ if ( ! function_exists('is_countable'))
);
}
}
+
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('ordinal_format'))
+{
+ /**
+ * Returns the English ordinal numeral for a given number
+ *
+ * @param int $number
+ * @return string
+ */
+ function ordinal_format($number)
+ {
+ if ( ! ctype_digit((string) $number) OR $number < 1)
+ {
+ return $number;
+ }
+
+ $last_digit = array(
+ 0 => 'th',
+ 1 => 'st',
+ 2 => 'nd',
+ 3 => 'rd',
+ 4 => 'th',
+ 5 => 'th',
+ 6 => 'th',
+ 7 => 'th',
+ 8 => 'th',
+ 9 => 'th'
+ );
+
+ if (($number % 100) >= 11 && ($number % 100) <= 13)
+ {
+ return $number.'th';
+ }
+
+ return $number.$last_digit[$number % 10];
+ }
+}
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 4eb63883d..048f06b68 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -80,30 +80,6 @@ if ( ! function_exists('sanitize_filename'))
}
}
-// --------------------------------------------------------------------
-
-if ( ! function_exists('do_hash'))
-{
- /**
- * Hash encode a string
- *
- * @todo Remove in version 3.1+.
- * @deprecated 3.0.0 Use PHP's native hash() instead.
- * @param string $str
- * @param string $type = 'sha1'
- * @return string
- */
- function do_hash($str, $type = 'sha1')
- {
- if ( ! in_array(strtolower($type), hash_algos()))
- {
- $type = 'md5';
- }
-
- return hash($type, $str);
- }
-}
-
// ------------------------------------------------------------------------
if ( ! function_exists('strip_image_tags'))
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
deleted file mode 100644
index 688ca24c2..000000000
--- a/system/helpers/smiley_helper.php
+++ /dev/null
@@ -1,255 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 1.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * CodeIgniter Smiley Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author EllisLab Dev Team
- * @link https://codeigniter.com/user_guide/helpers/smiley_helper.html
- * @deprecated 3.0.0 This helper is too specific for CI.
- */
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('smiley_js'))
-{
- /**
- * Smiley Javascript
- *
- * Returns the javascript required for the smiley insertion. Optionally takes
- * an array of aliases to loosely couple the smiley array to the view.
- *
- * @param mixed alias name or array of alias->field_id pairs
- * @param string field_id if alias name was passed in
- * @param bool
- * @return array
- */
- function smiley_js($alias = '', $field_id = '', $inline = TRUE)
- {
- static $do_setup = TRUE;
- $r = '';
-
- if ($alias !== '' && ! is_array($alias))
- {
- $alias = array($alias => $field_id);
- }
-
- if ($do_setup === TRUE)
- {
- $do_setup = FALSE;
- $m = array();
-
- if (is_array($alias))
- {
- foreach ($alias as $name => $id)
- {
- $m[] = '"'.$name.'" : "'.$id.'"';
- }
- }
-
- $m = '{'.implode(',', $m).'}';
-
- $r .= <<<EOF
- var smiley_map = {$m};
-
- function insert_smiley(smiley, field_id) {
- var el = document.getElementById(field_id), newStart;
-
- if ( ! el && smiley_map[field_id]) {
- el = document.getElementById(smiley_map[field_id]);
-
- if ( ! el)
- return false;
- }
-
- el.focus();
- smiley = " " + smiley;
-
- if ('selectionStart' in el) {
- newStart = el.selectionStart + smiley.length;
-
- el.value = el.value.substr(0, el.selectionStart) +
- smiley +
- el.value.substr(el.selectionEnd, el.value.length);
- el.setSelectionRange(newStart, newStart);
- }
- else if (document.selection) {
- document.selection.createRange().text = smiley;
- }
- }
-EOF;
- }
- elseif (is_array($alias))
- {
- foreach ($alias as $name => $id)
- {
- $r .= 'smiley_map["'.$name.'"] = "'.$id."\";\n";
- }
- }
-
- return ($inline)
- ? '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>'
- : $r;
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('get_clickable_smileys'))
-{
- /**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @param string the URL to the folder containing the smiley images
- * @param array
- * @return array
- */
- function get_clickable_smileys($image_url, $alias = '')
- {
- // For backward compatibility with js_insert_smiley
- if (is_array($alias))
- {
- $smileys = $alias;
- }
- elseif (FALSE === ($smileys = _get_smiley_array()))
- {
- return FALSE;
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = rtrim($image_url, '/').'/';
-
- $used = array();
- foreach ($smileys as $key => $val)
- {
- // Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
- // :-) and :) might be replaced with the same image so both smileys
- // will be in the array.
- if (isset($used[$smileys[$key][0]]))
- {
- continue;
- }
-
- $link[] = '<a href="javascript:void(0);" onclick="insert_smiley(\''.$key.'\', \''.$alias.'\')"><img src="'.$image_url.$smileys[$key][0].'" alt="'.$smileys[$key][3].'" style="width: '.$smileys[$key][1].'; height: '.$smileys[$key][2].'; border: 0;" /></a>';
- $used[$smileys[$key][0]] = TRUE;
- }
-
- return $link;
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('parse_smileys'))
-{
- /**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @param array
- * @return string
- */
- function parse_smileys($str = '', $image_url = '', $smileys = NULL)
- {
- if ($image_url === '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())))
- {
- return $str;
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = rtrim($image_url, '/').'/';
-
- foreach ($smileys as $key => $val)
- {
- $str = str_replace($key, '<img src="'.$image_url.$smileys[$key][0].'" alt="'.$smileys[$key][3].'" style="width: '.$smileys[$key][1].'; height: '.$smileys[$key][2].'; border: 0;" />', $str);
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('_get_smiley_array'))
-{
- /**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @return mixed
- */
- function _get_smiley_array()
- {
- static $_smileys;
-
- if ( ! is_array($_smileys))
- {
- if (file_exists(APPPATH.'config/smileys.php'))
- {
- include(APPPATH.'config/smileys.php');
- }
-
- if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
- }
-
- if (empty($smileys) OR ! is_array($smileys))
- {
- $_smileys = array();
- return FALSE;
- }
-
- $_smileys = $smileys;
- }
-
- return $_smileys;
- }
-}
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index db531fa9a..62b1a18e0 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -49,33 +49,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
// ------------------------------------------------------------------------
-if ( ! function_exists('trim_slashes'))
-{
- /**
- * Trim Slashes
- *
- * Removes any leading/trailing slashes from a string:
- *
- * /this/that/theother/
- *
- * becomes:
- *
- * this/that/theother
- *
- * @todo Remove in version 3.1+.
- * @deprecated 3.0.0 This is just an alias for PHP's native trim()
- *
- * @param string
- * @return string
- */
- function trim_slashes($str)
- {
- return trim($str, '/');
- }
-}
-
-// ------------------------------------------------------------------------
-
if ( ! function_exists('strip_slashes'))
{
/**
@@ -284,23 +257,3 @@ if ( ! function_exists('alternator'))
return $args[($i++ % count($args))];
}
}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('repeater'))
-{
- /**
- * Repeater function
- *
- * @todo Remove in version 3.1+.
- * @deprecated 3.0.0 This is just an alias for PHP's native str_repeat()
- *
- * @param string $data String to repeat
- * @param int $num Number of repeats
- * @return string
- */
- function repeater($data, $num = 1)
- {
- return ($num > 0) ? str_repeat($data, $num) : '';
- }
-}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index fd7b5e116..8a5a75c44 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -443,7 +443,7 @@ if ( ! function_exists('prep_url'))
*/
function prep_url($str = '')
{
- if ($str === 'http://' OR $str === '')
+ if ($str === '')
{
return '';
}
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 836336d46..ab8bfab8b 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -102,10 +102,22 @@ class CI_Cache_memcached extends CI_Driver {
return;
}
- foreach ($this->_config as $cache_server)
+ foreach ($this->_config as $cache_name => $cache_server)
{
- isset($cache_server['hostname']) OR $cache_server['hostname'] = $defaults['host'];
- isset($cache_server['port']) OR $cache_server['port'] = $defaults['port'];
+ if ( ! isset($cache_server['hostname']))
+ {
+ log_message('debug', 'Cache: Memcache(d) configuration "'.$cache_name.'" doesn\'t include a hostname; ignoring.');
+ continue;
+ }
+ elseif ($cache_server['hostname'][0] === '/')
+ {
+ $cache_server['port'] = 0;
+ }
+ elseif (empty($cache_server['port']))
+ {
+ $cache_server['port'] = $defaults['port'];
+ }
+
isset($cache_server['weight']) OR $cache_server['weight'] = $defaults['weight'];
if ($this->_memcached instanceof Memcache)
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php
index d4d95ebb1..2d1ead452 100644
--- a/system/libraries/Cache/drivers/Cache_redis.php
+++ b/system/libraries/Cache/drivers/Cache_redis.php
@@ -55,11 +55,11 @@ class CI_Cache_redis extends CI_Driver
* @var array
*/
protected static $_default_config = array(
- 'socket_type' => 'tcp',
'host' => '127.0.0.1',
'password' => NULL,
'port' => 6379,
- 'timeout' => 0
+ 'timeout' => 0,
+ 'database' => 0
);
/**
@@ -69,13 +69,6 @@ class CI_Cache_redis extends CI_Driver
*/
protected $_redis;
- /**
- * An internal cache for storing keys of serialized values.
- *
- * @var array
- */
- protected $_serialized = array();
-
// ------------------------------------------------------------------------
/**
@@ -112,16 +105,7 @@ class CI_Cache_redis extends CI_Driver
try
{
- if ($config['socket_type'] === 'unix')
- {
- $success = $this->_redis->connect($config['socket']);
- }
- else // tcp socket
- {
- $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']);
- }
-
- if ( ! $success)
+ if ( ! $this->_redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']))
{
log_message('error', 'Cache: Redis connection failed. Check your configuration.');
}
@@ -130,15 +114,16 @@ class CI_Cache_redis extends CI_Driver
{
log_message('error', 'Cache: Redis authentication failed.');
}
+
+ if (isset($config['database']) && $config['database'] > 0 && ! $this->_redis->select($config['database']))
+ {
+ log_message('error', 'Cache: Redis select database failed.');
+ }
}
catch (RedisException $e)
{
log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')');
}
-
- // Initialize the index of serialized values.
- $serialized = $this->_redis->sMembers('_ci_redis_serialized');
- empty($serialized) OR $this->_serialized = array_flip($serialized);
}
// ------------------------------------------------------------------------
@@ -151,14 +136,30 @@ class CI_Cache_redis extends CI_Driver
*/
public function get($key)
{
- $value = $this->_redis->get($key);
+ $data = $this->_redis->hMGet($key, array('__ci_type', '__ci_value'));
- if ($value !== FALSE && isset($this->_serialized[$key]))
+ if ( ! isset($data['__ci_type'], $data['__ci_value']) OR $data['__ci_value'] === FALSE)
{
- return unserialize($value);
+ return FALSE;
}
- return $value;
+ switch ($data['__ci_type'])
+ {
+ case 'array':
+ case 'object':
+ return unserialize($data['__ci_value']);
+ case 'boolean':
+ case 'integer':
+ case 'double': // Yes, 'double' is returned and NOT 'float'
+ case 'string':
+ case 'NULL':
+ return settype($data['__ci_value'], $data['__ci_type'])
+ ? $data['__ci_value']
+ : FALSE;
+ case 'resource':
+ default:
+ return FALSE;
+ }
}
// ------------------------------------------------------------------------
@@ -174,23 +175,33 @@ class CI_Cache_redis extends CI_Driver
*/
public function save($id, $data, $ttl = 60, $raw = FALSE)
{
- if (is_array($data) OR is_object($data))
+ switch ($data_type = gettype($data))
{
- if ( ! $this->_redis->sIsMember('_ci_redis_serialized', $id) && ! $this->_redis->sAdd('_ci_redis_serialized', $id))
- {
+ case 'array':
+ case 'object':
+ $data = serialize($data);
+ break;
+ case 'boolean':
+ case 'integer':
+ case 'double': // Yes, 'double' is returned and NOT 'float'
+ case 'string':
+ case 'NULL':
+ break;
+ case 'resource':
+ default:
return FALSE;
- }
+ }
- isset($this->_serialized[$id]) OR $this->_serialized[$id] = TRUE;
- $data = serialize($data);
+ if ( ! $this->_redis->hMSet($id, array('__ci_type' => $data_type, '__ci_value' => $data)))
+ {
+ return FALSE;
}
- elseif (isset($this->_serialized[$id]))
+ elseif ($ttl)
{
- $this->_serialized[$id] = NULL;
- $this->_redis->sRemove('_ci_redis_serialized', $id);
+ $this->_redis->expireAt($id, time() + $ttl);
}
- return $this->_redis->set($id, $data, $ttl);
+ return TRUE;
}
// ------------------------------------------------------------------------
@@ -203,18 +214,7 @@ class CI_Cache_redis extends CI_Driver
*/
public function delete($key)
{
- if ($this->_redis->delete($key) !== 1)
- {
- return FALSE;
- }
-
- if (isset($this->_serialized[$key]))
- {
- $this->_serialized[$key] = NULL;
- $this->_redis->sRemove('_ci_redis_serialized', $key);
- }
-
- return TRUE;
+ return ($this->_redis->delete($key) === 1);
}
// ------------------------------------------------------------------------
@@ -228,7 +228,7 @@ class CI_Cache_redis extends CI_Driver
*/
public function increment($id, $offset = 1)
{
- return $this->_redis->incr($id, $offset);
+ return $this->_redis->hIncrBy($id, 'data', $offset);
}
// ------------------------------------------------------------------------
@@ -242,7 +242,7 @@ class CI_Cache_redis extends CI_Driver
*/
public function decrement($id, $offset = 1)
{
- return $this->_redis->decr($id, $offset);
+ return $this->_redis->hIncrBy($id, 'data', -$offset);
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
deleted file mode 100644
index 44d87e0bf..000000000
--- a/system/libraries/Cart.php
+++ /dev/null
@@ -1,567 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 1.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * Shopping Cart Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Shopping Cart
- * @author EllisLab Dev Team
- * @link https://codeigniter.com/user_guide/libraries/cart.html
- * @deprecated 3.0.0 This class is too specific for CI.
- */
-class CI_Cart {
-
- /**
- * These are the regular expression rules that we use to validate the product ID and product name
- * alpha-numeric, dashes, underscores, or periods
- *
- * @var string
- */
- public $product_id_rules = '\.a-z0-9_-';
-
- /**
- * These are the regular expression rules that we use to validate the product ID and product name
- * alpha-numeric, dashes, underscores, colons or periods
- *
- * @var string
- */
- public $product_name_rules = '\w \-\.\:';
-
- /**
- * only allow safe product names
- *
- * @var bool
- */
- public $product_name_safe = TRUE;
-
- // --------------------------------------------------------------------------
-
- /**
- * Reference to CodeIgniter instance
- *
- * @var object
- */
- protected $CI;
-
- /**
- * Contents of the cart
- *
- * @var array
- */
- protected $_cart_contents = array();
-
- /**
- * Shopping Class Constructor
- *
- * The constructor loads the Session class, used to store the shopping cart contents.
- *
- * @param array
- * @return void
- */
- public function __construct($params = array())
- {
- // Set the super object to a local variable for use later
- $this->CI =& get_instance();
-
- // Are any config settings being passed manually? If so, set them
- $config = is_array($params) ? $params : array();
-
- // Load the Sessions class
- $this->CI->load->driver('session', $config);
-
- // Grab the shopping cart array from the session table
- $this->_cart_contents = $this->CI->session->userdata('cart_contents');
- if ($this->_cart_contents === NULL)
- {
- // No cart exists so we'll set some base values
- $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0);
- }
-
- log_message('info', 'Cart Class Initialized');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Insert items into the cart and save it to the session table
- *
- * @param array
- * @return bool
- */
- public function insert($items = array())
- {
- // Was any cart data passed? No? Bah...
- if ( ! is_array($items) OR count($items) === 0)
- {
- log_message('error', 'The insert method must be passed an array containing data.');
- return FALSE;
- }
-
- // You can either insert a single product using a one-dimensional array,
- // or multiple products using a multi-dimensional one. The way we
- // determine the array type is by looking for a required array key named "id"
- // at the top level. If it's not found, we will assume it's a multi-dimensional array.
-
- $save_cart = FALSE;
- if (isset($items['id']))
- {
- if (($rowid = $this->_insert($items)))
- {
- $save_cart = TRUE;
- }
- }
- else
- {
- foreach ($items as $val)
- {
- if (is_array($val) && isset($val['id']))
- {
- if ($this->_insert($val))
- {
- $save_cart = TRUE;
- }
- }
- }
- }
-
- // Save the cart data if the insert was successful
- if ($save_cart === TRUE)
- {
- $this->_save_cart();
- return isset($rowid) ? $rowid : TRUE;
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Insert
- *
- * @param array
- * @return bool
- */
- protected function _insert($items = array())
- {
- // Was any cart data passed? No? Bah...
- if ( ! is_array($items) OR count($items) === 0)
- {
- log_message('error', 'The insert method must be passed an array containing data.');
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- // Does the $items array contain an id, quantity, price, and name? These are required
- if ( ! isset($items['id'], $items['qty'], $items['price'], $items['name']))
- {
- log_message('error', 'The cart array must contain a product ID, quantity, price, and name.');
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- // Prep the quantity. It can only be a number. Duh... also trim any leading zeros
- $items['qty'] = (float) $items['qty'];
-
- // If the quantity is zero or blank there's nothing for us to do
- if ($items['qty'] == 0)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- // Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods
- // Not totally sure we should impose this rule, but it seems prudent to standardize IDs.
- // Note: These can be user-specified by setting the $this->product_id_rules variable.
- if ( ! preg_match('/^['.$this->product_id_rules.']+$/i', $items['id']))
- {
- log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores');
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods.
- // Note: These can be user-specified by setting the $this->product_name_rules variable.
- if ($this->product_name_safe && ! preg_match('/^['.$this->product_name_rules.']+$/i'.(UTF8_ENABLED ? 'u' : ''), $items['name']))
- {
- log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- // Prep the price. Remove leading zeros and anything that isn't a number or decimal point.
- $items['price'] = (float) $items['price'];
-
- // We now need to create a unique identifier for the item being inserted into the cart.
- // Every time something is added to the cart it is stored in the master cart array.
- // Each row in the cart array, however, must have a unique index that identifies not only
- // a particular product, but makes it possible to store identical products with different options.
- // For example, what if someone buys two identical t-shirts (same product ID), but in
- // different sizes? The product ID (and other attributes, like the name) will be identical for
- // both sizes because it's the same shirt. The only difference will be the size.
- // Internally, we need to treat identical submissions, but with different options, as a unique product.
- // Our solution is to convert the options array to a string and MD5 it along with the product ID.
- // This becomes the unique "row ID"
- if (isset($items['options']) && count($items['options']) > 0)
- {
- $rowid = md5($items['id'].serialize($items['options']));
- }
- else
- {
- // No options were submitted so we simply MD5 the product ID.
- // Technically, we don't need to MD5 the ID in this case, but it makes
- // sense to standardize the format of array indexes for both conditions
- $rowid = md5($items['id']);
- }
-
- // --------------------------------------------------------------------
-
- // Now that we have our unique "row ID", we'll add our cart items to the master array
- // grab quantity if it's already there and add it on
- $old_quantity = isset($this->_cart_contents[$rowid]['qty']) ? (int) $this->_cart_contents[$rowid]['qty'] : 0;
-
- // Re-create the entry, just to make sure our index contains only the data from this submission
- $items['rowid'] = $rowid;
- $items['qty'] += $old_quantity;
- $this->_cart_contents[$rowid] = $items;
-
- return $rowid;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update the cart
- *
- * This function permits the quantity of a given item to be changed.
- * Typically it is called from the "view cart" page if a user makes
- * changes to the quantity before checkout. That array must contain the
- * product ID and quantity for each item.
- *
- * @param array
- * @return bool
- */
- public function update($items = array())
- {
- // Was any cart data passed?
- if ( ! is_array($items) OR count($items) === 0)
- {
- return FALSE;
- }
-
- // You can either update a single product using a one-dimensional array,
- // or multiple products using a multi-dimensional one. The way we
- // determine the array type is by looking for a required array key named "rowid".
- // If it's not found we assume it's a multi-dimensional array
- $save_cart = FALSE;
- if (isset($items['rowid']))
- {
- if ($this->_update($items) === TRUE)
- {
- $save_cart = TRUE;
- }
- }
- else
- {
- foreach ($items as $val)
- {
- if (is_array($val) && isset($val['rowid']))
- {
- if ($this->_update($val) === TRUE)
- {
- $save_cart = TRUE;
- }
- }
- }
- }
-
- // Save the cart data if the insert was successful
- if ($save_cart === TRUE)
- {
- $this->_save_cart();
- return TRUE;
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update the cart
- *
- * This function permits changing item properties.
- * Typically it is called from the "view cart" page if a user makes
- * changes to the quantity before checkout. That array must contain the
- * rowid and quantity for each item.
- *
- * @param array
- * @return bool
- */
- protected function _update($items = array())
- {
- // Without these array indexes there is nothing we can do
- if ( ! isset($items['rowid'], $this->_cart_contents[$items['rowid']]))
- {
- return FALSE;
- }
-
- // Prep the quantity
- if (isset($items['qty']))
- {
- $items['qty'] = (float) $items['qty'];
- // Is the quantity zero? If so we will remove the item from the cart.
- // If the quantity is greater than zero we are updating
- if ($items['qty'] == 0)
- {
- unset($this->_cart_contents[$items['rowid']]);
- return TRUE;
- }
- }
-
- // find updatable keys
- $keys = array_intersect(array_keys($this->_cart_contents[$items['rowid']]), array_keys($items));
- // if a price was passed, make sure it contains valid data
- if (isset($items['price']))
- {
- $items['price'] = (float) $items['price'];
- }
-
- // product id & name shouldn't be changed
- foreach (array_diff($keys, array('id', 'name')) as $key)
- {
- $this->_cart_contents[$items['rowid']][$key] = $items[$key];
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Save the cart array to the session DB
- *
- * @return bool
- */
- protected function _save_cart()
- {
- // Let's add up the individual prices and set the cart sub-total
- $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0;
- foreach ($this->_cart_contents as $key => $val)
- {
- // We make sure the array contains the proper indexes
- if ( ! is_array($val) OR ! isset($val['price'], $val['qty']))
- {
- continue;
- }
-
- $this->_cart_contents['cart_total'] += ($val['price'] * $val['qty']);
- $this->_cart_contents['total_items'] += $val['qty'];
- $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']);
- }
-
- // Is our cart empty? If so we delete it from the session
- if (count($this->_cart_contents) <= 2)
- {
- $this->CI->session->unset_userdata('cart_contents');
-
- // Nothing more to do... coffee time!
- return FALSE;
- }
-
- // If we made it this far it means that our cart has data.
- // Let's pass it to the Session class so it can be stored
- $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));
-
- // Woot!
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Cart Total
- *
- * @return int
- */
- public function total()
- {
- return $this->_cart_contents['cart_total'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Remove Item
- *
- * Removes an item from the cart
- *
- * @param int
- * @return bool
- */
- public function remove($rowid)
- {
- // unset & save
- unset($this->_cart_contents[$rowid]);
- $this->_save_cart();
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total Items
- *
- * Returns the total item count
- *
- * @return int
- */
- public function total_items()
- {
- return $this->_cart_contents['total_items'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Cart Contents
- *
- * Returns the entire cart array
- *
- * @param bool
- * @return array
- */
- public function contents($newest_first = FALSE)
- {
- // do we want the newest first?
- $cart = ($newest_first) ? array_reverse($this->_cart_contents) : $this->_cart_contents;
-
- // Remove these so they don't create a problem when showing the cart table
- unset($cart['total_items']);
- unset($cart['cart_total']);
-
- return $cart;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get cart item
- *
- * Returns the details of a specific item in the cart
- *
- * @param string $row_id
- * @return array
- */
- public function get_item($row_id)
- {
- return (in_array($row_id, array('total_items', 'cart_total'), TRUE) OR ! isset($this->_cart_contents[$row_id]))
- ? FALSE
- : $this->_cart_contents[$row_id];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Has options
- *
- * Returns TRUE if the rowid passed to this function correlates to an item
- * that has options associated with it.
- *
- * @param string $row_id = ''
- * @return bool
- */
- public function has_options($row_id = '')
- {
- return (isset($this->_cart_contents[$row_id]['options']) && count($this->_cart_contents[$row_id]['options']) !== 0);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Product options
- *
- * Returns the an array of options, for a particular product row ID
- *
- * @param string $row_id = ''
- * @return array
- */
- public function product_options($row_id = '')
- {
- return isset($this->_cart_contents[$row_id]['options']) ? $this->_cart_contents[$row_id]['options'] : array();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Number
- *
- * Returns the supplied number with commas and a decimal point.
- *
- * @param float
- * @return string
- */
- public function format_number($n = '')
- {
- return ($n === '') ? '' : number_format( (float) $n, 2, '.', ',');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Destroy the cart
- *
- * Empties the cart and kills the session
- *
- * @return void
- */
- public function destroy()
- {
- $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0);
- $this->CI->session->unset_userdata('cart_contents');
- }
-
-}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 2e6f5be90..90a68f129 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -147,7 +147,7 @@ class CI_Email {
*
* @var string
*/
- public $charset = 'UTF-8';
+ public $charset = 'utf-8';
/**
* Alternative message (for HTML messages only)
@@ -161,7 +161,7 @@ class CI_Email {
*
* @var bool
*/
- public $validate = FALSE;
+ public $validate = TRUE;
/**
* X-Priority header value.
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index c39b65d89..c2bc22f95 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -164,7 +164,7 @@ class CI_Form_validation {
* @param array $errors
* @return CI_Form_validation
*/
- public function set_rules($field, $label = '', $rules = array(), $errors = array())
+ public function set_rules($field, $label = null, $rules = null, $errors = array())
{
// No reason to set rules if we have no POST data
// or a validation array has not been specified
@@ -197,6 +197,10 @@ class CI_Form_validation {
return $this;
}
+ elseif ( ! isset($rules))
+ {
+ throw new BadMethodCallException('Form_validation: set_rules() called without a $rules parameter');
+ }
// No fields or no rules? Nothing to do...
if ( ! is_string($field) OR $field === '' OR empty($rules))
@@ -1484,38 +1488,6 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
- * Prep data for form
- *
- * This function allows HTML to be safely shown in a form.
- * Special characters are converted.
- *
- * @deprecated 3.0.6 Not used anywhere within the framework and pretty much useless
- * @param mixed $data Input data
- * @return mixed
- */
- public function prep_for_form($data)
- {
- if ($this->_safe_form_data === FALSE OR empty($data))
- {
- return $data;
- }
-
- if (is_array($data))
- {
- foreach ($data as $key => $val)
- {
- $data[$key] = $this->prep_for_form($val);
- }
-
- return $data;
- }
-
- return str_replace(array("'", '"', '<', '>'), array('&#39;', '&quot;', '&lt;', '&gt;'), stripslashes($data));
- }
-
- // --------------------------------------------------------------------
-
- /**
* Prep URL
*
* @param string
@@ -1523,12 +1495,7 @@ class CI_Form_validation {
*/
public function prep_url($str = '')
{
- if ($str === 'http://' OR $str === '')
- {
- return '';
- }
-
- if (strpos($str, 'http://') !== 0 && strpos($str, 'https://') !== 0)
+ if ($str !== '' && stripos($str, 'http://') !== 0 && stripos($str, 'https://') !== 0)
{
return 'http://'.$str;
}
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
deleted file mode 100644
index dcf933779..000000000
--- a/system/libraries/Javascript.php
+++ /dev/null
@@ -1,856 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 1.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * Javascript Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Javascript
- * @author EllisLab Dev Team
- * @link https://codeigniter.com/user_guide/libraries/javascript.html
- * @deprecated 3.0.0 This was never a good idea in the first place.
- */
-class CI_Javascript {
-
- /**
- * JavaScript location
- *
- * @var string
- */
- protected $_javascript_location = 'js';
-
- // --------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param array $params
- * @return void
- */
- public function __construct($params = array())
- {
- $defaults = array('js_library_driver' => 'jquery', 'autoload' => TRUE);
-
- foreach ($defaults as $key => $val)
- {
- if (isset($params[$key]) && $params[$key] !== '')
- {
- $defaults[$key] = $params[$key];
- }
- }
-
- extract($defaults);
-
- $this->CI =& get_instance();
-
- // load the requested js library
- $this->CI->load->library('Javascript/'.$js_library_driver, array('autoload' => $autoload));
- // make js to refer to current library
- $this->js =& $this->CI->$js_library_driver;
-
- log_message('info', 'Javascript Class Initialized and loaded. Driver used: '.$js_library_driver);
- }
-
- // --------------------------------------------------------------------
- // Event Code
- // --------------------------------------------------------------------
-
- /**
- * Blur
- *
- * Outputs a javascript library blur event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function blur($element = 'this', $js = '')
- {
- return $this->js->_blur($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Change
- *
- * Outputs a javascript library change event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function change($element = 'this', $js = '')
- {
- return $this->js->_change($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Click
- *
- * Outputs a javascript library click event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @param bool whether or not to return false
- * @return string
- */
- public function click($element = 'this', $js = '', $ret_false = TRUE)
- {
- return $this->js->_click($element, $js, $ret_false);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Double Click
- *
- * Outputs a javascript library dblclick event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function dblclick($element = 'this', $js = '')
- {
- return $this->js->_dblclick($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Error
- *
- * Outputs a javascript library error event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function error($element = 'this', $js = '')
- {
- return $this->js->_error($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Focus
- *
- * Outputs a javascript library focus event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function focus($element = 'this', $js = '')
- {
- return $this->js->_focus($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Hover
- *
- * Outputs a javascript library hover event
- *
- * @param string - element
- * @param string - Javascript code for mouse over
- * @param string - Javascript code for mouse out
- * @return string
- */
- public function hover($element = 'this', $over = '', $out = '')
- {
- return $this->js->_hover($element, $over, $out);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Keydown
- *
- * Outputs a javascript library keydown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function keydown($element = 'this', $js = '')
- {
- return $this->js->_keydown($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Keyup
- *
- * Outputs a javascript library keydown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function keyup($element = 'this', $js = '')
- {
- return $this->js->_keyup($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Load
- *
- * Outputs a javascript library load event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function load($element = 'this', $js = '')
- {
- return $this->js->_load($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mousedown
- *
- * Outputs a javascript library mousedown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function mousedown($element = 'this', $js = '')
- {
- return $this->js->_mousedown($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouse Out
- *
- * Outputs a javascript library mouseout event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function mouseout($element = 'this', $js = '')
- {
- return $this->js->_mouseout($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouse Over
- *
- * Outputs a javascript library mouseover event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function mouseover($element = 'this', $js = '')
- {
- return $this->js->_mouseover($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouseup
- *
- * Outputs a javascript library mouseup event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function mouseup($element = 'this', $js = '')
- {
- return $this->js->_mouseup($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Output
- *
- * Outputs the called javascript to the screen
- *
- * @param string The code to output
- * @return string
- */
- public function output($js)
- {
- return $this->js->_output($js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Ready
- *
- * Outputs a javascript library mouseup event
- *
- * @param string $js Code to execute
- * @return string
- */
- public function ready($js)
- {
- return $this->js->_document_ready($js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Resize
- *
- * Outputs a javascript library resize event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function resize($element = 'this', $js = '')
- {
- return $this->js->_resize($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Scroll
- *
- * Outputs a javascript library scroll event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function scroll($element = 'this', $js = '')
- {
- return $this->js->_scroll($element, $js);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Unload
- *
- * Outputs a javascript library unload event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- public function unload($element = 'this', $js = '')
- {
- return $this->js->_unload($element, $js);
- }
-
- // --------------------------------------------------------------------
- // Effects
- // --------------------------------------------------------------------
-
- /**
- * Add Class
- *
- * Outputs a javascript library addClass event
- *
- * @param string - element
- * @param string - Class to add
- * @return string
- */
- public function addClass($element = 'this', $class = '')
- {
- return $this->js->_addClass($element, $class);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Animate
- *
- * Outputs a javascript library animate event
- *
- * @param string $element = 'this'
- * @param array $params = array()
- * @param mixed $speed 'slow', 'normal', 'fast', or time in milliseconds
- * @param string $extra
- * @return string
- */
- public function animate($element = 'this', $params = array(), $speed = '', $extra = '')
- {
- return $this->js->_animate($element, $params, $speed, $extra);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fade In
- *
- * Outputs a javascript library hide event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function fadeIn($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_fadeIn($element, $speed, $callback);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fade Out
- *
- * Outputs a javascript library hide event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function fadeOut($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_fadeOut($element, $speed, $callback);
- }
- // --------------------------------------------------------------------
-
- /**
- * Slide Up
- *
- * Outputs a javascript library slideUp event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function slideUp($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_slideUp($element, $speed, $callback);
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Remove Class
- *
- * Outputs a javascript library removeClass event
- *
- * @param string - element
- * @param string - Class to add
- * @return string
- */
- public function removeClass($element = 'this', $class = '')
- {
- return $this->js->_removeClass($element, $class);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Slide Down
- *
- * Outputs a javascript library slideDown event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function slideDown($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_slideDown($element, $speed, $callback);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Slide Toggle
- *
- * Outputs a javascript library slideToggle event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function slideToggle($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_slideToggle($element, $speed, $callback);
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Hide
- *
- * Outputs a javascript library hide action
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function hide($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_hide($element, $speed, $callback);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Toggle
- *
- * Outputs a javascript library toggle event
- *
- * @param string - element
- * @return string
- */
- public function toggle($element = 'this')
- {
- return $this->js->_toggle($element);
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Toggle Class
- *
- * Outputs a javascript library toggle class event
- *
- * @param string $element = 'this'
- * @param string $class = ''
- * @return string
- */
- public function toggleClass($element = 'this', $class = '')
- {
- return $this->js->_toggleClass($element, $class);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show
- *
- * Outputs a javascript library show event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function show($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_show($element, $speed, $callback);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Compile
- *
- * gather together all script needing to be output
- *
- * @param string $view_var
- * @param bool $script_tags
- * @return string
- */
- public function compile($view_var = 'script_foot', $script_tags = TRUE)
- {
- $this->js->_compile($view_var, $script_tags);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clear Compile
- *
- * Clears any previous javascript collected for output
- *
- * @return void
- */
- public function clear_compile()
- {
- $this->js->_clear_compile();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * External
- *
- * Outputs a <script> tag with the source as an external js file
- *
- * @param string $external_file
- * @param bool $relative
- * @return string
- */
- public function external($external_file = '', $relative = FALSE)
- {
- if ($external_file !== '')
- {
- $this->_javascript_location = $external_file;
- }
- elseif ($this->CI->config->item('javascript_location') !== '')
- {
- $this->_javascript_location = $this->CI->config->item('javascript_location');
- }
-
- if ($relative === TRUE OR strpos($external_file, 'http://') === 0 OR strpos($external_file, 'https://') === 0)
- {
- $str = $this->_open_script($external_file);
- }
- elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
- {
- $str = $this->_open_script($this->_javascript_location.$external_file);
- }
- else
- {
- $str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file);
- }
-
- return $str.$this->_close_script();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Inline
- *
- * Outputs a <script> tag
- *
- * @param string The element to attach the event to
- * @param bool If a CDATA section should be added
- * @return string
- */
- public function inline($script, $cdata = TRUE)
- {
- return $this->_open_script()
- . ($cdata ? "\n// <![CDATA[\n".$script."\n// ]]>\n" : "\n".$script."\n")
- . $this->_close_script();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Open Script
- *
- * Outputs an opening <script>
- *
- * @param string
- * @return string
- */
- protected function _open_script($src = '')
- {
- return '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"'
- .($src === '' ? '>' : ' src="'.$src.'">');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Close Script
- *
- * Outputs an closing </script>
- *
- * @param string
- * @return string
- */
- protected function _close_script($extra = "\n")
- {
- return '</script>'.$extra;
- }
-
- // --------------------------------------------------------------------
- // AJAX-Y STUFF - still a testbed
- // --------------------------------------------------------------------
-
- /**
- * Update
- *
- * Outputs a javascript library slideDown event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- public function update($element = 'this', $speed = '', $callback = '')
- {
- return $this->js->_updater($element, $speed, $callback);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate JSON
- *
- * Can be passed a database result or associative array and returns a JSON formatted string
- *
- * @param mixed result set or array
- * @param bool match array types (defaults to objects)
- * @return string a json formatted string
- */
- public function generate_json($result = NULL, $match_array_type = FALSE)
- {
- // JSON data can optionally be passed to this function
- // either as a database result object or an array, or a user supplied array
- if ($result !== NULL)
- {
- if (is_object($result))
- {
- $json_result = is_callable(array($result, 'result_array')) ? $result->result_array() : (array) $result;
- }
- elseif (is_array($result))
- {
- $json_result = $result;
- }
- else
- {
- return $this->_prep_args($result);
- }
- }
- else
- {
- return 'null';
- }
-
- $json = array();
- $_is_assoc = TRUE;
-
- if ( ! is_array($json_result) && empty($json_result))
- {
- show_error('Generate JSON Failed - Illegal key, value pair.');
- }
- elseif ($match_array_type)
- {
- $_is_assoc = $this->_is_associative_array($json_result);
- }
-
- foreach ($json_result as $k => $v)
- {
- if ($_is_assoc)
- {
- $json[] = $this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type);
- }
- else
- {
- $json[] = $this->generate_json($v, $match_array_type);
- }
- }
-
- $json = implode(',', $json);
-
- return $_is_assoc ? '{'.$json.'}' : '['.$json.']';
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Is associative array
- *
- * Checks for an associative array
- *
- * @param array
- * @return bool
- */
- protected function _is_associative_array($arr)
- {
- foreach (array_keys($arr) as $key => $val)
- {
- if ($key !== $val)
- {
- return TRUE;
- }
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep Args
- *
- * Ensures a standard json value and escapes values
- *
- * @param mixed $result
- * @param bool $is_key = FALSE
- * @return string
- */
- protected function _prep_args($result, $is_key = FALSE)
- {
- if ($result === NULL)
- {
- return 'null';
- }
- elseif (is_bool($result))
- {
- return ($result === TRUE) ? 'true' : 'false';
- }
- elseif (is_string($result) OR $is_key)
- {
- return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
- }
- elseif (is_scalar($result))
- {
- return $result;
- }
- }
-
-}
diff --git a/system/libraries/Javascript/Jquery.php b/system/libraries/Javascript/Jquery.php
deleted file mode 100644
index 9df1be1c1..000000000
--- a/system/libraries/Javascript/Jquery.php
+++ /dev/null
@@ -1,1076 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 1.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * Jquery Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Loader
- * @author EllisLab Dev Team
- * @link https://codeigniter.com/user_guide/libraries/javascript.html
- */
-class CI_Jquery extends CI_Javascript {
-
- /**
- * JavaScript directory location
- *
- * @var string
- */
- protected $_javascript_folder = 'js';
-
- /**
- * JQuery code for load
- *
- * @var array
- */
- public $jquery_code_for_load = array();
-
- /**
- * JQuery code for compile
- *
- * @var array
- */
- public $jquery_code_for_compile = array();
-
- /**
- * JQuery corner active flag
- *
- * @var bool
- */
- public $jquery_corner_active = FALSE;
-
- /**
- * JQuery table sorter active flag
- *
- * @var bool
- */
- public $jquery_table_sorter_active = FALSE;
-
- /**
- * JQuery table sorter pager active
- *
- * @var bool
- */
- public $jquery_table_sorter_pager_active = FALSE;
-
- /**
- * JQuery AJAX image
- *
- * @var string
- */
- public $jquery_ajax_img = '';
-
- // --------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param array $params
- * @return void
- */
- public function __construct($params)
- {
- $this->CI =& get_instance();
- extract($params);
-
- if ($autoload === TRUE)
- {
- $this->script();
- }
-
- log_message('info', 'Jquery Class Initialized');
- }
-
- // --------------------------------------------------------------------
- // Event Code
- // --------------------------------------------------------------------
-
- /**
- * Blur
- *
- * Outputs a jQuery blur event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _blur($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'blur');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Change
- *
- * Outputs a jQuery change event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _change($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'change');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Click
- *
- * Outputs a jQuery click event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @param bool whether or not to return false
- * @return string
- */
- protected function _click($element = 'this', $js = '', $ret_false = TRUE)
- {
- is_array($js) OR $js = array($js);
-
- if ($ret_false)
- {
- $js[] = 'return false;';
- }
-
- return $this->_add_event($element, $js, 'click');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Double Click
- *
- * Outputs a jQuery dblclick event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _dblclick($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'dblclick');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Error
- *
- * Outputs a jQuery error event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _error($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'error');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Focus
- *
- * Outputs a jQuery focus event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _focus($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'focus');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Hover
- *
- * Outputs a jQuery hover event
- *
- * @param string - element
- * @param string - Javascript code for mouse over
- * @param string - Javascript code for mouse out
- * @return string
- */
- protected function _hover($element = 'this', $over = '', $out = '')
- {
- $event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
-
- $this->jquery_code_for_compile[] = $event;
-
- return $event;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Keydown
- *
- * Outputs a jQuery keydown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _keydown($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'keydown');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Keyup
- *
- * Outputs a jQuery keydown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _keyup($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'keyup');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Load
- *
- * Outputs a jQuery load event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _load($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'load');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mousedown
- *
- * Outputs a jQuery mousedown event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _mousedown($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'mousedown');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouse Out
- *
- * Outputs a jQuery mouseout event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _mouseout($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'mouseout');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouse Over
- *
- * Outputs a jQuery mouseover event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _mouseover($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'mouseover');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mouseup
- *
- * Outputs a jQuery mouseup event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _mouseup($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'mouseup');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Output
- *
- * Outputs script directly
- *
- * @param array $array_js = array()
- * @return void
- */
- protected function _output($array_js = array())
- {
- if ( ! is_array($array_js))
- {
- $array_js = array($array_js);
- }
-
- foreach ($array_js as $js)
- {
- $this->jquery_code_for_compile[] = "\t".$js."\n";
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Resize
- *
- * Outputs a jQuery resize event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _resize($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'resize');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Scroll
- *
- * Outputs a jQuery scroll event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _scroll($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'scroll');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Unload
- *
- * Outputs a jQuery unload event
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @return string
- */
- protected function _unload($element = 'this', $js = '')
- {
- return $this->_add_event($element, $js, 'unload');
- }
-
- // --------------------------------------------------------------------
- // Effects
- // --------------------------------------------------------------------
-
- /**
- * Add Class
- *
- * Outputs a jQuery addClass event
- *
- * @param string $element
- * @param string $class
- * @return string
- */
- protected function _addClass($element = 'this', $class = '')
- {
- $element = $this->_prep_element($element);
- return '$('.$element.').addClass("'.$class.'");';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Animate
- *
- * Outputs a jQuery animate event
- *
- * @param string $element
- * @param array $params
- * @param string $speed 'slow', 'normal', 'fast', or time in milliseconds
- * @param string $extra
- * @return string
- */
- protected function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- $animations = "\t\t\t";
-
- foreach ($params as $param => $value)
- {
- $animations .= $param.": '".$value."', ";
- }
-
- $animations = substr($animations, 0, -2); // remove the last ", "
-
- if ($speed !== '')
- {
- $speed = ', '.$speed;
- }
-
- if ($extra !== '')
- {
- $extra = ', '.$extra;
- }
-
- return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fade In
- *
- * Outputs a jQuery hide event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _fadeIn($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return "$({$element}).fadeIn({$speed}{$callback});";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fade Out
- *
- * Outputs a jQuery hide event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _fadeOut($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return '$('.$element.').fadeOut('.$speed.$callback.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Hide
- *
- * Outputs a jQuery hide action
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _hide($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return "$({$element}).hide({$speed}{$callback});";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Remove Class
- *
- * Outputs a jQuery remove class event
- *
- * @param string $element
- * @param string $class
- * @return string
- */
- protected function _removeClass($element = 'this', $class = '')
- {
- $element = $this->_prep_element($element);
- return '$('.$element.').removeClass("'.$class.'");';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Slide Up
- *
- * Outputs a jQuery slideUp event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _slideUp($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return '$('.$element.').slideUp('.$speed.$callback.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Slide Down
- *
- * Outputs a jQuery slideDown event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _slideDown($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return '$('.$element.').slideDown('.$speed.$callback.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Slide Toggle
- *
- * Outputs a jQuery slideToggle event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _slideToggle($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return '$('.$element.').slideToggle('.$speed.$callback.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Toggle
- *
- * Outputs a jQuery toggle event
- *
- * @param string - element
- * @return string
- */
- protected function _toggle($element = 'this')
- {
- $element = $this->_prep_element($element);
- return '$('.$element.').toggle();';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Toggle Class
- *
- * Outputs a jQuery toggle class event
- *
- * @param string $element
- * @param string $class
- * @return string
- */
- protected function _toggleClass($element = 'this', $class = '')
- {
- $element = $this->_prep_element($element);
- return '$('.$element.').toggleClass("'.$class.'");';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show
- *
- * Outputs a jQuery show event
- *
- * @param string - element
- * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
- * @param string - Javascript callback function
- * @return string
- */
- protected function _show($element = 'this', $speed = '', $callback = '')
- {
- $element = $this->_prep_element($element);
- $speed = $this->_validate_speed($speed);
-
- if ($callback !== '')
- {
- $callback = ", function(){\n{$callback}\n}";
- }
-
- return '$('.$element.').show('.$speed.$callback.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Updater
- *
- * An Ajax call that populates the designated DOM node with
- * returned content
- *
- * @param string The element to attach the event to
- * @param string the controller to run the call against
- * @param string optional parameters
- * @return string
- */
-
- protected function _updater($container = 'this', $controller = '', $options = '')
- {
- $container = $this->_prep_element($container);
- $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller);
-
- // ajaxStart and ajaxStop are better choices here... but this is a stop gap
- if ($this->CI->config->item('javascript_ajax_img') === '')
- {
- $loading_notifier = 'Loading...';
- }
- else
- {
- $loading_notifier = '<img src="'.$this->CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'" alt="Loading" />';
- }
-
- $updater = '$('.$container.").empty();\n" // anything that was in... get it out
- ."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image
-
- $request_options = '';
- if ($options !== '')
- {
- $request_options .= ', {'
- .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'")
- .'}';
- }
-
- return $updater."\t\t$($container).load('$controller'$request_options);";
- }
-
- // --------------------------------------------------------------------
- // Pre-written handy stuff
- // --------------------------------------------------------------------
-
- /**
- * Zebra tables
- *
- * @param string $class
- * @param string $odd
- * @param string $hover
- * @return string
- */
- protected function _zebraTables($class = '', $odd = 'odd', $hover = '')
- {
- $class = ($class !== '') ? '.'.$class : '';
- $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
-
- $this->jquery_code_for_compile[] = $zebra;
-
- if ($hover !== '')
- {
- $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');");
- }
-
- return $zebra;
- }
-
- // --------------------------------------------------------------------
- // Plugins
- // --------------------------------------------------------------------
-
- /**
- * Corner Plugin
- *
- * @link http://www.malsup.com/jquery/corner/
- * @param string $element
- * @param string $corner_style
- * @return string
- */
- public function corner($element = '', $corner_style = '')
- {
- // may want to make this configurable down the road
- $corner_location = '/plugins/jquery.corner.js';
-
- if ($corner_style !== '')
- {
- $corner_style = '"'.$corner_style.'"';
- }
-
- return '$('.$this->_prep_element($element).').corner('.$corner_style.');';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Modal window
- *
- * Load a thickbox modal window
- *
- * @param string $src
- * @param bool $relative
- * @return void
- */
- public function modal($src, $relative = FALSE)
- {
- $this->jquery_code_for_load[] = $this->external($src, $relative);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Effect
- *
- * Load an Effect library
- *
- * @param string $src
- * @param bool $relative
- * @return void
- */
- public function effect($src, $relative = FALSE)
- {
- $this->jquery_code_for_load[] = $this->external($src, $relative);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Plugin
- *
- * Load a plugin library
- *
- * @param string $src
- * @param bool $relative
- * @return void
- */
- public function plugin($src, $relative = FALSE)
- {
- $this->jquery_code_for_load[] = $this->external($src, $relative);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * UI
- *
- * Load a user interface library
- *
- * @param string $src
- * @param bool $relative
- * @return void
- */
- public function ui($src, $relative = FALSE)
- {
- $this->jquery_code_for_load[] = $this->external($src, $relative);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Sortable
- *
- * Creates a jQuery sortable
- *
- * @param string $element
- * @param array $options
- * @return string
- */
- public function sortable($element, $options = array())
- {
- if (count($options) > 0)
- {
- $sort_options = array();
- foreach ($options as $k=>$v)
- {
- $sort_options[] = "\n\t\t".$k.': '.$v;
- }
- $sort_options = implode(',', $sort_options);
- }
- else
- {
- $sort_options = '';
- }
-
- return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Table Sorter Plugin
- *
- * @param string table name
- * @param string plugin location
- * @return string
- */
- public function tablesorter($table = '', $options = '')
- {
- $this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n";
- }
-
- // --------------------------------------------------------------------
- // Class functions
- // --------------------------------------------------------------------
-
- /**
- * Add Event
- *
- * Constructs the syntax for an event, and adds to into the array for compilation
- *
- * @param string The element to attach the event to
- * @param string The code to execute
- * @param string The event to pass
- * @return string
- */
- protected function _add_event($element, $js, $event)
- {
- if (is_array($js))
- {
- $js = implode("\n\t\t", $js);
- }
-
- $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n";
- $this->jquery_code_for_compile[] = $event;
- return $event;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Compile
- *
- * As events are specified, they are stored in an array
- * This function compiles them all for output on a page
- *
- * @param string $view_var
- * @param bool $script_tags
- * @return void
- */
- protected function _compile($view_var = 'script_foot', $script_tags = TRUE)
- {
- // External references
- $external_scripts = implode('', $this->jquery_code_for_load);
- $this->CI->load->vars(array('library_src' => $external_scripts));
-
- if (count($this->jquery_code_for_compile) === 0)
- {
- // no inline references, let's just return
- return;
- }
-
- // Inline references
- $script = '$(document).ready(function() {'."\n"
- .implode('', $this->jquery_code_for_compile)
- .'});';
-
- $output = ($script_tags === FALSE) ? $script : $this->inline($script);
-
- $this->CI->load->vars(array($view_var => $output));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clear Compile
- *
- * Clears the array of script events collected for output
- *
- * @return void
- */
- protected function _clear_compile()
- {
- $this->jquery_code_for_compile = array();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Document Ready
- *
- * A wrapper for writing document.ready()
- *
- * @param array $js
- * @return void
- */
- protected function _document_ready($js)
- {
- is_array($js) OR $js = array($js);
-
- foreach ($js as $script)
- {
- $this->jquery_code_for_compile[] = $script;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Script Tag
- *
- * Outputs the script tag that loads the jquery.js file into an HTML document
- *
- * @param string $library_src
- * @param bool $relative
- * @return string
- */
- public function script($library_src = '', $relative = FALSE)
- {
- $library_src = $this->external($library_src, $relative);
- $this->jquery_code_for_load[] = $library_src;
- return $library_src;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep Element
- *
- * Puts HTML element in quotes for use in jQuery code
- * unless the supplied element is the Javascript 'this'
- * object, in which case no quotes are added
- *
- * @param string
- * @return string
- */
- protected function _prep_element($element)
- {
- if ($element !== 'this')
- {
- $element = '"'.$element.'"';
- }
-
- return $element;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate Speed
- *
- * Ensures the speed parameter is valid for jQuery
- *
- * @param string
- * @return string
- */
- protected function _validate_speed($speed)
- {
- if (in_array($speed, array('slow', 'normal', 'fast')))
- {
- return '"'.$speed.'"';
- }
- elseif (preg_match('/[^0-9]/', $speed))
- {
- return '';
- }
-
- return $speed;
- }
-
-}
diff --git a/system/libraries/Javascript/index.html b/system/libraries/Javascript/index.html
deleted file mode 100644
index b702fbc39..000000000
--- a/system/libraries/Javascript/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>403 Forbidden</title>
-</head>
-<body>
-
-<p>Directory access is forbidden.</p>
-
-</body>
-</html>
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index a780100b1..233b15619 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -92,27 +92,40 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
log_message('error', 'Session: No Redis save path configured.');
}
- elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->_config['save_path'], $matches))
+ elseif (preg_match('#^unix://([^\?]+)(?<options>\?.+)?$#', $this->_config['save_path'], $matches))
{
- isset($matches[3]) OR $matches[3] = ''; // Just to avoid undefined index notices below
- $this->_config['save_path'] = array(
- 'host' => $matches[1],
- 'port' => empty($matches[2]) ? NULL : $matches[2],
- 'password' => preg_match('#auth=([^\s&]+)#', $matches[3], $match) ? $match[1] : NULL,
- 'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : NULL,
- 'timeout' => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : NULL
+ $save_path = array('path' => $matches[1]);
+ }
+ elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(?<options>\?.+)?#', $this->_config['save_path'], $matches))
+ {
+ $save_path = array(
+ 'host' => $matches[1],
+ 'port' => empty($matches[2]) ? NULL : $matches[2],
+ 'timeout' => NULL // We always pass this to Redis::connect(), so it needs to exist
);
-
- preg_match('#prefix=([^\s&]+)#', $matches[3], $match) && $this->_key_prefix = $match[1];
}
else
{
log_message('error', 'Session: Invalid Redis save path format: '.$this->_config['save_path']);
}
- if ($this->_config['match_ip'] === TRUE)
+ if (isset($save_path))
{
- $this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
+ if (isset($matches['options']))
+ {
+ $save_path['password'] = preg_match('#auth=([^\s&]+)#', $matches['options'], $match) ? $match[1] : NULL;
+ $save_path['database'] = preg_match('#database=(\d+)#', $matches['options'], $match) ? (int) $match[1] : NULL;
+ $save_path['timeout'] = preg_match('#timeout=(\d+\.\d+)#', $matches['options'], $match) ? (float) $match[1] : NULL;
+
+ preg_match('#prefix=([^\s&]+)#', $matches['options'], $match) && $this->_key_prefix = $match[1];
+ }
+
+ $this->_config['save_path'] = $save_path;
+
+ if ($this->_config['match_ip'] === TRUE)
+ {
+ $this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
+ }
}
}
@@ -135,22 +148,33 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
}
$redis = new Redis();
- if ( ! $redis->connect($this->_config['save_path']['host'], $this->_config['save_path']['port'], $this->_config['save_path']['timeout']))
- {
- log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
- }
- elseif (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
- {
- log_message('error', 'Session: Unable to authenticate to Redis instance.');
- }
- elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
+ $connected = isset($this->_config['save_path']['path'])
+ ? $redis->connect($this->_config['save_path']['path'])
+ : $redis->connect(
+ $this->_config['save_path']['host'],
+ $this->_config['save_path']['port'],
+ $this->_config['save_path']['timeout']
+ );
+
+ if ($connected)
{
- log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
+ if (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
+ {
+ log_message('error', 'Session: Unable to authenticate to Redis instance.');
+ }
+ elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
+ {
+ log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
+ }
+ else
+ {
+ $this->_redis = $redis;
+ return $this->_success;
+ }
}
else
{
- $this->_redis = $redis;
- return $this->_success;
+ log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
}
return $this->_fail();
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index f2fa434d9..2f1b3b414 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -427,6 +427,7 @@ class CI_Table {
$this->rows = array();
$this->heading = array();
$this->auto_heading = TRUE;
+ $this->caption = NULL;
return $this;
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 778ed6892..490421af9 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1259,9 +1259,7 @@ class CI_Upload {
*/
if (DIRECTORY_SEPARATOR !== '\\')
{
- $cmd = function_exists('escapeshellarg')
- ? 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'
- : 'file --brief --mime '.$file['tmp_name'].' 2>&1';
+ $cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1';
if (function_usable('exec'))
{
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index b5c9e849d..5201d46dc 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -152,13 +152,6 @@ class Config_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_system_url()
- {
- $this->assertEquals($this->cfg['base_url'].'system/', $this->config->system_url());
- }
-
- // --------------------------------------------------------------------
-
public function test_load()
{
// Test regular load
@@ -237,4 +230,4 @@ class Config_test extends CI_TestCase {
$this->assertNull($this->config->load($file));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
index 26416d3fc..13e9abf84 100644
--- a/tests/codeigniter/database/DB_driver_test.php
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -7,8 +7,6 @@ class DB_driver_test extends CI_TestCase {
$config = Mock_Database_DB::config(DB_DRIVER);
sscanf(DB_DRIVER, '%[^/]/', $driver_name);
$driver = $this->{$driver_name}($config[DB_DRIVER]);
-
- $this->assertTrue($driver->initialize());
}
protected function pdo($config)
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index 8a3502280..00139de5c 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -73,106 +73,6 @@ class Date_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
- public function test_standard_date_rfc822()
- {
- $this->assertEquals(
- date(DATE_RFC822, $this->time),
- standard_date('DATE_RFC822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_atom()
- {
- $this->assertEquals(
- date(DATE_ATOM, $this->time),
- standard_date('DATE_ATOM', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_cookie()
- {
- $this->assertEquals(
- date(DATE_COOKIE, $this->time),
- standard_date('DATE_COOKIE', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_iso8601()
- {
- $this->assertEquals(
- date(DATE_ISO8601, $this->time),
- standard_date('DATE_ISO8601', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc850()
- {
- $this->assertEquals(
- date(DATE_RFC850, $this->time),
- standard_date('DATE_RFC850', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1036()
- {
- $this->assertEquals(
- date(DATE_RFC1036, $this->time),
- standard_date('DATE_RFC1036', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1123()
- {
- $this->assertEquals(
- date(DATE_RFC1123, $this->time),
- standard_date('DATE_RFC1123', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc2822()
- {
- $this->assertEquals(
- date(DATE_RFC2822, $this->time),
- standard_date('DATE_RFC2822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rss()
- {
- $this->assertEquals(
- date(DATE_RSS, $this->time),
- standard_date('DATE_RSS', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_w3c()
- {
- $this->assertEquals(
- date(DATE_W3C, $this->time),
- standard_date('DATE_W3C', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
public function test_timespan()
{
$this->ci_vfs_clone('system/language/english/date_lang.php');
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
deleted file mode 100644
index 529e96910..000000000
--- a/tests/codeigniter/helpers/email_helper_test.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class Email_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('email');
- }
-
- public function test_valid_email()
- {
- $this->assertEquals(FALSE, valid_email('test'));
- $this->assertEquals(FALSE, valid_email('test@test@test.com'));
- $this->assertEquals(TRUE, valid_email('test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@subdomain.test.com'));
- }
-
- public function test_send_mail()
- {
- $this->markTestSkipped("Can't test");
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php
index c31817595..5ed8cb5c0 100644
--- a/tests/codeigniter/helpers/file_helper_test.php
+++ b/tests/codeigniter/helpers/file_helper_test.php
@@ -14,19 +14,6 @@ class File_helper_Test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_read_file()
- {
- $this->assertFalse(read_file('does_not_exist'));
-
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt')->withContent($content)->at($this->_test_dir);
-
- $this->assertEquals($content, read_file(vfsStream::url('my_file.txt')));
- }
-
- // --------------------------------------------------------------------
-
public function test_octal_permissions()
{
$content = 'Jack and Jill went up the mountain to fight a billy goat.';
@@ -144,4 +131,4 @@ class File_helper_Test extends CI_TestCase {
$this->assertTrue(write_file(vfsStream::url('write.txt'), $content));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
index b5fe99b96..4ecfaa5f7 100644
--- a/tests/codeigniter/helpers/form_helper_test.php
+++ b/tests/codeigniter/helpers/form_helper_test.php
@@ -271,20 +271,4 @@ EOH;
$this->assertEquals($expected, form_close('</div></div>'));
}
-
- // ------------------------------------------------------------------------
-
- public function test_form_prep()
- {
- $this->assertEquals(
- 'Here is a string containing &quot;quoted&quot; text.',
- form_prep('Here is a string containing "quoted" text.')
- );
-
- $this->assertEquals(
- 'Here is a string containing a &lt;tag&gt;.',
- form_prep('Here is a string containing a <tag>.', TRUE)
- );
- }
-
}
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
index d66ad895c..5565e011b 100644
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -9,13 +9,6 @@ class Html_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
- public function test_br()
- {
- $this->assertEquals('<br /><br />', br(2));
- }
-
- // ------------------------------------------------------------------------
-
public function test_heading()
{
$this->assertEquals('<h1>foobar</h1>', heading('foobar'));
@@ -72,21 +65,26 @@ EOH;
// ------------------------------------------------------------------------
- public function test_NBS()
- {
- $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
- }
-
- // ------------------------------------------------------------------------
-
public function test_meta()
{
- $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
-
- $expect = "<meta name=\"foo\" content=\"\" />\n";
-
- $this->assertEquals($expect, meta(array('name' => 'foo')));
-
+ $this->assertEquals(
+ "<meta name=\"test\" content=\"foo\" />\n",
+ meta('test', 'foo')
+ );
+
+ $this->assertEquals(
+ "<meta name=\"foo\" content=\"\" />\n",
+ meta(array('name' => 'foo'))
+ );
+
+ $this->assertEquals(
+ "<meta charset=\"foo\" />\n",
+ meta(array('name' => 'foo', 'type' => 'charset'))
+ );
+
+ $this->assertEquals(
+ "<meta charset=\"foo\" />\n",
+ meta(array('name' => 'foo', 'type' => 'charset'))
+ );
}
-
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
index 81ce5e394..4a1e64fae 100644
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -93,4 +93,23 @@ class Inflector_helper_test extends CI_TestCase {
}
}
+ // --------------------------------------------------------------------
+
+ public function test_ordinal_format()
+ {
+ $strs = array(
+ 1 => '1st',
+ 2 => '2nd',
+ 4 => '4th',
+ 11 => '11th',
+ 12 => '12th',
+ 13 => '13th',
+ 'something else' => 'something else',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, ordinal_format($str));
+ }
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/security_helper_test.php b/tests/codeigniter/helpers/security_helper_test.php
index effd3ec02..ab05d57ba 100644
--- a/tests/codeigniter/helpers/security_helper_test.php
+++ b/tests/codeigniter/helpers/security_helper_test.php
@@ -25,30 +25,6 @@ class Security_helper_tests extends CI_TestCase {
$this->assertEquals('foo', sanitize_filename($filename));
}
- function test_do_hash()
- {
- $md5 = md5('foo');
- $sha1 = sha1('foo');
-
- $algos = hash_algos();
- $algo_results = array();
- foreach ($algos as $k => $v)
- {
- $algo_results[$v] = hash($v, 'foo');
- }
-
- $this->assertEquals($sha1, do_hash('foo'));
- $this->assertEquals($sha1, do_hash('foo', 'sha1'));
- $this->assertEquals($md5, do_hash('foo', 'md5'));
- $this->assertEquals($md5, do_hash('foo', 'foobar'));
-
- // Test each algorithm available to PHP
- foreach ($algo_results as $algo => $result)
- {
- $this->assertEquals($result, do_hash('foo', $algo));
- }
- }
-
function test_strip_image_tags()
{
$this->assertEquals('http://example.com/spacer.gif', strip_image_tags('http://example.com/spacer.gif'));
@@ -61,4 +37,4 @@ class Security_helper_tests extends CI_TestCase {
$this->assertEquals('&lt;? echo $foo; ?&gt;', encode_php_tags('<? echo $foo; ?>'));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
index 75701ec13..6de336b01 100644
--- a/tests/codeigniter/helpers/string_helper_test.php
+++ b/tests/codeigniter/helpers/string_helper_test.php
@@ -22,19 +22,6 @@ class String_helper_test extends CI_TestCase {
$this->assertEquals($expected, strip_slashes($str));
}
- public function test_trim_slashes()
- {
- $strs = array(
- '//Slashes//\/' => 'Slashes//\\',
- '/var/www/html/' => 'var/www/html'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, trim_slashes($str));
- }
- }
-
// --------------------------------------------------------------------
public function test_strip_quotes()
@@ -108,23 +95,6 @@ class String_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_repeater()
- {
- $strs = array(
- 'a' => 'aaaaaaaaaa',
- '&nbsp;' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
- '<br>' => '<br><br><br><br><br><br><br><br><br><br>'
-
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, repeater($str, 10));
- }
- }
-
- // --------------------------------------------------------------------
-
public function test_random_string()
{
$this->assertEquals(16, strlen(random_string('alnum', 16)));
@@ -145,4 +115,4 @@ class String_helper_test extends CI_TestCase {
$this->assertEquals(124, increment_string('123', ''));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index 0815300e6..4be080f90 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -435,6 +435,12 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($form_validation->run('fail'));
}
+ public function test_set_rules_exception()
+ {
+ $this->setExpectedException('BadMethodCallException');
+ $this->form_validation->set_rules('foo', 'bar');
+ }
+
public function test_has_rule()
{
$this->form_validation->reset_validation();
@@ -573,20 +579,6 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($this->form_validation->regex_match('bar', $regex));
}
- public function test_prep_for_form()
- {
- $this->form_validation->reset_validation();
- $error_msg_unprepped = '<error =\'foobar\'">';
- $error_msg_prepped = '&lt;error =&#39;foobar&#39;&quot;&gt;';
- $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $error_msg_unprepped));
- $_POST = array('foo' => '');
- $this->form_validation->run();
- $error_arr = $this->form_validation->error_array();
-
- $this->assertEquals('', $this->form_validation->prep_for_form(''));
- $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr));
- }
-
public function test_prep_url()
{
$this->assertEquals('', $this->form_validation->prep_url(''));
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index 11825de2c..a912327ca 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -33,7 +33,6 @@ function autoload($class)
$ci_libraries = array(
'Calendar',
- 'Cart',
'Driver_Library',
'Email',
'Encrypt',
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 25a301440..6adb5073a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -2,6 +2,70 @@
Change Log
##########
+Version 3.2.0
+=============
+
+Release Date: Not Released
+
+- Core
+
+ - Changed :doc:`URI Library <libraries/uri>` to ignore the ``$config['url_suffix']``, ``$config['permitted_uri_chars']`` configuration settings for CLI requests.
+ - Removed previously deprecated :doc:`Input Library <libraries/input>` method ``is_cli_request()`` (use :php:func:`is_cli()` instead).
+ - Removed previously deprecated :doc:`Routing Class <general/routing>` methods ``fetch_directory()``, ``fetch_class()`` and ``fetch_method()`` (use the respective class properties instead).
+ - Removed previously deprecated :doc:`Config Library <libraries/config>` method ``system_url()`` (encourages insecure practices).
+ - Removed previously deprecated :doc:`Form Validation Library <libraries/form_validation>` method ``prep_for_form()`` / rule *prep_for_form*.
+ - Removed previously deprecated :doc:`Date Helper <helpers/date_helper>` function ``standard_date()`` (use PHP's native ``date()`` instead).
+ - Removed previously deprecated :doc:`Security Helper <helpers/security_helper>` function ``do_hash()`` (use PHP's native ``hash()`` instead).
+ - Removed previously deprecated :doc:`HTML Helper <helpers/html_helper>` functions ``br()`` and ``nbs()`` (use PHP's native ``str_repeat()`` with ``'<br />'`` and ``'&nbsp;'`` respectively).
+ - Removed previously deprecated :doc:`String Helper <helpers/string_helper>` functions ``trim_slashes()`` and ``repeater()`` (use PHP's native ``trim()`` with ``'/'`` and ``str_repeat()`` respectively).
+ - Removed previously deprecated :doc:`File Helper <helpers/file_helper>` function ``read_file()`` (use PHP's native ``file_get_contents()`` instead).
+ - Removed previously deprecated :doc:`Form Helper <helpers/form_helper>` function ``form_prep()`` (use :php:func:`html_escape()` instead).
+ - Removed previously deprecated *Email Helper* (had only two functions, aliases for PHP's native ``filter_var()`` and ``mail()``).
+ - Removed previously deprecated *Smiley Helper*.
+ - Removed previously deprecated *Cart Library*.
+ - Removed previously deprecated *Javascript Library* (it was always experimental in the first place).
+
+- Libraries
+
+ - Added UNIX socket connection support to :doc:`Session Library <libraries/sessions>` 'redis' driver.
+
+ - :doc:`Cache Library <libraries/caching>` changes include:
+
+ - Added UNIX socket connection support to the 'memcached' driver.
+ - Added 'database' configuration option to the 'redis' driver, allowing to auto-select another database.
+ - Changed the 'memcached' driver to ignore configurations that don't specify a hostname.
+ - Removed the *socket_type* configuration setting from the 'redis' driver.
+ - Changed data serialization logic in 'redis' driver for better performance.
+
+ - :doc:`Form Validation Library <libraries/form_validation>` changes include:
+
+ - Changed method ``set_rules()`` to throw a ``BadMethodCallException`` when its first parameter is not an array and the ``$rules`` one is unused.
+
+ - :doc:`HTML Table Library <libraries/table>` changes include:
+
+ - Changed method ``clear()`` to also reset captions.
+
+ - :doc:`Email Library <libraries/email>` changes include:
+
+ - Changed the default value of the **validate** option to ``TRUE``.
+
+- :doc:`Database <database/index>`
+
+ - Changed method ``initialize()`` to return void and instead throw a ``RuntimeException`` in case of failure.
+ - Changed method ``db_connect()`` to always set the connection character set (if supported by the driver) and to fail if it can't.
+ - Removed method ``db_set_charset()`` and the ability to change a connection character set at runtime.
+
+ - :doc:`Database Forge <database/forge>`:
+
+ - Added support for declaring date/time type fields default values as ``CURRENT_TIMESTAMP`` and similar.
+
+- Helpers
+
+ - Added new function :php:func:`ordinal_format()` to :doc:`Inflector Helper <helpers/inflector_helper>`.
+ - Updated :doc:`Download Helper <helpers/download_helper>` :php:func:`force_download()` to allow existing files to be renamed for download.
+ - Updated :doc:`HTML Helper <helpers/html_helper>` function :php:func:`meta()` with support for "charset" and "property" properties.
+ - Changed :doc:`HTML Helper <helpers/html_helper>` function :php:func:`doctype()` default document type to HTML 5.
+
Version 3.1.3
=============
@@ -497,15 +561,15 @@ Release Date: March 30, 2015
- :doc:`Form Helper <helpers/form_helper>` changes include:
- :php:func:`form_dropdown()` will now also take an array for unity with other form helpers.
- - :php:func:`form_prep()` is now DEPRECATED and only acts as an alias for :doc:`common function <general/common_functions>` :php:func:`html_escape()`.
+ - ``form_prep()`` is now DEPRECATED and only acts as an alias for :doc:`common function <general/common_functions>` :php:func:`html_escape()`.
- :php:func:`set_value()` will now also accept a third argument, allowing to turn off HTML escaping of the value.
- :doc:`Security Helper <helpers/security_helper>` changes include:
- - :php:func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
+ - ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
- :php:func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library <libraries/security>`.
- - :doc:`Smiley Helper <helpers/smiley_helper>` changes include:
+ - *Smiley Helper* changes include:
- Deprecated the whole helper as too specific for CodeIgniter.
- Removed previously deprecated function ``js_insert_smiley()``.
@@ -541,7 +605,7 @@ Release Date: March 30, 2015
- :doc:`Directory Helper <helpers/directory_helper>` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array.
- :doc:`Array Helper <helpers/array_helper>` :php:func:`element()` and :php:func:`elements()` now return NULL instead of FALSE when the required elements don't exist.
- :doc:`Language Helper <helpers/language_helper>` :php:func:`lang()` now accepts an optional list of additional HTML attributes.
- - Deprecated the :doc:`Email Helper <helpers/email_helper>` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively.
+ - Deprecated the *Email Helper* as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively.
- Database
@@ -716,7 +780,7 @@ Release Date: March 30, 2015
- Added support for templating via an array in addition to the encoded string.
- Changed method ``get_total_days()`` to be an alias for :doc:`Date Helper <helpers/date_helper>` :php:func:`days_in_month()`.
- - :doc:`Cart Library <libraries/cart>` changes include:
+ - *Cart Library* changes include:
- Deprecated the library as too specific for CodeIgniter.
- Added method ``remove()`` to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
@@ -985,7 +1049,7 @@ Bug fixes for 3.0
- Fixed a bug where :doc:`Database Forge <database/forge>` method ``create_table()`` with PostgreSQL database could lead to fetching the whole table.
- Fixed a bug (#795) - :doc:`Form Helper <helpers/form_helper>` :php:func:`form_open()` didn't add the default form *method* and *accept-charset* when an empty array is passed to it.
- Fixed a bug (#797) - :doc:`Date Helper <helpers/date_helper>` :php:func:`timespan()` was using incorrect seconds for year and month.
-- Fixed a bug in :doc:`Cart Library <libraries/cart>` method ``contents()`` where if called without a TRUE (or equal) parameter, it would fail due to a typo.
+- Fixed a bug in *Cart Library* method ``contents()`` where if called without a TRUE (or equal) parameter, it would fail due to a typo.
- Fixed a bug (#406) - SQLSRV DB driver not returning resource on ``db_pconnect()``.
- Fixed a bug in :doc:`Image Manipulation Library <libraries/image_lib>` method ``gd_loaded()`` where it was possible for the script execution to end or a PHP E_WARNING message to be emitted.
- Fixed a bug in the :doc:`Pagination library <libraries/pagination>` where when use_page_numbers=TRUE previous link and page 1 link did not have the same url.
@@ -1067,7 +1131,7 @@ Bug fixes for 3.0
- Fixed a bug (#79) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly validate array fields that use associative keys or have custom indexes.
- Fixed a bug (#427) - :doc:`Form Validation Library <libraries/form_validation>` method ``strip_image_tags()`` was an alias to a non-existent method.
- Fixed a bug (#1545) - :doc:`Query Builder <database/query_builder>` method ``limit()`` wasn't executed properly under Oracle.
-- Fixed a bug (#1551) - :doc:`Date Helper <helpers/date_helper>` function :php:func:`standard_date()` didn't properly format *W3C* and *ATOM* standard dates.
+- Fixed a bug (#1551) - :doc:`Date Helper <helpers/date_helper>` function ``standard_date()`` didn't properly format *W3C* and *ATOM* standard dates.
- Fixed a bug where :doc:`Query Builder <database/query_builder>` method ``join()`` escaped literal values as if they were fields.
- Fixed a bug (#135) - PHP Error logging was impossible without the errors being displayed.
- Fixed a bug (#1613) - :doc:`Form Helper <helpers/form_helper>` functions :php:func:`form_multiselect()`, :php:func:`form_dropdown()` didn't properly handle empty array option groups.
@@ -1122,7 +1186,7 @@ Bug fixes for 3.0
- Fixed a bug (#2298) - :doc:`Database Results <database/results>` method ``next_row()`` kept returning the last row, allowing for infinite loops.
- Fixed a bug (#2236, #2639) - :doc:`Form Helper <helpers/form_helper>` functions :php:func:`set_value()`, :php:func:`set_select()`, :php:func:`set_radio()`, :php:func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library <libraries/form_validation>`.
- Fixed a bug (#2353) - :doc:`Query Builder <database/query_builder>` erroneously prefixed literal strings with **dbprefix**.
-- Fixed a bug (#78) - :doc:`Cart Library <libraries/cart>` didn't allow non-English letters in product names.
+- Fixed a bug (#78) - *Cart Library* didn't allow non-English letters in product names.
- Fixed a bug (#77) - :doc:`Database Class <database/index>` didn't properly handle the transaction "test mode" flag.
- Fixed a bug (#2380) - :doc:`URI Routing <general/routing>` method ``fetch_method()`` returned 'index' if the requested method name matches its controller name.
- Fixed a bug (#2388) - :doc:`Email Library <libraries/email>` used to ignore attachment errors, resulting in broken emails being sent.
@@ -1357,9 +1421,8 @@ Release Date: November 14, 2011
- Libraries
- - Changed ``$this->cart->insert()`` in the :doc:`Cart
- Library <libraries/cart>` to return the Row ID if a single
- item was inserted successfully.
+ - Changed ``$this->cart->insert()`` in the *Cart Library*
+ to return the Row ID if a single item was inserted successfully.
- Added support to set an optional parameter in your callback rules
of validation using the :doc:`Form Validation
Library <libraries/form_validation>`.
@@ -1467,9 +1530,8 @@ Release Date: August 20, 2011
string. See upgrade notes if using database sessions.
- Added $this->db->set_dbprefix() to the :doc:`Database
Driver <database/queries>`.
- - Changed $this->cart->insert() in the :doc:`Cart
- Library <libraries/cart>` to return the Row ID if a single
- item was inserted successfully.
+ - Changed ``$this->cart->insert()`` in the *Cart Library*
+ to return the Row ID if a single item was inserted successfully.
- Added $this->load->get_var() to the :doc:`Loader
library <libraries/loader>` to retrieve global vars set with
$this->load->view() and $this->load->vars().
@@ -1494,8 +1556,8 @@ Bug fixes for 2.0.3
properly escaped.
- Fixed issue #199 - Attributes passed as string does not include a
space between it and the opening tag.
-- Fixed a bug where the method $this->cart->total_items() from :doc:`Cart
- Library <libraries/cart>` now returns the sum of the quantity
+- Fixed a bug where the method ``$this->cart->total_items()`` from
+ *Cart Library* now returns the sum of the quantity
of all items in the cart instead of your total count.
- Fixed a bug where not setting 'null' when adding fields in db_forge
for mysql and mysqli drivers would default to NULL instead of NOT
@@ -1531,8 +1593,8 @@ Hg Tag: v2.0.2
- Helpers
- - Removed the previously deprecated dohash() from the :doc:`Security
- helper <./helpers/security_helper>`; use do_hash() instead.
+ - Removed the previously deprecated ``dohash()`` from the :doc:`Security
+ helper <./helpers/security_helper>`; use ``do_hash()`` instead.
- Changed the 'plural' function so that it doesn't ruin the
captalization of your string. It also take into consideration
acronyms which are all caps.
@@ -1774,7 +1836,7 @@ Hg Tag: v2.0.0
helper <./helpers/text_helper>`.
- Added accept-charset to the list of inserted attributes of
form_open() in the :doc:`Form Helper <helpers/form_helper>`.
- - Deprecated the dohash() function in favour of do_hash() for
+ - Deprecated the ``dohash()`` function in favour of ``do_hash()`` for
naming consistency.
- Non-backwards compatible change made to get_dir_file_info() in
the :doc:`File Helper <helpers/file_helper>`. No longer recurses
@@ -1794,7 +1856,7 @@ Hg Tag: v2.0.0
string already has a scheme.
- Modified get_file_info in the file helper, changing filectime()
to filemtime() for dates.
- - Modified smiley_js() to add optional third parameter to return
+ - Modified ``smiley_js()`` to add optional third parameter to return
only the javascript with no script tags.
- The img() function of the :doc:`HTML
helper <./helpers/html_helper>` will now generate an empty
@@ -1914,7 +1976,7 @@ Hg Tag: v1.7.2
- Libraries
- - Added a new :doc:`Cart Class <libraries/cart>`.
+ - Added a new *Cart Class*.
- Added the ability to pass $config['file_name'] for the :doc:`File
Uploading Class <libraries/file_uploading>` and rename the
uploaded file.
@@ -1941,7 +2003,7 @@ Hg Tag: v1.7.2
- Modified form_hidden() in the :doc:`Form
helper <helpers/form_helper>` to accept multi-dimensional
arrays.
- - Modified form_prep() in the :doc:`Form
+ - Modified ``form_prep()`` in the :doc:`Form
helper <helpers/form_helper>` to keep track of prepped
fields to avoid multiple prep/mutation from subsequent calls which
can occur when using Form Validation and form helper functions to
@@ -1949,7 +2011,7 @@ Hg Tag: v1.7.2
- Modified directory_map() in the :doc:`Directory
helper <helpers/directory_helper>` to allow the inclusion of
hidden files, and to return FALSE on failure to read directory.
- - Modified the :doc:`Smiley helper <helpers/smiley_helper>` to work
+ - Modified the *Smiley helper* to work
with multiple fields and insert the smiley at the last known
cursor position.
@@ -2000,7 +2062,7 @@ Bug fixes for 1.7.2
- Fixed a case sensitive string replacement in xss_clean()
- Fixed a bug in form_textarea() where form data was not prepped
correctly.
-- Fixed a bug in form_prep() causing it to not preserve entities in
+- Fixed a bug in ``form_prep()`` causing it to not preserve entities in
the user's original input when called back into a form element
- Fixed a bug in _protect_identifiers() where the swap prefix
($swap_pre) was not being observed.
@@ -2693,7 +2755,7 @@ Release Date: January 30, 2008
class. <./libraries/sessions>`
- Removed 'last_visit' from the Session class.
- Added a language entry for valid_ip validation error.
- - Modified prep_for_form() in the Validation class to accept
+ - Modified ``prep_for_form()`` in the Validation class to accept
arrays, adding support for POST array validation (via callbacks
only)
- Added an "integer" rule into the Validation library.
@@ -2717,8 +2779,7 @@ Release Date: January 30, 2008
helper. <./helpers/html_helper>`
- Added img() to the :doc:`HTML helper. <./helpers/html_helper>`
- Added ability to :doc:`"extend" Helpers <./general/helpers>`.
- - Added an :doc:`email helper <./helpers/email_helper>` into core
- helpers.
+ - Added an *Email Helper* into core helpers.
- Added strip_quotes() function to :doc:`string
helper <./helpers/string_helper>`.
- Added reduce_multiples() function to :doc:`string
@@ -2919,7 +2980,7 @@ Release Date: July 12, 2007
- Fixed various doc typos.
- Documented two functions from the :doc:`String
helper <./helpers/string_helper>` that were missing from the
- user guide: trim_slashes() and reduce_double_slashes().
+ user guide: ``trim_slashes()`` and ``reduce_double_slashes()``.
- Docs now validate to XHTML 1 transitional
- Updated the XSS Filtering to take into account the IE expression()
ability and improved certain deletions to prevent possible exploits
@@ -2950,7 +3011,7 @@ Release Date: April 15, 2007
- Added array to string into the profiler
- Code Igniter references updated to CodeIgniter
- pMachine references updated to EllisLab
-- Fixed a bug in the repeater function of :doc:`string
+- Fixed a bug in the ``repeater()`` function of :doc:`string
helper <./helpers/string_helper>`.
- Fixed a bug in ODBC driver
- Fixed a bug in result_array() that was returning an empty array when
@@ -3049,8 +3110,7 @@ Release Date: October 30, 2006
- Added :doc:`Download Helper <./helpers/download_helper>`.
- Added :doc:`simple_query() <./database/queries>` function to the
database classes
-- Added :doc:`standard_date() <./helpers/date_helper>` function to
- the Date Helper.
+- Added ``standard_date()`` function function to the :doc:`Date Helper <helpers/date_helper>`.
- Added :doc:`$query->free_result() <./database/results>` to database
class.
- Added :doc:`$query->list_fields() <./database/metadata>` function to
@@ -3058,7 +3118,7 @@ Release Date: October 30, 2006
- Added :doc:`$this->db->platform() <./database/helpers>` function
- Added new :doc:`File Helper <./helpers/file_helper>`:
get_filenames()
-- Added new helper: :doc:`Smiley Helper <./helpers/smiley_helper>`
+- Added new helper: *Smiley Helper*
- Added support for <ul> and <ol> lists in the :doc:`HTML
Helper <./helpers/html_helper>`
- Added the ability to rewrite :doc:`short
@@ -3091,7 +3151,7 @@ Release Date: October 30, 2006
- Fixed a bug in the validation class.
- Fixed a bug in the typography helper that was incorrectly wrapping
block level elements in paragraph tags.
-- Fixed a problem in the form_prep() function that was double encoding
+- Fixed a problem in the ``form_prep()`` function that was double encoding
entities.
- Fixed a bug that affects some versions of PHP when output buffering
is nested.
@@ -3453,7 +3513,7 @@ Release Date: March 10, 2006
- Fixed a pagination problem in the scaffolding.
- Fixed a bug in the mysql class "where" function.
- Fixed a regex problem in some code that trimmed duplicate slashes.
-- Fixed a bug in the br() function in the HTML helper
+- Fixed a bug in the ``br()`` function in the HTML helper
- Fixed a syntax mistake in the form_dropdown function in the Form
Helper.
- Removed the "style" attributes form the form helpers.
diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py
index 4d2edbe60..4714b0d62 100644
--- a/user_guide_src/source/conf.py
+++ b/user_guide_src/source/conf.py
@@ -48,9 +48,9 @@ copyright = u'2014 - 2016, British Columbia Institute of Technology'
# built documents.
#
# The short X.Y version.
-version = '3.1.3-dev'
+version = '3.2.0-dev'
# The full version, including alpha/beta/rc tags.
-release = '3.1.3-dev'
+release = '3.2.0-dev'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/user_guide_src/source/database/db_driver_reference.rst b/user_guide_src/source/database/db_driver_reference.rst
index 1f036cd77..6f2fa5fb1 100644
--- a/user_guide_src/source/database/db_driver_reference.rst
+++ b/user_guide_src/source/database/db_driver_reference.rst
@@ -17,8 +17,8 @@ This article is intended to be a reference for them.
.. php:method:: initialize()
- :returns: TRUE on success, FALSE on failure
- :rtype: bool
+ :rtype: void
+ :throws: RuntimeException In case of failure
Initialize database settings, establish a connection to
the database.
@@ -61,14 +61,6 @@ This article is intended to be a reference for them.
Select / switch the current database.
- .. php:method:: db_set_charset($charset)
-
- :param string $charset: Character set name
- :returns: TRUE on success, FALSE on failure
- :rtype: bool
-
- Set client character set.
-
.. php:method:: platform()
:returns: Platform name
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index 600a07574..909528855 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -67,45 +67,6 @@ The following functions are available:
If a timestamp is not included in the second parameter the current time
will be used.
-.. php:function:: standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]])
-
- :param string $fmt: Date format
- :param int $time: UNIX timestamp
- :returns: Formatted date or FALSE on invalid format
- :rtype: string
-
- Lets you generate a date string in one of several standardized formats.
-
- Example::
-
- $format = 'DATE_RFC822';
- $time = time();
- echo standard_date($format, $time);
-
- .. note:: This function is DEPRECATED. Use the native ``date()`` combined with
- `DateTime's format constants
- <https://secure.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
- instead::
-
- echo date(DATE_RFC822, time());
-
- **Supported formats:**
-
- =============== ======================= ======================================
- Constant Description Example
- =============== ======================= ======================================
- DATE_ATOM Atom 2005-08-15T16:13:03+0000
- DATE_COOKIE HTTP Cookies Sun, 14 Aug 2005 16:13:03 UTC
- DATE_ISO8601 ISO-8601 2005-08-14T16:13:03+00:00
- DATE_RFC822 RFC 822 Sun, 14 Aug 05 16:13:03 UTC
- DATE_RFC850 RFC 850 Sunday, 14-Aug-05 16:13:03 UTC
- DATE_RFC1036 RFC 1036 Sunday, 14-Aug-05 16:13:03 UTC
- DATE_RFC1123 RFC 1123 Sun, 14 Aug 2005 16:13:03 UTC
- DATE_RFC2822 RFC 2822 Sun, 14 Aug 2005 16:13:03 +0000
- DATE_RSS RSS Sun, 14 Aug 2005 16:13:03 UTC
- DATE_W3C W3C 2005-08-14T16:13:03+0000
- =============== ======================= ======================================
-
.. php:function:: local_to_gmt([$time = ''])
:param int $time: UNIX timestamp
diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst
index 1a4065073..e11d92a14 100644
--- a/user_guide_src/source/helpers/download_helper.rst
+++ b/user_guide_src/source/helpers/download_helper.rst
@@ -26,7 +26,7 @@ The following functions are available:
.. php:function:: force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]])
- :param string $filename: Filename
+ :param mixed $filename: Filename
:param mixed $data: File contents
:param bool $set_mime: Whether to try to send the actual MIME type
:rtype: void
@@ -37,8 +37,11 @@ The following functions are available:
file data.
If you set the second parameter to NULL and ``$filename`` is an existing, readable
- file path, then its content will be read instead.
-
+ file path, then its content will be read instead. You may also set ``$filename``
+ as an associative array with a single element, where the key of that element would be
+ the local file you are trying to read and where the value is the name of the downloadable
+ file that will be sent to browser. An example of this is provided below.
+
If you set the third parameter to boolean TRUE, then the actual file MIME type
(based on the filename extension) will be sent, so that if your browser has a
handler for that type - it can use it.
@@ -53,4 +56,10 @@ The following functions are available:
do the following::
// Contents of photo.jpg will be automatically read
- force_download('/path/to/photo.jpg', NULL); \ No newline at end of file
+ force_download('/path/to/photo.jpg', NULL);
+
+ If you want to download an existing file from your server, but change the name
+ of the actual file sent to browser, you will need this::
+
+ // Contents of photo.jpg will be automatically read and sent as my-photo.jpg
+ force_download(array('/path/to/photo.jpg' => 'my-photo.jpg'), NULL); \ No newline at end of file
diff --git a/user_guide_src/source/helpers/email_helper.rst b/user_guide_src/source/helpers/email_helper.rst
deleted file mode 100644
index 1ee97d902..000000000
--- a/user_guide_src/source/helpers/email_helper.rst
+++ /dev/null
@@ -1,75 +0,0 @@
-############
-Email Helper
-############
-
-The Email Helper provides some assistive functions for working with
-Email. For a more robust email solution, see CodeIgniter's :doc:`Email
-Class <../libraries/email>`.
-
-.. important:: The Email helper is DEPRECATED and is currently
- only kept for backwards compatibility.
-
-.. contents::
- :local:
-
-.. raw:: html
-
- <div class="custom-index container"></div>
-
-Loading this Helper
-===================
-
-This helper is loaded using the following code::
-
- $this->load->helper('email');
-
-Available Functions
-===================
-
-The following functions are available:
-
-
-.. php:function:: valid_email($email)
-
- :param string $email: E-mail address
- :returns: TRUE if a valid email is supplied, FALSE otherwise
- :rtype: bool
-
- Checks if the input is a correctly formatted e-mail address. Note that is
- doesn't actually prove that the address will be able recieve mail, but
- simply that it is a validly formed address.
-
- Example::
-
- if (valid_email('email@somesite.com'))
- {
- echo 'email is valid';
- }
- else
- {
- echo 'email is not valid';
- }
-
- .. note:: All that this function does is to use PHP's native ``filter_var()``::
-
- (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
-
-.. php:function:: send_email($recipient, $subject, $message)
-
- :param string $recipient: E-mail address
- :param string $subject: Mail subject
- :param string $message: Message body
- :returns: TRUE if the mail was successfully sent, FALSE in case of an error
- :rtype: bool
-
- Sends an email using PHP's native `mail() <http://php.net/function.mail>`_
- function.
-
- .. note:: All that this function does is to use PHP's native ``mail``
-
- ::
-
- mail($recipient, $subject, $message);
-
- For a more robust email solution, see CodeIgniter's :doc:`Email Library
- <../libraries/email>`. \ No newline at end of file
diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst
index 833cddea4..dcf3a2340 100644
--- a/user_guide_src/source/helpers/file_helper.rst
+++ b/user_guide_src/source/helpers/file_helper.rst
@@ -23,32 +23,6 @@ Available Functions
The following functions are available:
-
-.. php:function:: read_file($file)
-
- :param string $file: File path
- :returns: File contents or FALSE on failure
- :rtype: string
-
- Returns the data contained in the file specified in the path.
-
- Example::
-
- $string = read_file('./path/to/file.php');
-
- The path can be a relative or full server path. Returns FALSE (boolean) on failure.
-
- .. note:: The path is relative to your main site index.php file, NOT your
- controller or view files. CodeIgniter uses a front controller so paths
- are always relative to the main site index.
-
- .. note:: This function is DEPRECATED. Use the native ``file_get_contents()``
- instead.
-
- .. important:: If your server is running an **open_basedir** restriction this
- function might not work if you are trying to access a file above the
- calling script.
-
.. php:function:: write_file($path, $data[, $mode = 'wb'])
:param string $path: File path
@@ -199,4 +173,4 @@ The following functions are available:
::
- echo octal_permissions(fileperms('./index.php')); // 644 \ No newline at end of file
+ echo octal_permissions(fileperms('./index.php')); // 644
diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
index bc30a0e98..cf52cd523 100644
--- a/user_guide_src/source/helpers/form_helper.rst
+++ b/user_guide_src/source/helpers/form_helper.rst
@@ -724,20 +724,3 @@ The following functions are available:
<span class="error">The "password" field doesn't match the "repeat_password" field!</span>
*/
-
-.. php:function:: form_prep($str)
-
- :param string $str: Value to escape
- :returns: Escaped value
- :rtype: string
-
- Allows you to safely use HTML and characters such as quotes within form
- elements without breaking out of the form.
-
- .. note:: If you use any of the form helper functions listed in this page the form
- values will be prepped automatically, so there is no need to call this
- function. Use it only if you are creating your own form elements.
-
- .. note:: This function is DEPRECATED and is just an alias for
- :doc:`common function <../general/common_functions>`
- :func:`html_escape()` - please use that instead.
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 2c748bea0..734b4465c 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -286,7 +286,7 @@ The following functions are available:
// Generates: <meta name="description" content="My Great Site" />
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
- // Note the third parameter. Can be "equiv" or "name"
+ // Note the third parameter. Can be "charset", "http-equiv", "name" or "property"
// Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
@@ -310,8 +310,13 @@ The following functions are available:
'content' => 'no-cache'
),
array(
- 'name' => 'Content-type',
- 'content' => 'text/html; charset=utf-8', 'type' => 'equiv'
+ 'name' => 'Content-Type',
+ 'type' => 'http-equiv',
+ 'content' => 'text/html; charset=utf-8'
+ ),
+ array(
+ 'name' => 'UTF-8',
+ 'type' => 'charset'
)
);
@@ -321,21 +326,22 @@ The following functions are available:
// <meta name="description" content="My Great Site" />
// <meta name="keywords" content="love, passion, intrigue, deception" />
// <meta name="robots" content="no-cache" />
- // <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ // <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ // <meta charset="UTF-8" />
-.. php:function:: doctype([$type = 'xhtml1-strict'])
+.. php:function:: doctype([$type = 'html5'])
:param string $type: Doctype name
:returns: HTML DocType tag
:rtype: string
- Helps you generate document type declarations, or DTD's. XHTML 1.0
- Strict is used by default, but many doctypes are available.
+ Helps you generate document type declarations, or DTD's. HTML 5
+ is used by default, but many doctypes are available.
Example::
- echo doctype(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ echo doctype(); // <!DOCTYPE html>
echo doctype('html4-trans'); // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -365,43 +371,3 @@ The following functions are available:
XHTML+RDFa 1.0 xhtml-rdfa-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
XHTML+RDFa 1.1 xhtml-rdfa-2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
=============================== =================== ==================================================================================================================================================
-
-.. php:function:: br([$count = 1])
-
- :param int $count: Number of times to repeat the tag
- :returns: HTML line break tag
- :rtype: string
-
- Generates line break tags (<br />) based on the number you submit.
- Example::
-
- echo br(3);
-
- The above would produce:
-
- .. code-block:: html
-
- <br /><br /><br />
-
- .. note:: This function is DEPRECATED. Use the native ``str_repeat()``
- in combination with ``<br />`` instead.
-
-.. php:function:: nbs([$num = 1])
-
- :param int $num: Number of space entities to produce
- :returns: A sequence of non-breaking space HTML entities
- :rtype: string
-
- Generates non-breaking spaces (&nbsp;) based on the number you submit.
- Example::
-
- echo nbs(3);
-
- The above would produce:
-
- .. code-block:: html
-
- &nbsp;&nbsp;&nbsp;
-
- .. note:: This function is DEPRECATED. Use the native ``str_repeat()``
- in combination with ``&nbsp;`` instead.
diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst
index df0c568c0..76cce6f4d 100644
--- a/user_guide_src/source/helpers/inflector_helper.rst
+++ b/user_guide_src/source/helpers/inflector_helper.rst
@@ -93,4 +93,20 @@ The following functions are available:
Checks if the given word has a plural version. Example::
- is_countable('equipment'); // Returns FALSE \ No newline at end of file
+ is_countable('equipment'); // Returns FALSE
+
+.. php:function:: ordinal_format($number)
+
+ :param int $number: non-negative natural number to be converted
+ :returns: Ordinal numeral for given number or original value on failure
+ :rtype: string
+
+ Returns the ordinal numeral (1st, 2nd, 3rd etc.) for a
+ non-negative natural number. If the input is not a natural number
+ greater than 0, the function will return the original value. Examples::
+
+ echo ordinal_format(1); // Returns 1st
+ echo ordinal_format(3); // Returns 3rd
+ echo ordinal_format(21); // Returns 21st
+ echo ordinal_format(102); // Returns 102nd
+ echo ordinal_format(-5); // Invalid input, will return -5
diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst
index 103880cf9..e981bc6b6 100644
--- a/user_guide_src/source/helpers/security_helper.rst
+++ b/user_guide_src/source/helpers/security_helper.rst
@@ -48,31 +48,6 @@ The following functions are available:
For more info, please see the :doc:`Security Library <../libraries/security>`
documentation.
-
-.. php:function:: do_hash($str[, $type = 'sha1'])
-
- :param string $str: Input
- :param string $type: Algorithm
- :returns: Hex-formatted hash
- :rtype: string
-
- Permits you to create one way hashes suitable for encrypting
- passwords. Will use SHA1 by default.
-
- See `hash_algos() <http://php.net/function.hash_algos>`_
- for a full list of supported algorithms.
-
- Examples::
-
- $str = do_hash($str); // SHA1
- $str = do_hash($str, 'md5'); // MD5
-
- .. note:: This function was formerly named ``dohash()``, which has been
- removed in favor of ``do_hash()``.
-
- .. note:: This function is DEPRECATED. Use the native ``hash()`` instead.
-
-
.. php:function:: strip_image_tags($str)
:param string $str: Input string
@@ -103,4 +78,4 @@ The following functions are available:
Example::
- $string = encode_php_tags($string); \ No newline at end of file
+ $string = encode_php_tags($string);
diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst
deleted file mode 100644
index 3e7669942..000000000
--- a/user_guide_src/source/helpers/smiley_helper.rst
+++ /dev/null
@@ -1,169 +0,0 @@
-#############
-Smiley Helper
-#############
-
-The Smiley Helper file contains functions that let you manage smileys
-(emoticons).
-
-.. important:: The Smiley helper is DEPRECATED and should not be used.
- It is currently only kept for backwards compatibility.
-
-.. contents::
- :local:
-
-.. raw:: html
-
- <div class="custom-index container"></div>
-
-Loading this Helper
-===================
-
-This helper is loaded using the following code::
-
- $this->load->helper('smiley');
-
-Overview
-========
-
-The Smiley helper has a renderer that takes plain text smileys, like
-:-) and turns them into a image representation, like |smile!|
-
-It also lets you display a set of smiley images that when clicked will
-be inserted into a form field. For example, if you have a blog that
-allows user commenting you can show the smileys next to the comment
-form. Your users can click a desired smiley and with the help of some
-JavaScript it will be placed into the form field.
-
-Clickable Smileys Tutorial
-==========================
-
-Here is an example demonstrating how you might create a set of clickable
-smileys next to a form field. This example requires that you first
-download and install the smiley images, then create a controller and the
-View as described.
-
-.. important:: Before you begin, please `download the smiley images
- <https://ellislab.com/asset/ci_download_files/smileys.zip>`_
- and put them in a publicly accessible place on your server.
- This helper also assumes you have the smiley replacement array
- located at `application/config/smileys.php`
-
-The Controller
---------------
-
-In your **application/controllers/** directory, create a file called
-Smileys.php and place the code below in it.
-
-.. important:: Change the URL in the :php:func:`get_clickable_smileys()`
- function below so that it points to your smiley folder.
-
-You'll notice that in addition to the smiley helper, we are also using
-the :doc:`Table Class <../libraries/table>`::
-
- <?php
-
- class Smileys extends CI_Controller {
-
- public function index()
- {
- $this->load->helper('smiley');
- $this->load->library('table');
-
- $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');
- $col_array = $this->table->make_columns($image_array, 8);
-
- $data['smiley_table'] = $this->table->generate($col_array);
- $this->load->view('smiley_view', $data);
- }
-
- }
-
-In your **application/views/** directory, create a file called **smiley_view.php**
-and place this code in it::
-
- <html>
- <head>
- <title>Smileys</title>
- <?php echo smiley_js(); ?>
- </head>
- <body>
- <form name="blog">
- <textarea name="comments" id="comments" cols="40" rows="4"></textarea>
- </form>
- <p>Click to insert a smiley!</p>
- <?php echo $smiley_table; ?> </body> </html>
- When you have created the above controller and view, load it by visiting http://www.example.com/index.php/smileys/
- </body>
- </html>
-
-Field Aliases
--------------
-
-When making changes to a view it can be inconvenient to have the field
-id in the controller. To work around this, you can give your smiley
-links a generic name that will be tied to a specific id in your view.
-
-::
-
- $image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");
-
-To map the alias to the field id, pass them both into the
-:func:`smiley_js()` function::
-
- $image_array = smiley_js("comment_textarea_alias", "comments");
-
-Available Functions
-===================
-
-.. php:function:: get_clickable_smileys($image_url[, $alias = ''[, $smileys = NULL]])
-
- :param string $image_url: URL path to the smileys directory
- :param string $alias: Field alias
- :returns: An array of ready to use smileys
- :rtype: array
-
- Returns an array containing your smiley images wrapped in a clickable
- link. You must supply the URL to your smiley folder and a field id or
- field alias.
-
- Example::
-
- $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comment');
-
-.. php:function:: smiley_js([$alias = ''[, $field_id = ''[, $inline = TRUE]]])
-
- :param string $alias: Field alias
- :param string $field_id: Field ID
- :param bool $inline: Whether we're inserting an inline smiley
- :returns: Smiley-enabling JavaScript code
- :rtype: string
-
- Generates the JavaScript that allows the images to be clicked and
- inserted into a form field. If you supplied an alias instead of an id
- when generating your smiley links, you need to pass the alias and
- corresponding form id into the function. This function is designed to be
- placed into the <head> area of your web page.
-
- Example::
-
- <?php echo smiley_js(); ?>
-
-.. php:function:: parse_smileys([$str = ''[, $image_url = ''[, $smileys = NULL]]])
-
- :param string $str: Text containing smiley codes
- :param string $image_url: URL path to the smileys directory
- :param array $smileys: An array of smileys
- :returns: Parsed smileys
- :rtype: string
-
- Takes a string of text as input and replaces any contained plain text
- smileys into the image equivalent. The first parameter must contain your
- string, the second must contain the URL to your smiley folder
-
- Example::
-
- $str = 'Here are some smileys: :-) ;-)';
- $str = parse_smileys($str, 'http://example.com/images/smileys/');
- echo $str;
-
-.. |smile!| image:: ../images/smile.gif \ No newline at end of file
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index 53052557e..d697d824b 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -27,7 +27,6 @@ Available Functions
The following functions are available:
-
.. php:function:: random_string([$type = 'alnum'[, $len = 8]])
:param string $type: Randomization type
@@ -102,24 +101,6 @@ The following functions are available:
.. note:: To use multiple separate calls to this function simply call the
function with no arguments to re-initialize.
-.. php:function:: repeater($data[, $num = 1])
-
- :param string $data: Input
- :param int $num: Number of times to repeat
- :returns: Repeated string
- :rtype: string
-
- Generates repeating copies of the data you submit. Example::
-
- $string = "\n";
- echo repeater($string, 30);
-
- The above would generate 30 newlines.
-
- .. note:: This function is DEPRECATED. Use the native ``str_repeat()``
- instead.
-
-
.. php:function:: reduce_double_slashes($str)
:param string $str: Input string
@@ -134,7 +115,6 @@ The following functions are available:
$string = "http://example.com//index.php";
echo reduce_double_slashes($string); // results in "http://example.com/index.php"
-
.. php:function:: strip_slashes($data)
:param mixed $data: Input string or an array of strings
@@ -163,21 +143,6 @@ The following functions are available:
and handle string inputs. This however makes it just an
alias for ``stripslashes()``.
-.. php:function:: trim_slashes($str)
-
- :param string $str: Input string
- :returns: Slash-trimmed string
- :rtype: string
-
- Removes any leading/trailing slashes from a string. Example::
-
- $string = "/this/that/theother/";
- echo trim_slashes($string); // results in this/that/theother
-
- .. note:: This function is DEPRECATED. Use the native ``trim()`` instead:
- |
- | trim($str, '/');
-
.. php:function:: reduce_multiples($str[, $character = ''[, $trim = FALSE]])
:param string $str: Text to search in
@@ -220,4 +185,4 @@ The following functions are available:
Removes single and double quotes from a string. Example::
$string = "Joe's \"dinner\"";
- $string = strip_quotes($string); //results in "Joes dinner" \ No newline at end of file
+ $string = strip_quotes($string); //results in "Joes dinner"
diff --git a/user_guide_src/source/images/smile.gif b/user_guide_src/source/images/smile.gif
deleted file mode 100644
index bf0922504..000000000
--- a/user_guide_src/source/images/smile.gif
+++ /dev/null
Binary files differ
diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst
index 5992ba291..ae58e796f 100644
--- a/user_guide_src/source/installation/downloads.rst
+++ b/user_guide_src/source/installation/downloads.rst
@@ -2,7 +2,8 @@
Downloading CodeIgniter
#######################
-- `CodeIgniter v3.1.3 (Current version) <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1-stable>`_
+- `CodeIgniter v3.2.0-dev (Current version) <https://codeload.github.com/bcit-ci/CodeIgniter/zip/develop>`_
+- `CodeIgniter v3.1.3-dev <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1-stable>`_
- `CodeIgniter v3.1.2 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.2>`_
- `CodeIgniter v3.1.1 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.1>`_
- `CodeIgniter v3.1.0 <https://codeload.github.com/bcit-ci/CodeIgniter/zip/3.1.0>`_
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 0fc211f89..7b9082679 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -532,9 +532,9 @@ the ``EXT`` constant has been removed. Use just '.php' instead.
Smiley helper
=============
-The :doc:`Smiley Helper <../helpers/smiley_helper>` is a legacy feature from EllisLab's
-ExpressionEngine product. However, it is too specific for a general purpose framework like
-CodeIgniter and as such it is now deprecated.
+The *Smiley Helper* is a legacy feature from EllisLab's ExpressionEngine product.
+However, it is too specific for a general purpose framework like CodeIgniter
+and as such it is now deprecated.
Also, the previously deprecated ``js_insert_smiley()`` (since version 1.7.2) is now removed.
@@ -559,12 +559,12 @@ implemented cryptographic functions.
The Cart library
================
-The :doc:`Cart Library <../libraries/cart>`, similarly to the :doc:`Smiley Helper
-<../helpers/smiley_helper>` is too specific for CodeIgniter. It is now deprecated
-and scheduled for removal in CodeIgniter 3.1+.
+The *Cart Library*, similarly to the *Smiley Helper* is too specific for
+CodeIgniter. It is now deprecated and scheduled for removal in
+CodeIgniter 3.1+.
-.. note:: The library is still available, but you're strongly encouraged to remove its usage sooner
- rather than later.
+.. note:: The library is still available, but you're strongly encouraged to
+ remove its usage sooner rather than later.
Database drivers 'mysql', 'sqlite', 'mssql', 'pdo/dblib'
========================================================
@@ -624,7 +624,7 @@ CodeIgniter 3.1+.
String helper repeater()
========================
-:doc:`String Helper <../helpers/string_helper>` function :php:func:`repeater()` is now just an alias for
+:doc:`String Helper <../helpers/string_helper>` function ``repeater()`` is now just an alias for
PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner
@@ -633,7 +633,7 @@ PHP's native ``str_repeat()`` function. It is deprecated and scheduled for remov
String helper trim_slashes()
============================
-:doc:`String Helper <../helpers/string_helper>` function :php:func:`trim_slashes()` is now just an alias
+:doc:`String Helper <../helpers/string_helper>` function ``trim_slashes()`` is now just an alias
for PHP's native ``trim()`` function (with a slash passed as its second argument). It is deprecated and
scheduled for removal in CodeIgniter 3.1+.
@@ -643,8 +643,8 @@ scheduled for removal in CodeIgniter 3.1+.
Form helper form_prep()
=======================
-:doc:`Form Helper <../helpers/form_helper>` function :php:func:`form_prep()`
-is now just an alias for :doc:`common function </general/common_functions>`
+:doc:`Form Helper <../helpers/form_helper>` function ``form_prep()`` is now
+just an alias for :doc:`common function </general/common_functions>`
:func:`html_escape()`. It is deprecated and will be removed in the future.
Please use :php:func:`html_escape()` instead.
@@ -655,14 +655,13 @@ Please use :php:func:`html_escape()` instead.
Email helper functions
======================
-:doc:`Email Helper <../helpers/email_helper>` only has two functions
+The *Email Helper* only has two functions:
- - :php:func:`valid_email()`
- - :php:func:`send_email()`
+ - ``valid_email()``
+ - ``send_email()``
Both of them are now aliases for PHP's native ``filter_var()`` and ``mail()`` functions, respectively.
-Therefore the :doc:`Email Helper <../helpers/email_helper>` altogether is being deprecated and
-is scheduled for removal in CodeIgniter 3.1+.
+Therefore, the *Email Helper* altogether is being deprecated and is scheduled for removal in CodeIgniter 3.1+.
.. note:: These functions are still available, but you're strongly encouraged to remove their usage
sooner rather than later.
@@ -845,8 +844,8 @@ CodeIgniter 3.1+.
The Javascript library
======================
-The :doc:`Javascript Library <../libraries/javascript>` has always had an
-'experimental' status and was never really useful, nor a proper solution.
+The *Javascript Library* has always had an 'experimental' status and was
+never really useful, nor a proper solution.
It is now deprecated and scheduled for removal in CodeIgniter 3.1+.
diff --git a/user_guide_src/source/installation/upgrade_310.rst b/user_guide_src/source/installation/upgrade_310.rst
index 9e0108691..cae814327 100644
--- a/user_guide_src/source/installation/upgrade_310.rst
+++ b/user_guide_src/source/installation/upgrade_310.rst
@@ -35,4 +35,4 @@ does not provide a function that allows to safely escape user-supplied strings f
inside an SQL query (which our :doc:`Query Builder <../database/query_builder>` relies on).
Thus, user inputs MUST be bound, as shown in :doc:`Running Queries <../database/queries>`,
-under the "Query Bindings" section. \ No newline at end of file
+under the "Query Bindings" section.
diff --git a/user_guide_src/source/installation/upgrade_320.rst b/user_guide_src/source/installation/upgrade_320.rst
new file mode 100644
index 000000000..b587470f2
--- /dev/null
+++ b/user_guide_src/source/installation/upgrade_320.rst
@@ -0,0 +1,158 @@
+#############################
+Upgrading from 3.1.x to 3.2.x
+#############################
+
+Before performing an update you should take your site offline by
+replacing the index.php file with a static one.
+
+Step 1: Update your CodeIgniter files
+=====================================
+
+Replace all files and directories in your *system/* directory.
+
+.. note:: If you have any custom developed files in these directories,
+ please make copies of them first.
+
+Step 2: Change database connection handling
+===========================================
+
+"Loading" a database, whether by using the *config/autoload.php* settings
+or manually via calling ``$this->load->database()`` or the less-known
+``DB()`` function, will now throw a ``RuntimeException`` in case of a
+failure.
+
+In addition, being unable to set the configured character set is now also
+considered a connection failure.
+
+.. note:: This has been the case for most database drivers in the in the
+ past as well (i.e. all but the 'mysql', 'mysqli' and 'postgre'
+ drivers).
+
+What this means is that if you're unable to connect to a database, or
+have an erroneous character set configured, CodeIgniter will no longer
+fail silently, but will throw an exception instead.
+
+You may choose to explicitly catch it (and for that purpose you can't use
+*config/autoload.php* to load the :doc:`Database Class <../database/index>`)
+::
+
+ try
+ {
+ $this->load->database();
+ }
+ catch (RuntimeException $e)
+ {
+ // Handle the failure
+ }
+
+Or you may leave it to CodeIgniter's default exception handler, which would
+log the error message and display an error screen if you're running in
+development mode.
+
+Remove db_set_charset() calls
+-----------------------------
+
+With the above-mentioned changes, the purpose of the ``db_set_charset()``
+method would now only be to change the connection character set at runtime.
+That doesn't make sense and that's the reason why most database drivers
+don't support it at all.
+Thus, ``db_set_charset()`` is no longer necessary and is removed.
+
+Step 3: Check logic related to URI parsing of CLI requests
+==========================================================
+
+When running a CodeIgniter application from the CLI, the
+:doc:`URI Library <../libraries/uri>` will now ignore the
+``$config['url_suffix']`` and ``$config['permitted_uri_chars']``
+configuration settings.
+
+These two options don't make sense under the command line (which is why
+this change was made) and therefore you shouldn't be affected by this, but
+if you've relied on them for some reason, you'd probably have to make some
+changes to your code.
+
+Step 4: Check Cache Library configurations for Redis, Memcache(d)
+=================================================================
+
+The new improvements for the 'redis' and 'memcached' drivers of the
+:doc:`Cache Library <../libraries/caching>` may require some small
+adjustments to your configuration values ...
+
+Redis
+-----
+
+If you're using the 'redis' driver with a UNIX socket connection, you'll
+have to move the socket path from ``$config['socket']`` to
+``$config['host']`` instead.
+
+The ``$config['socket_type']`` option is also removed, although that won't
+affect your application - it will be ignored and the connection type will
+be determined by the format used for ``$config['host']`` instead.
+
+Memcache(d)
+-----------
+
+The 'memcached' will now ignore configurations that don't specify a ``host``
+value (previously, it just set the host to the default '127.0.0.1').
+
+Therefore, if you've added a configuration that only sets e.g. a ``port``,
+you will now have to explicitly set the ``host`` to '127.0.0.1' as well.
+
+Step 5: Check usage of the Email library
+========================================
+
+The :doc:`Email Library <../libraries/email>` will now by default check the
+validity of all e-mail addresses passed to it. This check used to be Off by
+default, and required explicitly setting the **validate** option to ``TRUE``
+in order to enable it.
+
+Naturally, a validity check should not result in any problems, but this is
+technically a backwards-compability break and you should check that
+everything works fine.
+If something indeed goes wrong with that, please report it as a bug to us,
+and you can disable the **validate** option to revert to the old behavior.
+
+Step 6: Check usage of doctype() HTML helper
+============================================
+
+The :doc:`HTML Helper <../helpers/html_helper>` function
+:php:func:`doctype()` used to default to 'xhtml1-strict' (XHTML 1.0 Strict)
+when no document type was specified. That default value is now changed to
+'html5', which obviously stands for the modern HTML 5 standard.
+
+Nothing should be really broken by this change, but if your application
+relies on the default value, you should double-check it and either
+explicitly set the desired format, or adapt your front-end to use proper
+HTML 5 formatting.
+
+Step 7: Remove usage of previously deprecated functionalities
+=============================================================
+
+The following is a list of functionalities deprecated in CodeIgniter
+version 3.0.x, that have been removed in 3.2.0:
+
+- ``CI_Input::is_cli_request()`` (use :php:func:`is_cli()` instead)
+- ``CI_Router::fetch_directory()`` (use ``CI_Router::$directory`` instead)
+- ``CI_Router::fetch_class()`` (use ``CI_Router::$class`` instead)
+- ``CI_Router::fetch_method()`` (use ``CI_Router::$method`` instead)
+- ``CI_Config::system_url()`` (encourages insecure practices)
+- ``CI_Form_validation::prep_for_form()`` (the *prep_for_form* rule)
+
+- ``standard_date()`` :doc:`Date Helper <../helpers/date_helper>` function (use ``date()`` instead)
+- ``do_hash()`` :doc:`Security Helper <../helpers/security_helper>` function (use ``hash()`` instead)
+- ``br()`` :doc:`HTML Helper <../helpers/html_helper>` function (use ``str_repeat()`` with ``'<br />'`` instead)
+- ``nbs()`` :doc:`HTML Helper <../helpers/html_helper>` function (use ``str_repeat()`` with ``'&nbsp;'`` instead)
+- ``trim_slashes()`` :doc:`String Helper <../helpers/string_helper>` function (use ``trim()`` with ``'/'`` instead)
+- ``repeater()`` :doc:`String Helper <../helpers/string_helper>` function (use ``str_repeat()`` instead)
+- ``read_file()`` :doc:`File Helper <../helpers/file_helper>` function (use ``file_get_contents()`` instead)
+- ``form_prep()`` :doc:`Form Helper <../helpers/form_helper>` function (use :php:func:`html_escape()` instead)
+
+- The entire *Cart Library* (an archived version is available on GitHub: `bcit-ci/ci3-cart-library <https://github.com/bcit-ci/ci3-cart-library>`_)
+- The entire *Javascript Library* (it was always experimental in the first place)
+
+- The entire *Email Helper*, which only had two functions:
+
+ - ``valid_email()`` (use ``filter_var($email, FILTER_VALIDATE_EMAIL)`` instead)
+ - ``send_email()`` (use ``mail()`` instead)
+
+- The entire *Smiley Helper* (an archived version is available on GitHub: `bcit-ci/ci3-smiley-helper <https://github.com/bcit-ci/ci3-smiley-helper>`_)
diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst
index bc96e209f..14127d42e 100644
--- a/user_guide_src/source/installation/upgrading.rst
+++ b/user_guide_src/source/installation/upgrading.rst
@@ -8,6 +8,7 @@ upgrading from.
.. toctree::
:titlesonly:
+ Upgrading from 3.1.2+ to 3.2.x <upgrade_320>
Upgrading from 3.1.2 to 3.1.3 <upgrade_313>
Upgrading from 3.1.1 to 3.1.2 <upgrade_312>
Upgrading from 3.1.0 to 3.1.1 <upgrade_311>
diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst
index a7081ec6b..81019c015 100644
--- a/user_guide_src/source/libraries/caching.rst
+++ b/user_guide_src/source/libraries/caching.rst
@@ -255,8 +255,6 @@ To use it, you need `Redis server and phpredis PHP extension <https://github.com
Config options to connect to redis server must be stored in the application/config/redis.php file.
Available options are::
- $config['socket_type'] = 'tcp'; //`tcp` or `unix`
- $config['socket'] = '/var/run/redis.sock'; // in case of `unix` socket type
$config['host'] = '127.0.0.1';
$config['password'] = NULL;
$config['port'] = 6379;
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
deleted file mode 100644
index be343320d..000000000
--- a/user_guide_src/source/libraries/cart.rst
+++ /dev/null
@@ -1,398 +0,0 @@
-###################
-Shopping Cart Class
-###################
-
-The Cart Class permits items to be added to a session that stays active
-while a user is browsing your site. These items can be retrieved and
-displayed in a standard "shopping cart" format, allowing the user to
-update the quantity or remove items from the cart.
-
-.. important:: The Cart library is DEPRECATED and should not be used.
- It is currently only kept for backwards compatibility.
-
-Please note that the Cart Class ONLY provides the core "cart"
-functionality. It does not provide shipping, credit card authorization,
-or other processing components.
-
-.. contents::
- :local:
-
-.. raw:: html
-
- <div class="custom-index container"></div>
-
-********************
-Using the Cart Class
-********************
-
-Initializing the Shopping Cart Class
-====================================
-
-.. important:: The Cart class utilizes CodeIgniter's :doc:`Session
- Class <sessions>` to save the cart information to a database, so
- before using the Cart class you must set up a database table as
- indicated in the :doc:`Session Documentation <sessions>`, and set the
- session preferences in your application/config/config.php file to
- utilize a database.
-
-To initialize the Shopping Cart Class in your controller constructor,
-use the ``$this->load->library()`` method::
-
- $this->load->library('cart');
-
-Once loaded, the Cart object will be available using::
-
- $this->cart
-
-.. note:: The Cart Class will load and initialize the Session Class
- automatically, so unless you are using sessions elsewhere in your
- application, you do not need to load the Session class.
-
-Adding an Item to The Cart
-==========================
-
-To add an item to the shopping cart, simply pass an array with the
-product information to the ``$this->cart->insert()`` method, as shown
-below::
-
- $data = array(
- 'id' => 'sku_123ABC',
- 'qty' => 1,
- 'price' => 39.95,
- 'name' => 'T-Shirt',
- 'options' => array('Size' => 'L', 'Color' => 'Red')
- );
-
- $this->cart->insert($data);
-
-.. important:: The first four array indexes above (id, qty, price, and
- name) are **required**. If you omit any of them the data will not be
- saved to the cart. The fifth index (options) is optional. It is intended
- to be used in cases where your product has options associated with it.
- Use an array for options, as shown above.
-
-The five reserved indexes are:
-
-- **id** - Each product in your store must have a unique identifier.
- Typically this will be an "sku" or other such identifier.
-- **qty** - The quantity being purchased.
-- **price** - The price of the item.
-- **name** - The name of the item.
-- **options** - Any additional attributes that are needed to identify
- the product. These must be passed via an array.
-
-In addition to the five indexes above, there are two reserved words:
-rowid and subtotal. These are used internally by the Cart class, so
-please do NOT use those words as index names when inserting data into
-the cart.
-
-Your array may contain additional data. Anything you include in your
-array will be stored in the session. However, it is best to standardize
-your data among all your products in order to make displaying the
-information in a table easier.
-
-::
-
- $data = array(
- 'id' => 'sku_123ABC',
- 'qty' => 1,
- 'price' => 39.95,
- 'name' => 'T-Shirt',
- 'coupon' => 'XMAS-50OFF'
- );
-
- $this->cart->insert($data);
-
-The ``insert()`` method will return the $rowid if you successfully insert a
-single item.
-
-Adding Multiple Items to The Cart
-=================================
-
-By using a multi-dimensional array, as shown below, it is possible to
-add multiple products to the cart in one action. This is useful in cases
-where you wish to allow people to select from among several items on the
-same page.
-
-::
-
- $data = array(
- array(
- 'id' => 'sku_123ABC',
- 'qty' => 1,
- 'price' => 39.95,
- 'name' => 'T-Shirt',
- 'options' => array('Size' => 'L', 'Color' => 'Red')
- ),
- array(
- 'id' => 'sku_567ZYX',
- 'qty' => 1,
- 'price' => 9.95,
- 'name' => 'Coffee Mug'
- ),
- array(
- 'id' => 'sku_965QRS',
- 'qty' => 1,
- 'price' => 29.95,
- 'name' => 'Shot Glass'
- )
- );
-
- $this->cart->insert($data);
-
-Displaying the Cart
-===================
-
-To display the cart you will create a :doc:`view
-file </general/views>` with code similar to the one shown below.
-
-Please note that this example uses the :doc:`form
-helper </helpers/form_helper>`.
-
-::
-
- <?php echo form_open('path/to/controller/update/method'); ?>
-
- <table cellpadding="6" cellspacing="1" style="width:100%" border="0">
-
- <tr>
- <th>QTY</th>
- <th>Item Description</th>
- <th style="text-align:right">Item Price</th>
- <th style="text-align:right">Sub-Total</th>
- </tr>
-
- <?php $i = 1; ?>
-
- <?php foreach ($this->cart->contents() as $items): ?>
-
- <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
-
- <tr>
- <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
- <td>
- <?php echo $items['name']; ?>
-
- <?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
-
- <p>
- <?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
-
- <strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />
-
- <?php endforeach; ?>
- </p>
-
- <?php endif; ?>
-
- </td>
- <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
- <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
- </tr>
-
- <?php $i++; ?>
-
- <?php endforeach; ?>
-
- <tr>
- <td colspan="2"> </td>
- <td class="right"><strong>Total</strong></td>
- <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
- </tr>
-
- </table>
-
- <p><?php echo form_submit('', 'Update your Cart'); ?></p>
-
-Updating The Cart
-=================
-
-To update the information in your cart, you must pass an array
-containing the Row ID and one or more pre-defined properties to the
-``$this->cart->update()`` method.
-
-.. note:: If the quantity is set to zero, the item will be removed from
- the cart.
-
-::
-
- $data = array(
- 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
- 'qty' => 3
- );
-
- $this->cart->update($data);
-
- // Or a multi-dimensional array
-
- $data = array(
- array(
- 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
- 'qty' => 3
- ),
- array(
- 'rowid' => 'xw82g9q3r495893iajdh473990rikw23',
- 'qty' => 4
- ),
- array(
- 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
- 'qty' => 2
- )
- );
-
- $this->cart->update($data);
-
-You may also update any property you have previously defined when
-inserting the item such as options, price or other custom fields.
-
-::
-
- $data = array(
- 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
- 'qty' => 1,
- 'price' => 49.95,
- 'coupon' => NULL
- );
-
- $this->cart->update($data);
-
-What is a Row ID?
-*****************
-
-The row ID is a unique identifier that is generated by the cart code
-when an item is added to the cart. The reason a unique ID is created
-is so that identical products with different options can be managed
-by the cart.
-
-For example, let's say someone buys two identical t-shirts (same product
-ID), but in different sizes. The product ID (and other attributes) will
-be identical for both sizes because it's the same shirt. The only
-difference will be the size. The cart must therefore have a means of
-identifying this difference so that the two sizes of shirts can be
-managed independently. It does so by creating a unique "row ID" based on
-the product ID and any options associated with it.
-
-In nearly all cases, updating the cart will be something the user does
-via the "view cart" page, so as a developer, it is unlikely that you
-will ever have to concern yourself with the "row ID", other than making
-sure your "view cart" page contains this information in a hidden form
-field, and making sure it gets passed to the ``update()`` method when
-the update form is submitted. Please examine the construction of the
-"view cart" page above for more information.
-
-
-***************
-Class Reference
-***************
-
-.. php:class:: CI_Cart
-
- .. attribute:: $product_id_rules = '\.a-z0-9_-'
-
- These are the regular expression rules that we use to validate the product
- ID - alpha-numeric, dashes, underscores, or periods by default
-
- .. attribute:: $product_name_rules = '\w \-\.\:'
-
- These are the regular expression rules that we use to validate the product ID and product name - alpha-numeric, dashes, underscores, colons or periods by
- default
-
- .. attribute:: $product_name_safe = TRUE
-
- Whether or not to only allow safe product names. Default TRUE.
-
-
- .. php:method:: insert([$items = array()])
-
- :param array $items: Items to insert into the cart
- :returns: TRUE on success, FALSE on failure
- :rtype: bool
-
- Insert items into the cart and save it to the session table. Returns TRUE
- on success and FALSE on failure.
-
-
- .. php:method:: update([$items = array()])
-
- :param array $items: Items to update in the cart
- :returns: TRUE on success, FALSE on failure
- :rtype: bool
-
- This method permits changing the properties of a given item.
- Typically it is called from the "view cart" page if a user makes changes
- to the quantity before checkout. That array must contain the rowid
- for each item.
-
- .. php:method:: remove($rowid)
-
- :param int $rowid: ID of the item to remove from the cart
- :returns: TRUE on success, FALSE on failure
- :rtype: bool
-
- Allows you to remove an item from the shopping cart by passing it the
- ``$rowid``.
-
- .. php:method:: total()
-
- :returns: Total amount
- :rtype: int
-
- Displays the total amount in the cart.
-
-
- .. php:method:: total_items()
-
- :returns: Total amount of items in the cart
- :rtype: int
-
- Displays the total number of items in the cart.
-
-
- .. php:method:: contents([$newest_first = FALSE])
-
- :param bool $newest_first: Whether to order the array with newest items first
- :returns: An array of cart contents
- :rtype: array
-
- Returns an array containing everything in the cart. You can sort the
- order by which the array is returned by passing it TRUE where the contents
- will be sorted from newest to oldest, otherwise it is sorted from oldest
- to newest.
-
- .. php:method:: get_item($row_id)
-
- :param int $row_id: Row ID to retrieve
- :returns: Array of item data
- :rtype: array
-
- Returns an array containing data for the item matching the specified row
- ID, or FALSE if no such item exists.
-
- .. php:method:: has_options($row_id = '')
-
- :param int $row_id: Row ID to inspect
- :returns: TRUE if options exist, FALSE otherwise
- :rtype: bool
-
- Returns TRUE (boolean) if a particular row in the cart contains options.
- This method is designed to be used in a loop with ``contents()``, since
- you must pass the rowid to this method, as shown in the Displaying
- the Cart example above.
-
- .. php:method:: product_options([$row_id = ''])
-
- :param int $row_id: Row ID
- :returns: Array of product options
- :rtype: array
-
- Returns an array of options for a particular product. This method is
- designed to be used in a loop with ``contents()``, since you
- must pass the rowid to this method, as shown in the Displaying the
- Cart example above.
-
- .. php:method:: destroy()
-
- :rtype: void
-
- Permits you to destroy the cart. This method will likely be called
- when you are finished processing the customer's order. \ No newline at end of file
diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst
index a45cacdf5..7398329c3 100644
--- a/user_guide_src/source/libraries/config.rst
+++ b/user_guide_src/source/libraries/config.rst
@@ -239,14 +239,3 @@ Class Reference
This method is normally accessed via the corresponding functions in the
:doc:`URL Helper </helpers/url_helper>`.
-
- .. php:method:: system_url()
-
- :returns: URL pointing at your CI system/ directory
- :rtype: string
-
- This method retrieves the URL to your CodeIgniter system/ directory.
-
- .. note:: This method is DEPRECATED because it encourages usage of
- insecure coding practices. Your *system/* directory shouldn't
- be publicly accessible. \ No newline at end of file
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index 0b38737f1..253d85c71 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -108,7 +108,7 @@ Preference Default Value Options Descript
page. Make sure you don't have any relative links or relative image
paths otherwise they will not work.
**charset** ``$config['charset']`` Character set (utf-8, iso-8859-1, etc.).
-**validate** FALSE TRUE or FALSE (boolean) Whether to validate the email address.
+**validate** TRUE TRUE or FALSE (boolean) Whether to validate the email address.
**priority** 3 1, 2, 3, 4, 5 Email Priority. 1 = highest. 5 = lowest. 3 = normal.
**crlf** \\n "\\r\\n" or "\\n" or "\\r" Newline character. (Use "\\r\\n" to comply with RFC 822).
**newline** \\n "\\r\\n" or "\\n" or "\\r" Newline character. (Use "\\r\\n" to comply with RFC 822).
@@ -402,4 +402,4 @@ Class Reference
// Will only print the email headers, excluding the message subject and body
$this->email->print_debugger(array('headers'));
- .. note:: By default, all of the raw data will be printed. \ No newline at end of file
+ .. note:: By default, all of the raw data will be printed.
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 7792369b2..915ce876f 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -1009,7 +1009,6 @@ to use:
==================== ========= ==============================================================================================================
Name Parameter Description
==================== ========= ==============================================================================================================
-**prep_for_form** No DEPRECATED: Converts special characters so that HTML data can be shown in a form field without breaking it.
**prep_url** No Adds "\http://" to URLs if missing.
**strip_image_tags** No Strips the HTML from image tags leaving the raw URL.
**encode_php_tags** No Converts PHP tags to entities.
@@ -1027,13 +1026,14 @@ Class Reference
.. php:class:: CI_Form_validation
- .. php:method:: set_rules($field[, $label = ''[, $rules = ''[, $errors = array()]]])
+ .. php:method:: set_rules($field[, $label = null[, $rules = null[, $errors = array()]]])
:param string $field: Field name
:param string $label: Field label
:param mixed $rules: Validation rules, as a string list separated by a pipe "|", or as an array or rules
:param array $errors: A list of custom error messages
:returns: CI_Form_validation instance (method chaining)
+ :throws: BadMethodCallException If $field is not an array and $rules was not used
:rtype: CI_Form_validation
Permits you to set validation rules, as described in the tutorial
diff --git a/user_guide_src/source/libraries/image_lib.rst b/user_guide_src/source/libraries/image_lib.rst
index 22407962f..442541bf6 100644
--- a/user_guide_src/source/libraries/image_lib.rst
+++ b/user_guide_src/source/libraries/image_lib.rst
@@ -283,7 +283,7 @@ Preference Default Value Options Description
**wm_shadow_color** None None The color of the drop shadow, specified in hex. If you leave this blank
a drop shadow will not be used. Both the full 6-length (ie, 993300) and
the short three character abbreviated version (ie, fff) are supported.
-**wm_shadow_distance** 3 None The distance (in pixels) from the font that the drop shadow should
+**wm_shadow_distance** 2 None The distance (in pixels) from the font that the drop shadow should
appear.
======================= =================== =================== ==========================================================================
@@ -408,7 +408,7 @@ Class Reference
method is not very useful unless you intend to build such an
interface. That's exactly what we did using for the photo gallery module
in ExpressionEngine, the CMS we develop. We added a JavaScript UI that
- lets the cropping area be selected.
+ lets the cropping area be selected. (from EllisLab)
.. php:method:: rotate()
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index d9c6c2dd1..899070ef4 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -440,25 +440,6 @@ Class Reference
Checks to see if the HTTP_X_REQUESTED_WITH server header has been
set, and returns boolean TRUE if it is or FALSE if not.
- .. php:method:: is_cli_request()
-
- :returns: TRUE if it is a CLI request, FALSE if not
- :rtype: bool
-
- Checks to see if the application was run from the command-line
- interface.
-
- .. note:: This method checks both the PHP SAPI name currently in use
- and if the ``STDIN`` constant is defined, which is usually a
- failsafe way to see if PHP is being run via the command line.
-
- ::
-
- $this->input->is_cli_request()
-
- .. note:: This method is DEPRECATED and is now just an alias for the
- :func:`is_cli()` function.
-
.. php:method:: method([$upper = FALSE])
:param bool $upper: Whether to return the request method name in upper or lower case
diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst
deleted file mode 100644
index e91b9ad78..000000000
--- a/user_guide_src/source/libraries/javascript.rst
+++ /dev/null
@@ -1,322 +0,0 @@
-################
-Javascript Class
-################
-
-CodeIgniter provides a library to help you with certain common functions
-that you may want to use with Javascript. Please note that CodeIgniter
-does not require the jQuery library to run, and that any scripting
-library will work equally well. The jQuery library is simply presented
-as a convenience if you choose to use it.
-
-.. important:: This library is DEPRECATED and should not be used. It has always
- been with an 'experimental' status and is now no longer supported.
- Currently only kept for backwards compatibility.
-
-.. contents::
- :local:
-
-.. raw:: html
-
- <div class="custom-index container"></div>
-
-**************************
-Using the Javascript Class
-**************************
-
-Initializing the Class
-======================
-
-To initialize the Javascript class manually in your controller
-constructor, use the ``$this->load->library()`` method. Currently,
-the only available library is jQuery, which will automatically be
-loaded like this::
-
- $this->load->library('javascript');
-
-The Javascript class also accepts parameters:
-
-- js_library_driver (string) *default: 'jquery'*
-- autoload (bool) *default: TRUE*
-
-You may override the defaults by sending an associative array::
-
- $this->load->library(
- 'javascript',
- array(
- 'js_library_driver' => 'scripto',
- 'autoload' => FALSE
- )
- );
-
-Again, presently only 'jquery' is available. You may wish to set
-autoload to FALSE, though, if you do not want the jQuery library to
-automatically include a script tag for the main jQuery script file. This
-is useful if you are loading it from a location outside of CodeIgniter,
-or already have the script tag in your markup.
-
-Once loaded, the jQuery library object will be available using:
-
- $this->javascript
-
-Setup and Configuration
-=======================
-
-Set these variables in your view
---------------------------------
-
-As a Javascript library, your files must be available to your
-application.
-
-As Javascript is a client side language, the library must be able to
-write content into your final output. This generally means a view.
-You'll need to include the following variables in the ``<head>``
-sections of your output.
-
-::
-
- <?php echo $library_src;?>
- <?php echo $script_head;?>
-
-
-``$library_src``, is where the actual library file will be loaded, as
-well as any subsequent plugin script calls; $script_head is where
-specific events, functions and other commands will be rendered.
-
-Set the path to the librarys with config items
-----------------------------------------------
-
-There are some configuration items in Javascript library. These can
-either be set in *application/config.php*, within its own
-*config/javascript.php* file, or within any controller usings the
-``set_item()`` function.
-
-An image to be used as an "ajax loader", or progress indicator. Without
-one, the simple text message of "loading" will appear when Ajax calls
-need to be made.
-
-::
-
- $config['javascript_location'] = 'http://localhost/codeigniter/themes/js/jquery/';
- $config['javascript_ajax_img'] = 'images/ajax-loader.gif';
-
-If you keep your files in the same directories they were downloaded
-from, then you need not set this configuration items.
-
-The jQuery Class
-================
-
-To initialize the jQuery class manually in your controller constructor,
-use the ``$this->load->library()`` method::
-
- $this->load->library('javascript/jquery');
-
-You may send an optional parameter to determine whether or not a script
-tag for the main jQuery file will be automatically included when loading
-the library. It will be created by default. To prevent this, load the
-library as follows::
-
- $this->load->library('javascript/jquery', FALSE);
-
-Once loaded, the jQuery library object will be available using:
-
- $this->jquery
-
-jQuery Events
-=============
-
-Events are set using the following syntax.
-::
-
- $this->jquery->event('element_path', code_to_run());
-
-In the above example:
-
-- "event" is any of blur, change, click, dblclick, error, focus, hover,
- keydown, keyup, load, mousedown, mouseup, mouseover, mouseup, resize,
- scroll, or unload.
-- "element_path" is any valid `jQuery selector
- <http://api.jquery.com/category/selectors/>`_. Due to jQuery's unique
- selector syntax, this is usually an element id, or CSS selector. For
- example "#notice_area" would effect ``<div id="notice_area">``, and
- "#content a.notice" would effect all anchors with a class of "notice"
- in the div with id "content".
-- "``code_to_run()``" is script your write yourself, or an action such as
- an effect from the jQuery library below.
-
-Effects
-=======
-
-The query library supports a powerful
-`Effects <http://api.jquery.com/category/effects/>`_ repertoire. Before an effect
-can be used, it must be loaded::
-
- $this->jquery->effect([optional path] plugin name); // for example $this->jquery->effect('bounce');
-
-
-hide() / show()
----------------
-
-Each of this functions will affect the visibility of an item on your
-page. hide() will set an item invisible, show() will reveal it.
-
-::
-
- $this->jquery->hide(target, optional speed, optional extra information);
- $this->jquery->show(target, optional speed, optional extra information);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "speed" is optional, and is set to either slow, normal, fast, or
- alternatively a number of milliseconds.
-- "extra information" is optional, and could include a callback, or
- other additional information.
-
-toggle()
---------
-
-toggle() will change the visibility of an item to the opposite of its
-current state, hiding visible elements, and revealing hidden ones.
-
-::
-
- $this->jquery->toggle(target);
-
-
-- "target" will be any valid jQuery selector or selectors.
-
-animate()
----------
-
-::
-
- $this->jquery->animate(target, parameters, optional speed, optional extra information);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "parameters" in jQuery would generally include a series of CSS
- properties that you wish to change.
-- "speed" is optional, and is set to either slow, normal, fast, or
- alternatively a number of milliseconds.
-- "extra information" is optional, and could include a callback, or
- other additional information.
-
-For a full summary, see
-`http://api.jquery.com/animate/ <http://api.jquery.com/animate/>`_
-
-Here is an example of an animate() called on a div with an id of "note",
-and triggered by a click using the jQuery library's click() event.
-
-::
-
- $params = array(
- 'height' => 80,
- 'width' => '50%',
- 'marginLeft' => 125
- );
- $this->jquery->click('#trigger', $this->jquery->animate('#note', $params, 'normal'));
-
-fadeIn() / fadeOut()
---------------------
-
-::
-
- $this->jquery->fadeIn(target, optional speed, optional extra information);
- $this->jquery->fadeOut(target, optional speed, optional extra information);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "speed" is optional, and is set to either slow, normal, fast, or
- alternatively a number of milliseconds.
-- "extra information" is optional, and could include a callback, or
- other additional information.
-
-toggleClass()
--------------
-
-This function will add or remove a CSS class to its target.
-
-::
-
- $this->jquery->toggleClass(target, class)
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "class" is any CSS classname. Note that this class must be defined
- and available in a CSS that is already loaded.
-
-fadeIn() / fadeOut()
---------------------
-
-These effects cause an element(s) to disappear or reappear over time.
-
-::
-
- $this->jquery->fadeIn(target, optional speed, optional extra information);
- $this->jquery->fadeOut(target, optional speed, optional extra information);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "speed" is optional, and is set to either slow, normal, fast, or
- alternatively a number of milliseconds.
-- "extra information" is optional, and could include a callback, or
- other additional information.
-
-slideUp() / slideDown() / slideToggle()
----------------------------------------
-
-These effects cause an element(s) to slide.
-
-::
-
- $this->jquery->slideUp(target, optional speed, optional extra information);
- $this->jquery->slideDown(target, optional speed, optional extra information);
- $this->jquery->slideToggle(target, optional speed, optional extra information);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "speed" is optional, and is set to either slow, normal, fast, or
- alternatively a number of milliseconds.
-- "extra information" is optional, and could include a callback, or
- other additional information.
-
-Plugins
-=======
-
-Some select jQuery plugins are made available using this library.
-
-corner()
---------
-
-Used to add distinct corners to page elements. For full details see
-`http://malsup.com/jquery/corner/ <http://malsup.com/jquery/corner/>`_
-
-::
-
- $this->jquery->corner(target, corner_style);
-
-
-- "target" will be any valid jQuery selector or selectors.
-- "corner_style" is optional, and can be set to any valid style such
- as round, sharp, bevel, bite, dog, etc. Individual corners can be set
- by following the style with a space and using "tl" (top left), "tr"
- (top right), "bl" (bottom left), or "br" (bottom right).
-
-::
-
- $this->jquery->corner("#note", "cool tl br");
-
-
-tablesorter()
--------------
-
-description to come
-
-modal()
--------
-
-description to come
-
-calendar()
-----------
-
-description to come \ No newline at end of file
diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst
index 91ae1ae8d..06dfe59de 100644
--- a/user_guide_src/source/libraries/table.rst
+++ b/user_guide_src/source/libraries/table.rst
@@ -275,11 +275,16 @@ Class Reference
:returns: CI_Table instance (method chaining)
:rtype: CI_Table
- Lets you clear the table heading and row data. If you need to show multiple tables with different data you should to call this method
- after each table has been generated to clear the previous table information. Example::
+ Lets you clear the table heading, row data and caption. If
+ you need to show multiple tables with different data you
+ should to call this method after each table has been
+ generated to clear the previous table information.
+
+ Example ::
$this->load->library('table');
+ $this->table->set_caption('Preferences');
$this->table->set_heading('Name', 'Color', 'Size');
$this->table->add_row('Fred', 'Blue', 'Small');
$this->table->add_row('Mary', 'Red', 'Large');
@@ -289,6 +294,7 @@ Class Reference
$this->table->clear();
+ $this->table->set_caption('Shipping');
$this->table->set_heading('Name', 'Day', 'Delivery');
$this->table->add_row('Fred', 'Wednesday', 'Express');
$this->table->add_row('Mary', 'Monday', 'Air');