Esempio n. 1
0
 /**
  * Create a Metalib Record Link
  *
  * @param string|array $url		URL or array to construct link from metalib templates
  * @param string $type			[optional] type of link, or data from which to determine that
  * @param string $display		[optional] text to display
  */
 public function __construct($url, $type = null, $display = null)
 {
     // special metalib construct link
     if (is_array($url)) {
         // @todo: construct the link
     }
     parent::__construct($url, $type, $display);
 }
Esempio n. 2
0
 public function map()
 {
     // score
     $this->score = (string) $this->document->documentElement->getAttribute("RANK");
     // record data
     $record = $this->document->documentElement->getElementsByTagName("record")->item(0);
     // print $this->document->saveXML();
     $control = $this->getElement($record, "control");
     $display = $this->getElement($record, "display");
     $links = $this->getElement($record, "links");
     $search = $this->getElement($record, "search");
     $sort = $this->getElement($record, "sort");
     $addata = $this->getElement($record, "addata");
     $facets = $this->getElement($record, "facets");
     $sourceid = "";
     if ($control != null) {
         $sourceid = $this->getElementValue($control, "sourceid");
     }
     if ($display != null) {
         // database name
         $this->database_name = $this->getElementValue($display, "source");
         $this->database_name = strip_tags($this->database_name);
         // journal
         $this->journal = $this->getElementValue($display, "ispartof");
         // snippet
         $this->snippet = $this->getElementValue($display, "snippet");
         $this->snippet = strip_tags($this->snippet);
         // description
         $this->abstract = $this->getElementValue($display, "description");
         $this->abstract = strip_tags($this->abstract);
         // language
         $this->language = $this->getElementValue($display, "language");
         // peer reviewed
         $peer_reviewed = $this->getElementValue($display, 'lds50');
         if ($peer_reviewed == 'peer_reviewed') {
             $this->refereed = true;
         }
     }
     if ($search != null) {
         // record id
         $this->record_id = $this->getElementValue($search, "recordid");
         // year
         $this->year = $this->getElementValue($search, "creationdate");
         // issn
         $issn = $this->getElementValue($search, "issn");
         $issn = preg_replace('/\\D/', "", $issn);
         array_push($this->issns, $issn);
         // authors
         $authors = $this->getElementValues($search, "creatorcontrib");
         foreach ($authors as $author) {
             array_push($this->authors, new Xerxes\Record\Author($author, null, "personal"));
         }
         // format
         $format = $this->getElementValue($search, "rsrctype");
         $this->format()->setInternalFormat($format);
         // create a readable display
         $format_display = self::createReadableLabel($format);
         $this->format()->setPublicFormat($format_display);
     }
     // article data
     if ($addata != null) {
         $this->journal_title = $this->start_page = $this->getElementValue($addata, "jtitle");
         $this->volume = $this->getElementValue($addata, "volume");
         $this->issue = $this->getElementValue($addata, "issue");
         $this->start_page = $this->getElementValue($addata, "spage");
         $this->end_page = $this->getElementValue($addata, "epage");
         // primo's own ris type
         $ris_type = $this->getElementValue($addata, 'ristype');
         if ($ris_type != "") {
             $this->format()->setNormalizedFormat($ris_type);
         }
         // abstract
         $abstract = $this->getElementValue($addata, "abstract");
         if ($this->abstract == "") {
             $this->abstract = strip_tags($abstract);
         }
     }
     // subjects
     if ($facets != null) {
         $topics = $this->getElementValues($facets, "topic");
         foreach ($topics as $topic) {
             $subject_object = new Xerxes\Record\Subject();
             $subject_object->value = $topic;
             $subject_object->display = $topic;
             array_push($this->subjects, $subject_object);
         }
     }
     // title
     if ($sort != null) {
         $this->title = $this->getElementValue($sort, "title");
     }
     // direct link
     $backlink = $this->getElementValue($links, "backlink");
     if ($backlink != "") {
         $backlink = Parser::removeLeft($backlink, '$$U');
         $url = Parser::removeRight($backlink, '$$E');
         $message = Parser::removeLeft($backlink, '$$E');
         $link = new Link($url);
         $link->setType(Link::ONLINE);
         $this->links[] = $link;
     }
     // 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 (stristr($sourceid, "gale") || stristr($sourceid, "muse")) {
         $gale_regex = '/\\(([^)]*)\\)/';
         $matches = array();
         if (preg_match_all($gale_regex, $this->title, $matches) != 0) {
             $this->title = preg_replace($gale_regex, "", $this->title);
             foreach ($matches[1] as $match) {
                 array_push($this->notes, $match);
             }
         }
         if (strpos($this->abstract, 'the full-text of this article') !== false) {
             $this->abstract = Parser::removeLeft($this->abstract, 'Abstract:');
         }
     }
 }
Esempio n. 3
0
 /**
  * Create new Metalib Record
  * @param \Xerxes_MetalibRecord $record
  */
 public function __construct(\Xerxes_MetalibRecord $record)
 {
     parent::__construct();
     // inspect the metalib record
     $metalib_reflect = new \ReflectionClass($record);
     $metalib_properties = $metalib_reflect->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED);
     // take it's properties and convert them into updated x2 equivalent
     foreach ($metalib_properties as $metalib_prop) {
         $metalib_prop->setAccessible(true);
         $name = $metalib_prop->getName();
         $value = $metalib_prop->getValue($record);
         if ($value == "") {
             continue;
         }
         // objects
         if ($name == 'authors') {
             foreach ($value as $metalib_author) {
                 $author = new Xerxes\Record\Author();
                 $author->first_name = $metalib_author->first_name;
                 $author->last_name = $metalib_author->last_name;
                 $author->init = $metalib_author->init;
                 $author->name = $metalib_author->name;
                 $author->type = $metalib_author->type;
                 $author->additional = $metalib_author->additional;
                 $author->display = $metalib_author->display;
                 $this->authors[] = $author;
             }
         } elseif ($name == 'subjects') {
             if (!is_array($value)) {
                 $value = array($value);
             }
             foreach ($value as $metalib_subject) {
                 $subject = new Xerxes\Record\Subject();
                 $subject->display = $metalib_subject->display;
                 $subject->value = $metalib_subject->value;
             }
         } elseif ($name == 'format') {
             $this->format = new Xerxes\Record\Format();
             $this->format->determineFormat($value);
         } elseif ($name == 'links') {
             foreach ($value as $metalib_link_array) {
                 $display = $metalib_link_array[0];
                 $type = $metalib_link_array[2];
                 // url handling
                 $url = '?base=databases&action=proxy&database=' . $this->metalib_id;
                 // link template
                 if (is_array($metalib_link_array[1])) {
                     foreach ($metalib_link_array[1] as $key => $value) {
                         $url .= '&param=' . urlencode("{$key}={$value}");
                     }
                 } else {
                     $url .= '&url=' . urlencode($metalib_link_array[1]);
                 }
                 switch ($type) {
                     case 'original_record':
                         $type = Xerxes\Record\Link::ORIGINAL_RECORD;
                         break;
                     case 'pdf':
                         $type = Xerxes\Record\Link::PDF;
                         break;
                     case 'html':
                         $type = Xerxes\Record\Link::HTML;
                         break;
                     case 'none':
                         $type = Xerxes\Record\Link::INFORMATIONAL;
                         break;
                     case 'online':
                         $type = Xerxes\Record\Link::ONLINE;
                         break;
                 }
                 $link = new Xerxes\Record\Link($url);
                 $link->setDisplay($display);
                 $link->setType($type);
                 $this->links[] = $link;
             }
         } elseif ($name == 'toc') {
             if (!is_array($value)) {
                 $value = array($value);
             }
             foreach ($value as $metalib_toc) {
                 $toc = new Xerxes\Record\Chapter();
                 $toc->statement = $metalib_toc;
                 $this->toc;
             }
         } elseif ($name == 'journal_title_continues' || $name == 'journal_title_continued_by') {
             // ignore for now
         } elseif (property_exists($this, $name)) {
             $this->{$name} = $value;
         }
     }
 }
Esempio n. 4
0
 /**
  * Map the source data to record properties
  */
 protected function map($document)
 {
     // print_r($document); exit;
     $this->database_name = $this->extractValue($document, "Source/0");
     $this->record_id = $this->extractValue($document, "ID/0");
     $this->score = $this->extractValue($document, "Score/0");
     $this->open_url = $this->extractValue($document, "openUrl");
     // title
     $this->title = $this->extractValue($document, "Title/0");
     $this->sub_title = $this->extractValue($document, "Subtitle/0");
     // basic info
     $this->language = $this->extractValue($document, "Language/0");
     $this->extent = $this->extractValue($document, "PageCount/0");
     // date
     $this->year = (int) $this->extractValue($document, "PublicationDate_xml/0/year");
     $this->month = (int) $this->extractValue($document, "PublicationDate_xml/0/month");
     $this->day = (int) $this->extractValue($document, "PublicationDate_xml/0/day");
     // only use this if it has text in it
     $publication_date = $this->extractValue($document, "PublicationDate_xml/0/text");
     if (preg_match('/[a-zA-Z]{1}/', $publication_date)) {
         $this->publication_date = $publication_date;
     }
     // format
     $format = $this->extractValue($document, "ContentType/0");
     $this->format->setPublicFormat($format);
     $this->format->setInternalFormat($format);
     $this->format->setNormalizedFormat($this->normalizeFormat($format));
     // summary
     $this->snippet = $this->extractValue($document, "Snippet/0");
     $this->abstract = $this->extractValue($document, "Abstract/0");
     if (ord($this->abstract) == 194) {
         $this->abstract = substr($this->abstract, 2);
         // so strip it and the adjoining character
     }
     // books
     $this->edition = $this->extractValue($document, "Edition/0");
     $this->publisher = $this->toTitleCase($this->extractValue($document, "Publisher/0"));
     $this->place = $this->extractValue($document, "PublicationPlace_xml/0/name");
     // article
     $this->journal_title = $this->toTitleCase($this->extractValue($document, "PublicationTitle/0"));
     $this->issue = $this->extractValue($document, "Issue/0");
     $this->volume = $this->extractValue($document, "Volume/0");
     $this->start_page = $this->extractValue($document, "StartPage/0");
     $this->end_page = $this->extractValue($document, "EndPage/0");
     $this->doi = $this->extractValue($document, "DOI/0");
     // subscription
     $has_full_text = (int) $this->extractValue($document, 'hasFullText');
     $in_holdings = (int) $this->extractValue($document, 'inHoldings');
     if ($has_full_text == 1 && $in_holdings == 1) {
         $this->setSubscription(true);
     }
     // direct link
     if ($this->config()->getConfig('direct_linking', false, false)) {
         $direct_link = $this->extractValue($document, "link");
         $model = $this->extractValue($document, "LinkModel/0");
         if ($model == 'DirectLink') {
             $link = new Link($direct_link);
             if ($has_full_text == 1) {
                 $link->setType(Link::ONLINE);
             } else {
                 $link->setType(Link::ORIGINAL_RECORD);
             }
             $this->links[] = $link;
         }
     }
     // original record link
     $uri = $this->extractValue($document, "URI/0");
     if ($uri != '') {
         $this->links[] = new Link($uri, Link::ORIGINAL_RECORD);
     }
     // peer reviewed
     if ($this->extractValue($document, "IsPeerReviewed/0") == "true") {
         $this->refereed = true;
     }
     // subjects
     if (array_key_exists('SubjectTerms', $document)) {
         foreach ($document['SubjectTerms'] as $subject) {
             $subject = Parser::toSentenceCase($subject);
             $subject_object = new Xerxes\Record\Subject();
             $subject_object->display = $subject;
             $subject_object->value = $subject;
             array_push($this->subjects, $subject_object);
         }
     }
     // isbn
     if (array_key_exists('ISBN', $document)) {
         $this->isbns = $document['ISBN'];
     }
     // issn
     if (array_key_exists('ISSN', $document)) {
         $this->issns = $document['ISSN'];
     } elseif (array_key_exists('EISSN', $document)) {
         $this->issns = $document['EISSN'];
     }
     // notes
     if (array_key_exists('Notes', $document)) {
         $this->notes = $document['Notes'];
     }
     if (array_key_exists('Genre', $document)) {
         $this->notes = $document['Genre'];
     }
     // authors
     if (array_key_exists('Author_xml', $document)) {
         foreach ($document['Author_xml'] as $author) {
             $author_object = new Xerxes\Record\Author();
             if (array_key_exists('givenname', $author)) {
                 $author_object->type = "personal";
                 $author_object->last_name = $author['surname'];
                 $author_object->first_name = $author['givenname'];
             } elseif (array_key_exists('fullname', $author)) {
                 $author_object = new Xerxes\Record\Author($author['fullname'], null, 'personal');
             }
             array_push($this->authors, $author_object);
         }
     }
 }
Esempio n. 5
0
 /**
  * Parse full-text and informational links
  */
 protected function parseLinks()
 {
     // examine the 856s present in the record to see if they are in
     // fact to full-text, and not to a table of contents or something
     // stupid like that
     foreach ($this->marc->datafield("856") as $link) {
         $resource_type = $link->ind2;
         $part = (string) $link->subfield("3");
         $url = (string) $link->subfield("u");
         $host_name = (string) $link->subfield("a");
         $display = (string) $link->subfield("z");
         $link_format_type = (string) $link->subfield("q");
         $link_text = (string) $link->subfield("y");
         if ($display == "") {
             if ($link_text != "") {
                 $display = $link_text;
             } elseif ($host_name != "") {
                 $display = $host_name;
             }
         }
         if ($part != "") {
             $display = $part . " " . $display;
         }
         // no url supplied
         if ((string) $link->subfield("u") == "") {
             continue;
         }
         // link includes loc url (bad catalogers!)
         if (stristr($url, "catdir") || $resource_type == 2) {
             $this->links[] = new Link($url, Link::INFORMATIONAL);
         } else {
             $link_object = new Link($url, null, $display);
             // we check these a bit differently, since we don't want the presence of .html in the
             // URL alone to determine if the format is html, only if other subfields say so
             // but we will take .pdf in the link as indicating the file is PDF
             $link_html_check = $display . "" . $link_format_type . " " . $link_text;
             $link_pdf_check = $link_html_check . " " . $url;
             if ($link_object->extractType($link_pdf_check) == Link::PDF) {
                 $link_object->setType(Link::PDF);
             } elseif ($link_object->extractType($link_html_check) == Link::HTML) {
                 $link_object->setType(Link::HTML);
             } else {
                 $link_object->setType(Link::ONLINE);
             }
             $this->links[] = $link_object;
         }
     }
 }
Esempio n. 6
0
 /**
  * (non-PHPdoc)
  * @see \Xerxes\Record::map()
  */
 public function map()
 {
     $registry = Registry::getInstance();
     $xml = simplexml_load_string($this->document->saveXML());
     $control_info = $xml->header->controlInfo;
     $this->database_name = (string) $xml->header["longDbName"];
     $this->database_openurl = (string) $xml->header["longDbName"];
     $short_db_name = (string) $xml->header["shortDbName"];
     $book = $control_info->bkinfo;
     $journal = $control_info->jinfo;
     $publication = $control_info->pubinfo;
     $article = $control_info->artinfo;
     if (count($book) > 0) {
         // usually an editor
         if (count($book->aug) > 0) {
             if (count($book->aug->au) > 0) {
                 foreach ($book->aug->au as $auth) {
                     $author = new Xerxes\Record\Author((string) $auth, "", "personal");
                     if ((string) $auth["type"] == "editor") {
                         $this->editor = true;
                     }
                     array_push($this->authors, $author);
                 }
             }
         }
         // isbn
         if (count($book->isbn) > 0) {
             foreach ($book->isbn as $isbn) {
                 array_push($this->isbns, $isbn);
             }
         }
     }
     if (count($journal) > 0) {
         // journal title
         $this->journal_title = (string) $journal->jtl;
         // issn
         foreach ($journal->issn as $issn) {
             array_push($this->issns, $issn);
         }
     }
     if (count($publication) > 0) {
         // year
         $this->year = (string) $publication->dt["year"];
         // volume
         $this->volume = (string) $publication->vid;
         // issue
         $this->issue = (string) $publication->iid;
     }
     if (count($article) > 0) {
         // identifiers
         foreach ($article->ui as $ui) {
             $id_number = (string) $ui;
             if ((string) $ui["type"] == "doi") {
                 // doi
                 $this->doi = $id_number;
             } elseif ((string) $ui["type"] == "") {
                 // ebsco id
                 $this->record_id = $short_db_name . "-" . $id_number;
                 // eric doc number
                 if ($short_db_name == "eric" && substr($id_number, 0, 2) == "ED") {
                     $this->eric_number = $id_number;
                     $this->issns = array();
                 }
             }
         }
         // full-text
         if (count($article->formats->fmt) > 0) {
             foreach ($article->formats->fmt as $fmt) {
                 $link = '';
                 $type = '';
                 if ((string) $fmt["type"] == "T") {
                     $link = $xml->plink;
                     $type = Xerxes\Record\Link::HTML;
                 } elseif ((string) $fmt["type"] == "P") {
                     // pdf link is set only if there is both html and pdf full-text?
                     $link = $xml->pdfLink;
                     if ($link == "") {
                         $link = $xml->plink;
                     }
                     $type = Xerxes\Record\Link::PDF;
                 }
                 $link_obj = new Xerxes\Record\Link($link, $type);
                 $link_obj->addProxyPrefix($registry->getConfig('PROXY_SERVER', false));
                 $this->links[] = $link_obj;
             }
         }
         // start page
         $this->start_page = (string) $article->ppf;
         // extent
         $this->extent = (string) $article->ppct;
         // end page
         $pages = explode('-', (string) $article->pages);
         if (count($pages) > 1) {
             $this->end_page = $pages[1];
         }
         // title
         $this->title = (string) $article->tig->atl;
         // authors
         if (count($article->aug->au) > 0) {
             foreach ($article->aug->au as $auth) {
                 $author = new Xerxes\Record\Author((string) $auth, "", "personal");
                 array_push($this->authors, $author);
             }
         }
         // subjects
         foreach ($article->su as $subject) {
             $subject_object = new Xerxes\Record\Subject();
             $subject_object->value = (string) $subject;
             $subject_object->display = (string) $subject;
             array_push($this->subjects, $subject_object);
         }
         // abstract
         $this->abstract = (string) $article->ab;
         $this->summary = $this->abstract;
         // format
         $formats = array();
         foreach ($article->doctype as $doc_type) {
             array_push($formats, (string) $doc_type);
         }
         foreach ($article->pubtype as $pubtype) {
             array_push($formats, (string) $pubtype);
         }
         $this->notes = array_merge_recursive($this->notes, $formats);
         // format
         // @todo map this to internal
         $this->format->determineFormat($formats);
         if (count($formats) > 0) {
             $this->format->setPublicFormat($formats[0]);
         }
         // language
         $this->language = (string) $article->language;
     }
 }
Esempio n. 7
0
 /**
  * Map the source data to record properties
  * 
  * By default here it maps from the internal xml produced by toXML()
  */
 protected function map()
 {
     $xml = simplexml_load_string($this->document->saveXML());
     foreach ($xml->children() as $child) {
         $name = $child->getName();
         if ($name == 'standard_numbers') {
             foreach ($child->children() as $number) {
                 $this->addPropertyFromXML($number);
             }
         } elseif ($name == 'authors') {
             foreach ($child->children() as $author) {
                 $author_object = new Author();
                 $author_object->fromXML($author);
                 $this->authors[] = $author_object;
             }
         } elseif ($name == 'links') {
             foreach ($child->children() as $link) {
                 $link_object = new Link();
                 $link_object->fromXML($link);
                 $this->links[] = $link_object;
             }
         } elseif ($name == 'format') {
             $this->format->fromXML($child);
         } elseif ($name == 'subjects') {
             foreach ($child->children() as $subject) {
                 $subject_object = new Subject();
                 $subject_object->display = (string) $subject->display;
                 $subject_object->value = (string) $subject->value;
                 $this->subjects[] = $subject_object;
             }
         } elseif ($name == 'toc') {
             foreach ($child->children() as $chapter) {
                 $chapter_object = new Chapter();
                 $chapter_object->title = (string) $chapter->display;
                 $chapter_object->author = (string) $chapter->value;
                 $chapter_object->statement = (string) $chapter->value;
                 $this->toc[] = $chapter_object;
             }
         } else {
             $this->addPropertyFromXML($child);
         }
     }
 }