示例#1
0
 /**
  * @param \File_MARC_Subfield $field
  *
  * @return SubField
  */
 private function convertSubfield(\File_MARC_Subfield $field)
 {
     $code = $field->getCode();
     $data = $field->getData();
     return new SubField($code, $data);
 }
示例#2
0
 /**
  * Returns an id extracted from the identifier subfield passed in
  *
  * @param \File_MARC_Subfield $idField MARC field containing id information
  * @param string              $prefix  Prefix to search for in id field
  * @param bool                $raw     Return raw match, or normalize?
  *
  * @return string|bool                 ID on success, false on failure
  */
 protected function getIdFromLinkingField($idField, $prefix = null, $raw = false)
 {
     $text = $idField->getData();
     if (preg_match('/\\(([^)]+)\\)(.+)/', $text, $matches)) {
         // If prefix matches, return ID:
         if ($matches[1] == $prefix) {
             // Special case -- LCCN should not be stripped:
             return $raw ? $matches[2] : trim(str_replace(range('a', 'z'), '', $matches[2]));
         }
     } else {
         if ($prefix == null) {
             // If no prefix was given or found, we presume it is a raw bib record
             return $text;
         }
     }
     return false;
 }
示例#3
0
 /**
  * Prepends subfield to subfield list
  *
  * Adds a File_MARC_Subfield object to the  start of the existing list
  * of subfields.
  *
  * @param File_MARC_Subfield $new_subfield The subfield to add
  *
  * @return File_MARC_Subfield the new File_MARC_Subfield object
  */
 function prependSubfield(File_MARC_Subfield $new_subfield)
 {
     $pos = 0;
     $new_subfield->setPosition($pos);
     $this->subfields->shift($new_subfield);
     $node = null;
     $this->subfields->rewind();
     while ($node = $this->subfields->next()) {
         $pos++;
         $node->setPosition($pos);
     }
     return $new_subfield;
 }