Exemplo n.º 1
0
 /**
  * Get the 2 Parts of the ISBN-Subbody (ISBN-10/ISBN-13)
  *
  * @param string  $isbnsubbody  ISBN-Subbody
  * @param integer $groupid      Registrationgroup
  * @param string  &$registrant  Registrant
  * @param string  &$publication Publication
  *
  * @return boolean  False if failed, true on success
  *
  * @access private
  */
 function _isbnSubbodyParts($isbnsubbody, $groupid, &$registrant, &$publication)
 {
     /* validate input (should not be needed, @access private) */
     $r = settype($isbnsubbody, 'string');
     if ($r === false) {
         return false;
     }
     $l = strlen($isbnsubbody);
     if ($l < 1 || $l > 8) {
         return false;
     }
     if (ctype_digit($isbnsubbody) === false) {
         return false;
     }
     $r = settype($groupid, 'integer');
     if ($r === false) {
         return false;
     }
     if ($groupid < 0 || $groupid > 99999) {
         return false;
     }
     /* extract registrant based on group and registrant range
      * parse this specific group format:
      *  array(
      *      'English speaking area',
      *      '00-09;10-19;200-699;7000-8499;85000-89999;' .
      *         '900000-949999;9500000-9999999'
      *      );
      */
     $group = ISBN::_getISBN10Group($groupid);
     if ($group === false) {
         return false;
     }
     $len = ISBN::_getRegistrantLength($isbnsubbody, $group[1]);
     if ($len === false) {
         return false;
     }
     $registrant = substr($isbnsubbody, 0, $len);
     $publication = substr($isbnsubbody, $len);
     return true;
 }