Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'zf2/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 66 changed files with 6,001 additions and 88 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-i18n",
"description": "Zend\\I18n component",
"description": " ",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-i18n",
"autoload": {
"psr-4": {
"Zend\\I18n\\": "src/"
"Zend\\I18n": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
Expand Down
19 changes: 19 additions & 0 deletions src/Exception/ExceptionInterface.php
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
{}
20 changes: 20 additions & 0 deletions src/Exception/InvalidArgumentException.php
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
{}
20 changes: 20 additions & 0 deletions src/Exception/OutOfBoundsException.php
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
{}
19 changes: 19 additions & 0 deletions src/Exception/ParseException.php
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
{}
19 changes: 19 additions & 0 deletions src/Exception/RangeException.php
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
{}
19 changes: 19 additions & 0 deletions src/Exception/RuntimeException.php
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
{}
46 changes: 46 additions & 0 deletions src/Filter/AbstractLocale.php
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'];
}
}
97 changes: 97 additions & 0 deletions src/Filter/Alnum.php
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);
}
}
Loading

0 comments on commit 56480f4

Please sign in to comment.