diff -r 000000000000 -r 4eba9c11703f web/Zend/Validate/Barcode/Issn.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Validate/Barcode/Issn.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,119 @@ +_checksum = '_issn'; + } else { + $this->_checksum = '_gtin'; + } + + return parent::checksum($value); + } + + /** + * Validates the checksum () + * ISSN implementation (reversed mod11) + * + * @param string $value The barcode to validate + * @return boolean + */ + protected function _issn($value) + { + $checksum = substr($value, -1, 1); + $values = str_split(substr($value, 0, -1)); + $check = 0; + $multi = 8; + foreach($values as $token) { + if ($token == 'X') { + $token = 10; + } + + $check += ($token * $multi); + --$multi; + } + + $check %= 11; + $check = 11 - $check; + if ($check == $checksum) { + return true; + } else if (($check == 10) && ($checksum == 'X')) { + return true; + } + + return false; + } +}