Exemple #1
0
 public function map()
 {
     parent::map();
     // we assume that all records have items
     // ... unless told otherwise
     // here we've defined marc fields that contain the physical holdings
     // if the record doesn't have these, then it doesn't have items
     $config = Config::getInstance();
     $item_field = $config->getConfig("ITEM_FIELD", false);
     $item_query = $config->getConfig("ITEM_FIELD_QUERY", false);
     // simple field value
     if ($item_field != null) {
         $items = $this->datafield($item_field);
         // print_r($items);
         if ($items->length() == 0) {
             $this->physical_holdings = false;
         }
     } elseif ($item_query != null) {
         $items = $this->marc->xpath($item_query);
         // print_r($items);
         if ($items->length == 0) {
             $this->physical_holdings = false;
         }
     }
 }
Exemple #2
0
 public function map()
 {
     parent::map();
     $this->oclc_number = $this->control_number;
     // blank all links
     $this->links = array();
 }
Exemple #3
0
 /**
  * Map properties
  * 
  * Special handling here for metalib id's, openurl context object, and various metalib
  * data-munging hacks
  */
 public function map()
 {
     ## source database
     $sid = $this->marc->datafield("SID");
     $this->metalib_id = (string) $sid->subfield("d");
     $this->record_number = (string) $sid->subfield("j");
     $this->result_set = (string) $sid->subfield("s");
     $this->database_name = (string) $sid->subfield("t");
     $this->source = (string) $sid->subfield("b");
     // eric doc number
     $this->eric_number = (string) $this->marc->datafield("ERI")->subfield("a");
     ## metalib weirdness
     $leader = $this->marc->leader();
     // puts leader in control field
     $strLeaderMetalib = (string) $this->marc->controlfield("LDR");
     if ($strLeaderMetalib != "") {
         $leader->value = $strLeaderMetalib;
     }
     $demunge = array("1XX", "6XX");
     // character entity references de-munging code -- thanks a lot metalib!
     foreach ($demunge as $field) {
         $got_one = true;
         do {
             $authors = $this->marc->datafield($field);
             // variable is called 'authors' but this also now covers subjects
             $got_one = false;
             // whether we found any in the list
             for ($x = 0; $x < $authors->length(); $x++) {
                 $this_datafield = $authors->item($x);
                 $this_value = (string) $this_datafield->subfield();
                 // we found an un-terminated char entity ref
                 $matches = array();
                 if (preg_match('/\\&\\#\\d{3}$/', $this_value, $matches)) {
                     $got_one = true;
                     $new_value = "";
                     // grab the value out of the next field
                     $x++;
                     // hopefully we aren't at the end?
                     if ($x < $authors->length()) {
                         // nope, so grab the next field's value
                         $next_datafield = $authors->item($x);
                         $next_value = (string) $next_datafield->subfield();
                         // add back in the terminating semi-colon
                         $new_value = "{$this_value};{$next_value}";
                         // blank it so we don't re-process it
                         $next_datafield->tag = "XXX";
                     } else {
                         // yup, just add a terminating char to the value
                         $new_value = $this_value . ";";
                     }
                     // now create a new datafield composed of both old and new values
                     $fixed_datafield = new Marc\DataField();
                     $fixed_datafield->tag = $this_datafield->tag;
                     // we'll just assume this is |a
                     $fixed_subfield = new Marc\Subfield();
                     $fixed_subfield->code = "a";
                     $fixed_subfield->value = $new_value;
                     $fixed_datafield->addSubField($fixed_subfield);
                     // add it to the main record
                     $this->marc->addDataField($fixed_datafield);
                     // now blank the old ones
                     $this_datafield->tag = "XXX";
                 } else {
                     // we need to shift this to the end to keep field order in tact
                     // (critical for authors) so the above code works right
                     $new_field = clone $this_datafield;
                     $this->marc->addDataField($new_field);
                     $this_datafield->tag = "XXX";
                 }
             }
             // if we found one, cycle back again to see if our now-combined
             // field(s) *also* have un-terminated references since there may have
             // been more than one broken char reference for a single author, e.g.
         } while ($got_one == true);
     }
     // z3950/sutrs and some screen-scrapers have multiple authors in repeating 100 fields;
     // invalid marc, so switch all but first to 700
     $authors = $this->marc->datafield("100");
     if ($authors->length() > 1) {
         for ($x = 1; $x < $authors->length(); $x++) {
             $author = $authors->item($x);
             $author->tag = "700";
         }
     }
     // there are often multiple 773's, just combine them into one so we don't
     // have to iterate over all of them in other code
     $obj773 = new Marc\DataField();
     $obj773->tag = "773";
     foreach ($this->marc->datafield("773") as $linked_entry) {
         // add all of its subfields to the new one
         foreach ($linked_entry->subfield() as $linked_entry_subfield) {
             $obj773->addSubField($linked_entry_subfield);
         }
         // now blank this one to take it out of the mix
         $linked_entry->tag = "XXX";
     }
     // add our new one to the document
     $this->marc->addDataField($obj773);
     // psycinfo and related databases
     if (strstr($this->source, "EBSCO_PDH") || strstr($this->source, "EBSCO_PSYH") || strstr($this->source, "EBSCO_LOH")) {
         // includes a 502 that is not a thesis note -- bonkers!
         // need to make this a basic note, otherwise xerxes will assume this is a thesis
         foreach ($this->marc->datafield("502") as $thesis) {
             $thesis->tag = "500";
         }
     }
     ### context object
     $this->isbns = $this->context_object->getISBN();
     $this->issns = $this->context_object->getISSN();
     // now do a regular marc mapping, with exceptions below
     parent::map();
     ## oclc dissertation abstracts
     // (HACK) 10/1/2007 this assumes that the diss abs record includes the 904, which means
     // there needs to be a local search config that performs an 'add new' action rather than
     // the  'remove' action that the parser uses by default
     if (strstr($this->source, "OCLC_DABS")) {
         $this->degree = $this->marc->datafield("904")->subfield("j");
         $this->institution = $this->marc->datafield("904")->subfield("h");
         $this->journal_title = $this->marc->datafield("904")->subfield("c");
         $this->journal = $this->journal_title . " " . $this->journal;
         if ($this->journal_title == "MAI") {
             $format = "Thesis";
         } else {
             $format = "Dissertation";
         }
         $this->format = new Format();
         $this->format->setFormat($format);
     }
     ## ebsco 77X weirdness
     if (strstr($this->source, "EBSCO")) {
         // pages in $p (abbreviated title)
         $pages = (string) $this->datafield("773")->subfield('p');
         if ($pages != "") {
             $this->short_title = "";
         }
         // book chapter
         $btitle = (string) $this->datafield("771")->subfield('a');
         if ($btitle != "") {
             $this->book_title = $btitle;
             $this->format = "Book Chapter";
         }
     }
     ## JSTOR book review correction
     // title is meaningless, but subjects contain the title of the books,
     // so we'll swap them to the title here
     if (strstr($this->source, 'JSTOR') && $this->title == "Review") {
         $this->title = "";
         $this->sub_title = "";
         foreach ($this->subjects as $subject) {
             $this->title .= " " . $subject->value;
         }
         $this->title = trim($this->title);
         $this->subjects = null;
         $this->format = new Format();
         $this->format->setFormat("Book Review");
         // @todo: normalized?
     }
 }