diff options
author | Derek Jones <derek.jones@ellislab.com> | 2008-05-13 06:22:33 +0200 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2008-05-13 06:22:33 +0200 |
commit | 0b59f270a432f8c7b6128981f0a39b4a2e2fbd34 (patch) | |
tree | 1e7655eabd76bb981692f5d4f21cb1fc7be3e9cd /system/helpers/typography_helper.php | |
parent | 5cf664748ee295867f593d7eb7991bd35fe8eca6 (diff) |
Some sweeping syntax changes for consistency:
(! foo) changed to ( ! foo)
|| changed to OR
changed newline standardization code in various places from preg_replace to str_replace
Diffstat (limited to 'system/helpers/typography_helper.php')
-rw-r--r-- | system/helpers/typography_helper.php | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index 78ade5cc3..cfb2b94f6 100644 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.php @@ -1,4 +1,4 @@ -<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -34,7 +34,7 @@ * @param string
* @return string
*/
-if (! function_exists('nl2br_except_pre'))
+if ( ! function_exists('nl2br_except_pre'))
{
function nl2br_except_pre($str)
{
@@ -71,7 +71,7 @@ if (! function_exists('nl2br_except_pre')) * @param string
* @return string
*/
-if (! function_exists('auto_typography'))
+if ( ! function_exists('auto_typography'))
{
function auto_typography($str)
{
@@ -117,7 +117,10 @@ class Auto_typography { $str = ' '.$str.' ';
// Standardize Newlines to make matching easier
- $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
/*
* Reduce line breaks
@@ -330,13 +333,13 @@ class Auto_typography { $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 != "<")
+ if ( ! in_array($one_after, $space, TRUE) && $one_after != "<")
{
$str = str_replace( $one_before."\"'".$one_after,
$one_before."“‘".$one_after,
$str);
}
- elseif (! in_array($one_before, $space, TRUE) && (in_array($one_after, $space, TRUE) OR $one_after == '<'))
+ 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."”’".$one_after,
@@ -363,7 +366,7 @@ class Auto_typography { $one_before."‘“".$one_after,
$str);
}
- elseif (! in_array($one_before, $space, TRUE) && $one_before != ">")
+ elseif ( ! in_array($one_before, $space, TRUE) && $one_before != ">")
{
$str = str_replace( $one_before."'\"".$one_after,
$one_before."’”".$one_after,
@@ -378,7 +381,7 @@ class Auto_typography { {
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))
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
{
$str = str_replace( $matches['0'][$i],
$matches['1'][$i]."“".$matches['2'][$i]."”".$matches['3'][$i],
@@ -391,7 +394,7 @@ class Auto_typography { {
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))
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
{
$str = str_replace( $matches['0'][$i],
$matches['1'][$i]."‘".$matches['2'][$i]."’".$matches['3'][$i],
@@ -412,7 +415,7 @@ class Auto_typography { $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))
+ if ( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
{
$str = str_replace( $one_before."'".$one_after,
$one_before."’".$one_after,
@@ -435,9 +438,9 @@ class Auto_typography { $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))
+ 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 == ' ')
+ ( ! 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,
@@ -468,13 +471,13 @@ class Auto_typography { $one_before = substr($str, $start+$current-1, 1);
$one_after = substr($str, $start+$current+1, 1);
- if (! in_array($one_after, $space, TRUE))
+ if ( ! in_array($one_after, $space, TRUE))
{
$str = str_replace( $one_before.'"'.$one_after,
$one_before."“".$one_after,
$str);
}
- elseif(! in_array($one_before, $space, TRUE))
+ elseif( ! in_array($one_before, $space, TRUE))
{
$str = str_replace( $one_before."'".$one_after,
$one_before."”".$one_after,
@@ -495,13 +498,13 @@ class Auto_typography { $one_before = substr($str, $start+$current-1, 1);
$one_after = substr($str, $start+$current+1, 1);
- if (! in_array($one_after, $space, TRUE))
+ if ( ! in_array($one_after, $space, TRUE))
{
$str = str_replace( $one_before."'".$one_after,
$one_before."‘".$one_after,
$str);
}
- elseif(! in_array($one_before, $space, TRUE))
+ elseif( ! in_array($one_before, $space, TRUE))
{
$str = str_replace( $one_before."'".$one_after,
$one_before."’".$one_after,
@@ -542,6 +545,6 @@ class Auto_typography { }
- -/* End of file typography_helper.php */ +
+/* End of file typography_helper.php */
/* Location: ./system/helpers/typography_helper.php */
\ No newline at end of file |