[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
Backup
/
14082024
/
Data
/
htdocs
/
htdocs
/
ojs
/
248
/
lib
/
pkp
/
classes
/
validation
/
[
Home
]
File: ValidatorISSN.inc.php
<?php /** * @file classes/validation/ValidatorISSN.inc.php * * Copyright (c) 2013-2019 Simon Fraser University * Copyright (c) 2000-2019 John Willinsky * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. * * @class ValidatorISSN * @ingroup validation * @see Validator * * @brief Validation check for ISSNs. */ import('lib.pkp.classes.validation.ValidatorRegExp'); class ValidatorISSN extends ValidatorRegExp { /** * Constructor. */ function ValidatorISSN() { parent::ValidatorRegExp(self::getRegexp()); } // // Implement abstract methods from Validator // /** * @see Validator::isValid() * @param $value mixed * @return boolean */ function isValid($value) { if (!parent::isValid($value)) return false; // Test the check digit $matches = $this->getMatches(); $issn = $matches[1] . $matches[2]; $check = 0; for ($i=0; $i<7; $i++) { $check += $issn[$i] * (8-$i); } $check = $check % 11; switch ($check) { case 0: $check = '0'; break; case 1: $check = 'X'; break; default: $check = (string) (11 - $check); } return ($issn[7] === $check); } // // Public static methods // /** * Return the regex for an ISSN check. This can be called * statically. * @return string */ static function getRegexp() { return '/^(\d{4})-(\d{3}[\dX])$/'; } } ?>