summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/array_helper.php140
-rw-r--r--system/helpers/cookie_helper.php250
-rw-r--r--system/helpers/date_helper.php6
-rw-r--r--system/helpers/directory_helper.php132
-rw-r--r--system/helpers/download_helper.php6
-rw-r--r--system/helpers/file_helper.php356
-rw-r--r--system/helpers/form_helper.php6
-rw-r--r--system/helpers/html_helper.php406
-rw-r--r--system/helpers/inflector_helper.php278
-rw-r--r--system/helpers/security_helper.php222
-rw-r--r--system/helpers/smiley_helper.php328
-rw-r--r--system/helpers/string_helper.php6
-rw-r--r--system/helpers/text_helper.php840
-rw-r--r--system/helpers/typography_helper.php1078
-rw-r--r--system/helpers/url_helper.php6
-rw-r--r--system/helpers/xml_helper.php114
16 files changed, 2087 insertions, 2087 deletions
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index 491c61577..674ef3bec 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -1,71 +1,71 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Array Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Element
- *
- * Lets you determine whether an array index is set and whether it has a value.
- * If the element is empty it returns FALSE (or whatever you specify as the default value.)
- *
- * @access public
- * @param string
- * @param array
- * @param mixed
- * @return mixed depends on what the array contains
- */
-function element($item, $array, $default = FALSE)
-{
- if ( ! isset($array[$item]) OR $array[$item] == "")
- {
- return $default;
- }
-
- return $array[$item];
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Random Element - Takes an array as input and returns a random element
- *
- * @access public
- * @param array
- * @return mixed depends on what the array contains
- */
-function random_element($array)
-{
- if ( ! is_array($array))
- {
- return $array;
- }
- return $array[array_rand($array)];
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Array Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Element
+ *
+ * Lets you determine whether an array index is set and whether it has a value.
+ * If the element is empty it returns FALSE (or whatever you specify as the default value.)
+ *
+ * @access public
+ * @param string
+ * @param array
+ * @param mixed
+ * @return mixed depends on what the array contains
+ */
+function element($item, $array, $default = FALSE)
+{
+ if ( ! isset($array[$item]) OR $array[$item] == "")
+ {
+ return $default;
+ }
+
+ return $array[$item];
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Random Element - Takes an array as input and returns a random element
+ *
+ * @access public
+ * @param array
+ * @return mixed depends on what the array contains
+ */
+function random_element($array)
+{
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+ return $array[array_rand($array)];
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index b117816e2..9dc5df9b1 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -1,126 +1,126 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Cookie Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/cookie_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Set cookie
- *
- * Accepts six parameter, or you can submit an associative
- * array in the first parameter containing all the values.
- *
- * @access public
- * @param mixed
- * @param string the value of the cookie
- * @param string the number of seconds until expiration
- * @param string the cookie domain. Usually: .yourdomain.com
- * @param string the cookie path
- * @param string the cookie prefix
- * @return void
- */
-function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
-{
- if (is_array($name))
- {
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
- {
- if (isset($name[$item]))
- {
- $$item = $name[$item];
- }
- }
- }
-
- // Set the config file options
- $CI =& get_instance();
-
- if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
- {
- $CI->config->item('cookie_prefix');
- }
- if ($domain == '' AND $CI->config->item('cookie_domain') != '')
- {
- $CI->config->item('cookie_domain');
- }
- if ($prefix == '/' AND $CI->config->item('cookie_path') != '/')
- {
- $CI->config->item('cookie_path');
- }
-
- if ( ! is_numeric($expire))
- {
- $expire = time() - 86500;
- }
- else
- {
- if ($expire > 0)
- {
- $expire = time() + $expire;
- }
- else
- {
- $expire = 0;
- }
- }
-
- setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Fetch an item from the COOKIE array
- *
- * @access public
- * @param string
- * @param bool
- * @return mixed
- */
-function get_cookie($index = '', $xss_clean = FALSE)
-{
- $CI =& get_instance();
- return $CI->input->cookie($index, $xss_clean);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Delete a COOKIE
- *
- * @param mixed
- * @param string the cookie domain. Usually: .yourdomain.com
- * @param string the cookie path
- * @param string the cookie prefix
- * @return void
- */
-function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
-{
- set_cookie($name, '', '', $domain, $path, $prefix);
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Cookie Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/cookie_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set cookie
+ *
+ * Accepts six parameter, or you can submit an associative
+ * array in the first parameter containing all the values.
+ *
+ * @access public
+ * @param mixed
+ * @param string the value of the cookie
+ * @param string the number of seconds until expiration
+ * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie path
+ * @param string the cookie prefix
+ * @return void
+ */
+function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+{
+ if (is_array($name))
+ {
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
+ {
+ if (isset($name[$item]))
+ {
+ $$item = $name[$item];
+ }
+ }
+ }
+
+ // Set the config file options
+ $CI =& get_instance();
+
+ if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
+ {
+ $CI->config->item('cookie_prefix');
+ }
+ if ($domain == '' AND $CI->config->item('cookie_domain') != '')
+ {
+ $CI->config->item('cookie_domain');
+ }
+ if ($prefix == '/' AND $CI->config->item('cookie_path') != '/')
+ {
+ $CI->config->item('cookie_path');
+ }
+
+ if ( ! is_numeric($expire))
+ {
+ $expire = time() - 86500;
+ }
+ else
+ {
+ if ($expire > 0)
+ {
+ $expire = time() + $expire;
+ }
+ else
+ {
+ $expire = 0;
+ }
+ }
+
+ setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Fetch an item from the COOKIE array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return mixed
+ */
+function get_cookie($index = '', $xss_clean = FALSE)
+{
+ $CI =& get_instance();
+ return $CI->input->cookie($index, $xss_clean);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Delete a COOKIE
+ *
+ * @param mixed
+ * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie path
+ * @param string the cookie prefix
+ * @return void
+ */
+function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+{
+ set_cookie($name, '', '', $domain, $path, $prefix);
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 504a962ce..c67e3da2d 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Date Helpers
+ * CodeIgniter Date Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
index ad868519d..71f3778a1 100644
--- a/system/helpers/directory_helper.php
+++ b/system/helpers/directory_helper.php
@@ -1,67 +1,67 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Directory Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Create a Directory Map
- *
- * Reads the specified directory and builds an array
- * representation of it. Sub-folders contained with the
- * directory will be mapped as well.
- *
- * @access public
- * @param string path to source
- * @param bool whether to limit the result to the top level only
- * @return array
- */
-function directory_map($source_dir, $top_level_only = FALSE)
-{
- if ($fp = @opendir($source_dir))
- {
- $filedata = array();
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
- {
- $temp_array = array();
-
- $temp_array = directory_map($source_dir.$file."/");
-
- $filedata[$file] = $temp_array;
- }
- elseif (substr($file, 0, 1) != ".")
- {
- $filedata[] = $file;
- }
- }
- return $filedata;
- }
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Directory Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create a Directory Map
+ *
+ * Reads the specified directory and builds an array
+ * representation of it. Sub-folders contained with the
+ * directory will be mapped as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool whether to limit the result to the top level only
+ * @return array
+ */
+function directory_map($source_dir, $top_level_only = FALSE)
+{
+ if ($fp = @opendir($source_dir))
+ {
+ $filedata = array();
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
+ {
+ $temp_array = array();
+
+ $temp_array = directory_map($source_dir.$file."/");
+
+ $filedata[$file] = $temp_array;
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+ $filedata[] = $file;
+ }
+ }
+ return $filedata;
+ }
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 34cc152cc..c9d81f692 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Download Helpers
+ * CodeIgniter Download Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 4da62ade6..89801c0bf 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -1,179 +1,179 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter File Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/file_helpers.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Read File
- *
- * Opens the file specfied in the path and returns it as a string.
- *
- * @access public
- * @param string path to file
- * @return string
- */
-function read_file($file)
-{
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- if (function_exists('file_get_contents'))
- {
- return file_get_contents($file);
- }
-
- if ( ! $fp = @fopen($file, 'rb'))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_SH);
-
- $data = '';
- if (filesize($file) > 0)
- {
- $data =& fread($fp, filesize($file));
- }
-
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return $data;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Write File
- *
- * Writes data to the file specified in the path.
- * Creates a new file if non-existent.
- *
- * @access public
- * @param string path to file
- * @param string file data
- * @return bool
- */
-function write_file($path, $data, $mode = 'wb')
-{
- if ( ! $fp = @fopen($path, $mode))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_EX);
- fwrite($fp, $data);
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return TRUE;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Delete Files
- *
- * Deletes all files contained in the supplied directory path.
- * Files must be writable or owned by the system in order to be deleted.
- * If the second parameter is set to TRUE, any directories contained
- * within the supplied base directory will be nuked as well.
- *
- * @access public
- * @param string path to file
- * @param bool whether to delete any directories found in the path
- * @return bool
- */
-function delete_files($path, $del_dir = FALSE, $level = 0)
-{
- // Trim the trailing slash
- $path = preg_replace("|^(.+?)/*$|", "\\1", $path);
-
- if ( ! $current_dir = @opendir($path))
- return;
-
- while(FALSE !== ($filename = @readdir($current_dir)))
- {
- if ($filename != "." and $filename != "..")
- {
- if (is_dir($path.'/'.$filename))
- {
- $level++;
- delete_files($path.'/'.$filename, $del_dir, $level);
- }
- else
- {
- unlink($path.'/'.$filename);
- }
- }
- }
- @closedir($current_dir);
-
- if ($del_dir == TRUE AND $level > 0)
- {
- @rmdir($path);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Filenames
- *
- * Reads the specified directory and builds an array containing the filenames.
- * Any sub-folders contained within the specified path are read as well.
- *
- * @access public
- * @param string path to source
- * @param bool whether to include the path as part of the filename
- * @return array
- */
-function get_filenames($source_dir, $include_path = FALSE)
-{
- static $_filedata = array();
-
- if ($fp = @opendir($source_dir))
- {
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.')
- {
- get_filenames($source_dir.$file."/", $include_path);
- }
- elseif (substr($file, 0, 1) != ".")
- {
-
- $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
- }
- }
- return $_filedata;
- }
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter File Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/file_helpers.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Read File
+ *
+ * Opens the file specfied in the path and returns it as a string.
+ *
+ * @access public
+ * @param string path to file
+ * @return string
+ */
+function read_file($file)
+{
+ if ( ! file_exists($file))
+ {
+ return FALSE;
+ }
+
+ if (function_exists('file_get_contents'))
+ {
+ return file_get_contents($file);
+ }
+
+ if ( ! $fp = @fopen($file, 'rb'))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_SH);
+
+ $data = '';
+ if (filesize($file) > 0)
+ {
+ $data =& fread($fp, filesize($file));
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return $data;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creates a new file if non-existent.
+ *
+ * @access public
+ * @param string path to file
+ * @param string file data
+ * @return bool
+ */
+function write_file($path, $data, $mode = 'wb')
+{
+ if ( ! $fp = @fopen($path, $mode))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any directories contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @access public
+ * @param string path to file
+ * @param bool whether to delete any directories found in the path
+ * @return bool
+ */
+function delete_files($path, $del_dir = FALSE, $level = 0)
+{
+ // Trim the trailing slash
+ $path = preg_replace("|^(.+?)/*$|", "\\1", $path);
+
+ if ( ! $current_dir = @opendir($path))
+ return;
+
+ while(FALSE !== ($filename = @readdir($current_dir)))
+ {
+ if ($filename != "." and $filename != "..")
+ {
+ if (is_dir($path.'/'.$filename))
+ {
+ $level++;
+ delete_files($path.'/'.$filename, $del_dir, $level);
+ }
+ else
+ {
+ unlink($path.'/'.$filename);
+ }
+ }
+ }
+ @closedir($current_dir);
+
+ if ($del_dir == TRUE AND $level > 0)
+ {
+ @rmdir($path);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Filenames
+ *
+ * Reads the specified directory and builds an array containing the filenames.
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool whether to include the path as part of the filename
+ * @return array
+ */
+function get_filenames($source_dir, $include_path = FALSE)
+{
+ static $_filedata = array();
+
+ if ($fp = @opendir($source_dir))
+ {
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.')
+ {
+ get_filenames($source_dir.$file."/", $include_path);
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+
+ $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
+ }
+ }
+ return $_filedata;
+ }
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index a166198fb..adbddd5ad 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Form Helpers
+ * CodeIgniter Form Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 90a776386..152d18b76 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -1,204 +1,204 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter HTML Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/html_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Heading
- *
- * Generates an HTML heading tag. First param is the data.
- * Second param is the size of the heading tag.
- *
- * @access public
- * @param string
- * @param integer
- * @return string
- */
-function heading($data = '', $h = '1')
-{
- return "<h".$h.">".$data."</h".$h.">";
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Unordered List
- *
- * Generates an HTML unordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-function ul($list, $attributes = '')
-{
- return _list('ul', $list, $attributes);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Ordered List
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-function ol($list, $attributes = '')
-{
- return _list('ol', $list, $attributes);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates the list
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access private
- * @param string
- * @param mixed
- * @param mixed
- * @param intiger
- * @return string
- */
-function _list($type = 'ul', $list, $attributes = '', $depth = 0)
-{
- // If an array wasn't submitted there's nothing to do...
- if ( ! is_array($list))
- {
- return $list;
- }
-
- // Set the indentation based on the depth
- $out = str_repeat(" ", $depth);
-
- // Were any attributes submitted? If so generate a string
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' ' . $key . '="' . $val . '"';
- }
- $attributes = $atts;
- }
-
- // Write the opening list tag
- $out .= "<".$type.$attributes.">\n";
-
- // Cycle through the list elements. If an array is
- // encountered we will recursively call _list()
-
- static $_last_list_item = '';
- foreach ($list as $key => $val)
- {
- $_last_list_item = $key;
-
- $out .= str_repeat(" ", $depth + 2);
- $out .= "<li>";
-
- if ( ! is_array($val))
- {
- $out .= $val;
- }
- else
- {
- $out .= $_last_list_item."\n";
- $out .= _list($type, $val, '', $depth + 4);
- $out .= str_repeat(" ", $depth + 2);
- }
-
- $out .= "</li>\n";
- }
-
- // Set the indentation for the closing tag
- $out .= str_repeat(" ", $depth);
-
- // Write the closing list tag
- $out .= "</".$type.">\n";
-
- return $out;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates HTML BR tags based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-function br($num = 1)
-{
- return str_repeat("<br />", $num);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates non-breaking space entities based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-function nbs($num = 1)
-{
- return str_repeat("&nbsp;", $num);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates meta tags from an array of key/values
- *
- * @access public
- * @param array
- * @return string
- */
-function meta($meta = array(), $newline = "\n")
-{
- $str = '';
- foreach ($meta as $key => $val)
- {
- $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
- }
-
- return $str;
-}
-
-
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter HTML Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/html_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Heading
+ *
+ * Generates an HTML heading tag. First param is the data.
+ * Second param is the size of the heading tag.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return string
+ */
+function heading($data = '', $h = '1')
+{
+ return "<h".$h.">".$data."</h".$h.">";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unordered List
+ *
+ * Generates an HTML unordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+function ul($list, $attributes = '')
+{
+ return _list('ul', $list, $attributes);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Ordered List
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+function ol($list, $attributes = '')
+{
+ return _list('ol', $list, $attributes);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates the list
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access private
+ * @param string
+ * @param mixed
+ * @param mixed
+ * @param intiger
+ * @return string
+ */
+function _list($type = 'ul', $list, $attributes = '', $depth = 0)
+{
+ // If an array wasn't submitted there's nothing to do...
+ if ( ! is_array($list))
+ {
+ return $list;
+ }
+
+ // Set the indentation based on the depth
+ $out = str_repeat(" ", $depth);
+
+ // Were any attributes submitted? If so generate a string
+ if (is_array($attributes))
+ {
+ $atts = '';
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ' ' . $key . '="' . $val . '"';
+ }
+ $attributes = $atts;
+ }
+
+ // Write the opening list tag
+ $out .= "<".$type.$attributes.">\n";
+
+ // Cycle through the list elements. If an array is
+ // encountered we will recursively call _list()
+
+ static $_last_list_item = '';
+ foreach ($list as $key => $val)
+ {
+ $_last_list_item = $key;
+
+ $out .= str_repeat(" ", $depth + 2);
+ $out .= "<li>";
+
+ if ( ! is_array($val))
+ {
+ $out .= $val;
+ }
+ else
+ {
+ $out .= $_last_list_item."\n";
+ $out .= _list($type, $val, '', $depth + 4);
+ $out .= str_repeat(" ", $depth + 2);
+ }
+
+ $out .= "</li>\n";
+ }
+
+ // Set the indentation for the closing tag
+ $out .= str_repeat(" ", $depth);
+
+ // Write the closing list tag
+ $out .= "</".$type.">\n";
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function br($num = 1)
+{
+ return str_repeat("<br />", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function nbs($num = 1)
+{
+ return str_repeat("&nbsp;", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates meta tags from an array of key/values
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+function meta($meta = array(), $newline = "\n")
+{
+ $str = '';
+ foreach ($meta as $key => $val)
+ {
+ $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
+ }
+
+ return $str;
+}
+
+
+
+
?> \ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 666ec40b8..fbe851f3b 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -1,140 +1,140 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Inflector Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
- */
-
-
-// --------------------------------------------------------------------
-
-/**
- * Singular
- *
- * Takes a singular word and makes it plural
- *
- * @access public
- * @param string
- * @return str
- */
-function singular($str)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -3);
-
- if ($end == 'ies')
- {
- $str = substr($str, 0, strlen($str)-3).'y';
- }
- else
- {
- $end = substr($str, -1);
-
- if ($end == 's')
- {
- $str = substr($str, 0, strlen($str)-1);
- }
- }
-
- return $str;
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Plural
- *
- * Takes a plural word and makes it singular
- *
- * @access public
- * @param string
- * @return str
- */
-function plural($str)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -1);
-
- if ($end == 'y')
- {
- $str = substr($str, 0, strlen($str)-1).'ies';
- }
- elseif ($end != 's')
- {
- $str .= 's';
- }
-
- return $str;
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Camelize
- *
- * Takes multiple words separated by spaces or underscores and camelizes them
- *
- * @access public
- * @param string
- * @return str
- */
-function camelize($str)
-{
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
- return substr(str_replace(' ', '', $str), 1);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Underscore
- *
- * Takes multiple words separated by spaces and underscores them
- *
- * @access public
- * @param string
- * @return str
- */
-function underscore($str)
-{
- return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Humanize
- *
- * Takes multiple words separated by underscores and changes them to spaces
- *
- * @access public
- * @param string
- * @return str
- */
-function humanize($str)
-{
- return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Inflector Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+
+// --------------------------------------------------------------------
+
+/**
+ * Singular
+ *
+ * Takes a singular word and makes it plural
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function singular($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -3);
+
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ else
+ {
+ $end = substr($str, -1);
+
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Plural
+ *
+ * Takes a plural word and makes it singular
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function plural($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end != 's')
+ {
+ $str .= 's';
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Camelize
+ *
+ * Takes multiple words separated by spaces or underscores and camelizes them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function camelize($str)
+{
+ $str = 'x'.strtolower(trim($str));
+ $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
+ return substr(str_replace(' ', '', $str), 1);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Underscore
+ *
+ * Takes multiple words separated by spaces and underscores them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function underscore($str)
+{
+ return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Humanize
+ *
+ * Takes multiple words separated by underscores and changes them to spaces
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function humanize($str)
+{
+ return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 06228468f..eec04015d 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -1,112 +1,112 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Security Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/security_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * XSS Filtering
- *
- * @access public
- * @param string
- * @param string the character set of your data
- * @return string
- */
-function xss_clean($str, $charset = 'ISO-8859-1')
-{
- $CI =& get_instance();
- return $CI->input->xss_clean($str, $charset);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Hash encode a string
- *
- * @access public
- * @param string
- * @return string
- */
-function dohash($str, $type = 'sha1')
-{
- if ($type == 'sha1')
- {
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
- }
- else
- {
- return md5($str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Strip Image Tags
- *
- * @access public
- * @param string
- * @return string
- */
-function strip_image_tags($str)
-{
- $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
- $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert PHP tags to entities
- *
- * @access public
- * @param string
- * @return string
- */
-function encode_php_tags($str)
-{
- return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Security Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/security_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * XSS Filtering
+ *
+ * @access public
+ * @param string
+ * @param string the character set of your data
+ * @return string
+ */
+function xss_clean($str, $charset = 'ISO-8859-1')
+{
+ $CI =& get_instance();
+ return $CI->input->xss_clean($str, $charset);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function dohash($str, $type = 'sha1')
+{
+ if ($type == 'sha1')
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+ else
+ {
+ return md5($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function strip_image_tags($str)
+{
+ $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
+ $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function encode_php_tags($str)
+{
+ return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index a07337246..9f16d3132 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,165 +1,165 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Smiley Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/smiley_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * JS Insert Smiley
- *
- * Generates the javascrip function needed to insert smileys into a form field
- *
- * @access public
- * @param string form name
- * @param string field name
- * @return string
- */
-function js_insert_smiley($form_name = '', $form_field = '')
-{
-return <<<EOF
-<script type="text/javascript">
- function insert_smiley(smiley)
- {
- document.{$form_name}.{$form_field}.value += " " + smiley;
- }
-</script>
-EOF;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @access public
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
-function get_clickable_smileys($image_url = '', $smileys = NULL)
-{
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- $used = array();
- foreach ($smileys as $key => $val)
- {
- // Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
- // :-) and :) might be replaced with the same image so both smileys
- // will be in the array.
- if (isset($used[$smileys[$key][0]]))
- {
- continue;
- }
-
- $link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
-
- $used[$smileys[$key][0]] = TRUE;
- }
-
- return $link;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @access public
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
-function parse_smileys($str = '', $image_url = '', $smileys = NULL)
-{
- if ($image_url == '')
- {
- return $str;
- }
-
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- foreach ($smileys as $key => $val)
- {
- $str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @access private
- * @return mixed
- */
-function _get_smiley_array()
-{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
- {
- return FALSE;
- }
-
- include(APPPATH.'config/smileys'.EXT);
-
- if ( ! isset($smileys) OR ! is_array($smileys))
- {
- return FALSE;
- }
-
- return $smileys;
-}
-
-
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Smiley Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/smiley_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * JS Insert Smiley
+ *
+ * Generates the javascrip function needed to insert smileys into a form field
+ *
+ * @access public
+ * @param string form name
+ * @param string field name
+ * @return string
+ */
+function js_insert_smiley($form_name = '', $form_field = '')
+{
+return <<<EOF
+<script type="text/javascript">
+ function insert_smiley(smiley)
+ {
+ document.{$form_name}.{$form_field}.value += " " + smiley;
+ }
+</script>
+EOF;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @access public
+ * @param string the URL to the folder containing the smiley images
+ * @return array
+ */
+function get_clickable_smileys($image_url = '', $smileys = NULL)
+{
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ $used = array();
+ foreach ($smileys as $key => $val)
+ {
+ // Keep duplicates from being used, which can happen if the
+ // mapping array contains multiple identical replacements. For example:
+ // :-) and :) might be replaced with the same image so both smileys
+ // will be in the array.
+ if (isset($used[$smileys[$key][0]]))
+ {
+ continue;
+ }
+
+ $link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
+
+ $used[$smileys[$key][0]] = TRUE;
+ }
+
+ return $link;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @access public
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @return string
+ */
+function parse_smileys($str = '', $image_url = '', $smileys = NULL)
+{
+ if ($image_url == '')
+ {
+ return $str;
+ }
+
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ foreach ($smileys as $key => $val)
+ {
+ $str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @access private
+ * @return mixed
+ */
+function _get_smiley_array()
+{
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ {
+ return FALSE;
+ }
+
+ include(APPPATH.'config/smileys'.EXT);
+
+ if ( ! isset($smileys) OR ! is_array($smileys))
+ {
+ return FALSE;
+ }
+
+ return $smileys;
+}
+
+
+
+
?> \ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index c0a8854dc..04c3a592a 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter String Helpers
+ * CodeIgniter String Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 655d6e531..3c7270b9b 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,421 +1,421 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Text Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/text_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Limiter
- *
- * Limits a string to X number of words.
- *
- * @access public
- * @param string
- * @param integer
- * @param string the end character. Usually an ellipsis
- * @return string
- */
-function word_limiter($str, $n = 100, $end_char = '&#8230;')
-{
- if (strlen($str) < $n)
- {
- return $str;
- }
-
- $words = explode(' ', preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str)));
-
- if (count($words) <= $n)
- {
- return $str;
- }
-
- $str = '';
- for ($i = 0; $i < $n; $i++)
- {
- $str .= $words[$i].' ';
- }
-
- return trim($str).$end_char;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Character Limiter
- *
- * Limits the string based on the character count. Preserves complete words
- * so the character count may not be exactly as specified.
- *
- * @access public
- * @param string
- * @param integer
- * @param string the end character. Usually an ellipsis
- * @return string
- */
-function character_limiter($str, $n = 500, $end_char = '&#8230;')
-{
- if (strlen($str) < $n)
- {
- return $str;
- }
-
- $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
-
- if (strlen($str) <= $n)
- {
- return $str;
- }
-
- $out = "";
- foreach (explode(' ', trim($str)) as $val)
- {
- $out .= $val.' ';
- if (strlen($out) >= $n)
- {
- return trim($out).$end_char;
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @access public
- * @param string
- * @return string
- */
-function ascii_to_entities($str)
-{
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= '&#'.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
-function entities_to_ascii($str, $all = TRUE)
-{
- if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
- {
- for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
- {
- $digits = $matches['1'][$i];
-
- $out = '';
-
- if ($digits < 128)
- {
- $out .= chr($digits);
-
- }
- elseif ($digits < 2048)
- {
- $out .= chr(192 + (($digits - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
- else
- {
- $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
- $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
-
- $str = str_replace($matches['0'][$i], $out, $str);
- }
- }
-
- if ($all)
- {
- $str = str_replace(array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
- array("&","<",">","\"", "'", "-"),
- $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @access public
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
-function word_censor($str, $censored, $replacement = '')
-{
- if ( ! is_array($censored))
- {
- return $str;
- }
-
- $str = ' '.$str.' ';
- foreach ($censored as $badword)
- {
- if ($replacement != '')
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
- }
- else
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
- }
- }
-
- return trim($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @access public
- * @param string the text string
- * @return string
- */
-function highlight_code($str)
-{
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('&lt;', '&gt;'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('&lt;?php', '?&gt;', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
-
- // The highlight_string function requires that the text be surrounded
- // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
- // or B) whether the PHP tags enclose the entire string, we will add our
- // own PHP tags around the string along with some markers to make replacement easier later
-
- $str = '<?php //tempstart'."\n".$str.'//tempend ?>';
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
-
- // Prior to PHP 5, the highlight function used icky font tags
- // so we'll replace them with span tags.
- if (abs(phpversion()) < 5)
- {
- $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
-
- // Remove our artificially added PHP
- $str = preg_replace("#\<code\>.+?//tempstart\<br />\</span\>#is", "<code>\n", $str);
- $str = preg_replace("#\<code\>.+?//tempstart\<br />#is", "<code>\n", $str);
- $str = preg_replace("#//tempend.+#is", "</span>\n</code>", $str);
-
- // Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('&lt;?php', '?&gt;', '\\'), $str); //<?
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @access public
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
-function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
-{
- if ($str == '')
- {
- return '';
- }
-
- if ($phrase != '')
- {
- return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @access public
- * @param string the text string
- * @param integer the number of characters to wrap at
- * @return string
- */
-function word_wrap($str, $charlim = '76')
-{
- // Se the character limit
- if ( ! is_numeric($charlim))
- $charlim = 76;
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- $str = preg_replace("/\r\n|\r/", "\n", $str);
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native function to do the initial wordwrap.
- // We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
- $str = wordwrap($str, $charlim, "\n", FALSE);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line."\n";
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= "\n";
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
- return $output;
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Text Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/text_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Limiter
+ *
+ * Limits a string to X number of words.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
+function word_limiter($str, $n = 100, $end_char = '&#8230;')
+{
+ if (strlen($str) < $n)
+ {
+ return $str;
+ }
+
+ $words = explode(' ', preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str)));
+
+ if (count($words) <= $n)
+ {
+ return $str;
+ }
+
+ $str = '';
+ for ($i = 0; $i < $n; $i++)
+ {
+ $str .= $words[$i].' ';
+ }
+
+ return trim($str).$end_char;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Character Limiter
+ *
+ * Limits the string based on the character count. Preserves complete words
+ * so the character count may not be exactly as specified.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
+function character_limiter($str, $n = 500, $end_char = '&#8230;')
+{
+ if (strlen($str) < $n)
+ {
+ return $str;
+ }
+
+ $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
+
+ if (strlen($str) <= $n)
+ {
+ return $str;
+ }
+
+ $out = "";
+ foreach (explode(' ', trim($str)) as $val)
+ {
+ $out .= $val.' ';
+ if (strlen($out) >= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function ascii_to_entities($str)
+{
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= '&#'.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+function entities_to_ascii($str, $all = TRUE)
+{
+ if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+function word_censor($str, $censored, $replacement = '')
+{
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+function highlight_code($str)
+{
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('&lt;', '&gt;'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('&lt;?php', '?&gt;', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
+ // or B) whether the PHP tags enclose the entire string, we will add our
+ // own PHP tags around the string along with some markers to make replacement easier later
+
+ $str = '<?php //tempstart'."\n".$str.'//tempend ?>';
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highlight function used icky font tags
+ // so we'll replace them with span tags.
+ if (abs(phpversion()) < 5)
+ {
+ $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP
+ $str = preg_replace("#\<code\>.+?//tempstart\<br />\</span\>#is", "<code>\n", $str);
+ $str = preg_replace("#\<code\>.+?//tempstart\<br />#is", "<code>\n", $str);
+ $str = preg_replace("#//tempend.+#is", "</span>\n</code>", $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('&lt;?php', '?&gt;', '\\'), $str); //<?
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+function word_wrap($str, $charlim = '76')
+{
+ // Se the character limit
+ if ( ! is_numeric($charlim))
+ $charlim = 76;
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ $str = preg_replace("/\r\n|\r/", "\n", $str);
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native function to do the initial wordwrap.
+ // We set the cut flag to FALSE so that any individual words that are
+ // too long get left alone. In the next step we'll deal with them.
+ $str = wordwrap($str, $charlim, "\n", FALSE);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line."\n";
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp.$this->newline.$line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= "\n";
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ // Remove the unwrap tags
+ $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+
+ return $output;
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 1681fa37c..131358c6a 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -1,540 +1,540 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Typography Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/typography_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @access public
- * @param string
- * @return string
- */
-function nl2br_except_pre($str)
-{
- $ex = explode("pre>",$str);
- $ct = count($ex);
-
- $newstr = "";
- for ($i = 0; $i < $ct; $i++)
- {
- if (($i % 2) == 0)
- {
- $newstr .= nl2br($ex[$i]);
- }
- else
- {
- $newstr .= $ex[$i];
- }
-
- if ($ct - 1 != $i)
- $newstr .= "pre>";
- }
-
- return $newstr;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Wrapper Function
- *
- *
- * @access public
- * @param string
- * @return string
- */
-function auto_typography($str)
-{
- $TYPE = new Auto_typography();
- return $TYPE->convert($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Class
- *
- *
- * @access private
- * @category Helpers
- * @author Rick Ellis
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/helpers/
- */
-class Auto_typography {
-
- // Block level elements that should not be wrapped inside <p> tags
- var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
-
- // Elements that should not have <p> and <br /> tags within them.
- var $skip_elements = 'pre|ol|ul';
-
- // Tags we want the parser to completely ignore when splitting the string.
- var $ignore_elements = 'a|b|i|em|strong|span|img|li';
-
-
- /**
- * Main Processing Function
- *
- */
- function convert($str)
- {
- if ($str == '')
- {
- return '';
- }
-
- $str = ' '.$str.' ';
-
- // Standardize Newlines to make matching easier
- $str = preg_replace("/(\r\n|\r)/", "\n", $str);
-
- /*
- * Reduce line breaks
- *
- * If there are more than two consecutive line
- * breaks we'll compress them down to a maximum
- * of two since there's no benefit to more.
- *
- */
- $str = preg_replace("/\n\n+/", "\n\n", $str);
-
- /*
- * Convert quotes within tags to temporary marker
- *
- * We don't want quotes converted within
- * tags so we'll temporarily convert them to
- * {@DQ} and {@SQ}
- *
- */
- if (preg_match_all("#\<.+?>#si", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $str = str_replace($matches['0'][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
- $str);
- }
- }
-
-
- /*
- * Add closing/opening paragraph tags before/after "block" elements
- *
- * Since block elements (like <blockquotes>, <pre>, etc.) do not get
- * wrapped in paragraph tags we will add a closing </p> tag just before
- * each block element starts and an opening <p> tag right after the block element
- * ends. Later on we'll do some further clean up.
- *
- */
- $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "</p>\\1\\2\\3", $str);
- $str = preg_replace("#(</.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3<p>", $str);
-
- /*
- * Convert "ignore" tags to temporary marker
- *
- * The parser splits out the string at every tag
- * it encounters. Certain inline tags, like image
- * tags, links, span tags, etc. will be adversely
- * affected if they are split out so we'll convert
- * the opening < temporarily to: {@TAG}
- *
- */
- $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
-
- /*
- * Split the string at every tag
- *
- * This creates an array with this prototype:
- *
- * [array]
- * {
- * [0] = <opening tag>
- * [1] = Content contained between the tags
- * [2] = <closing tag>
- * Etc...
- * }
- *
- */
- $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
-
- /*
- * Build our finalized string
- *
- * We'll cycle through the array, skipping tags,
- * and processing the contained text
- *
- */
- $str = '';
- $process = TRUE;
- foreach ($chunks as $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->skip_elements."#", $match['2']))
- {
- $process = ($match['1'] == '/') ? TRUE : FALSE;
- }
-
- $str .= $chunk;
- continue;
- }
-
- if ($process == FALSE)
- {
- $str .= $chunk;
- continue;
- }
-
- // Convert Newlines into <p> and <br /> tags
- $str .= $this->format_newlines($chunk);
- }
-
- // FINAL CLEAN UP
- // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
-
- /*
- * Clean up paragraph tags before/after "block" elements
- *
- * Earlier we added <p></p> tags before/after block level elements.
- * Then, we added paragraph tags around double line breaks. This
- * potentially created incorrectly formatted paragraphs so we'll
- * clean it up here.
- *
- */
- $str = preg_replace("#<p>({@TAG}.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3", $str);
- $str = preg_replace("#({@TAG}/.*?)(".$this->block_elements.")(.*?>)</p>#", "\\1\\2\\3", $str);
-
- // Convert Quotes and other characters
- $str = $this->format_characters($str);
-
- // Fix an artifact that happens during the paragraph replacement
- $str = preg_replace('#(<p>\n*</p>)#', '', $str);
-
- // If the user submitted their own paragraph tags with class data
- // in them we will retain them instead of using our tags.
- $str = preg_replace('#(<p.*?>)<p>#', "\\1", $str);
-
- // Final clean up
- $str = str_replace(
- array(
- '</p></p>',
- '</p><p>',
- '<p> ',
- ' </p>',
- '{@TAG}',
- '{@DQ}',
- '{@SQ}',
- '<p></p>'
- ),
- array(
- '</p>',
- '<p>',
- '<p>',
- '</p>',
- '<',
- '"',
- "'",
- ''
- ),
- $str
- );
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Characters
- *
- * This function mainly converts double and single quotes
- * to entities, but since these are directional, it does
- * it based on some rules. It also converts em-dashes
- * and a couple other things.
- */
- function format_characters($str)
- {
- $table = array(
- ' "' => " &#8220;",
- '" ' => "&#8221; ",
- " '" => " &#8216;",
- "' " => "&#8217; ",
-
- '>"' => ">&#8220;",
- '"<' => "&#8221;<",
- ">'" => ">&#8216;",
- "'<" => "&#8217;<",
-
- "\"." => "&#8221;.",
- "\"," => "&#8221;,",
- "\";" => "&#8221;;",
- "\":" => "&#8221;:",
- "\"!" => "&#8221;!",
- "\"?" => "&#8221;?",
-
- ". " => ".&nbsp; ",
- "? " => "?&nbsp; ",
- "! " => "!&nbsp; ",
- ": " => ":&nbsp; ",
- );
-
- // These deal with quotes within quotes, like: "'hi here'"
- $start = 0;
- $space = array("\n", "\t", " ");
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "\"'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
-
- if ( ! in_array($one_after, $space, TRUE) && $one_after != "<")
- {
- $str = str_replace( $one_before."\"'".$one_after,
- $one_before."&#8220;&#8216;".$one_after,
- $str);
- }
- elseif ( ! in_array($one_before, $space, TRUE) && (in_array($one_after, $space, TRUE) OR $one_after == '<'))
- {
- $str = str_replace( $one_before."\"'".$one_after,
- $one_before."&#8221;&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'\"");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
-
- if ( in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE) && $one_after != "<")
- {
- $str = str_replace( $one_before."'\"".$one_after,
- $one_before."&#8216;&#8220;".$one_after,
- $str);
- }
- elseif ( ! in_array($one_before, $space, TRUE) && $one_before != ">")
- {
- $str = str_replace( $one_before."'\"".$one_after,
- $one_before."&#8217;&#8221;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Are there quotes within a word, as in: ("something")
- if (preg_match_all("/(.)\"(\S+?)\"(.)/", $str, $matches))
- {
- for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
- {
- if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
- {
- $str = str_replace( $matches['0'][$i],
- $matches['1'][$i]."&#8220;".$matches['2'][$i]."&#8221;".$matches['3'][$i],
- $str);
- }
- }
- }
-
- if (preg_match_all("/(.)\'(\S+?)\'(.)/", $str, $matches))
- {
- for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
- {
- if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
- {
- $str = str_replace( $matches['0'][$i],
- $matches['1'][$i]."&#8216;".$matches['2'][$i]."&#8217;".$matches['3'][$i],
- $str);
- }
- }
- }
-
- // How about one apostrophe, as in Rick's
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Em-dashes
- $start = 0;
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "--");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
- $two_before = substr($str, $start+$current-2, 1);
- $two_after = substr($str, $start+$current+3, 1);
-
- if (( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
- OR
- ( ! in_array($two_before, $space, TRUE) && ! in_array($two_after, $space, TRUE) && $one_before == ' ' && $one_after == ' ')
- )
- {
- $str = str_replace( $two_before.$one_before."--".$one_after.$two_after,
- $two_before.trim($one_before)."&#8212;".trim($one_after).$two_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Ellipsis
- $str = preg_replace("#(\w)\.\.\.(\s|<br />|</p>)#", "\\1&#8230;\\2", $str);
- $str = preg_replace("#(\s|<br />|</p>)\.\.\.(\w)#", "\\1&#8230;\\2", $str);
-
- // Run the translation array we defined above
- $str = str_replace(array_keys($table), array_values($table), $str);
-
- // If there are any stray double quotes we'll catch them here
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), '"');
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before.'"'.$one_after,
- $one_before."&#8220;".$one_after,
- $str);
- }
- elseif( ! in_array($one_before, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8221;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8216;".$one_after,
- $str);
- }
- elseif( ! in_array($one_before, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Newlines
- *
- * Converts newline characters into either <p> tags or <br />
- *
- */
- function format_newlines($str)
- {
- if ($str == '')
- {
- return $str;
- }
-
- if (strpos($str, "\n") === FALSE)
- {
- return '<p>'.$str.'</p>';
- }
-
- $str = str_replace("\n\n", "</p>\n\n<p>", $str);
- $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
-
- return '<p>'.$str.'</p>';
- }
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Typography Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/typography_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function nl2br_except_pre($str)
+{
+ $ex = explode("pre>",$str);
+ $ct = count($ex);
+
+ $newstr = "";
+ for ($i = 0; $i < $ct; $i++)
+ {
+ if (($i % 2) == 0)
+ {
+ $newstr .= nl2br($ex[$i]);
+ }
+ else
+ {
+ $newstr .= $ex[$i];
+ }
+
+ if ($ct - 1 != $i)
+ $newstr .= "pre>";
+ }
+
+ return $newstr;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function auto_typography($str)
+{
+ $TYPE = new Auto_typography();
+ return $TYPE->convert($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Class
+ *
+ *
+ * @access private
+ * @category Helpers
+ * @author Rick Ellis
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/helpers/
+ */
+class Auto_typography {
+
+ // Block level elements that should not be wrapped inside <p> tags
+ var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
+
+ // Elements that should not have <p> and <br /> tags within them.
+ var $skip_elements = 'pre|ol|ul';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $ignore_elements = 'a|b|i|em|strong|span|img|li';
+
+
+ /**
+ * Main Processing Function
+ *
+ */
+ function convert($str)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ $str = ' '.$str.' ';
+
+ // Standardize Newlines to make matching easier
+ $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+
+ /*
+ * Reduce line breaks
+ *
+ * If there are more than two consecutive line
+ * breaks we'll compress them down to a maximum
+ * of two since there's no benefit to more.
+ *
+ */
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+
+ /*
+ * Convert quotes within tags to temporary marker
+ *
+ * We don't want quotes converted within
+ * tags so we'll temporarily convert them to
+ * {@DQ} and {@SQ}
+ *
+ */
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $str = str_replace($matches['0'][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
+ $str);
+ }
+ }
+
+
+ /*
+ * Add closing/opening paragraph tags before/after "block" elements
+ *
+ * Since block elements (like <blockquotes>, <pre>, etc.) do not get
+ * wrapped in paragraph tags we will add a closing </p> tag just before
+ * each block element starts and an opening <p> tag right after the block element
+ * ends. Later on we'll do some further clean up.
+ *
+ */
+ $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "</p>\\1\\2\\3", $str);
+ $str = preg_replace("#(</.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3<p>", $str);
+
+ /*
+ * Convert "ignore" tags to temporary marker
+ *
+ * The parser splits out the string at every tag
+ * it encounters. Certain inline tags, like image
+ * tags, links, span tags, etc. will be adversely
+ * affected if they are split out so we'll convert
+ * the opening < temporarily to: {@TAG}
+ *
+ */
+ $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
+
+ /*
+ * Split the string at every tag
+ *
+ * This creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] = <opening tag>
+ * [1] = Content contained between the tags
+ * [2] = <closing tag>
+ * Etc...
+ * }
+ *
+ */
+ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+ /*
+ * Build our finalized string
+ *
+ * We'll cycle through the array, skipping tags,
+ * and processing the contained text
+ *
+ */
+ $str = '';
+ $process = TRUE;
+ foreach ($chunks as $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->skip_elements."#", $match['2']))
+ {
+ $process = ($match['1'] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into <p> and <br /> tags
+ $str .= $this->format_newlines($chunk);
+ }
+
+ // FINAL CLEAN UP
+ // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
+
+ /*
+ * Clean up paragraph tags before/after "block" elements
+ *
+ * Earlier we added <p></p> tags before/after block level elements.
+ * Then, we added paragraph tags around double line breaks. This
+ * potentially created incorrectly formatted paragraphs so we'll
+ * clean it up here.
+ *
+ */
+ $str = preg_replace("#<p>({@TAG}.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3", $str);
+ $str = preg_replace("#({@TAG}/.*?)(".$this->block_elements.")(.*?>)</p>#", "\\1\\2\\3", $str);
+
+ // Convert Quotes and other characters
+ $str = $this->format_characters($str);
+
+ // Fix an artifact that happens during the paragraph replacement
+ $str = preg_replace('#(<p>\n*</p>)#', '', $str);
+
+ // If the user submitted their own paragraph tags with class data
+ // in them we will retain them instead of using our tags.
+ $str = preg_replace('#(<p.*?>)<p>#', "\\1", $str);
+
+ // Final clean up
+ $str = str_replace(
+ array(
+ '</p></p>',
+ '</p><p>',
+ '<p> ',
+ ' </p>',
+ '{@TAG}',
+ '{@DQ}',
+ '{@SQ}',
+ '<p></p>'
+ ),
+ array(
+ '</p>',
+ '<p>',
+ '<p>',
+ '</p>',
+ '<',
+ '"',
+ "'",
+ ''
+ ),
+ $str
+ );
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Characters
+ *
+ * This function mainly converts double and single quotes
+ * to entities, but since these are directional, it does
+ * it based on some rules. It also converts em-dashes
+ * and a couple other things.
+ */
+ function format_characters($str)
+ {
+ $table = array(
+ ' "' => " &#8220;",
+ '" ' => "&#8221; ",
+ " '" => " &#8216;",
+ "' " => "&#8217; ",
+
+ '>"' => ">&#8220;",
+ '"<' => "&#8221;<",
+ ">'" => ">&#8216;",
+ "'<" => "&#8217;<",
+
+ "\"." => "&#8221;.",
+ "\"," => "&#8221;,",
+ "\";" => "&#8221;;",
+ "\":" => "&#8221;:",
+ "\"!" => "&#8221;!",
+ "\"?" => "&#8221;?",
+
+ ". " => ".&nbsp; ",
+ "? " => "?&nbsp; ",
+ "! " => "!&nbsp; ",
+ ": " => ":&nbsp; ",
+ );
+
+ // These deal with quotes within quotes, like: "'hi here'"
+ $start = 0;
+ $space = array("\n", "\t", " ");
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "\"'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( ! in_array($one_after, $space, TRUE) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."&#8220;&#8216;".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space, TRUE) && (in_array($one_after, $space, TRUE) OR $one_after == '<'))
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."&#8221;&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'\"");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."&#8216;&#8220;".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space, TRUE) && $one_before != ">")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."&#8217;&#8221;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Are there quotes within a word, as in: ("something")
+ if (preg_match_all("/(.)\"(\S+?)\"(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."&#8220;".$matches['2'][$i]."&#8221;".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ if (preg_match_all("/(.)\'(\S+?)\'(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."&#8216;".$matches['2'][$i]."&#8217;".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ // How about one apostrophe, as in Rick's
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Em-dashes
+ $start = 0;
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "--");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+ $two_before = substr($str, $start+$current-2, 1);
+ $two_after = substr($str, $start+$current+3, 1);
+
+ if (( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
+ OR
+ ( ! in_array($two_before, $space, TRUE) && ! in_array($two_after, $space, TRUE) && $one_before == ' ' && $one_after == ' ')
+ )
+ {
+ $str = str_replace( $two_before.$one_before."--".$one_after.$two_after,
+ $two_before.trim($one_before)."&#8212;".trim($one_after).$two_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Ellipsis
+ $str = preg_replace("#(\w)\.\.\.(\s|<br />|</p>)#", "\\1&#8230;\\2", $str);
+ $str = preg_replace("#(\s|<br />|</p>)\.\.\.(\w)#", "\\1&#8230;\\2", $str);
+
+ // Run the translation array we defined above
+ $str = str_replace(array_keys($table), array_values($table), $str);
+
+ // If there are any stray double quotes we'll catch them here
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), '"');
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before.'"'.$one_after,
+ $one_before."&#8220;".$one_after,
+ $str);
+ }
+ elseif( ! in_array($one_before, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8221;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8216;".$one_after,
+ $str);
+ }
+ elseif( ! in_array($one_before, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Newlines
+ *
+ * Converts newline characters into either <p> tags or <br />
+ *
+ */
+ function format_newlines($str)
+ {
+ if ($str == '')
+ {
+ return $str;
+ }
+
+ if (strpos($str, "\n") === FALSE)
+ {
+ return '<p>'.$str.'</p>';
+ }
+
+ $str = str_replace("\n\n", "</p>\n\n<p>", $str);
+ $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
+
+ return '<p>'.$str.'</p>';
+ }
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index baac0e5d8..c05bc2088 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter URL Helpers
+ * CodeIgniter URL Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 856722b32..398b07e3f 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -1,58 +1,58 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter XML Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/xml_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert Reserved XML characters to Entities
- *
- * @access public
- * @param string
- * @return string
- */
-function xml_convert($str)
-{
- $temp = '__TEMP_AMPERSANDS__';
-
- // Replace entities to temporary markers so that
- // ampersands won't get messed up
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
- $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
-
- $str = str_replace(array("&","<",">","\"", "'", "-"),
- array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
- $str);
-
- // Decode the temp markers back to entities
- $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
-
- return $str;
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter XML Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/xml_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert Reserved XML characters to Entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function xml_convert($str)
+{
+ $temp = '__TEMP_AMPERSANDS__';
+
+ // Replace entities to temporary markers so that
+ // ampersands won't get messed up
+ $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+ $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
+
+ $str = str_replace(array("&","<",">","\"", "'", "-"),
+ array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
+ $str);
+
+ // Decode the temp markers back to entities
+ $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
+ $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+
+ return $str;
+}
+
+
?> \ No newline at end of file