public function __construct(Record $record, Config $config) { $xerxes_record = $record->xerxes_record; // old metalib record from xerxes 1 if ($xerxes_record instanceof \Xerxes_MetalibRecord) { $xerxes_record = new Metalib\Record($xerxes_record); // convert it x2 record } elseif ($xerxes_record instanceof \Xerxes_TransRecord) { try { $xerxes_record = $xerxes_record->record(); // extract the x2 record } catch (\Exception $e) { trigger_error('Xerxes Error (' . $e->getLine() . '): ' . $e->getMessage()); } } // record has been corrupted @todo fix this problem if (!$xerxes_record instanceof Xerxes\Record) { $this->corrupted = true; // mark it as such // make a new record with the data we have on hand in the other // saved_records fields $xerxes_record = new Xerxes\Record(); $title = $record->title; if ($record->nonsort != "") { $title = $record->nonsort . ' ' . $title; } $author = new Author($record->author, null, Author::PERSONAL); $format = new \Xerxes\Record\Format(); $format->setFormat($record->format); $properties = array('title' => $title, 'format' => $format, 'authors' => array($author), 'year' => $record->year); $xerxes_record->setProperties($properties); } parent::__construct($xerxes_record, $config); }
public function getMediumMap($group, $keys) { $map = array(); $format = new Format(); foreach ($keys as $key) { $map[$key] = $format->getConstNameForValue($key); } return $map; }
protected function parseFormat() { $format_object = new Format(); // metalib usually maps format info from database to this field $format_array = $this->marc->fieldArray("513", "a"); // isbd media and format notes $strTitleFormat = $this->datafield("245")->subfield("hk")->__toString(); if ($strTitleFormat != null) { array_push($format_array, $strTitleFormat); } // context object array_push($format_array, $this->context_object->format()->getPublicFormat()); // @todo switch to normalized? ## ebsco format if (strstr($this->source, "EBSCO")) { // leader appears to be hard-wired; useless $this->marc->leader()->value = ""; // format array_push($format_array, (string) $this->marc->datafield("656")->subfield("a")); array_push($format_array, (string) $this->marc->datafield("514")->subfield("a")); $strEbscoType = (string) $this->marc->datafield("072")->subfield("a"); if (strstr($this->source, "EBSCO_PSY") || strstr($this->source, "EBSCO_PDH")) { $strEbscoType = ""; } array_push($format_array, $strEbscoType); // ebsco book chapter $strEbscoBookTitle = (string) $this->marc->datafield("771")->subfield("a"); if ($strEbscoBookTitle != "") { array_push($format_array, "Book Chapter"); } } // format made explicit from metalib $format = $format_object->extractFormat($format_array); // nothing good found, so get it from the basic marc parsing if ($format == Format::Unknown) { $format = $this->convertToNormalizedFormat(); } // explicit format related changes if ((string) $this->marc->controlfield("002") == "DS") { $format = "Thesis"; } elseif (strstr($this->source, 'ERIC') && strstr($this->eric_number, 'ED') && !stristr($this->title, "proceeding")) { $format = "Report"; } elseif (strstr($this->source, 'ERIC') && !strstr($this->eric_number, 'ED')) { $format = "Article"; } elseif (strstr($this->source, 'OCLC_PAPERS')) { $format = "Conference Paper"; } elseif (strstr($this->source, 'PCF1')) { $format = "Conference Proceeding"; } elseif (stristr($this->source, "GOOGLE_B")) { $format = "Book"; } elseif (strstr($this->source, "EBSCO_LOH")) { $format = "Tests & Measures"; } elseif (strstr($this->source, "OXFORD_MUSIC_ONLINE")) { $format = "Article"; } elseif (strstr($this->source, "ESPACENET")) { $format = "Patent"; } elseif (strstr($this->source, "WIPO_PCT")) { $format = "Patent"; } elseif (strstr($this->source, "USPA")) { $format = "Patent"; } elseif (strstr($this->source, "DEPATIS")) { $format = "Patent"; } elseif (strstr($this->source, "DART")) { $format = "Thesis"; } elseif (strstr($this->source, "DDI")) { $format = "Thesis"; } elseif (strstr($this->source, "ETHOS")) { $format = "Thesis"; } elseif (strstr($this->source, "DIVA_EXTR")) { $format = "Thesis"; } elseif (strstr($this->source, "UNION_NDLTD")) { $format = "Thesis"; } // set it $this->format->setFormat($format); }
/** * Add labels to ResultSet * * Primarily for formats, facets, and other 'data'-based labels * * @param ResultSet $results */ public function addResultsLabels(ResultSet &$results) { // format in record foreach ($results->getRecords() as $result) { $format = $result->getXerxesRecord()->format(); $label_id = $format->getLabel(); $label = $this->labels->getLabel($label_id); if ($label != $label_id) { $format->setPublicFormat($label); } } // facets foreach ($results->getFacets()->getGroups() as $group) { $label_group_name = $this->config->getFacetAttribute($group->name, 'label'); if ($label_group_name == "") { $label_group_name = $this->config->getFacetAttribute($group->name, 'public'); } $group->public = $this->labels->getLabel($label_group_name); // format values in facets foreach ($group->getFacets() as $facet) { $facet->display = $facet->name; $label_id = Format::createLabelIdentifier($facet->name); $label = $this->labels->getLabel($label_id); if ($label != $label_id) { $facet->display = $label; } } } }
/** * Returns the object's properties that correspond to the OpenURL standard * as an easy to use associative array * * @return array */ private function referantArray() { $arrReferant = array(); $strTitle = ""; ### simple values $arrReferant["rft.genre"] = $this->format->toOpenURLGenre(); switch ($arrReferant["rft.genre"]) { case "dissertation": $arrReferant["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:dissertation"; break; case "book": case "bookitem": case "conference": case "proceeding": case "report": case "document": $arrReferant["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:book"; break; case "journal": case "issue": case "article": case "proceeding": case "conference": case "preprint": case "unknown": $arrReferant["rft_val_fmt"] = "info:ofi/fmt:kev:mtx:journal"; break; } if (count($this->isbns) > 0) { $arrReferant["rft.isbn"] = $this->isbns[0]; } if (count($this->issns) > 0) { $arrReferant["rft.issn"] = $this->issns[0]; } // rft.ed_number not an actual openurl 1.0 standard element, // but sfx recognizes it. But only add if the eric type // is ED, adding an EJ or other as an ED just confuses SFX. if ($this->eric_number) { $strEricType = substr($this->eric_number, 0, 2); if ($strEricType == "ED") { $arrReferant["rft.ed_number"] = $this->eric_number; } } $arrReferant["rft.series"] = $this->series_title; $arrReferant["rft.place"] = $this->place; $arrReferant["rft.pub"] = $this->publisher; $arrReferant["rft.edition"] = $this->edition; $arrReferant["rft.tpages"] = $this->extent; $arrReferant["rft.jtitle"] = $this->journal_title; $arrReferant["rft.stitle"] = $this->short_title; $arrReferant["rft.volume"] = $this->volume; $arrReferant["rft.issue"] = $this->issue; $arrReferant["rft.spage"] = $this->start_page; $arrReferant["rft.epage"] = $this->end_page; $arrReferant["rft.degree"] = $this->degree; $arrReferant["rft.inst"] = $this->institution; // date $arrReferant["rft.date"] = $this->year; // $this->getPublicationDate('Y-m-d'); ### title if ($this->non_sort != "") { $strTitle = $this->non_sort . " "; } if ($this->title != "") { $strTitle .= $this->title . " "; } if ($this->sub_title != "") { $strTitle .= ": " . $this->sub_title . " "; } // map title to appropriate element based on genre if ($arrReferant["rft.genre"] == "book" || $arrReferant["rft.genre"] == "conference" || $arrReferant["rft.genre"] == "proceeding" || $arrReferant["rft.genre"] == "report") { $arrReferant["rft.btitle"] = $strTitle; } elseif ($arrReferant["rft.genre"] == "bookitem") { $arrReferant["rft.atitle"] = $strTitle; $arrReferant["rft.btitle"] = $this->book_title; } elseif ($arrReferant["rft.genre"] == "dissertation") { $arrReferant["rft.title"] = $strTitle; // since this is sometimes divined from diss abs, we'll drop all // the journal stuff that is still in the openurl but messes up sfx $arrReferant["rft.jtitle"] = null; $arrReferant["rft.issn"] = null; $arrReferant["rft.volume"] = null; $arrReferant["rft.issue"] = null; $arrReferant["rft.spage"] = null; $arrReferant["rft.epage"] = null; } elseif ($arrReferant["rft.genre"] == "journal") { $arrReferant["rft.title"] = $strTitle; // remove these elements from a journal, since they produce // some erroneous info, especially date! $arrReferant["rft.date"] = null; $arrReferant["rft.pub"] = null; $arrReferant["rft.place"] = null; } else { $arrReferant["rft.atitle"] = $strTitle; } return $arrReferant; }