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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
Fixed files permissions
  • Loading branch information
Show file tree
Hide file tree
Showing 121 changed files with 2,320 additions and 1,713 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
"dev-master": "2.1-dev",
"dev-develop": "2.2-dev"
}
},
"autoload-dev": {
Expand Down
7 changes: 1 addition & 6 deletions src/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator;
Expand All @@ -16,10 +15,6 @@
use Zend\Stdlib\ArrayUtils;
use Zend\Validator\Exception\InvalidArgumentException;

/**
* @category Zend
* @package Zend_Validator
*/
abstract class AbstractValidator implements
TranslatorAwareInterface,
ValidatorInterface
Expand Down Expand Up @@ -145,7 +140,7 @@ public function setOptions($options = array())
$this->{$name}($option);
} elseif (($fname != 'setOptions') && method_exists($this, $fname)) {
$this->{$fname}($option);
} elseif (($fname2 != 'setOptions') && method_exists($this, $fname2)) {
} elseif (method_exists($this, $fname2)) {
$this->{$fname2}($option);
} elseif (isset($this->options)) {
$this->options[$name] = $option;
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator;

use Traversable;

/**
* @category Zend
* @package Zend_Validator
*/
class Barcode extends AbstractValidator
{
const INVALID = 'barcodeInvalid';
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
abstract class AbstractAdapter implements AdapterInterface
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
interface AdapterInterface
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Codabar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Codabar extends AbstractAdapter
{
/**
Expand Down
71 changes: 52 additions & 19 deletions src/Barcode/Code128.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
use Zend\Validator\Exception;
use Zend\Stdlib\StringUtils;
use Zend\Stdlib\StringWrapper\StringWrapperInterface;

class Code128 extends AbstractAdapter
{
/**
* The used string wrapper used for basic UTF-8 string functions
*
* @var StringWrapperInterface
*/
protected $utf8StringWrapper;

/**
* Constructor for this barcode adapter
*/
Expand Down Expand Up @@ -72,6 +78,29 @@ public function __construct()

}

public function setUtf8StringWrapper(StringWrapperInterface $utf8StringWrapper)
{
if (!$utf8StringWrapper->isSupported('UTF-8')) {
throw new Exception\InvalidArgumentException(
"The string wrapper needs to support UTF-8 character encoding"
);
}
$this->utf8StringWrapper = $utf8StringWrapper;
}

/**
* Get the string wrapper supporting UTF-8 character encoding
*
* @return StringWrapperInterface
*/
public function getUtf8StringWrapper()
{
if (!$this->utf8StringWrapper) {
$this->utf8StringWrapper = StringUtils::getWrapper('UTF-8');
}
return $this->utf8StringWrapper;
}

/**
* Checks for allowed characters within the barcode
*
Expand All @@ -84,16 +113,19 @@ public function hasValidCharacters($value)
return false;
}

// get used string wrapper for UTF-8 character encoding
$strWrapper = $this->getUtf8StringWrapper();

// detect starting charset
$set = $this->getCodingSet($value);
$read = $set;
if ($set != '') {
$value = iconv_substr($value, 1, iconv_strlen($value, 'UTF-8'), 'UTF-8');
$value = $strWrapper->substr($value, 1, null);
}

// process barcode
while ($value != '') {
$char = iconv_substr($value, 0, 1, 'UTF-8');
$char = $strWrapper->substr($value, 0, 1);

switch ($char) {
// Function definition
Expand Down Expand Up @@ -149,11 +181,11 @@ public function hasValidCharacters($value)
break;
}

$value = iconv_substr($value, 1);
$value = $strWrapper->substr($value, 1, null);
$read = $set;
}

if (($value != '') && (iconv_strlen($value, 'UTF-8') != 1)) {
if (($value != '') && ($strWrapper->strlen($value) != 1)) {
return false;
}

Expand All @@ -173,7 +205,8 @@ protected function code128($value)
$set = $this->getCodingSet($value);
$read = $set;
$usecheck = $this->useChecksum(null);
$char = iconv_substr($value, 0, 1, 'UTF-8');
$strWrapper = $this->getUtf8StringWrapper();
$char = $strWrapper->substr($value, 0, 1);
if ($char == '') {
$sum = 103;
} elseif ($char == 'ˆ') {
Expand All @@ -185,11 +218,11 @@ protected function code128($value)
return false;
}

$value = iconv_substr($value, 1, iconv_strlen($value, 'UTF-8'), 'UTF-8');
while (iconv_strpos($value, 'Š') || ($value != '')) {
$char = iconv_substr($value, 0, 1, 'UTF-8');
$value = $strWrapper->substr($value, 1, null);
while ($strWrapper->strpos($value, 'Š') || ($value != '')) {
$char = $strWrapper->substr($value, 0, 1);
if ($read == 'C') {
$char = iconv_substr($value, 0, 2, 'UTF-8');
$char = $strWrapper->substr($value, 0, 2);
}

switch ($char) {
Expand Down Expand Up @@ -246,22 +279,22 @@ protected function code128($value)
break;
}

$value = iconv_substr($value, 1, iconv_strlen($value, 'UTF-8'), 'UTF-8');
$value = $strWrapper->substr($value, 1);
++$pos;
if ((iconv_strpos($value, 'Š', 0, 'UTF-8') == 1) && (iconv_strlen($value, 'UTF-8') == 2)) {
if (($strWrapper->strpos($value, 'Š') == 1) && ($strWrapper->strlen($value) == 2)) {
// break by stop and checksum char
break;
}
$read = $set;
}

if ((iconv_strpos($value, 'Š', 0, 'UTF-8') != 1) || (iconv_strlen($value, 'UTF-8') != 2)) {
if (($strWrapper->strpos($value, 'Š') != 1) || ($strWrapper->strlen($value) != 2)) {
// return false if checksum is not readable and true if no startvalue is detected
return (!$usecheck);
}

$mod = $sum % 103;
if (iconv_substr($value, 0, 1, 'UTF-8') == $this->chr128($mod, $set)) {
if ($strWrapper->substr($value, 0, 1) == $this->chr128($mod, $set)) {
return true;
}

Expand All @@ -276,7 +309,7 @@ protected function code128($value)
*/
protected function getCodingSet($value)
{
$value = iconv_substr($value, 0, 1, 'UTF-8');
$value = $this->getUtf8StringWrapper()->substr($value, 0, 1);
switch ($value) {
case '' :
return 'A';
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code25.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code25 extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code25interleaved.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code25interleaved extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code39.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code39 extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code39ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code39ext extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code93.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code93 extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Code93ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Code93ext extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Ean12.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Ean12 extends AbstractAdapter
{
/**
Expand Down
5 changes: 0 additions & 5 deletions src/Barcode/Ean13.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Validator
*/

namespace Zend\Validator\Barcode;

/**
* @category Zend
* @package Zend_Validator
*/
class Ean13 extends AbstractAdapter
{
/**
Expand Down
Loading

0 comments on commit b64a638

Please sign in to comment.