This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'zf2/master'
- Loading branch information
30 parents
a262823
+
b79aef6
+
c2284e4
+
70193eb
+
96acf77
+
9675426
+
5f02411
+
0dafea7
+
15dc674
+
4a2447d
+
e6eb7f3
+
e9499c5
+
272b15f
+
11c7758
+
6f0e918
+
5f4980a
+
ecca95a
+
88b5971
+
ecb8d13
+
9de1c08
+
44aad17
+
13269e9
+
ea3fc65
+
f6c04c2
+
7ea3aed
+
df6a706
+
a82fc82
+
7c2a059
+
4fefb53
+
599ee3a
commit 56480f4
Showing
66 changed files
with
6,001 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
interface ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
class InvalidArgumentException extends \InvalidArgumentException implements | ||
ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
class OutOfBoundsException extends \OutOfBoundsException implements | ||
ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
class ParseException extends RuntimeException implements ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
class RangeException extends \RangeException implements ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Exception; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_I18n | ||
* @subpackage Translator | ||
*/ | ||
class RuntimeException extends \RuntimeException implements ExceptionInterface | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Filter; | ||
|
||
use Locale; | ||
use Zend\Filter\AbstractFilter; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Filter | ||
*/ | ||
abstract class AbstractLocale extends AbstractFilter | ||
{ | ||
/** | ||
* Sets the locale option | ||
* | ||
* @param string|null $locale | ||
* @return AbstractLocale | ||
*/ | ||
public function setLocale($locale = null) | ||
{ | ||
$this->options['locale'] = $locale; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Returns the locale option | ||
* | ||
* @return string | ||
*/ | ||
public function getLocale() | ||
{ | ||
if (!isset($this->options['locale'])) { | ||
$this->options['locale'] = Locale::getDefault(); | ||
} | ||
return $this->options['locale']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_I18n | ||
*/ | ||
|
||
namespace Zend\I18n\Filter; | ||
|
||
use Locale; | ||
use Traversable; | ||
use Zend\Stdlib\ArrayUtils; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Filter | ||
*/ | ||
class Alnum extends AbstractLocale | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $options = array( | ||
'locale' => null, | ||
'allow_white_space' => false, | ||
); | ||
|
||
/** | ||
* Sets default option values for this instance | ||
* | ||
* @param array|Traversable|boolean|null $allowWhiteSpaceOrOptions | ||
* @param string|null $locale | ||
*/ | ||
public function __construct($allowWhiteSpaceOrOptions = null, $locale = null) | ||
{ | ||
if ($allowWhiteSpaceOrOptions !== null) { | ||
if (static::isOptions($allowWhiteSpaceOrOptions)){ | ||
$this->setOptions($allowWhiteSpaceOrOptions); | ||
} else { | ||
$this->setAllowWhiteSpace($allowWhiteSpaceOrOptions); | ||
$this->setLocale($locale); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Sets the allowWhiteSpace option | ||
* | ||
* @param boolean $flag | ||
* @return Alnum Provides a fluent interface | ||
*/ | ||
public function setAllowWhiteSpace($flag = true) | ||
{ | ||
$this->options['allow_white_space'] = (boolean) $flag; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Whether white space is allowed | ||
* | ||
* @return boolean | ||
*/ | ||
public function getAllowWhiteSpace() | ||
{ | ||
return $this->options['allow_white_space']; | ||
} | ||
|
||
/** | ||
* Defined by Zend\Filter\FilterInterface | ||
* | ||
* Returns $value as string with all non-alphanumeric characters removed | ||
* | ||
* @param mixed $value | ||
* @return string | ||
*/ | ||
public function filter($value) | ||
{ | ||
$whiteSpace = $this->options['allow_white_space'] ? '\s' : ''; | ||
$language = Locale::getPrimaryLanguage($this->getLocale()); | ||
|
||
if (!static::hasPcreUnicodeSupport()) { | ||
// POSIX named classes are not supported, use alternative a-zA-Z0-9 match | ||
$pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/'; | ||
} elseif ($language == 'ja'|| $language == 'ko' || $language == 'zh') { | ||
// Use english alphabet | ||
$pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u'; | ||
} else { | ||
// Use native language alphabet | ||
$pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u'; | ||
} | ||
|
||
return preg_replace($pattern, '', (string) $value); | ||
} | ||
} |
Oops, something went wrong.