Ejemplo n.º 1
0
 /**
  * Get all values for a tag
  *
  * @param string $tag XML tag to get
  *
  * @return array
  */
 protected function getValues($tag)
 {
     $values = [];
     foreach ($this->doc->{$tag} as $value) {
         $values[] = MetadataUtils::stripTrailingPunctuation((string) $value);
     }
     return $values;
 }
Ejemplo n.º 2
0
 /**
  * Get an array of all fields relevant to allfields search
  *
  * @return string[]
  */
 protected function getAllFields()
 {
     $subfieldFilter = ['650' => ['0' => 1, '2' => 1, '6' => 1, '8' => 1], '773' => ['0' => 1, '6' => 1, '7' => 1, '8' => 1, 'w' => 1], '856' => ['0' => 1, '6' => 1, '8' => 1, 'q' => 1], '979' => ['0' => 1, 'a' => 1, 'f' => 1]];
     $allFields = [];
     // Include ISBNs, also normalized if possible
     foreach ($this->getFields('020') as $field) {
         $isbns = $this->getSubfieldsArray($field, ['a' => 1, 'z' => 1]);
         foreach ($isbns as $isbn) {
             $allFields[] = $isbn;
             $isbn = MetadataUtils::normalizeISBN($isbn);
             if ($isbn) {
                 $allFields[] = $isbn;
             }
         }
     }
     foreach ($this->fields as $tag => $fields) {
         if ($tag >= 100 && $tag < 841 && $tag != 336 && $tag != 337 || $tag == 856 || $tag == 880 || $tag == 979) {
             foreach ($fields as $field) {
                 $subfields = $this->getAllSubfields($field, isset($subfieldFilter[$tag]) ? $subfieldFilter[$tag] : ['0' => 1, '6' => 1, '8' => 1]);
                 if ($subfields) {
                     $allFields = array_merge($allFields, $subfields);
                 }
             }
         }
     }
     $allFields = array_map(function ($str) {
         return MetadataUtils::stripLeadingPunctuation(MetadataUtils::stripTrailingPunctuation($str));
     }, $allFields);
     return array_values(array_unique($allFields));
 }
Ejemplo n.º 3
0
 /**
  * Get an array of all fields relevant to allfields search
  *
  * @return string[]
  */
 protected function getAllFields()
 {
     $subfieldFilter = ['650' => ['2' => 1, '6' => 1, '8' => 1], '773' => ['6' => 1, '7' => 1, '8' => 1, 'w' => 1], '856' => ['6' => 1, '8' => 1, 'q' => 1]];
     $allFields = [];
     foreach ($this->fields as $tag => $fields) {
         if ($tag >= 100 && $tag < 841 || $tag == 856 || $tag == 880) {
             foreach ($fields as $field) {
                 $subfields = $this->getAllSubfields($field, isset($subfieldFilter[$tag]) ? $subfieldFilter[$tag] : ['6' => 1, '8' => 1]);
                 if ($subfields) {
                     $allFields = array_merge($allFields, $subfields);
                 }
             }
         }
     }
     $allFields = array_map(function ($str) {
         return MetadataUtils::stripLeadingPunctuation(MetadataUtils::stripTrailingPunctuation($str));
     }, $allFields);
     return array_values(array_unique($allFields));
 }
Ejemplo n.º 4
0
 /**
  * Dedup: Return record title
  *
  * @param bool $forFiling Whether the title is to be used in filing
  * (e.g. sorting, non-filing characters should be removed)
  *
  * @return string
  */
 public function getTitle($forFiling = false)
 {
     $title = trim((string) $this->doc->title);
     $title = MetadataUtils::stripTrailingPunctuation($title);
     if ($forFiling) {
         $title = MetadataUtils::stripLeadingPunctuation($title);
         $title = MetadataUtils::stripLeadingArticle($title);
         // Again, just in case stripping the article affected this
         $title = MetadataUtils::stripLeadingPunctuation($title);
         $title = mb_strtolower($title, 'UTF-8');
     }
     return $title;
 }