コード例 #1
0
ファイル: Solr.php プロジェクト: victorfcm/VuFind-Plus
 /**
  * Turn our results into an RSS feed
  *
  * @access  public
  * @public  array      $result      Existing result set (null to do new search)
  * @return  string                  XML document
  */
 public function buildRSS($result = null)
 {
     global $configArray;
     // XML HTTP header
     header('Content-type: text/xml', true);
     // First, get the search results if none were provided
     // (we'll go for 50 at a time)
     if (is_null($result)) {
         $this->limit = 50;
         $result = $this->processSearch(false, false);
     }
     // Now prepare the serializer
     $serializer_options = array('addDecl' => TRUE, 'encoding' => 'UTF-8', 'indent' => '  ', 'rootName' => 'json', 'mode' => 'simplexml');
     $serializer = new XML_Serializer($serializer_options);
     $baseUrl = $configArray['Site']['url'];
     for ($i = 0; $i < count($result['response']['docs']); $i++) {
         //Since the base URL can be different depending on the record type, add the url to the response
         if (strcasecmp($result['response']['docs'][$i]['recordtype'], 'econtentRecord') == 0) {
             $id = str_replace('econtentRecord', '', $result['response']['docs'][$i]['id']);
             $result['response']['docs'][$i]['recordUrl'] = $baseUrl . '/EcontentRecord/' . $id;
         } else {
             if (strcasecmp($result['response']['docs'][$i]['recordtype'], 'grouped_work') == 0) {
                 $id = str_replace('econtentRecord', '', $result['response']['docs'][$i]['id']);
                 $result['response']['docs'][$i]['recordUrl'] = $baseUrl . '/GroupedWork/' . $id;
                 require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
                 $groupedWorkDriver = new GroupedWorkDriver($id);
                 $image = $groupedWorkDriver->getBookcoverUrl('medium');
                 $description = "<img src='{$image}'/> " . $groupedWorkDriver->getDescriptionFast();
                 $result['response']['docs'][$i]['description'] = $description;
             } else {
                 $id = $result['response']['docs'][$i]['id'];
                 $result['response']['docs'][$i]['recordUrl'] = $baseUrl . '/Record/' . $id;
             }
         }
     }
     // Serialize our results from PHP arrays to XML
     if ($serializer->serialize($result)) {
         $xmlResults = $serializer->getSerializedData();
     }
     // Prepare an XSLT processor and pass it some variables
     $xsl = new XSLTProcessor();
     $xsl->registerPHPFunctions('urlencode');
     $xsl->registerPHPFunctions('translate');
     // On-screen display value for our search
     if ($this->searchType == 'newitem') {
         $lookfor = translate('New Items');
     } else {
         if ($this->searchType == 'reserves') {
             $lookfor = translate('Course Reserves');
         } else {
             $lookfor = $this->displayQuery();
         }
     }
     if (count($this->filterList) > 0) {
         // TODO : better display of filters
         $xsl->setParameter('', 'lookfor', $lookfor . " (" . translate('with filters') . ")");
     } else {
         $xsl->setParameter('', 'lookfor', $lookfor);
     }
     // The full url to recreate this search
     $xsl->setParameter('', 'searchUrl', $this->renderSearchUrl());
     // Stub of a url for a records screen
     $xsl->setParameter('', 'baseUrl', $configArray['Site']['url'] . "/Record/");
     // Load up the style sheet
     $style = new DOMDocument();
     $style->load('services/Search/xsl/json-rss.xsl');
     $xsl->importStyleSheet($style);
     // Load up the XML document
     $xml = new DOMDocument();
     $xml->loadXML($xmlResults);
     // Process and return the xml through the style sheet
     try {
         $xmlResult = $xsl->transformToXML($xml);
         return $xmlResult;
     } catch (Exception $e) {
         global $logger;
         $logger->log("Error loading RSS feed {$e}", PEAR_LOG_ERR);
         return "";
     }
 }
コード例 #2
0
ファイル: AJAX.php プロジェクト: victorfcm/VuFind-Plus
 function reloadCover()
 {
     require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
     $id = $_REQUEST['id'];
     $recordDriver = new MarcRecord($id);
     //Reload small cover
     $smallCoverUrl = str_replace('&amp;', '&', $recordDriver->getBookcoverUrl('small')) . '&reload';
     file_get_contents($smallCoverUrl);
     //Reload medium cover
     $mediumCoverUrl = str_replace('&amp;', '&', $recordDriver->getBookcoverUrl('medium')) . '&reload';
     file_get_contents($mediumCoverUrl);
     //Reload large cover
     $largeCoverUrl = str_replace('&amp;', '&', $recordDriver->getBookcoverUrl('large')) . '&reload';
     file_get_contents($largeCoverUrl);
     //Also reload covers for the grouped work
     require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
     $groupedWorkDriver = new GroupedWorkDriver($recordDriver->getGroupedWorkId());
     global $configArray;
     //Reload small cover
     $smallCoverUrl = $configArray['Site']['coverUrl'] . str_replace('&amp;', '&', $groupedWorkDriver->getBookcoverUrl('small')) . '&reload';
     file_get_contents($smallCoverUrl);
     //Reload medium cover
     $mediumCoverUrl = $configArray['Site']['coverUrl'] . str_replace('&amp;', '&', $groupedWorkDriver->getBookcoverUrl('medium')) . '&reload';
     file_get_contents($mediumCoverUrl);
     //Reload large cover
     $largeCoverUrl = $configArray['Site']['coverUrl'] . str_replace('&amp;', '&', $groupedWorkDriver->getBookcoverUrl('large')) . '&reload';
     file_get_contents($largeCoverUrl);
     return $this->json_utf8_encode(array('success' => true, 'message' => 'Covers have been reloaded.  You may need to refresh the page to clear your local cache.'));
 }
コード例 #3
0
ファイル: AJAX.php プロジェクト: victorfcm/VuFind-Plus
 function reloadCover()
 {
     require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
     global $configArray;
     $id = $_REQUEST['id'];
     $recordDriver = new GroupedWorkDriver($id);
     //Reload small cover
     $smallCoverUrl = $configArray['Site']['coverUrl'] . $recordDriver->getBookcoverUrl('small') . '&reload';
     $ret = file_get_contents($smallCoverUrl);
     //Reload medium cover
     $mediumCoverUrl = $configArray['Site']['coverUrl'] . $recordDriver->getBookcoverUrl('medium') . '&reload';
     $ret = file_get_contents($mediumCoverUrl);
     //Reload large cover
     $largeCoverUrl = $configArray['Site']['coverUrl'] . $recordDriver->getBookcoverUrl('large') . '&reload';
     $ret = file_get_contents($largeCoverUrl);
     return json_encode(array('success' => true, 'message' => 'Covers have been reloaded.  You may need to refresh the page to clear your local cache.'));
 }
コード例 #4
0
ファイル: Novelist3.php プロジェクト: victorfcm/VuFind-Plus
 private function loadNoveListTitle($currentId, $item, &$titleList, &$titlesOwned, $seriesName = '')
 {
     global $user;
     global $timer;
     global $configArray;
     //Find the correct grouped work based on the isbns;
     require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php';
     require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifier.php';
     require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifierRef.php';
     $timer->logTime("Start loadNoveListTitle");
     /** @var SimpleXMLElement $titleItem */
     $permanentId = null;
     $concatenatedIsbns = "'" . implode("','", $item->isbns) . "'";
     $groupedWorkIdentifier = new GroupedWorkIdentifier();
     $groupedWorkIdentifier->type = "isbn";
     $groupedWorkIdentifier->whereAdd("identifier in ({$concatenatedIsbns})");
     if ($groupedWorkIdentifier->find()) {
         while ($groupedWorkIdentifier->fetch()) {
             $groupedWorkIdentifierRef = new GroupedWorkIdentifierRef();
             $groupedWorkIdentifierRef->identifier_id = $groupedWorkIdentifier->id;
             $groupedWorkIdentifierRef->find();
             if ($groupedWorkIdentifierRef->N == 1) {
                 $groupedWorkIdentifierRef->fetch();
                 $groupedWork = new GroupedWork();
                 $groupedWork->id = $groupedWorkIdentifierRef->grouped_work_id;
                 if ($groupedWork->find(true)) {
                     $permanentId = $groupedWork->permanent_id;
                     break;
                 }
             }
         }
     }
     $timer->logTime("Load Novelist Title - Find Grouped Work based on identifier {$permanentId}");
     $isCurrent = $currentId == $permanentId;
     if (isset($seriesName)) {
         $series = $seriesName;
     } else {
         $series = '';
     }
     $volume = '';
     if (isset($item->volume)) {
         $volume = $item->volume;
     }
     //We didn't find a match in the database so we don't own it
     if ($permanentId == null) {
         $isbn = reset($item->isbns);
         $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn);
         $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn);
         $curTitle = array('title' => $item->full_title, 'author' => $item->author, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume, 'reason' => isset($item->reason) ? $item->reason : '', 'smallCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=small&isn=" . $isbn13, 'mediumCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=medium&isn=" . $isbn13);
     } else {
         //Get more information from Solr
         /** @var GroupedWorkDriver $recordDriver */
         $recordDriver = new GroupedWorkDriver($permanentId);
         $timer->logTime("Find grouped work in solr");
         if ($recordDriver->isValid) {
             if (!isset($series)) {
                 if (isset($ownedRecord['series'])) {
                     $series = $ownedRecord['series'][0];
                 }
             }
             //Load data about the record
             $ratingData = $recordDriver->getRatingData($user);
             $timer->logTime("Get Rating data");
             $fullRecordLink = $recordDriver->getLinkUrl();
             //See if we can get the series title from the record
             $curTitle = array('title' => $recordDriver->getTitle(), 'title_short' => $recordDriver->getTitle(), 'author' => $recordDriver->getPrimaryAuthor(), 'isbn' => $recordDriver->getCleanISBN(), 'isbn10' => $recordDriver->getCleanISBN(), 'upc' => $recordDriver->getCleanUPC(), 'recordId' => $recordDriver->getPermanentId(), 'recordtype' => 'grouped_work', 'id' => $recordDriver->getPermanentId(), 'libraryOwned' => true, 'isCurrent' => $isCurrent, 'shortId' => $recordDriver->getPermanentId(), 'format_category' => $recordDriver->getFormatCategory(), 'series' => $series, 'volume' => $volume, 'ratingData' => $ratingData, 'fullRecordLink' => $fullRecordLink, 'reason' => isset($item->reason) ? $item->reason : '', 'recordDriver' => $recordDriver, 'smallCover' => $recordDriver->getBookcoverUrl('small'), 'mediumCover' => $recordDriver->getBookcoverUrl('medium'));
             $timer->logTime("Load title information");
             $titlesOwned++;
         } else {
             $isbn = reset($item->isbns);
             $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn);
             $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn);
             $curTitle = array('title' => $item->full_title, 'author' => $item->author, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume, 'reason' => isset($item->reason) ? $item->reason : '', 'smallCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=small&isn=" . $isbn13, 'mediumCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=medium&isn=" . $isbn13);
         }
     }
     $titleList[] = $curTitle;
     return $curTitle;
 }