コード例 #1
0
ファイル: MyRatings.php プロジェクト: victorfcm/VuFind-Plus
 public function launch()
 {
     global $interface;
     global $user;
     //Load user ratings
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserWorkReview.php';
     require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php';
     require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
     $rating = new UserWorkReview();
     $rating->userId = $user->id;
     $rating->find();
     $ratings = array();
     while ($rating->fetch()) {
         $groupedWorkDriver = new GroupedWorkDriver($rating->groupedRecordPermanentId);
         if ($groupedWorkDriver->isValid) {
             $ratings[] = array('id' => $rating->id, 'groupedWorkId' => $rating->groupedRecordPermanentId, 'title' => $groupedWorkDriver->getTitle(), 'author' => $groupedWorkDriver->getPrimaryAuthor(), 'rating' => $rating->rating, 'review' => $rating->review, 'link' => $groupedWorkDriver->getLinkUrl(), 'dateRated' => $rating->dateRated, 'ratingData' => $groupedWorkDriver->getRatingData());
         }
     }
     asort($ratings);
     //Load titles the user is not interested in
     $notInterested = array();
     require_once ROOT_DIR . '/sys/LocalEnrichment/NotInterested.php';
     $notInterestedObj = new NotInterested();
     $notInterestedObj->userId = $user->id;
     $notInterestedObj->find();
     while ($notInterestedObj->fetch()) {
         $groupedWorkId = $notInterestedObj->groupedRecordPermanentId;
         $groupedWorkDriver = new GroupedWorkDriver($groupedWorkId);
         if ($groupedWorkDriver->isValid) {
             $notInterested[] = array('id' => $notInterestedObj->id, 'title' => $groupedWorkDriver->getTitle(), 'author' => $groupedWorkDriver->getPrimaryAuthor(), 'dateMarked' => $notInterestedObj->dateMarked, 'link' => $groupedWorkDriver->getLinkUrl());
         }
     }
     $interface->assign('ratings', $ratings);
     $interface->assign('notInterested', $notInterested);
     $interface->assign('showNotInterested', false);
     $interface->setPageTitle('My Ratings');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('myRatings.tpl');
     $interface->display('layout.tpl');
 }
コード例 #2
0
 /**
  * Display a "cover unavailable" graphic and terminate execution.
  */
 function getDefaultCover()
 {
     $useDefaultNoCover = true;
     //Get the resource for the cover so we can load the title and author
     $title = '';
     $author = '';
     if ($this->type == 'grouped_work') {
         $this->loadGroupedWork();
         require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php';
         if ($this->groupedWork) {
             $title = ucwords($this->groupedWork->getTitle());
             $author = ucwords($this->groupedWork->getPrimaryAuthor());
             $this->category = 'blank';
         }
     } elseif ($this->isEContent) {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->id = $this->id;
         if ($econtentRecord->find(true)) {
             $title = $econtentRecord->title;
             $author = $econtentRecord->author;
         }
     } else {
         require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
         $recordDriver = new MarcRecord($this->id);
         if ($recordDriver->isValid()) {
             $title = $recordDriver->getTitle();
             $author = $recordDriver->getAuthor();
         }
     }
     require_once ROOT_DIR . '/sys/DefaultCoverImageBuilder.php';
     $coverBuilder = new DefaultCoverImageBuilder();
     if (strlen($title) > 0 && $coverBuilder->blankCoverExists($this->format, $this->category)) {
         $this->log("Looking for default cover, format is {$this->format} category is {$this->category}", PEAR_LOG_DEBUG);
         $coverBuilder->getCover($title, $author, $this->format, $this->category, $this->cacheFile);
         return $this->processImageURL($this->cacheFile);
     } else {
         $themeName = $this->configArray['Site']['theme'];
         $noCoverUrl = "interface/themes/default/images/noCover2.png";
         if (isset($this->format) && strlen($this->format) > 0) {
             if (is_readable("interface/themes/{$themeName}/images/{$this->format}_{$this->size}.png")) {
                 $this->log("Found format image {$this->format}_{$this->size} .", PEAR_LOG_INFO);
                 $noCoverUrl = "interface/themes/{$themeName}/images/{$this->format}_{$this->size}.png";
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/{$themeName}/images/{$this->format}.png")) {
                 $noCoverUrl = "interface/themes/{$themeName}/images/{$this->format}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/default/images/{$this->format}_{$this->size}.png")) {
                 $this->log("Found format image {$this->format}_{$this->size} .", PEAR_LOG_INFO);
                 $noCoverUrl = "interface/themes/default/images/{$this->format}_{$this->size}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/default/images/{$this->format}.png")) {
                 $noCoverUrl = "interface/themes/default/images/{$this->format}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             }
         }
         if ($useDefaultNoCover && isset($this->category) && strlen($this->category) > 0) {
             if (is_readable("interface/themes/{$themeName}/images/{$this->category}_{$this->size}.png")) {
                 $this->log("Found category image {$this->category}_{$this->size} .", PEAR_LOG_INFO);
                 $noCoverUrl = "interface/themes/{$themeName}/images/{$this->category}_{$this->size}.png";
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/{$themeName}/images/{$this->category}.png")) {
                 $noCoverUrl = "interface/themes/{$themeName}/images/{$this->category}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/default/images/{$this->category}_{$this->size}.png")) {
                 $this->log("Found category image {$this->category}_{$this->size} .", PEAR_LOG_INFO);
                 $noCoverUrl = "interface/themes/default/images/{$this->category}_{$this->size}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             } elseif (is_readable("interface/themes/default/images/{$this->category}.png")) {
                 $noCoverUrl = "interface/themes/default/images/{$this->category}.png";
                 header('Content-type: image/png');
                 $useDefaultNoCover = false;
             }
         }
         if ($useDefaultNoCover) {
             header('Content-type: image/png');
         }
         $ret = $this->processImageURL($noCoverUrl, true);
         //$ret = copy($nocoverurl, $this->cacheFile);
         if (!$ret) {
             $this->error = "Unable to copy file {$noCoverUrl} to {$this->cacheFile}";
             return false;
         } else {
             return true;
         }
     }
 }
コード例 #3
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;
 }