summaryrefslogtreecommitdiffstats
path: root/system/helpers/text_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-26 17:31:02 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-26 17:31:02 +0100
commitea41c8aa1951216b6a9ccc99832d69d2b41c5ead (patch)
tree57b8b39c7325217795e172cafb71e5f7e63fc563 /system/helpers/text_helper.php
parent4247ed1c0fb588f968f18fd80a5f95debefc63f6 (diff)
Don't use error suppression on realpath() + style adjustments
Diffstat (limited to 'system/helpers/text_helper.php')
-rw-r--r--system/helpers/text_helper.php57
1 files changed, 31 insertions, 26 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 76e1735b5..af14dfea2 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -157,8 +157,8 @@ if ( ! function_exists('ascii_to_entities'))
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);
+ ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
+ : (($temp[0] % 32) * 64) + ($temp[1] % 64);
$out .= '&#'.$number.';';
$count = 1;
@@ -220,9 +220,11 @@ if ( ! function_exists('entities_to_ascii'))
if ($all)
{
- return str_replace(array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
- array('&', '<', '>', '"', "'", '-'),
- $str);
+ return str_replace(
+ array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
+ array('&', '<', '>', '"', "'", '-'),
+ $str
+ );
}
return $str;
@@ -297,31 +299,37 @@ if ( ! function_exists('highlight_code'))
* so they don't accidentally break the string out of PHP,
* and thus, thwart the highlighting.
*/
- $str = str_replace(array('&lt;', '&gt;', '<?', '?>', '<%', '%>', '\\', '</script>'),
- array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- $str);
+ $str = str_replace(
+ array('&lt;', '&gt;', '<?', '?>', '<%', '%>', '\\', '</script>'),
+ array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ $str
+ );
// The highlight_string function requires that the text be surrounded
// by PHP tags, which we will remove later
$str = highlight_string('<?php '.$str.' ?>', TRUE);
// Remove our artificially added PHP, and the syntax highlighting that came with it
- $str = preg_replace(array(
- '/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i',
- '/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is',
- '/<span style="color: #[A-Z0-9]+"\><\/span>/i'
- ),
- array(
- '<span style="color: #$1">',
- "$1</span>\n</span>\n</code>",
- ''
- ),
- $str);
+ $str = preg_replace(
+ array(
+ '/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i',
+ '/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is',
+ '/<span style="color: #[A-Z0-9]+"\><\/span>/i'
+ ),
+ array(
+ '<span style="color: #$1">',
+ "$1</span>\n</span>\n</code>",
+ ''
+ ),
+ $str
+ );
// Replace our markers back to PHP tags.
- return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'),
- $str);
+ return str_replace(
+ array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'),
+ $str
+ );
}
}
@@ -408,10 +416,7 @@ if ( ! function_exists('word_wrap'))
function word_wrap($str, $charlim = 76)
{
// Set the character limit
- if ( ! is_numeric($charlim))
- {
- $charlim = 76;
- }
+ is_numeric($charlim) OR $charlim = 76;
// Reduce multiple spaces
$str = preg_replace('| +|', ' ', $str);