예제 #1
0
 /**
  * Find alternate editions of the item represented by the current record.
  *
  * @return mixed Array of information or null if no other editions found.
  * @access private
  */
 private function _getEditions()
 {
     $wc = new WorldCatUtils();
     // Try to build an array of ISBN or ISSN-based sub-queries:
     $query = '';
     if (!empty($this->isbn)) {
         $isbnList = $wc->getXISBN($this->isbn);
         if (!empty($isbnList)) {
             $query = 'srw.bn any "' . implode(' ', $isbnList) . '"';
         }
     } else {
         if ($issnField = $this->record->getField('022')) {
             if ($issnData = $issnField->getSubfield('a')) {
                 $issnList = $wc->getXISSN(trim($issnData->getData()));
                 if (!empty($issnList)) {
                     $query = 'srw.sn any "' . implode(' ', $issnList) . '"';
                 }
             }
         }
     }
     // If we have query parts, we should try to find related records:
     if (!empty($query)) {
         // Assemble the query parts and filter out current record:
         $query = '(' . $query . ') not srw.no all "' . $this->id . '"';
         // Perform the search and return either results or an error:
         $result = $this->worldcat->search($query, null, 1, 5, 'LibraryCount,,0');
         if (!PEAR::isError($result)) {
             return isset($result['record']) ? $result['record'] : null;
         } else {
             return $result;
         }
     }
     // If we got this far, we were unable to find any results:
     return null;
 }
예제 #2
0
 /**
  * Get an array of search results for other editions of the title
  * represented by this record (empty if unavailable).  In most cases,
  * this will use the XISSN/XISBN logic to find matches.
  *
  * @return mixed Editions in index engine result format (or null if no
  * hits, or PEAR_Error object).
  * @access public
  */
 public function getEditions()
 {
     include_once 'sys/WorldCatUtils.php';
     $wc = new WorldCatUtils();
     // Try to build an array of OCLC Number, ISBN or ISSN-based sub-queries:
     $parts = array();
     $oclcNum = $this->getCleanOCLCNum();
     if (!empty($oclcNum)) {
         $oclcList = $wc->getXOCLCNUM($oclcNum);
         foreach ($oclcList as $current) {
             $parts[] = "oclc_num:" . $current;
         }
     }
     $isbn = $this->getCleanISBN();
     if (!empty($isbn)) {
         $isbnList = $wc->getXISBN($isbn);
         foreach ($isbnList as $current) {
             $parts[] = 'isbn:' . $current;
         }
     }
     $issn = $this->getCleanISSN();
     if (!empty($issn)) {
         $issnList = $wc->getXISSN($issn);
         foreach ($issnList as $current) {
             $parts[] = 'issn:' . $current;
         }
     }
     // If we have query parts, we should try to find related records:
     if (!empty($parts)) {
         // Limit the number of parts based on the boolean clause limit:
         $index = $this->getIndexEngine();
         $limit = $index->getBooleanClauseLimit();
         if (count($parts) > $limit) {
             $parts = array_slice($parts, 0, $limit);
         }
         // Assemble the query parts and filter out current record:
         $query = '(' . implode(' OR ', $parts) . ') NOT id:"' . addcslashes($this->getUniqueID(), '"') . '"';
         // Perform the search and return either results or an error:
         $result = $index->search($query, null, null, 0, 5);
         if (PEAR::isError($result)) {
             return $result;
         }
         if (isset($result['response']['docs']) && !empty($result['response']['docs'])) {
             return $result['response']['docs'];
         }
     }
     // If we got this far, we were unable to find any results:
     return null;
 }
예제 #3
0
 /**
  * Get an array of search results for other editions of the title
  * represented by this record (empty if unavailable).  In most cases,
  * this will use the XISSN/XISBN logic to find matches.
  *
  * @access  public
  * @return  mixed               Editions in index engine result format.
  *                              (or null if no hits, or PEAR_Error object).
  */
 public function getEditions()
 {
     require_once ROOT_DIR . '/sys/WorldCatUtils.php';
     $wc = new WorldCatUtils();
     // Try to build an array of ISBN or ISSN-based sub-queries:
     $parts = array();
     $isbn = $this->getCleanISBN();
     if (!empty($isbn)) {
         $isbnList = $wc->getXISBN($isbn);
         foreach ($isbnList as $current) {
             $parts[] = 'isbn:' . $current;
         }
     } else {
         $issn = $this->getCleanISSN();
         if (!empty($issn)) {
             $issnList = $wc->getXISSN($issn);
             foreach ($issnList as $current) {
                 $parts[] = 'issn:' . $current;
             }
         }
     }
     // If we have query parts, we should try to find related records:
     if (!empty($parts)) {
         // Assemble the query parts and filter out current record:
         $query = '(' . implode(' OR ', $parts) . ') NOT id:' . $this->getUniqueID();
         // Perform the search and return either results or an error:
         $index = $this->getIndexEngine();
         $result = $index->search($query, null, null, 0, 5);
         if (PEAR_Singleton::isError($result)) {
             return $result;
         }
         if (isset($result['response']['docs']) && !empty($result['response']['docs'])) {
             return $result['response']['docs'];
         }
     }
     // If we got this far, we were unable to find any results:
     return null;
 }