Ejemplo n.º 1
0
 protected function parseTitle()
 {
     // Gale title clean-up, because for some reason unknown to man they put weird
     // notes and junk at the end of the title. so remove them here and add them to notes.
     if (strstr($this->source, 'GALE_')) {
         $arrMatches = array();
         $strGaleRegExp = '/\\(([^)]*)\\)/';
         $title = $this->marc->datafield("245");
         $title_main = $title->subfield("a");
         $title_sub = $title->subfield("b");
         $note_field = new Marc\DataField();
         $note_field->tag = "500";
         if ($title_main != null) {
             if (preg_match_all($strGaleRegExp, $title_main->value, $arrMatches) != 0) {
                 $title_main->value = preg_replace($strGaleRegExp, "", $title_main->value);
             }
             foreach ($arrMatches[1] as $strMatch) {
                 $subfield = new Marc\Subfield();
                 $subfield->code = "a";
                 $subfield->value = "From title: " . $strMatch;
                 $note_field->addSubField($subfield);
             }
         }
         // sub title is only these wacky notes
         if ($title_sub != null) {
             $subfield = new Marc\Subfield();
             $subfield->code = "a";
             $subfield->value = "From title: " . $title_sub->value;
             $note_field->addSubField($subfield);
             $title_sub->value = "";
         }
         if ($note_field->subfield("a")->length() > 0) {
             $this->marc->addDataField($note_field);
         }
     }
     parent::parseTitle();
     // last chance, check the context object
     if ($this->title == "" && $this->context_object->getTitle() != null) {
         $this->title = $this->context_object->getTitle();
     }
 }