Ejemplo n.º 1
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;
         }
     }
 }
Ejemplo n.º 2
0
 public function getMyHolds($patron = null, $page = 1, $recordsPerPage = -1, $sortOption = 'title')
 {
     global $timer;
     $patronDump = $this->driver->_getPatronDump($this->driver->_getBarcode());
     //Load the information from millennium using CURL
     $sResult = $this->driver->_fetchPatronInfoPage($patronDump, 'holds');
     $timer->logTime("Got holds page from Millennium");
     $holds = $this->parseHoldsPage($sResult);
     $timer->logTime("Parsed Holds page");
     require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
     foreach ($holds as $section => $holdSections) {
         foreach ($holdSections as $key => $hold) {
             disableErrorHandler();
             $recordDriver = new MarcRecord($hold['recordId']);
             if ($recordDriver->isValid()) {
                 $hold['id'] = $recordDriver->getUniqueID();
                 $hold['shortId'] = $recordDriver->getShortId();
                 //Load title, author, and format information about the title
                 $hold['title'] = $recordDriver->getTitle();
                 $hold['sortTitle'] = $recordDriver->getSortableTitle();
                 $hold['author'] = $recordDriver->getAuthor();
                 $hold['format'] = $recordDriver->getFormat();
                 $hold['isbn'] = $recordDriver->getCleanISBN();
                 $hold['upc'] = $recordDriver->getCleanUPC();
                 $hold['format_category'] = $recordDriver->getFormatCategory();
                 //Load rating information
                 $hold['ratingData'] = $recordDriver->getRatingData();
                 $holds[$section][$key] = $hold;
             }
             enableErrorHandler();
         }
     }
     //Process sorting
     //echo ("<br/>\r\nSorting by $sortOption");
     foreach ($holds as $sectionName => $section) {
         $sortKeys = array();
         $i = 0;
         foreach ($section as $key => $hold) {
             $sortTitle = isset($hold['sortTitle']) ? $hold['sortTitle'] : (isset($hold['title']) ? $hold['title'] : "Unknown");
             if ($sectionName == 'available') {
                 $sortKeys[$key] = $sortTitle;
             } else {
                 if ($sortOption == 'title') {
                     $sortKeys[$key] = $sortTitle;
                 } elseif ($sortOption == 'author') {
                     $sortKeys[$key] = (isset($hold['author']) ? $hold['author'] : "Unknown") . '-' . $sortTitle;
                 } elseif ($sortOption == 'placed') {
                     $sortKeys[$key] = $hold['createTime'] . '-' . $sortTitle;
                 } elseif ($sortOption == 'format') {
                     $sortKeys[$key] = (isset($hold['format']) ? $hold['format'] : "Unknown") . '-' . $sortTitle;
                 } elseif ($sortOption == 'location') {
                     $sortKeys[$key] = (isset($hold['location']) ? $hold['location'] : "Unknown") . '-' . $sortTitle;
                 } elseif ($sortOption == 'holdQueueLength') {
                     $sortKeys[$key] = (isset($hold['holdQueueLength']) ? $hold['holdQueueLength'] : 0) . '-' . $sortTitle;
                 } elseif ($sortOption == 'position') {
                     $sortKeys[$key] = str_pad(isset($hold['position']) ? $hold['position'] : 1, 3, "0", STR_PAD_LEFT) . '-' . $sortTitle;
                 } elseif ($sortOption == 'status') {
                     $sortKeys[$key] = (isset($hold['status']) ? $hold['status'] : "Unknown") . '-' . (isset($hold['reactivateTime']) ? $hold['reactivateTime'] : "0") . '-' . $sortTitle;
                 } else {
                     $sortKeys[$key] = $sortTitle;
                 }
                 //echo ("<br/>\r\nSort Key for $key = {$sortKeys[$key]}");
             }
             $sortKeys[$key] = strtolower($sortKeys[$key] . '-' . $i++);
         }
         array_multisort($sortKeys, $section);
         $holds[$sectionName] = $section;
     }
     //Limit to a specific number of records
     if (isset($holds['unavailable'])) {
         $numUnavailableHolds = count($holds['unavailable']);
         if ($recordsPerPage != -1) {
             $startRecord = ($page - 1) * $recordsPerPage;
             $holds['unavailable'] = array_slice($holds['unavailable'], $startRecord, $recordsPerPage);
         }
     } else {
         $numUnavailableHolds = 0;
     }
     if (!isset($holds['available'])) {
         $holds['available'] = array();
     }
     if (!isset($holds['unavailable'])) {
         $holds['unavailable'] = array();
     }
     //Sort the hold sections so available holds are first.
     ksort($holds);
     $patronId = isset($patron) ? $patron['id'] : $this->driver->_getBarcode();
     $this->holds[$patronId] = $holds;
     $timer->logTime("Processed hold pagination and sorting");
     return array('holds' => $holds, 'numUnavailableHolds' => $numUnavailableHolds);
 }
Ejemplo n.º 3
0
 function getPurchaseOptions()
 {
     global $interface;
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $interface->assign('id', $id);
         $marcRecord = MarcLoader::loadMarcRecordByILSId($id);
         if ($marcRecord) {
             $linkFields = $marcRecord->getFields('856');
             $purchaseLinks = array();
             if ($linkFields) {
                 $field856Index = 0;
                 /** @var File_MARC_Data_Field[] $linkFields */
                 foreach ($linkFields as $marcField) {
                     $field856Index++;
                     //Get the link
                     if ($marcField->getSubfield('u')) {
                         $link = $marcField->getSubfield('u')->getData();
                         if ($marcField->getSubfield('3')) {
                             $linkText = $marcField->getSubfield('3')->getData();
                         } elseif ($marcField->getSubfield('y')) {
                             $linkText = $marcField->getSubfield('y')->getData();
                         } elseif ($marcField->getSubfield('z')) {
                             $linkText = $marcField->getSubfield('z')->getData();
                         } else {
                             $linkText = $link;
                         }
                         //Process some links differently so we can either hide them
                         //or show them in different areas of the catalog.
                         if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon\\.com/i', $link)) {
                             if (preg_match('/barnesandnoble/i', $link)) {
                                 $purchaseLinks[] = array('link' => $link, 'linkText' => 'Buy from Barnes & Noble', 'storeName' => 'Barnes & Noble', 'image' => '/images/barnes_and_noble.png', 'field856Index' => $field856Index);
                             } else {
                                 if (preg_match('/tatteredcover/i', $link)) {
                                     $purchaseLinks[] = array('link' => $link, 'linkText' => 'Buy from Tattered Cover', 'storeName' => 'Tattered Cover', 'image' => '/images/tattered_cover.png', 'field856Index' => $field856Index);
                                 } else {
                                     if (preg_match('/amazon\\.com/i', $link)) {
                                         $purchaseLinks[] = array('link' => $link, 'linkText' => 'Buy from Amazon', 'storeName' => 'Amazon', 'image' => '/images/amazon.png', 'field856Index' => $field856Index);
                                     } else {
                                         if (preg_match('/smashwords\\.com/i', $link)) {
                                             $purchaseLinks[] = array('link' => $link, 'linkText' => 'Buy from Smashwords', 'storeName' => 'Smashwords', 'image' => '/images/smashwords.png', 'field856Index' => $field856Index);
                                         } else {
                                             $purchaseLinks[] = array('link' => $link, 'linkText' => $linkText, 'storeName' => 'Smashwords', 'image' => '', 'field856Index' => $field856Index);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             //End checking for purchase information in the marc record
             if (count($purchaseLinks) > 0) {
                 $interface->assign('purchaseLinks', $purchaseLinks);
             } else {
                 require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
                 $recordDriver = new MarcRecord($id);
                 if ($recordDriver->isValid()) {
                     $title = $recordDriver->getTitle();
                     $author = $recordDriver->getAuthor();
                     require_once ROOT_DIR . '/services/Record/Purchase.php';
                     $purchaseLinks = Record_Purchase::getStoresForTitle($title, $author);
                     if (count($purchaseLinks) > 0) {
                         $interface->assign('purchaseLinks', $purchaseLinks);
                     } else {
                         $interface->assign('errors', array("Sorry we couldn't find any stores that offer this title."));
                     }
                 } else {
                     $interface->assign('errors', array("Sorry we couldn't find a resource for that id."));
                 }
             }
         } else {
             $errors = array("Could not load marc information for that id.");
             $interface->assign('errors', $errors);
         }
     } else {
         $errors = array("You must provide the id of the title to be purchased. ");
         $interface->assign('errors', $errors);
     }
     echo $interface->fetch('Record/ajax-purchase-options.tpl');
 }