summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cache/Cache.php36
-rw-r--r--system/libraries/Cache/drivers/Cache_apc.php30
-rw-r--r--system/libraries/Cache/drivers/Cache_dummy.php8
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php55
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php10
-rw-r--r--system/libraries/Encrypt.php105
-rw-r--r--system/libraries/Form_validation.php167
-rw-r--r--system/libraries/Javascript.php158
-rw-r--r--system/libraries/Pagination.php30
-rw-r--r--system/libraries/Profiler.php225
-rw-r--r--system/libraries/Sha1.php263
-rw-r--r--system/libraries/Typography.php101
-rw-r--r--system/libraries/Upload.php15
-rw-r--r--system/libraries/User_agent.php13
-rw-r--r--system/libraries/Xmlrpcs.php144
-rw-r--r--system/libraries/javascript/Jquery.php408
16 files changed, 573 insertions, 1195 deletions
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index c296fa770..87253739c 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -22,22 +22,22 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Caching Class
+ * CodeIgniter Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author EllisLab Dev Team
- * @link
+ * @link
*/
class CI_Cache extends CI_Driver_Library {
-
+
protected $valid_drivers = array(
'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
);
@@ -45,7 +45,7 @@ class CI_Cache extends CI_Driver_Library {
protected $_cache_path = NULL; // Path of cache files (if file-based cache)
protected $_adapter = 'dummy';
protected $_backup_driver;
-
+
// ------------------------------------------------------------------------
/**
@@ -64,16 +64,16 @@ class CI_Cache extends CI_Driver_Library {
// ------------------------------------------------------------------------
/**
- * Get
+ * Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
+ * @param string
* @return mixed value that is stored/FALSE on failure
*/
public function get($id)
- {
+ {
return $this->{$this->_adapter}->get($id);
}
@@ -124,7 +124,7 @@ class CI_Cache extends CI_Driver_Library {
* Cache Info
*
* @param string user/filehits
- * @return mixed array on success, false on failure
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = 'user')
{
@@ -132,7 +132,7 @@ class CI_Cache extends CI_Driver_Library {
}
// ------------------------------------------------------------------------
-
+
/**
* Get Cache Metadata
*
@@ -143,7 +143,7 @@ class CI_Cache extends CI_Driver_Library {
{
return $this->{$this->_adapter}->get_metadata($id);
}
-
+
// ------------------------------------------------------------------------
/**
@@ -151,7 +151,7 @@ class CI_Cache extends CI_Driver_Library {
*
* Initialize class properties based on the configuration array.
*
- * @param array
+ * @param array
* @return void
*/
private function _initialize($config)
@@ -219,10 +219,10 @@ class CI_Cache extends CI_Driver_Library {
return $obj;
}
-
+
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache.php */
-/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file
+/* Location: ./system/libraries/Cache/Cache.php */
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index f15cf8501..90b68688d 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -22,30 +22,30 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter APC Caching Class
+ * CodeIgniter APC Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author EllisLab Dev Team
- * @link
+ * @link
*/
class CI_Cache_apc extends CI_Driver {
/**
- * Get
+ * Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
+ * @param string
* @return mixed value that is stored/FALSE on failure
*/
public function get($id)
@@ -55,8 +55,8 @@ class CI_Cache_apc extends CI_Driver {
return (is_array($data)) ? $data[0] : FALSE;
}
- // ------------------------------------------------------------------------
-
+ // ------------------------------------------------------------------------
+
/**
* Cache Save
*
@@ -70,7 +70,7 @@ class CI_Cache_apc extends CI_Driver {
{
return apc_store($id, array($data, time(), $ttl), $ttl);
}
-
+
// ------------------------------------------------------------------------
/**
@@ -102,7 +102,7 @@ class CI_Cache_apc extends CI_Driver {
* Cache Info
*
* @param string user/filehits
- * @return mixed array on success, false on failure
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = NULL)
{
@@ -149,13 +149,13 @@ class CI_Cache_apc extends CI_Driver {
log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
return FALSE;
}
-
+
return TRUE;
}
// ------------------------------------------------------------------------
-
+
}
// End Class
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index 965bb2bef..ff787e90b 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -138,4 +138,4 @@ class CI_Cache_dummy extends CI_Driver {
// End Class
/* End of file Cache_dummy.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index be392d3d2..194279726 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -22,19 +22,19 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Memcached Caching Class
+ * CodeIgniter Memcached Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author EllisLab Dev Team
- * @link
+ * @link
*/
class CI_Cache_file extends CI_Driver {
@@ -48,9 +48,7 @@ class CI_Cache_file extends CI_Driver {
{
$CI =& get_instance();
$CI->load->helper('file');
-
$path = $CI->config->item('cache_path');
-
$this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
}
@@ -68,16 +66,15 @@ class CI_Cache_file extends CI_Driver {
{
return FALSE;
}
-
- $data = read_file($this->_cache_path.$id);
- $data = unserialize($data);
-
+
+ $data = unserialize(read_file($this->_cache_path.$id));
+
if (time() > $data['time'] + $data['ttl'])
{
unlink($this->_cache_path.$id);
return FALSE;
}
-
+
return $data['data'];
}
@@ -88,22 +85,22 @@ class CI_Cache_file extends CI_Driver {
*
* @param string unique key
* @param mixed data to store
- * @param int length of time (in seconds) the cache is valid
+ * @param int length of time (in seconds) the cache is valid
* - Default is 60 seconds
* @return boolean true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
- {
+ {
$contents = array(
'time' => time(),
- 'ttl' => $ttl,
+ 'ttl' => $ttl,
'data' => $data
);
-
+
if (write_file($this->_cache_path.$id, serialize($contents)))
{
@chmod($this->_cache_path.$id, 0777);
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -119,14 +116,7 @@ class CI_Cache_file extends CI_Driver {
*/
public function delete($id)
{
- if (file_exists($this->_cache_path.$id))
- {
- return unlink($this->_cache_path.$id);
- }
- else
- {
- return FALSE;
- }
+ return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE;
}
// ------------------------------------------------------------------------
@@ -135,7 +125,7 @@ class CI_Cache_file extends CI_Driver {
* Clean the Cache
*
* @return boolean false on failure/true on success
- */
+ */
public function clean()
{
return delete_files($this->_cache_path);
@@ -170,10 +160,9 @@ class CI_Cache_file extends CI_Driver {
{
return FALSE;
}
-
- $data = read_file($this->_cache_path.$id);
- $data = unserialize($data);
-
+
+ $data = unserialize(read_file($this->_cache_path.$id));
+
if (is_array($data))
{
$mtime = filemtime($this->_cache_path.$id);
@@ -188,7 +177,7 @@ class CI_Cache_file extends CI_Driver {
'mtime' => $mtime
);
}
-
+
return FALSE;
}
@@ -198,7 +187,7 @@ class CI_Cache_file extends CI_Driver {
* Is supported
*
* In the file driver, check to see that the cache directory is indeed writable
- *
+ *
* @return boolean
*/
public function is_supported()
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 78cab25d4..0037e6755 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -84,7 +84,7 @@ class CI_Cache_memcached extends CI_Driver {
{
return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
}
-
+
return FALSE;
}
@@ -256,4 +256,4 @@ class CI_Cache_memcached extends CI_Driver {
// End Class
/* End of file Cache_memcached.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index c2cb808dd..92b0b3c4a 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -40,22 +40,19 @@
*/
class CI_Encrypt {
- var $CI;
- var $encryption_key = '';
- var $_hash_type = 'sha1';
- var $_mcrypt_exists = FALSE;
- var $_mcrypt_cipher;
- var $_mcrypt_mode;
+ public $encryption_key = '';
+ protected $_hash_type = 'sha1';
+ protected $_mcrypt_exists = FALSE;
+ protected $_mcrypt_cipher;
+ protected $_mcrypt_mode;
/**
* Constructor
*
* Simply determines whether the mcrypt library exists.
- *
*/
public function __construct()
{
- $this->CI =& get_instance();
$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
log_message('debug', "Encrypt Class Initialized");
}
@@ -68,11 +65,10 @@ class CI_Encrypt {
* Returns it as MD5 in order to have an exact-length 128 bit key.
* Mcrypt is sensitive to keys that are not the correct length
*
- * @access public
* @param string
* @return string
*/
- function get_key($key = '')
+ public function get_key($key = '')
{
if ($key == '')
{
@@ -84,7 +80,7 @@ class CI_Encrypt {
$CI =& get_instance();
$key = $CI->config->item('encryption_key');
- if ($key == FALSE)
+ if ($key === FALSE)
{
show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
}
@@ -98,13 +94,13 @@ class CI_Encrypt {
/**
* Set the encryption key
*
- * @access public
* @param string
* @return void
*/
- function set_key($key = '')
+ public function set_key($key = '')
{
$this->encryption_key = $key;
+ return $this;
}
// --------------------------------------------------------------------
@@ -120,12 +116,11 @@ class CI_Encrypt {
* that is randomized with each call to this function,
* even if the supplied message and key are the same.
*
- * @access public
* @param string the string to encode
* @param string the key
* @return string
*/
- function encode($string, $key = '')
+ public function encode($string, $key = '')
{
$key = $this->get_key($key);
@@ -148,12 +143,11 @@ class CI_Encrypt {
*
* Reverses the above process
*
- * @access public
* @param string
* @param string
* @return string
*/
- function decode($string, $key = '')
+ public function decode($string, $key = '')
{
$key = $this->get_key($key);
@@ -191,13 +185,12 @@ class CI_Encrypt {
*
* For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
*
- * @access public
* @param string
* @param int (mcrypt mode constant)
* @param string
* @return string
*/
- function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
+ public function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
{
if ($this->_mcrypt_exists === FALSE)
{
@@ -242,12 +235,11 @@ class CI_Encrypt {
* Takes a plain-text string and key as input and generates an
* encoded bit-string using XOR
*
- * @access private
* @param string
* @param string
* @return string
*/
- function _xor_encode($string, $key)
+ protected function _xor_encode($string, $key)
{
$rand = '';
while (strlen($rand) < 32)
@@ -274,12 +266,11 @@ class CI_Encrypt {
* Takes an encoded string and key as input and generates the
* plain-text original message
*
- * @access private
* @param string
* @param string
* @return string
*/
- function _xor_decode($string, $key)
+ protected function _xor_decode($string, $key)
{
$string = $this->_xor_merge($string, $key);
@@ -299,12 +290,11 @@ class CI_Encrypt {
*
* Takes a string and key as input and computes the difference using XOR
*
- * @access private
* @param string
* @param string
* @return string
*/
- function _xor_merge($string, $key)
+ protected function _xor_merge($string, $key)
{
$hash = $this->hash($key);
$str = '';
@@ -321,12 +311,11 @@ class CI_Encrypt {
/**
* Encrypt using Mcrypt
*
- * @access public
* @param string
* @param string
* @return string
*/
- function mcrypt_encode($data, $key)
+ public function mcrypt_encode($data, $key)
{
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
@@ -338,12 +327,11 @@ class CI_Encrypt {
/**
* Decrypt using Mcrypt
*
- * @access public
* @param string
* @param string
* @return string
*/
- function mcrypt_decode($data, $key)
+ public function mcrypt_decode($data, $key)
{
$data = $this->_remove_cipher_noise($data, $key);
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
@@ -365,14 +353,11 @@ class CI_Encrypt {
* against Man-in-the-middle attacks on CBC mode ciphers
* http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
*
- * Function description
- *
- * @access private
* @param string
* @param string
* @return string
*/
- function _add_cipher_noise($data, $key)
+ protected function _add_cipher_noise($data, $key)
{
$keyhash = $this->hash($key);
$keylen = strlen($keyhash);
@@ -399,11 +384,10 @@ class CI_Encrypt {
*
* Function description
*
- * @access public
* @param type
* @return type
*/
- function _remove_cipher_noise($data, $key)
+ protected function _remove_cipher_noise($data, $key)
{
$keyhash = $this->hash($key);
$keylen = strlen($keyhash);
@@ -434,13 +418,13 @@ class CI_Encrypt {
/**
* Set the Mcrypt Cipher
*
- * @access public
* @param constant
* @return string
*/
- function set_cipher($cipher)
+ public function set_cipher($cipher)
{
$this->_mcrypt_cipher = $cipher;
+ return $this;
}
// --------------------------------------------------------------------
@@ -448,13 +432,13 @@ class CI_Encrypt {
/**
* Set the Mcrypt Mode
*
- * @access public
* @param constant
* @return string
*/
function set_mode($mode)
{
$this->_mcrypt_mode = $mode;
+ return $this;
}
// --------------------------------------------------------------------
@@ -462,10 +446,9 @@ class CI_Encrypt {
/**
* Get Mcrypt cipher Value
*
- * @access private
* @return string
*/
- function _get_cipher()
+ protected function _get_cipher()
{
if ($this->_mcrypt_cipher == '')
{
@@ -480,10 +463,9 @@ class CI_Encrypt {
/**
* Get Mcrypt Mode Value
*
- * @access private
* @return string
*/
- function _get_mode()
+ protected function _get_mode()
{
if ($this->_mcrypt_mode == '')
{
@@ -498,11 +480,10 @@ class CI_Encrypt {
/**
* Set the Hash type
*
- * @access public
* @param string
* @return string
*/
- function set_hash($type = 'sha1')
+ public function set_hash($type = 'sha1')
{
$this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
}
@@ -512,45 +493,13 @@ class CI_Encrypt {
/**
* Hash encode a string
*
- * @access public
* @param string
* @return string
*/
- function hash($str)
+ public function hash($str)
{
- return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
+ return ($this->_hash_type == 'sha1') ? sha1($str) : md5($str);
}
-
- // --------------------------------------------------------------------
-
- /**
- * Generate an SHA1 Hash
- *
- * @access public
- * @param string
- * @return string
- */
- function sha1($str)
- {
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1.php');
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
- }
-
}
// END CI_Encrypt class
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 3f5323233..d83afdd25 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -86,7 +86,7 @@ class CI_Form_validation {
public function set_rules($field, $label = '', $rules = '')
{
// No reason to set rules if we have no POST data
- if (count($_POST) == 0)
+ if (count($_POST) === 0)
{
return $this;
}
@@ -113,7 +113,7 @@ class CI_Form_validation {
}
// No fields? Nothing to do...
- if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
+ if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
{
return $this;
}
@@ -121,21 +121,20 @@ class CI_Form_validation {
// If the field label wasn't passed we use the field name
$label = ($label == '') ? $field : $label;
- // Is the field name an array? We test for the existence of a bracket "[" in
- // the field name to determine this. If it is an array, we break it apart
+ // Is the field name an array? If it is an array, we break it apart
// into its components so that we can fetch the corresponding POST data later
- if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))
+ if (preg_match_all('/\[(.*?)\]/', $field, $matches))
{
// Note: Due to a bug in current() that affects some versions
// of PHP we can not pass function call directly into it
$x = explode('[', $field);
$indexes[] = current($x);
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
{
- if ($matches['1'][$i] != '')
+ if ($matches[1][$i] != '')
{
- $indexes[] = $matches['1'][$i];
+ $indexes[] = $matches[1][$i];
}
}
@@ -293,17 +292,17 @@ class CI_Form_validation {
public function run($group = '')
{
// Do we even have any data to process? Mm?
- if (count($_POST) == 0)
+ if (count($_POST) === 0)
{
return FALSE;
}
// Does the _field_data array containing the validation rules exist?
// If not, we look to see if they were assigned via a config file
- if (count($this->_field_data) == 0)
+ if (count($this->_field_data) === 0)
{
// No validation rules? We're done...
- if (count($this->_config_rules) == 0)
+ if (count($this->_config_rules) === 0)
{
return FALSE;
}
@@ -321,7 +320,7 @@ class CI_Form_validation {
}
// We're we able to set the rules correctly?
- if (count($this->_field_data) == 0)
+ if (count($this->_field_data) === 0)
{
log_message('debug', "Unable to find validation rules");
return FALSE;
@@ -338,7 +337,7 @@ class CI_Form_validation {
// Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
// Depending on whether the field name is an array or a string will determine where we get it from.
- if ($row['is_array'] == TRUE)
+ if ($row['is_array'] === TRUE)
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
}
@@ -364,14 +363,7 @@ class CI_Form_validation {
// Now we need to re-set the POST data with the new, processed data
$this->_reset_post_array();
- // No errors, validation passes!
- if ($total_errors == 0)
- {
- return TRUE;
- }
-
- // Validation fails
- return FALSE;
+ return ($total_errors === 0);
}
// --------------------------------------------------------------------
@@ -379,7 +371,7 @@ class CI_Form_validation {
/**
* Traverse a multidimensional $_POST array index until the data is found
*
- * @access private
+ * @access protected
* @param array
* @param array
* @param integer
@@ -387,23 +379,9 @@ class CI_Form_validation {
*/
protected function _reduce_array($array, $keys, $i = 0)
{
- if (is_array($array))
+ if (is_array($array) && isset($keys[$i]))
{
- if (isset($keys[$i]))
- {
- if (isset($array[$keys[$i]]))
- {
- $array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
- }
- else
- {
- return NULL;
- }
- }
- else
- {
- return $array;
- }
+ return isset($array[$keys[$i]]) ? $this->_reduce_array($array[$keys[$i]], $keys, ($i+1)) : NULL;
}
return $array;
@@ -414,7 +392,7 @@ class CI_Form_validation {
/**
* Re-populate the _POST array with our finalized and processed data
*
- * @access private
+ * @access protected
* @return null
*/
protected function _reset_post_array()
@@ -423,7 +401,7 @@ class CI_Form_validation {
{
if ( ! is_null($row['postdata']))
{
- if ($row['is_array'] == FALSE)
+ if ($row['is_array'] === FALSE)
{
if (isset($_POST[$row['field']]))
{
@@ -436,7 +414,7 @@ class CI_Form_validation {
$post_ref =& $_POST;
// before we assign values, make a reference to the right POST key
- if (count($row['keys']) == 1)
+ if (count($row['keys']) === 1)
{
$post_ref =& $post_ref[current($row['keys'])];
}
@@ -472,7 +450,7 @@ class CI_Form_validation {
/**
* Executes the Validation routines
*
- * @access private
+ * @access protected
* @param array
* @param array
* @param mixed
@@ -514,7 +492,7 @@ class CI_Form_validation {
// --------------------------------------------------------------------
// Isset Test. Typically this rule will only apply to checkboxes.
- if (is_null($postdata) AND $callback == FALSE)
+ if (is_null($postdata) AND $callback === FALSE)
{
if (in_array('isset', $rules, TRUE) OR in_array('required', $rules))
{
@@ -605,7 +583,7 @@ class CI_Form_validation {
$result = $this->CI->$rule($postdata, $param);
// Re-assign the result to the master data array
- if ($_in_array == TRUE)
+ if ($_in_array === TRUE)
{
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
}
@@ -630,7 +608,7 @@ class CI_Form_validation {
{
$result = $rule($postdata);
- if ($_in_array == TRUE)
+ if ($_in_array === TRUE)
{
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
}
@@ -649,7 +627,7 @@ class CI_Form_validation {
$result = $this->$rule($postdata, $param);
- if ($_in_array == TRUE)
+ if ($_in_array === TRUE)
{
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
}
@@ -676,7 +654,7 @@ class CI_Form_validation {
// Is the parameter we are inserting into the error message the name
// of another field? If so we need to grab its "field label"
- if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
+ if (isset($this->_field_data[$param], $this->_field_data[$param]['label']))
{
$param = $this->_translate_fieldname($this->_field_data[$param]['label']);
}
@@ -702,7 +680,7 @@ class CI_Form_validation {
/**
* Translate a field name
*
- * @access private
+ * @access protected
* @param string the field name
* @return string
*/
@@ -710,7 +688,7 @@ class CI_Form_validation {
{
// Do we need to translate the field name?
// We look for the prefix lang: to determine this
- if (substr($fieldname, 0, 5) == 'lang:')
+ if (substr($fieldname, 0, 5) === 'lang:')
{
// Grab the variable
$line = substr($fieldname, 5);
@@ -858,33 +836,8 @@ class CI_Form_validation {
*/
public function set_checkbox($field = '', $value = '', $default = FALSE)
{
- if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
- {
- if ($default === TRUE AND count($this->_field_data) === 0)
- {
- return ' checked="checked"';
- }
- return '';
- }
-
- $field = $this->_field_data[$field]['postdata'];
-
- if (is_array($field))
- {
- if ( ! in_array($value, $field))
- {
- return '';
- }
- }
- else
- {
- if (($field == '' OR $value == '') OR ($field != $value))
- {
- return '';
- }
- }
-
- return ' checked="checked"';
+ // Logic is exactly the same as for radio fields
+ return $this->set_radio($field, $value, $default);
}
// --------------------------------------------------------------------
@@ -898,14 +851,7 @@ class CI_Form_validation {
*/
public function required($str)
{
- if ( ! is_array($str))
- {
- return (trim($str) == '') ? FALSE : TRUE;
- }
- else
- {
- return ( ! empty($str));
- }
+ return ( ! is_array($str)) ? (trim($str) !== '') : ( ! empty($str));
}
// --------------------------------------------------------------------
@@ -920,12 +866,7 @@ class CI_Form_validation {
*/
public function regex_match($str, $regex)
{
- if ( ! preg_match($regex, $str))
- {
- return FALSE;
- }
-
- return TRUE;
+ return (bool) preg_match($regex, $str);
}
// --------------------------------------------------------------------
@@ -947,7 +888,7 @@ class CI_Form_validation {
$field = $_POST[$field];
- return ($str !== $field) ? FALSE : TRUE;
+ return ($str === $field);
}
// --------------------------------------------------------------------
@@ -990,10 +931,10 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) < $val) ? FALSE : TRUE;
+ return ! (mb_strlen($str) < $val);
}
- return (strlen($str) < $val) ? FALSE : TRUE;
+ return ! (strlen($str) < $val);
}
// --------------------------------------------------------------------
@@ -1015,10 +956,10 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) > $val) ? FALSE : TRUE;
+ return ! (mb_strlen($str) > $val);
}
- return (strlen($str) > $val) ? FALSE : TRUE;
+ return ! (strlen($str) > $val);
}
// --------------------------------------------------------------------
@@ -1040,10 +981,10 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) != $val) ? FALSE : TRUE;
+ return (mb_strlen($str) == $val);
}
- return (strlen($str) != $val) ? FALSE : TRUE;
+ return (strlen($str) == $val);
}
// --------------------------------------------------------------------
@@ -1057,7 +998,7 @@ class CI_Form_validation {
*/
public function valid_email($str)
{
- return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
+ return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $str);
}
// --------------------------------------------------------------------
@@ -1078,7 +1019,7 @@ class CI_Form_validation {
foreach (explode(',', $str) as $email)
{
- if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
+ if (trim($email) !== '' && $this->valid_email(trim($email)) === FALSE)
{
return FALSE;
}
@@ -1112,7 +1053,7 @@ class CI_Form_validation {
*/
public function alpha($str)
{
- return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
+ return (bool) preg_match('/^[a-z]+$/i', $str);
}
// --------------------------------------------------------------------
@@ -1126,7 +1067,7 @@ class CI_Form_validation {
*/
public function alpha_numeric($str)
{
- return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE;
+ return (bool) preg_match('/^[a-z0-9]+$/i', $str);
}
// --------------------------------------------------------------------
@@ -1140,7 +1081,7 @@ class CI_Form_validation {
*/
public function alpha_dash($str)
{
- return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
+ return (bool) preg_match('/^[a-z0-9_-]+$/i', $str);
}
// --------------------------------------------------------------------
@@ -1154,7 +1095,7 @@ class CI_Form_validation {
*/
public function numeric($str)
{
- return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
+ return (bool) preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
}
@@ -1169,7 +1110,7 @@ class CI_Form_validation {
*/
public function is_numeric($str)
{
- return ( ! is_numeric($str)) ? FALSE : TRUE;
+ return is_numeric($str);
}
// --------------------------------------------------------------------
@@ -1247,7 +1188,7 @@ class CI_Form_validation {
*/
public function is_natural($str)
{
- return (bool) preg_match( '/^[0-9]+$/', $str);
+ return (bool) preg_match('/^[0-9]+$/', $str);
}
// --------------------------------------------------------------------
@@ -1261,17 +1202,7 @@ class CI_Form_validation {
*/
public function is_natural_no_zero($str)
{
- if ( ! preg_match( '/^[0-9]+$/', $str))
- {
- return FALSE;
- }
-
- if ($str == 0)
- {
- return FALSE;
- }
-
- return TRUE;
+ return ($str != 0 AND preg_match('/^[0-9]+$/', $str));
}
// --------------------------------------------------------------------
@@ -1339,7 +1270,7 @@ class CI_Form_validation {
return '';
}
- if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
+ if (substr($str, 0, 7) !== 'http://' && substr($str, 0, 8) !== 'https://')
{
$str = 'http://'.$str;
}
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 15887cb95..f872d672f 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,7 +38,7 @@
*/
class CI_Javascript {
- var $_javascript_location = 'js';
+ protected $_javascript_location = 'js';
public function __construct($params = array())
{
@@ -64,7 +64,7 @@ class CI_Javascript {
log_message('debug', "Javascript Class Initialized and loaded. Driver used: $js_library_driver");
}
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
// Event Code
// --------------------------------------------------------------------
@@ -73,12 +73,11 @@ class CI_Javascript {
*
* Outputs a javascript library blur event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function blur($element = 'this', $js = '')
+ public function blur($element = 'this', $js = '')
{
return $this->js->_blur($element, $js);
}
@@ -90,12 +89,11 @@ class CI_Javascript {
*
* Outputs a javascript library change event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function change($element = 'this', $js = '')
+ public function change($element = 'this', $js = '')
{
return $this->js->_change($element, $js);
}
@@ -107,13 +105,12 @@ class CI_Javascript {
*
* Outputs a javascript library click event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @param boolean whether or not to return false
* @return string
*/
- function click($element = 'this', $js = '', $ret_false = TRUE)
+ public function click($element = 'this', $js = '', $ret_false = TRUE)
{
return $this->js->_click($element, $js, $ret_false);
}
@@ -125,12 +122,11 @@ class CI_Javascript {
*
* Outputs a javascript library dblclick event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function dblclick($element = 'this', $js = '')
+ public function dblclick($element = 'this', $js = '')
{
return $this->js->_dblclick($element, $js);
}
@@ -142,12 +138,11 @@ class CI_Javascript {
*
* Outputs a javascript library error event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function error($element = 'this', $js = '')
+ public function error($element = 'this', $js = '')
{
return $this->js->_error($element, $js);
}
@@ -159,12 +154,11 @@ class CI_Javascript {
*
* Outputs a javascript library focus event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function focus($element = 'this', $js = '')
+ public function focus($element = 'this', $js = '')
{
return $this->js->__add_event($focus, $js);
}
@@ -176,13 +170,12 @@ class CI_Javascript {
*
* Outputs a javascript library hover event
*
- * @access public
* @param string - element
* @param string - Javascript code for mouse over
* @param string - Javascript code for mouse out
* @return string
*/
- function hover($element = 'this', $over, $out)
+ public function hover($element = 'this', $over, $out)
{
return $this->js->__hover($element, $over, $out);
}
@@ -194,12 +187,11 @@ class CI_Javascript {
*
* Outputs a javascript library keydown event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function keydown($element = 'this', $js = '')
+ public function keydown($element = 'this', $js = '')
{
return $this->js->_keydown($element, $js);
}
@@ -211,12 +203,11 @@ class CI_Javascript {
*
* Outputs a javascript library keydown event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function keyup($element = 'this', $js = '')
+ public function keyup($element = 'this', $js = '')
{
return $this->js->_keyup($element, $js);
}
@@ -228,12 +219,11 @@ class CI_Javascript {
*
* Outputs a javascript library load event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function load($element = 'this', $js = '')
+ public function load($element = 'this', $js = '')
{
return $this->js->_load($element, $js);
}
@@ -245,12 +235,11 @@ class CI_Javascript {
*
* Outputs a javascript library mousedown event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function mousedown($element = 'this', $js = '')
+ public function mousedown($element = 'this', $js = '')
{
return $this->js->_mousedown($element, $js);
}
@@ -262,12 +251,11 @@ class CI_Javascript {
*
* Outputs a javascript library mouseout event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function mouseout($element = 'this', $js = '')
+ public function mouseout($element = 'this', $js = '')
{
return $this->js->_mouseout($element, $js);
}
@@ -279,12 +267,11 @@ class CI_Javascript {
*
* Outputs a javascript library mouseover event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function mouseover($element = 'this', $js = '')
+ public function mouseover($element = 'this', $js = '')
{
return $this->js->_mouseover($element, $js);
}
@@ -296,12 +283,11 @@ class CI_Javascript {
*
* Outputs a javascript library mouseup event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function mouseup($element = 'this', $js = '')
+ public function mouseup($element = 'this', $js = '')
{
return $this->js->_mouseup($element, $js);
}
@@ -313,11 +299,10 @@ class CI_Javascript {
*
* Outputs the called javascript to the screen
*
- * @access public
* @param string The code to output
* @return string
*/
- function output($js)
+ public function output($js)
{
return $this->js->_output($js);
}
@@ -329,12 +314,11 @@ class CI_Javascript {
*
* Outputs a javascript library mouseup event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function ready($js)
+ public function ready($js)
{
return $this->js->_document_ready($js);
}
@@ -346,12 +330,11 @@ class CI_Javascript {
*
* Outputs a javascript library resize event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function resize($element = 'this', $js = '')
+ public function resize($element = 'this', $js = '')
{
return $this->js->_resize($element, $js);
}
@@ -363,12 +346,11 @@ class CI_Javascript {
*
* Outputs a javascript library scroll event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function scroll($element = 'this', $js = '')
+ public function scroll($element = 'this', $js = '')
{
return $this->js->_scroll($element, $js);
}
@@ -380,17 +362,16 @@ class CI_Javascript {
*
* Outputs a javascript library unload event
*
- * @access public
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function unload($element = 'this', $js = '')
+ public function unload($element = 'this', $js = '')
{
return $this->js->_unload($element, $js);
}
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
// Effects
// --------------------------------------------------------------------
@@ -400,12 +381,11 @@ class CI_Javascript {
*
* Outputs a javascript library addClass event
*
- * @access public
* @param string - element
* @param string - Class to add
* @return string
*/
- function addClass($element = 'this', $class = '')
+ public function addClass($element = 'this', $class = '')
{
return $this->js->_addClass($element, $class);
}
@@ -417,13 +397,12 @@ class CI_Javascript {
*
* Outputs a javascript library animate event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function animate($element = 'this', $params = array(), $speed = '', $extra = '')
+ public function animate($element = 'this', $params = array(), $speed = '', $extra = '')
{
return $this->js->_animate($element, $params, $speed, $extra);
}
@@ -435,13 +414,12 @@ class CI_Javascript {
*
* Outputs a javascript library hide event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function fadeIn($element = 'this', $speed = '', $callback = '')
+ public function fadeIn($element = 'this', $speed = '', $callback = '')
{
return $this->js->_fadeIn($element, $speed, $callback);
}
@@ -453,13 +431,12 @@ class CI_Javascript {
*
* Outputs a javascript library hide event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function fadeOut($element = 'this', $speed = '', $callback = '')
+ public function fadeOut($element = 'this', $speed = '', $callback = '')
{
return $this->js->_fadeOut($element, $speed, $callback);
}
@@ -470,13 +447,12 @@ class CI_Javascript {
*
* Outputs a javascript library slideUp event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function slideUp($element = 'this', $speed = '', $callback = '')
+ public function slideUp($element = 'this', $speed = '', $callback = '')
{
return $this->js->_slideUp($element, $speed, $callback);
@@ -489,12 +465,11 @@ class CI_Javascript {
*
* Outputs a javascript library removeClass event
*
- * @access public
* @param string - element
* @param string - Class to add
* @return string
*/
- function removeClass($element = 'this', $class = '')
+ public function removeClass($element = 'this', $class = '')
{
return $this->js->_removeClass($element, $class);
}
@@ -506,13 +481,12 @@ class CI_Javascript {
*
* Outputs a javascript library slideDown event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function slideDown($element = 'this', $speed = '', $callback = '')
+ public function slideDown($element = 'this', $speed = '', $callback = '')
{
return $this->js->_slideDown($element, $speed, $callback);
}
@@ -524,13 +498,12 @@ class CI_Javascript {
*
* Outputs a javascript library slideToggle event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function slideToggle($element = 'this', $speed = '', $callback = '')
+ public function slideToggle($element = 'this', $speed = '', $callback = '')
{
return $this->js->_slideToggle($element, $speed, $callback);
@@ -543,13 +516,12 @@ class CI_Javascript {
*
* Outputs a javascript library hide action
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function hide($element = 'this', $speed = '', $callback = '')
+ public function hide($element = 'this', $speed = '', $callback = '')
{
return $this->js->_hide($element, $speed, $callback);
}
@@ -561,11 +533,10 @@ class CI_Javascript {
*
* Outputs a javascript library toggle event
*
- * @access public
* @param string - element
* @return string
*/
- function toggle($element = 'this')
+ public function toggle($element = 'this')
{
return $this->js->_toggle($element);
@@ -578,11 +549,10 @@ class CI_Javascript {
*
* Outputs a javascript library toggle class event
*
- * @access public
* @param string - element
* @return string
*/
- function toggleClass($element = 'this', $class='')
+ public function toggleClass($element = 'this', $class='')
{
return $this->js->_toggleClass($element, $class);
}
@@ -594,13 +564,12 @@ class CI_Javascript {
*
* Outputs a javascript library show event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function show($element = 'this', $speed = '', $callback = '')
+ public function show($element = 'this', $speed = '', $callback = '')
{
return $this->js->_show($element, $speed, $callback);
}
@@ -613,11 +582,10 @@ class CI_Javascript {
*
* gather together all script needing to be output
*
- * @access public
* @param string The element to attach the event to
* @return string
*/
- function compile($view_var = 'script_foot', $script_tags = TRUE)
+ public function compile($view_var = 'script_foot', $script_tags = TRUE)
{
$this->js->_compile($view_var, $script_tags);
}
@@ -627,10 +595,9 @@ class CI_Javascript {
*
* Clears any previous javascript collected for output
*
- * @access public
* @return void
*/
- function clear_compile()
+ public function clear_compile()
{
$this->js->_clear_compile();
}
@@ -642,11 +609,10 @@ class CI_Javascript {
*
* Outputs a <script> tag with the source as an external js file
*
- * @access public
* @param string The element to attach the event to
* @return string
*/
- function external($external_file = '', $relative = FALSE)
+ public function external($external_file = '', $relative = FALSE)
{
if ($external_file !== '')
{
@@ -660,7 +626,7 @@ class CI_Javascript {
}
}
- if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0)
+ if ($relative === TRUE OR strncmp($external_file, 'http://', 7) === 0 OR strncmp($external_file, 'https://', 8) === 0)
{
$str = $this->_open_script($external_file);
}
@@ -673,8 +639,7 @@ class CI_Javascript {
$str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file);
}
- $str .= $this->_close_script();
- return $str;
+ return $str.$this->_close_script();
}
// --------------------------------------------------------------------
@@ -684,20 +649,17 @@ class CI_Javascript {
*
* Outputs a <script> tag
*
- * @access public
* @param string The element to attach the event to
* @param boolean If a CDATA section should be added
* @return string
*/
- function inline($script, $cdata = TRUE)
+ public function inline($script, $cdata = TRUE)
{
- $str = $this->_open_script();
- $str .= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
- $str .= $this->_close_script();
-
- return $str;
+ return $this->_open_script()
+ . ($cdata ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n")
+ . $this->_close_script();
}
-
+
// --------------------------------------------------------------------
/**
@@ -705,15 +667,13 @@ class CI_Javascript {
*
* Outputs an opening <script>
*
- * @access private
* @param string
* @return string
*/
- function _open_script($src = '')
+ protected function _open_script($src = '')
{
- $str = '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"';
- $str .= ($src == '') ? '>' : ' src="'.$src.'">';
- return $str;
+ return '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"'
+ . ($src == '' ? '>' : ' src="'.$src.'">');
}
// --------------------------------------------------------------------
@@ -723,11 +683,10 @@ class CI_Javascript {
*
* Outputs an closing </script>
*
- * @access private
* @param string
* @return string
*/
- function _close_script($extra = "\n")
+ protected function _close_script($extra = "\n")
{
return "</script>$extra";
}
@@ -744,13 +703,12 @@ class CI_Javascript {
*
* Outputs a javascript library slideDown event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function update($element = 'this', $speed = '', $callback = '')
+ public function update($element = 'this', $speed = '', $callback = '')
{
return $this->js->_updater($element, $speed, $callback);
}
@@ -766,7 +724,7 @@ class CI_Javascript {
* @param bool match array types (defaults to objects)
* @return string a json formatted string
*/
- function generate_json($result = NULL, $match_array_type = FALSE)
+ 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
@@ -827,11 +785,10 @@ class CI_Javascript {
*
* Checks for an associative array
*
- * @access public
* @param type
* @return type
*/
- function _is_associative_array($arr)
+ protected function _is_associative_array($arr)
{
foreach (array_keys($arr) as $key => $val)
{
@@ -851,11 +808,10 @@ class CI_Javascript {
*
* Ensures a standard json value and escapes values
*
- * @access public
* @param type
* @return type
*/
- function _prep_args($result, $is_key = FALSE)
+ protected function _prep_args($result, $is_key = FALSE)
{
if (is_null($result))
{
@@ -867,7 +823,7 @@ class CI_Javascript {
}
elseif (is_string($result) OR $is_key)
{
- return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
+ return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
}
elseif (is_scalar($result))
{
@@ -880,4 +836,4 @@ class CI_Javascript {
// END Javascript Class
/* End of file Javascript.php */
-/* Location: ./system/libraries/Javascript.php */ \ No newline at end of file
+/* Location: ./system/libraries/Javascript.php */
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index eea953ae4..008c15192 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -131,7 +131,7 @@ class CI_Pagination {
$num_pages = ceil($this->total_rows / $this->per_page);
// Is there only one page? Hm... nothing more to do here then.
- if ($num_pages == 1)
+ if ($num_pages === 1)
{
return '';
}
@@ -146,25 +146,16 @@ class CI_Pagination {
{
if ($CI->input->get($this->query_string_segment) != $base_page)
{
- $this->cur_page = $CI->input->get($this->query_string_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = (int) $this->cur_page;
+ $this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- else
+ elseif ($CI->uri->segment($this->uri_segment) != $base_page)
{
- if ($CI->uri->segment($this->uri_segment) != $base_page)
- {
- $this->cur_page = $CI->uri->segment($this->uri_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = (int) $this->cur_page;
- }
+ $this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
- // Set current page to 1 if using page numbers instead of offset
- if ($this->use_page_numbers AND $this->cur_page == 0)
+ // Set current page to 1 if it's not valid or if using page numbers instead of offset
+ if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0))
{
$this->cur_page = $base_page;
}
@@ -176,11 +167,6 @@ class CI_Pagination {
show_error('Your number of links must be a positive number.');
}
- if ( ! is_numeric($this->cur_page))
- {
- $this->cur_page = $base_page;
- }
-
// Is the page number beyond the result range?
// If so we show the last page
if ($this->use_page_numbers)
@@ -310,4 +296,4 @@ class CI_Pagination {
// END Pagination Class
/* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file
+/* Location: ./system/libraries/Pagination.php */
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 8a2568d8e..9cbd69bb2 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -126,12 +126,10 @@ class CI_Profiler {
{
// We match the "end" marker so that the list ends
// up in the order that it was defined
- if (preg_match("/(.+?)_end/i", $key, $match))
+ if (preg_match('/(.+?)_end/i', $key, $match)
+ AND isset($this->CI->benchmark->marker[$match[1].'_end'], $this->CI->benchmark->marker[$match[1].'_start']))
{
- if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start']))
- {
- $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
- }
+ $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key);
}
}
@@ -139,12 +137,11 @@ class CI_Profiler {
// Note: At some point we should turn this into a template that can
// be modified. We also might want to make this data available to be logged
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
- $output .= "\n\n<table style='width:100%'>\n";
+ $output = "\n\n"
+ . '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>'
+ . "\n\n\n<table style='width:100%'>\n";
foreach ($profile as $key => $val)
{
@@ -152,10 +149,7 @@ class CI_Profiler {
$output .= "<tr><td style='padding:5px;width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px;width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
}
- $output .= "</table>\n";
- $output .= "</fieldset>";
-
- return $output;
+ return $output."</table>\n</fieldset>";
}
// --------------------------------------------------------------------
@@ -178,19 +172,16 @@ class CI_Profiler {
}
}
- if (count($dbs) == 0)
+ if (count($dbs) === 0)
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
- $output .= "\n\n<table style='border:none; width:100%;'>\n";
- $output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
- $output .= "</table>\n";
- $output .= "</fieldset>";
-
- return $output;
+ return "\n\n"
+ . '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">'
+ . "\n"
+ . '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>'
+ . "\n\n\n<table style='border:none; width:100%;'>\n"
+ . '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">'
+ . $this->CI->lang->line('profiler_no_db')
+ . "</td></tr>\n</table>\n</fieldset>";
}
// Load the text helper so we can highlight the SQL
@@ -205,8 +196,6 @@ class CI_Profiler {
foreach ($dbs as $db)
{
- $count++;
-
$hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : '';
$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)';
@@ -216,13 +205,12 @@ class CI_Profiler {
$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)';
}
- $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>';
- $output .= "\n";
- $output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
+ $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>'
+ . "\n\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
- if (count($db->queries) == 0)
+ if (count($db->queries) === 0)
{
$output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n";
}
@@ -243,8 +231,7 @@ class CI_Profiler {
}
}
- $output .= "</table>\n";
- $output .= "</fieldset>";
+ $output .= "</table>\n</fieldset>";
}
@@ -261,13 +248,13 @@ class CI_Profiler {
*/
protected function _compile_get()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
+ $output = "\n\n"
+ . '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>'
+ . "\n";
- if (count($_GET) == 0)
+ if (count($_GET) === 0)
{
$output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>";
}
@@ -282,23 +269,15 @@ class CI_Profiler {
$key = "'".$key."'";
}
- $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>";
- if (is_array($val))
- {
- $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
- }
- else
- {
- $output .= htmlspecialchars(stripslashes($val));
- }
- $output .= "</td></tr>\n";
+ $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"
+ . (is_array($val) ? "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>" : htmlspecialchars(stripslashes($val)))
+ . "</td></tr>\n";
}
$output .= "</table>\n";
}
- $output .= "</fieldset>";
- return $output;
+ return $output.'</fieldset>';
}
// --------------------------------------------------------------------
@@ -310,11 +289,11 @@ class CI_Profiler {
*/
protected function _compile_post()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
+ $output = "\n\n"
+ . '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#009900;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>'
+ . "\n";
if (count($_POST) == 0)
{
@@ -345,9 +324,8 @@ class CI_Profiler {
$output .= "</table>\n";
}
- $output .= "</fieldset>";
- return $output;
+ return $output.'</fieldset>';
}
// --------------------------------------------------------------------
@@ -359,24 +337,13 @@ class CI_Profiler {
*/
protected function _compile_uri_string()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
-
- if ($this->CI->uri->uri_string == '')
- {
- $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>";
- }
- else
- {
- $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>";
- }
-
- $output .= "</fieldset>";
-
- return $output;
+ return "\n\n"
+ . '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</legend>'
+ . "\n<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>"
+ . ($this->CI->uri->uri_string == '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string)
+ . '</div></fieldset>';
}
// --------------------------------------------------------------------
@@ -388,17 +355,12 @@ class CI_Profiler {
*/
protected function _compile_controller_info()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
-
- $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>";
-
- $output .= "</fieldset>";
-
- return $output;
+ return "\n\n"
+ . '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>'
+ . "\n<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class().'/'.$this->CI->router->fetch_method()
+ . '</div></fieldset>';
}
// --------------------------------------------------------------------
@@ -412,24 +374,13 @@ class CI_Profiler {
*/
protected function _compile_memory_usage()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
-
- if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '')
- {
- $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>';
- }
- else
- {
- $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory')."</div>";
- }
-
- $output .= "</fieldset>";
-
- return $output;
+ return "\n\n"
+ . '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</legend>'
+ . "\n<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>"
+ . ((function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory'))
+ . '</div></fieldset>';
}
// --------------------------------------------------------------------
@@ -443,13 +394,11 @@ class CI_Profiler {
*/
protected function _compile_http_headers()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
- $output .= "\n";
-
- $output .= "\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
+ $output = "\n\n"
+ . '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+ . "\n\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
{
@@ -457,10 +406,7 @@ class CI_Profiler {
$output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header."&nbsp;&nbsp;</td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n";
}
- $output .= "</table>\n";
- $output .= "</fieldset>";
-
- return $output;
+ return $output."</table>\n</fieldset>";
}
// --------------------------------------------------------------------
@@ -474,13 +420,11 @@ class CI_Profiler {
*/
protected function _compile_config()
{
- $output = "\n\n";
- $output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= "\n";
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
- $output .= "\n";
-
- $output .= "\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
+ $output = "\n\n"
+ . '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . "\n"
+ . '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+ . "\n\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
foreach ($this->CI->config->config as $config=>$val)
{
@@ -492,10 +436,7 @@ class CI_Profiler {
$output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$config."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
}
- $output .= "</table>\n";
- $output .= "</fieldset>";
-
- return $output;
+ return $output."</table>\n</fieldset>";
}
// --------------------------------------------------------------------
@@ -512,9 +453,9 @@ class CI_Profiler {
return;
}
- $output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
- $output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
- $output .= "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
+ $output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'
+ . '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
+ . "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
foreach ($this->CI->session->all_userdata() as $key => $val)
{
@@ -526,9 +467,7 @@ class CI_Profiler {
$output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
}
- $output .= '</table>';
- $output .= "</fieldset>";
- return $output;
+ return $output."</table>\n</fieldset>";
}
// --------------------------------------------------------------------
@@ -553,14 +492,12 @@ class CI_Profiler {
}
}
- if ($fields_displayed == 0)
+ if ($fields_displayed === 0)
{
$output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>';
}
- $output .= '</div>';
-
- return $output;
+ return $output.'</div>';
}
}
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
deleted file mode 100644
index 477b92bcb..000000000
--- a/system/libraries/Sha1.php
+++ /dev/null
@@ -1,263 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 5.1.6 or newer
- *
- * NOTICE OF LICENSE
- *
- * Licensed under the Open Software License version 3.0
- *
- * This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
- * also available through the world wide web at this URL:
- * http://opensource.org/licenses/OSL-3.0
- * If you did not receive a copy of the license and are unable to obtain it
- * through the world wide web, please send an email to
- * licensing@ellislab.com so we can send you a copy immediately.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
- * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * SHA1 Encoding Class
- *
- * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
- * developed at the National Institute of Standards and Technology. The 40
- * character SHA1 message hash is computationally infeasible to crack.
- *
- * This class is a fallback for servers that are not running PHP greater than
- * 4.3, or do not have the MHASH library.
- *
- * This class is based on two scripts:
- *
- * Marcus Campbell's PHP implementation (GNU license)
- * http://www.tecknik.net/sha-1/
- *
- * ...which is based on Paul Johnston's JavaScript version
- * (BSD license). http://pajhome.org.uk/
- *
- * I encapsulated the functions and wrote one additional method to fix
- * a hex conversion bug. - Rick Ellis
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Encryption
- * @author EllisLab Dev Team
- * @link http://codeigniter.com/user_guide/libraries/encryption.html
- */
-class CI_SHA1 {
-
- public function __construct()
- {
- log_message('debug', "SHA1 Class Initialized");
- }
-
- /**
- * Generate the Hash
- *
- * @access public
- * @param string
- * @return string
- */
- function generate($str)
- {
- $n = ((strlen($str) + 8) >> 6) + 1;
-
- for ($i = 0; $i < $n * 16; $i++)
- {
- $x[$i] = 0;
- }
-
- for ($i = 0; $i < strlen($str); $i++)
- {
- $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
- }
-
- $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
-
- $x[$n * 16 - 1] = strlen($str) * 8;
-
- $a = 1732584193;
- $b = -271733879;
- $c = -1732584194;
- $d = 271733878;
- $e = -1009589776;
-
- for ($i = 0; $i < count($x); $i += 16)
- {
- $olda = $a;
- $oldb = $b;
- $oldc = $c;
- $oldd = $d;
- $olde = $e;
-
- for ($j = 0; $j < 80; $j++)
- {
- if ($j < 16)
- {
- $w[$j] = $x[$i + $j];
- }
- else
- {
- $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
- }
-
- $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
-
- $e = $d;
- $d = $c;
- $c = $this->_rol($b, 30);
- $b = $a;
- $a = $t;
- }
-
- $a = $this->_safe_add($a, $olda);
- $b = $this->_safe_add($b, $oldb);
- $c = $this->_safe_add($c, $oldc);
- $d = $this->_safe_add($d, $oldd);
- $e = $this->_safe_add($e, $olde);
- }
-
- return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert a decimal to hex
- *
- * @access private
- * @param string
- * @return string
- */
- function _hex($str)
- {
- $str = dechex($str);
-
- if (strlen($str) == 7)
- {
- $str = '0'.$str;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Return result based on iteration
- *
- * @access private
- * @return string
- */
- function _ft($t, $b, $c, $d)
- {
- if ($t < 20)
- return ($b & $c) | ((~$b) & $d);
- if ($t < 40)
- return $b ^ $c ^ $d;
- if ($t < 60)
- return ($b & $c) | ($b & $d) | ($c & $d);
-
- return $b ^ $c ^ $d;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determine the additive constant
- *
- * @access private
- * @return string
- */
- function _kt($t)
- {
- if ($t < 20)
- {
- return 1518500249;
- }
- else if ($t < 40)
- {
- return 1859775393;
- }
- else if ($t < 60)
- {
- return -1894007588;
- }
- else
- {
- return -899497514;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add integers, wrapping at 2^32
- *
- * @access private
- * @return string
- */
- function _safe_add($x, $y)
- {
- $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
- $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
-
- return ($msw << 16) | ($lsw & 0xFFFF);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Bitwise rotate a 32-bit number
- *
- * @access private
- * @return integer
- */
- function _rol($num, $cnt)
- {
- return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Pad string with zero
- *
- * @access private
- * @return string
- */
- function _zero_fill($a, $b)
- {
- $bin = decbin($a);
-
- if (strlen($bin) < $b)
- {
- $bin = 0;
- }
- else
- {
- $bin = substr($bin, 0, strlen($bin) - $b);
- }
-
- for ($i=0; $i < $b; $i++)
- {
- $bin = "0".$bin;
- }
-
- return bindec($bin);
- }
-}
-// END CI_SHA
-
-/* End of file Sha1.php */
-/* Location: ./system/libraries/Sha1.php */
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index af6ca2bf2..651ba7bff 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -31,7 +31,7 @@
* Typography Class
*
*
- * @access private
+ * @access protected
* @category Helpers
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/typography.html
@@ -39,22 +39,22 @@
class CI_Typography {
// Block level elements that should not be wrapped inside <p> tags
- var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
+ public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
// Elements that should not have <p> and <br /> tags within them.
- var $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d';
+ public $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d';
// Tags we want the parser to completely ignore when splitting the string.
- var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
+ public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
// array of block level elements that require inner content to be within another block level element
- var $inner_block_required = array('blockquote');
+ public $inner_block_required = array('blockquote');
// the last block element parsed
- var $last_block_element = '';
+ public $last_block_element = '';
// whether or not to protect quotes within { curly braces }
- var $protect_braced_quotes = FALSE;
+ public $protect_braced_quotes = FALSE;
/**
* Auto Typography
@@ -72,7 +72,7 @@ class CI_Typography {
* @param bool whether to reduce more then two consecutive newlines to two
* @return string
*/
- function auto_typography($str, $reduce_linebreaks = FALSE)
+ public function auto_typography($str, $reduce_linebreaks = FALSE)
{
if ($str == '')
{
@@ -127,35 +127,32 @@ class CI_Typography {
// adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
$str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
- // Split the string at every tag. This expression creates an array with this prototype:
- //
- // [array]
- // {
- // [0] = <opening tag>
- // [1] = Content...
- // [2] = <closing tag>
- // Etc...
- // }
+ /* Split the string at every tag. This expression creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] = <opening tag>
+ * [1] = Content...
+ * [2] = <closing tag>
+ * Etc...
+ * }
+ */
$chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
// Build our finalized string. We cycle through the array, skipping tags, and processing the contained text
$str = '';
$process = TRUE;
$paragraph = FALSE;
- $current_chunk = 0;
- $total_chunks = count($chunks);
- foreach ($chunks as $chunk)
+ for ($i = 1, $c = count($chunks); $i <= $c; $i++)
{
- $current_chunk++;
-
// Are we dealing with a tag? If so, we'll skip the processing for this cycle.
// Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
- if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match))
+ if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunks[$i], $match))
{
if (preg_match("#".$this->skip_elements."#", $match[2]))
{
- $process = ($match[1] == '/') ? TRUE : FALSE;
+ $process = ($match[1] === '/');
}
if ($match[1] == '')
@@ -163,24 +160,24 @@ class CI_Typography {
$this->last_block_element = $match[2];
}
- $str .= $chunk;
+ $str .= $chunks[$i];
continue;
}
- if ($process == FALSE)
+ if ($process === FALSE)
{
- $str .= $chunk;
+ $str .= $chunks[$i];
continue;
}
// Force a newline to make sure end tags get processed by _format_newlines()
- if ($current_chunk == $total_chunks)
+ if ($i === $c)
{
- $chunk .= "\n";
+ $chunks[$i] .= "\n";
}
// Convert Newlines into <p> and <br /> tags
- $str .= $this->_format_newlines($chunk);
+ $str .= $this->_format_newlines($chunks[$i]);
}
// No opening block level tag? Add it if needed.
@@ -265,7 +262,7 @@ class CI_Typography {
* @param string
* @return string
*/
- function format_characters($str)
+ public function format_characters($str)
{
static $table;
@@ -325,18 +322,13 @@ class CI_Typography {
*
* Converts newline characters into either <p> tags or <br />
*
- * @access public
+ * @access protected
* @param string
* @return string
*/
- function _format_newlines($str)
+ protected function _format_newlines($str)
{
- if ($str == '')
- {
- return $str;
- }
-
- if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required))
+ if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required)))
{
return $str;
}
@@ -373,11 +365,11 @@ class CI_Typography {
* and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
* likewise double spaces are converted to {@NBS} to prevent entity conversion
*
- * @access public
+ * @access protected
* @param array
* @return string
*/
- function _protect_characters($match)
+ protected function _protect_characters($match)
{
return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]);
}
@@ -391,25 +383,16 @@ class CI_Typography {
* @param string
* @return string
*/
- function nl2br_except_pre($str)
+ public function nl2br_except_pre($str)
{
- $ex = explode("pre>",$str);
- $ct = count($ex);
-
- $newstr = "";
- for ($i = 0; $i < $ct; $i++)
+ $newstr = '';
+ for ($ex = explode('pre>', $str), $ct = count($ex), $i = 0; $i < $ct; $i++)
{
- if (($i % 2) == 0)
+ $newstr .= (($i % 2) === 0) ? nl2br($ex[$i]) : $ex[$i];
+ if ($ct - 1 !== $i)
{
- $newstr .= nl2br($ex[$i]);
+ $newstr .= 'pre>';
}
- else
- {
- $newstr .= $ex[$i];
- }
-
- if ($ct - 1 != $i)
- $newstr .= "pre>";
}
return $newstr;
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 826bcceb8..5108afa1b 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -952,17 +952,12 @@ class CI_Upload {
{
global $mimes;
- if (count($this->mimes) == 0)
+ if (count($this->mimes) === 0)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
- }
- elseif (is_file(APPPATH.'config/mimes.php'))
- {
- include(APPPATH.'config//mimes.php');
- }
- else
+ load_environ_config('mimes');
+
+ // Return FALSE if we still have no mimes after trying to load them up.
+ if (count($this->mimes) === 0)
{
return FALSE;
}
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index c31ff2646..5288525cb 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -94,15 +94,10 @@ class CI_User_agent {
*/
protected function _load_agent_file()
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
- }
- elseif (is_file(APPPATH.'config/user_agents.php'))
- {
- include(APPPATH.'config/user_agents.php');
- }
- else
+ load_environ_config('user_agents');
+
+ // Return FALSE if we still have no mimes after trying to load them up.
+ if (count($this->mimes) === 0)
{
return FALSE;
}
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 587b75040..893e51873 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -48,12 +48,11 @@ if ( ! class_exists('CI_Xmlrpc'))
*/
class CI_Xmlrpcs extends CI_Xmlrpc
{
- var $methods = array(); //array of methods mapped to function names and signatures
- var $debug_msg = ''; // Debug Message
- var $system_methods = array(); // XML RPC Server methods
- var $controller_obj;
-
- var $object = FALSE;
+ public $methods = array(); //array of methods mapped to function names and signatures
+ public $debug_msg = ''; // Debug Message
+ public $system_methods = array(); // XML RPC Server methods
+ public $controller_obj;
+ public $object = FALSE;
/**
* Constructor
@@ -80,7 +79,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return void
*/
- function initialize($config=array())
+ public function initialize($config = array())
{
if (isset($config['functions']) && is_array($config['functions']))
{
@@ -111,26 +110,26 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @access public
* @return void
*/
- function set_system_methods()
+ public function set_system_methods()
{
$this->methods = array(
'system.listMethods' => array(
- 'function' => 'this.listMethods',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
- 'docstring' => 'Returns an array of available methods on this server'),
- 'system.methodHelp' => array(
- 'function' => 'this.methodHelp',
- 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
- 'docstring' => 'Returns a documentation string for the specified method'),
+ 'function' => 'this.listMethods',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
+ 'docstring' => 'Returns an array of available methods on this server'),
+ 'system.methodHelp' => array(
+ 'function' => 'this.methodHelp',
+ 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
+ 'docstring' => 'Returns a documentation string for the specified method'),
'system.methodSignature' => array(
- 'function' => 'this.methodSignature',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
- 'docstring' => 'Returns an array describing the return type and required parameters of a method'),
- 'system.multicall' => array(
- 'function' => 'this.multicall',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
- 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
- );
+ 'function' => 'this.methodSignature',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
+ 'docstring' => 'Returns an array describing the return type and required parameters of a method'),
+ 'system.multicall' => array(
+ 'function' => 'this.multicall',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
+ 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
+ );
}
// --------------------------------------------------------------------
@@ -141,12 +140,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @access public
* @return void
*/
- function serve()
+ public function serve()
{
$r = $this->parseRequest();
- $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
- $payload .= $this->debug_msg;
- $payload .= $r->prepare_response();
+ $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response();
header("Content-Type: text/xml");
header("Content-Length: ".strlen($payload));
@@ -165,7 +162,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param string docstring
* @return void
*/
- function add_to_map($methodname, $function, $sig, $doc)
+ public function add_to_map($methodname, $function, $sig, $doc)
{
$this->methods[$methodname] = array(
'function' => $function,
@@ -183,7 +180,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param string data
* @return object xmlrpc response
*/
- function parseRequest($data='')
+ public function parseRequest($data = '')
{
global $HTTP_RAW_POST_DATA;
@@ -203,13 +200,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$parser = xml_parser_create($this->xmlrpc_defencoding);
$parser_object = new XML_RPC_Message("filler");
- $parser_object->xh[$parser] = array();
- $parser_object->xh[$parser]['isf'] = 0;
- $parser_object->xh[$parser]['isf_reason'] = '';
- $parser_object->xh[$parser]['params'] = array();
- $parser_object->xh[$parser]['stack'] = array();
- $parser_object->xh[$parser]['valuestack'] = array();
- $parser_object->xh[$parser]['method'] = '';
+ $parser_object->xh[$parser] = array(
+ 'isf' => 0,
+ 'isf_reason' => '',
+ 'params' => array(),
+ 'stack' => array(),
+ 'valuestack' => array(),
+ 'method' => ''
+ );
xml_set_object($parser, $parser_object);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
@@ -243,7 +241,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
$plist='';
- for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
+ for ($i = 0, $c = count($parser_object->xh[$parser]['params']); $i < $c; $i++)
{
if ($this->debug === TRUE)
{
@@ -255,9 +253,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
if ($this->debug === TRUE)
{
- echo "<pre>";
- echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
- echo "</pre>";
+ echo "<pre>---PLIST---\n".$plist."\n---PLIST END---\n\n</pre>";
}
$r = $this->_execute($m);
@@ -284,12 +280,12 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param object
* @return mixed
*/
- function _execute($m)
+ protected function _execute($m)
{
$methName = $m->method_name;
// Check to see if it is a system call
- $system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE;
+ $system_call = (strncmp($methName, 'system', 5) === 0);
if ($this->xss_clean == FALSE)
{
@@ -310,22 +306,20 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
$method_parts = explode(".", $this->methods[$methName]['function']);
- $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE;
+ $objectCall = (isset($method_parts[1]) && $method_parts[1] != '');
if ($system_call === TRUE)
{
- if ( ! is_callable(array($this,$method_parts['1'])))
+ if ( ! is_callable(array($this,$method_parts[1])))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
else
{
- if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1'])))
- {
- return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
- }
- elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
+ if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1])))
+ OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function']))
+ )
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
@@ -338,13 +332,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc
if (isset($this->methods[$methName]['signature']))
{
$sig = $this->methods[$methName]['signature'];
- for ($i=0; $i<count($sig); $i++)
+ for ($i = 0, $c = count($sig); $i < $c; $i++)
{
$current_sig = $sig[$i];
- if (count($current_sig) == count($m->params)+1)
+ if (count($current_sig) === count($m->params)+1)
{
- for ($n=0; $n < count($m->params); $n++)
+ for ($n = 0, $mc = count($m->params); $n < $mc; $n++)
{
$p = $m->params[$n];
$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
@@ -370,7 +364,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
if ($objectCall === TRUE)
{
- if ($method_parts[0] == "this" && $system_call == TRUE)
+ if ($method_parts[0] === 'this' && $system_call === TRUE)
{
return call_user_func(array($this, $method_parts[1]), $m);
}
@@ -379,11 +373,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
if ($this->object === FALSE)
{
$CI =& get_instance();
- return $CI->$method_parts['1']($m);
+ return $CI->$method_parts[1]($m);
}
else
{
- return $this->object->$method_parts['1']($m);
+ return $this->object->$method_parts[1]($m);
//return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
}
}
@@ -393,7 +387,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return call_user_func($this->methods[$methName]['function'], $m);
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -403,7 +397,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function listMethods($m)
+ public function listMethods($m)
{
$v = new XML_RPC_Values();
$output = array();
@@ -421,7 +415,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$v->addArray($output);
return new XML_RPC_Response($v);
}
-
+
// --------------------------------------------------------------------
/**
@@ -431,7 +425,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function methodSignature($m)
+ public function methodSignature($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
@@ -443,15 +437,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$sigs = array();
$signature = $this->methods[$method_name]['signature'];
- for ($i=0; $i < count($signature); $i++)
+ for ($i = 0, $c = count($signature); $i < $c; $i++)
{
$cursig = array();
$inSig = $signature[$i];
- for ($j=0; $j<count($inSig); $j++)
+ for ($j = 0, $jc = count($inSig); $j < $jc; $j++)
{
$cursig[]= new XML_RPC_Values($inSig[$j], 'string');
}
- $sigs[]= new XML_RPC_Values($cursig, 'array');
+ $sigs[] = new XML_RPC_Values($cursig, 'array');
}
$r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
}
@@ -476,7 +470,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function methodHelp($m)
+ public function methodHelp($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
@@ -492,7 +486,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -502,7 +496,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function multicall($m)
+ public function multicall($m)
{
// Disabled
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
@@ -519,7 +513,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$m = new XML_RPC_Message($value[0]);
$plist='';
- for ($i=0; $i < count($value[1]); $i++)
+ for ($i = 0, $c = count($value[1]); $i < $c; $i++)
{
$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
}
@@ -546,7 +540,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function multicall_error($err)
+ public function multicall_error($err)
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
@@ -566,7 +560,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
* @param mixed
* @return object
*/
- function do_multicall($call)
+ public function do_multicall($call)
{
if ($call->kindOf() != 'struct')
{
@@ -597,11 +591,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $this->multicall_error('notarray');
}
- list($a,$b)=each($params->me);
- $numParams = count($b);
+ list($a,$b) = each($params->me);
$msg = new XML_RPC_Message($scalar_value);
- for ($i = 0; $i < $numParams; $i++)
+ for ($i = 0, $numParams = count($b); $i < $numParams; $i++)
{
$msg->params[] = $params->me['array'][$i];
}
@@ -619,6 +612,5 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
// END XML_RPC_Server class
-
/* End of file Xmlrpcs.php */
-/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file
+/* Location: ./system/libraries/Xmlrpcs.php */
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index 4b8f76a10..888e89b1b 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -36,80 +36,77 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/javascript.html
*/
-
+
class CI_Jquery extends CI_Javascript {
- var $_javascript_folder = 'js';
- var $jquery_code_for_load = array();
- var $jquery_code_for_compile = array();
- var $jquery_corner_active = FALSE;
- var $jquery_table_sorter_active = FALSE;
- var $jquery_table_sorter_pager_active = FALSE;
- var $jquery_ajax_img = '';
+ protected $_javascript_folder = 'js';
+ public $jquery_code_for_load = array();
+ public $jquery_code_for_compile = array();
+ public $jquery_corner_active = FALSE;
+ public $jquery_table_sorter_active = FALSE;
+ public $jquery_table_sorter_pager_active = FALSE;
+ public $jquery_ajax_img = '';
public function __construct($params)
{
- $this->CI =& get_instance();
+ $this->CI =& get_instance();
extract($params);
if ($autoload === TRUE)
{
- $this->script();
+ $this->script();
}
-
+
log_message('debug', "Jquery Class Initialized");
}
-
- // --------------------------------------------------------------------
+
+ // --------------------------------------------------------------------
// Event Code
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
/**
* Blur
*
* Outputs a jQuery blur event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _blur($element = 'this', $js = '')
+ protected function _blur($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'blur');
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Change
*
* Outputs a jQuery change event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _change($element = 'this', $js = '')
+ protected function _change($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'change');
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Click
*
* Outputs a jQuery click event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @param boolean whether or not to return false
* @return string
*/
- function _click($element = 'this', $js = '', $ret_false = TRUE)
+ protected function _click($element = 'this', $js = '', $ret_false = TRUE)
{
if ( ! is_array($js))
{
@@ -125,70 +122,66 @@ class CI_Jquery extends CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Double Click
*
* Outputs a jQuery dblclick event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _dblclick($element = 'this', $js = '')
+ protected function _dblclick($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'dblclick');
}
// --------------------------------------------------------------------
-
+
/**
* Error
*
* Outputs a jQuery error event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _error($element = 'this', $js = '')
+ protected function _error($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'error');
}
// --------------------------------------------------------------------
-
+
/**
* Focus
*
* Outputs a jQuery focus event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _focus($element = 'this', $js = '')
+ protected function _focus($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'focus');
}
// --------------------------------------------------------------------
-
+
/**
* Hover
*
* Outputs a jQuery hover event
*
- * @access private
* @param string - element
* @param string - Javascript code for mouse over
* @param string - Javascript code for mouse out
* @return string
*/
- function _hover($element = 'this', $over, $out)
+ 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";
@@ -198,103 +191,97 @@ class CI_Jquery extends CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Keydown
*
* Outputs a jQuery keydown event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _keydown($element = 'this', $js = '')
+ protected function _keydown($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'keydown');
}
// --------------------------------------------------------------------
-
+
/**
* Keyup
*
* Outputs a jQuery keydown event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _keyup($element = 'this', $js = '')
+ protected function _keyup($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'keyup');
- }
+ }
// --------------------------------------------------------------------
-
+
/**
* Load
*
* Outputs a jQuery load event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _load($element = 'this', $js = '')
+ protected function _load($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'load');
- }
-
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Mousedown
*
* Outputs a jQuery mousedown event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _mousedown($element = 'this', $js = '')
+ protected function _mousedown($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mousedown');
}
// --------------------------------------------------------------------
-
+
/**
* Mouse Out
*
* Outputs a jQuery mouseout event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _mouseout($element = 'this', $js = '')
+ protected function _mouseout($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseout');
}
// --------------------------------------------------------------------
-
+
/**
* Mouse Over
*
* Outputs a jQuery mouseover event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _mouseover($element = 'this', $js = '')
+ protected function _mouseover($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseover');
}
@@ -306,12 +293,11 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery mouseup event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _mouseup($element = 'this', $js = '')
+ protected function _mouseup($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseup');
}
@@ -323,18 +309,17 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs script directly
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _output($array_js = '')
+ protected function _output($array_js = '')
{
if ( ! is_array($array_js))
{
$array_js = array($array_js);
}
-
+
foreach ($array_js as $js)
{
$this->jquery_code_for_compile[] = "\t$js\n";
@@ -348,12 +333,11 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery resize event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _resize($element = 'this', $js = '')
+ protected function _resize($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'resize');
}
@@ -365,16 +349,15 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery scroll event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _scroll($element = 'this', $js = '')
+ protected function _scroll($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'scroll');
}
-
+
// --------------------------------------------------------------------
/**
@@ -382,34 +365,31 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery unload event
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @return string
*/
- function _unload($element = 'this', $js = '')
+ protected function _unload($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'unload');
}
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
// Effects
- // --------------------------------------------------------------------
-
+ // --------------------------------------------------------------------
+
/**
* Add Class
*
* Outputs a jQuery addClass event
*
- * @access private
* @param string - element
* @return string
*/
- function _addClass($element = 'this', $class='')
+ protected function _addClass($element = 'this', $class='')
{
$element = $this->_prep_element($element);
- $str = "$({$element}).addClass(\"$class\");";
- return $str;
+ return "$({$element}).addClass(\"$class\");";
}
// --------------------------------------------------------------------
@@ -419,19 +399,18 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery animate event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
+ 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.'\', ';
@@ -443,71 +422,63 @@ class CI_Jquery extends CI_Javascript {
{
$speed = ', '.$speed;
}
-
+
if ($extra != '')
{
$extra = ', '.$extra;
}
-
- $str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
-
- return $str;
+
+ return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
}
// --------------------------------------------------------------------
-
+
/**
* Fade In
*
* Outputs a jQuery hide event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _fadeIn($element = 'this', $speed = '', $callback = '')
+ protected function _fadeIn($element = 'this', $speed = '', $callback = '')
{
- $element = $this->_prep_element($element);
+ $element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).fadeIn({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).fadeIn({$speed}{$callback});";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Fade Out
*
* Outputs a jQuery hide event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _fadeOut($element = 'this', $speed = '', $callback = '')
+ protected function _fadeOut($element = 'this', $speed = '', $callback = '')
{
$element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).fadeOut({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).fadeOut({$speed}{$callback});";
}
// --------------------------------------------------------------------
@@ -517,27 +488,24 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery hide action
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _hide($element = 'this', $speed = '', $callback = '')
+ protected function _hide($element = 'this', $speed = '', $callback = '')
{
- $element = $this->_prep_element($element);
+ $element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).hide({$speed}{$callback});";
- return $str;
+ return "$({$element}).hide({$speed}{$callback});";
}
-
+
// --------------------------------------------------------------------
/**
@@ -545,163 +513,145 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs a jQuery remove class event
*
- * @access private
* @param string - element
* @return string
*/
- function _removeClass($element = 'this', $class='')
+ protected function _removeClass($element = 'this', $class='')
{
$element = $this->_prep_element($element);
- $str = "$({$element}).removeClass(\"$class\");";
- return $str;
+ return "$({$element}).removeClass(\"$class\");";
}
// --------------------------------------------------------------------
-
+
/**
* Slide Up
*
* Outputs a jQuery slideUp event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _slideUp($element = 'this', $speed = '', $callback = '')
+ protected function _slideUp($element = 'this', $speed = '', $callback = '')
{
- $element = $this->_prep_element($element);
+ $element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).slideUp({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).slideUp({$speed}{$callback});";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Slide Down
*
* Outputs a jQuery slideDown event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _slideDown($element = 'this', $speed = '', $callback = '')
+ protected function _slideDown($element = 'this', $speed = '', $callback = '')
{
$element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).slideDown({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).slideDown({$speed}{$callback});";
}
// --------------------------------------------------------------------
-
+
/**
* Slide Toggle
*
* Outputs a jQuery slideToggle event
*
- * @access public
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _slideToggle($element = 'this', $speed = '', $callback = '')
+ protected function _slideToggle($element = 'this', $speed = '', $callback = '')
{
$element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).slideToggle({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).slideToggle({$speed}{$callback});";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Toggle
*
* Outputs a jQuery toggle event
*
- * @access private
* @param string - element
* @return string
*/
- function _toggle($element = 'this')
+ protected function _toggle($element = 'this')
{
$element = $this->_prep_element($element);
- $str = "$({$element}).toggle();";
- return $str;
+ return "$({$element}).toggle();";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Toggle Class
*
* Outputs a jQuery toggle class event
*
- * @access private
* @param string - element
* @return string
*/
- function _toggleClass($element = 'this', $class='')
+ protected function _toggleClass($element = 'this', $class='')
{
$element = $this->_prep_element($element);
- $str = "$({$element}).toggleClass(\"$class\");";
- return $str;
+ return "$({$element}).toggleClass(\"$class\");";
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Show
*
* Outputs a jQuery show event
*
- * @access private
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
* @return string
*/
- function _show($element = 'this', $speed = '', $callback = '')
+ protected function _show($element = 'this', $speed = '', $callback = '')
{
- $element = $this->_prep_element($element);
+ $element = $this->_prep_element($element);
$speed = $this->_validate_speed($speed);
-
+
if ($callback != '')
{
$callback = ", function(){\n{$callback}\n}";
}
-
- $str = "$({$element}).show({$speed}{$callback});";
-
- return $str;
+
+ return "$({$element}).show({$speed}{$callback});";
}
// --------------------------------------------------------------------
@@ -709,22 +659,20 @@ class CI_Jquery extends CI_Javascript {
/**
* Updater
*
- * An Ajax call that populates the designated DOM node with
+ * An Ajax call that populates the designated DOM node with
* returned content
*
- * @access private
* @param string The element to attach the event to
* @param string the controller to run the call against
* @param string optional parameters
* @return string
*/
-
- function _updater($container = 'this', $controller, $options = '')
- {
+
+ 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') == '')
{
@@ -732,41 +680,38 @@ class CI_Jquery extends CI_Javascript {
}
else
{
- $loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />';
+ $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
- $updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image
+
+ $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 .= ", {";
- $request_options .= (is_array($options)) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'";
- $request_options .= "}";
+ $request_options .= ', {'
+ . (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'")
+ . '}';
}
- $updater .= "\t\t$($container).load('$controller'$request_options);";
- return $updater;
+ return $updater."\t\t$($container).load('$controller'$request_options);";
}
// --------------------------------------------------------------------
// Pre-written handy stuff
// --------------------------------------------------------------------
-
+
/**
* Zebra tables
*
- * @access private
* @param string table name
* @param string plugin location
* @return string
*/
- function _zebraTables($class = '', $odd = 'odd', $hover = '')
+ 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;
@@ -779,22 +724,19 @@ class CI_Jquery extends CI_Javascript {
return $zebra;
}
-
-
// --------------------------------------------------------------------
// Plugins
// --------------------------------------------------------------------
-
+
/**
* Corner Plugin
*
* http://www.malsup.com/jquery/corner/
*
- * @access public
* @param string target
* @return string
*/
- function corner($element = '', $corner_style = '')
+ public function corner($element = '', $corner_style = '')
{
// may want to make this configurable down the road
$corner_location = '/plugins/jquery.corner.js';
@@ -806,7 +748,7 @@ class CI_Jquery extends CI_Javascript {
return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");";
}
-
+
// --------------------------------------------------------------------
/**
@@ -814,11 +756,10 @@ class CI_Jquery extends CI_Javascript {
*
* Load a thickbox modal window
*
- * @access public
* @return void
*/
- function modal($src, $relative = FALSE)
- {
+ public function modal($src, $relative = FALSE)
+ {
$this->jquery_code_for_load[] = $this->external($src, $relative);
}
@@ -829,10 +770,9 @@ class CI_Jquery extends CI_Javascript {
*
* Load an Effect library
*
- * @access public
* @return void
*/
- function effect($src, $relative = FALSE)
+ public function effect($src, $relative = FALSE)
{
$this->jquery_code_for_load[] = $this->external($src, $relative);
}
@@ -844,10 +784,9 @@ class CI_Jquery extends CI_Javascript {
*
* Load a plugin library
*
- * @access public
* @return void
*/
- function plugin($src, $relative = FALSE)
+ public function plugin($src, $relative = FALSE)
{
$this->jquery_code_for_load[] = $this->external($src, $relative);
}
@@ -859,10 +798,9 @@ class CI_Jquery extends CI_Javascript {
*
* Load a user interface library
*
- * @access public
* @return void
*/
- function ui($src, $relative = FALSE)
+ public function ui($src, $relative = FALSE)
{
$this->jquery_code_for_load[] = $this->external($src, $relative);
}
@@ -873,10 +811,9 @@ class CI_Jquery extends CI_Javascript {
*
* Creates a jQuery sortable
*
- * @access public
* @return void
*/
- function sortable($element, $options = array())
+ public function sortable($element, $options = array())
{
if (count($options) > 0)
@@ -901,16 +838,15 @@ class CI_Jquery extends CI_Javascript {
/**
* Table Sorter Plugin
*
- * @access public
* @param string table name
* @param string plugin location
* @return string
*/
- function tablesorter($table = '', $options = '')
+ public function tablesorter($table = '', $options = '')
{
$this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n";
}
-
+
// --------------------------------------------------------------------
// Class functions
// --------------------------------------------------------------------
@@ -920,13 +856,12 @@ class CI_Jquery extends CI_Javascript {
*
* Constructs the syntax for an event, and adds to into the array for compilation
*
- * @access private
* @param string The element to attach the event to
* @param string The code to execute
* @param string The event to pass
* @return string
- */
- function _add_event($element, $js, $event)
+ */
+ protected function _add_event($element, $js, $event)
{
if (is_array($js))
{
@@ -947,65 +882,61 @@ class CI_Jquery extends CI_Javascript {
* As events are specified, they are stored in an array
* This funciton compiles them all for output on a page
*
- * @access private
* @return string
*/
- function _compile($view_var = 'script_foot', $script_tags = TRUE)
+ 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 )
+ if (count($this->jquery_code_for_compile) === 0)
{
// no inline references, let's just return
return;
}
// Inline references
- $script = '$(document).ready(function() {' . "\n";
- $script .= implode('', $this->jquery_code_for_compile);
- $script .= '});';
-
+ $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
*
- * @access public
* @return void
*/
- function _clear_compile()
+ protected function _clear_compile()
{
$this->jquery_code_for_compile = array();
}
// --------------------------------------------------------------------
-
+
/**
* Document Ready
*
* A wrapper for writing document.ready()
*
- * @access private
* @return string
*/
- function _document_ready($js)
+ protected function _document_ready($js)
{
if ( ! is_array($js))
{
- $js = array ($js);
-
+ $js = array($js);
}
-
+
foreach ($js as $script)
{
$this->jquery_code_for_compile[] = $script;
@@ -1019,17 +950,16 @@ class CI_Jquery extends CI_Javascript {
*
* Outputs the script tag that loads the jquery.js file into an HTML document
*
- * @access public
* @param string
* @return string
*/
- function script($library_src = '', $relative = FALSE)
+ public function script($library_src = '', $relative = FALSE)
{
$library_src = $this->external($library_src, $relative);
$this->jquery_code_for_load[] = $library_src;
return $library_src;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1039,20 +969,19 @@ class CI_Jquery extends CI_Javascript {
* unless the supplied element is the Javascript 'this'
* object, in which case no quotes are added
*
- * @access public
* @param string
* @return string
*/
- function _prep_element($element)
+ protected function _prep_element($element)
{
if ($element != 'this')
{
$element = '"'.$element.'"';
}
-
+
return $element;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1060,25 +989,24 @@ class CI_Jquery extends CI_Javascript {
*
* Ensures the speed parameter is valid for jQuery
*
- * @access private
* @param string
* @return string
- */
- function _validate_speed($speed)
+ */
+ protected function _validate_speed($speed)
{
if (in_array($speed, array('slow', 'normal', 'fast')))
{
- $speed = '"'.$speed.'"';
+ return '"'.$speed.'"';
}
elseif (preg_match("/[^0-9]/", $speed))
{
- $speed = '';
+ return '';
}
-
+
return $speed;
}
}
/* End of file Jquery.php */
-/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file
+/* Location: ./system/libraries/Jquery.php */