Example #1
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;
 }