mscherer 7 years ago
parent
commit
f8cb3a3cf2
4 changed files with 48 additions and 60 deletions
  1. 1 2
      .travis.yml
  2. 1 1
      src/Mailer/Email.php
  3. 0 2
      src/Utility/Time.php
  4. 46 55
      src/View/Helper/TypographyHelper.php

+ 1 - 2
.travis.yml

@@ -5,8 +5,7 @@ sudo: false
 php:
   - 5.6
   - 7.0
-  - 7.1
-  - 7.2
+  - 7.3
 
 env:
   matrix:

+ 1 - 1
src/Mailer/Email.php

@@ -36,7 +36,7 @@ class Email extends CakeEmail {
 	protected $_log = [];
 
 	/**
-	 * @var Mime|null
+	 * @var \Tools\Utility\Mime|null
 	 */
 	protected $_Mime;
 

+ 0 - 2
src/Utility/Time.php

@@ -7,8 +7,6 @@ use Cake\I18n\Date;
 use Cake\I18n\Time as CakeTime;
 use DateInterval;
 use DateTime;
-use DateTimeZone;
-use Geo\Geocoder\Calculator;
 
 /**
  * Extend CakeTime with a few important improvements:

+ 46 - 55
src/View/Helper/TypographyHelper.php

@@ -81,13 +81,6 @@ class TypographyHelper extends Helper {
 	];
 
 	/**
-	 * Cache definitions.
-	 *
-	 * @var array|null
-	 */
-	protected $table;
-
-	/**
 	 * Automatically uses the typography specified.
 	 * By default, uses Configure::read('App.language') to determine locale preference.
 	 * It will then try to match the language to the type of characters used.
@@ -307,57 +300,55 @@ class TypographyHelper extends Helper {
 			],
 		];
 
-		if (!isset($this->table)) {
-			$this->table = [
-				// nested smart quotes, opening and closing
-				// note that rules for grammar (English) allow only for two levels deep
-				// and that single quotes are _supposed_ to always be on the outside
-				// but we'll accommodate both
-				// Note that in all cases, whitespace is the primary determining factor
-				// on which direction to curl, with non-word characters like punctuation
-				// being a secondary factor only after whitespace is addressed.
-				'/\'"(\s|$)/'					=> '’”$1',
-				'/(^|\s|<p>)\'"/'				=> '$1&#8216;&#8220;',
-				'/\'"(\W)/'						=> '&#8217;&#8221;$1',
-				'/(\W)\'"/'						=> '$1&#8216;&#8220;',
-				'/"\'(\s|$)/'					=> '&#8221;&#8217;$1',
-				'/(^|\s|<p>)"\'/'				=> '$1&#8220;&#8216;',
-				'/"\'(\W)/'						=> '&#8221;&#8217;$1',
-				'/(\W)"\'/'						=> '$1&#8220;&#8216;',
-
-				// single quote smart quotes
-				'/\'(\s|$)/'					=> '&#8217;$1',
-				'/(^|\s|<p>)\'/'				=> '$1&#8216;',
-				'/\'(\W)/'						=> '&#8217;$1',
-				'/(\W)\'/'						=> '$1&#8216;',
-
-				// double quote smart quotes
-				'/"(\s|$)/'						=> '&#8221;$1',
-				'/(^|\s|<p>)"/'					=> '$1&#8220;',
-				'/"(\W)/'						=> '&#8221;$1',
-				'/(\W)"/'						=> '$1&#8220;',
-
-				// apostrophes
-				"/(\w)'(\w)/"					=> '$1&rsquo;$2', // we dont use #8217; to avoid collision on replace
-
-				// Em dash and ellipses dots
-				'/\s?\-\-\s?/'					=> '&#8212;',
-				'/(\w)\.{3}/'					=> '$1&#8230;',
-
-				// double space after sentences
-				'/(\W)  /'						=> '$1&nbsp; ',
-
-				// ampersands, if not a character entity
-				'/&(?!#?[a-zA-Z0-9]{2,};)/'		=> '&amp;'
-			];
-			if ($locale && !empty($locales[$locale])) {
-				foreach ($this->table as $key => $val) {
-					$this->table[$key] = str_replace($locales['default'], $locales[$locale], $val);
-				}
+		$table = [
+			// nested smart quotes, opening and closing
+			// note that rules for grammar (English) allow only for two levels deep
+			// and that single quotes are _supposed_ to always be on the outside
+			// but we'll accommodate both
+			// Note that in all cases, whitespace is the primary determining factor
+			// on which direction to curl, with non-word characters like punctuation
+			// being a secondary factor only after whitespace is addressed.
+			'/\'"(\s|$)/'					=> '&#8217;&#8221;$1',
+			'/(^|\s|<p>)\'"/'				=> '$1&#8216;&#8220;',
+			'/\'"(\W)/'						=> '&#8217;&#8221;$1',
+			'/(\W)\'"/'						=> '$1&#8216;&#8220;',
+			'/"\'(\s|$)/'					=> '&#8221;&#8217;$1',
+			'/(^|\s|<p>)"\'/'				=> '$1&#8220;&#8216;',
+			'/"\'(\W)/'						=> '&#8221;&#8217;$1',
+			'/(\W)"\'/'						=> '$1&#8220;&#8216;',
+
+			// single quote smart quotes
+			'/\'(\s|$)/'					=> '&#8217;$1',
+			'/(^|\s|<p>)\'/'				=> '$1&#8216;',
+			'/\'(\W)/'						=> '&#8217;$1',
+			'/(\W)\'/'						=> '$1&#8216;',
+
+			// double quote smart quotes
+			'/"(\s|$)/'						=> '&#8221;$1',
+			'/(^|\s|<p>)"/'					=> '$1&#8220;',
+			'/"(\W)/'						=> '&#8221;$1',
+			'/(\W)"/'						=> '$1&#8220;',
+
+			// apostrophes
+			"/(\w)'(\w)/"					=> '$1&rsquo;$2', // we dont use #8217; to avoid collision on replace
+
+			// Em dash and ellipses dots
+			'/\s?\-\-\s?/'					=> '&#8212;',
+			'/(\w)\.{3}/'					=> '$1&#8230;',
+
+			// double space after sentences
+			'/(\W)  /'						=> '$1&nbsp; ',
+
+			// ampersands, if not a character entity
+			'/&(?!#?[a-zA-Z0-9]{2,};)/'		=> '&amp;'
+		];
+		if ($locale && !empty($locales[$locale])) {
+			foreach ($table as $key => $val) {
+				$table[$key] = str_replace($locales['default'], $locales[$locale], $val);
 			}
 		}
 
-		return preg_replace(array_keys($this->table), $this->table, $str);
+		return preg_replace(array_keys($table), $table, $str);
 	}
 
 	/**