Ejemplo n.º 1
0
 function search($isbnList)
 {
     $bl = new BulkLookupQuery();
     if (!is_array($isbnList)) {
         return false;
     }
     foreach ($isbnList as $one) {
         // Check existing ISBN.
         $existBibid = $bl->getExistBiblio($one['isbn']);
         if ($existBibid > 0) {
             for ($i = 0; $i < $one['amount']; $i++) {
                 $bl->addCopy($existBibid);
             }
             $bl->setLookupStatus('copy', $one['isbn']);
             continue;
         }
         $list = $this->_getLookupServers();
         $retry = false;
         if (!is_array($list) || count($list) < 1) {
             $bl->setLookupStatus('manual', $one['isbn'], $one['amount']);
         }
         foreach ($list as $server) {
             $result = $this->_getLookupResult($server, $one['isbn']);
             if (!$result || isset($result['error'])) {
                 if (preg_match('/not connect/', $result['error']) || preg_match('/response error/', $result['error'])) {
                     $retry = true;
                 }
                 continue;
             }
             $book = array('isbn' => $one['isbn'], 'data' => $result, 'amount' => $one['amount']);
             $this->_addResult($book);
             break;
         }
         if (isset($result['error'])) {
             $book = array('isbn' => $one['isbn'], 'data' => NULL);
             $this->_addResult($book);
             if ($retry) {
                 $bl->setLookupStatus('retry', $one['isbn']);
             } else {
                 $bl->setLookupStatus('manual', $one['isbn'], $one['amount']);
             }
         }
     }
     $bl->saveResults($this->_results);
 }
Ejemplo n.º 2
0
 function import($row)
 {
     require_once "../classes/BulkLookup.php";
     $bl = new BulkLookupQuery();
     if (!isset($row['020a'], $row['100a'], $row['245a'])) {
         return false;
     }
     $isbn = $this->verifyISBN($row['020a']);
     $existBibid = $this->getExistBiblio($isbn);
     if ($existBibid > 0) {
         $bl->addCopy($existBibid);
         return 'copy';
     }
     $this->_formatResults($row);
     $bib = $this->_getBiblio($row);
     $insert_bib[$isbn]['bibid'] = 0 + $this->_insertBiblio($bib);
     if ($insert_bib[$isbn]['bibid'] > 0) {
         $this->addCopy($insert_bib[$isbn]['bibid']);
         return 'done';
     } else {
         return false;
     }
 }