コード例 #1
0
ファイル: ISBNTest.php プロジェクト: bryandease/VuFind-Plus
 /**
  * Test citation generation
  *
  * @return void
  * @access public
  */
 public function testISBNs()
 {
     // Valid ISBN-10:
     $isbn = new ISBN('0123456789');
     $this->assertEquals($isbn->get10(), '0123456789');
     $this->assertEquals($isbn->get13(), '9780123456786');
     $this->assertTrue($isbn->isValid());
     // Valid ISBN-13:
     $isbn = new ISBN('9780123456786');
     $this->assertEquals($isbn->get10(), '0123456789');
     $this->assertEquals($isbn->get13(), '9780123456786');
     $this->assertTrue($isbn->isValid());
     // Valid ISBN-10 with dashes:
     $isbn = new ISBN('0-12-345678-9');
     $this->assertEquals($isbn->get10(), '0123456789');
     $this->assertEquals($isbn->get13(), '9780123456786');
     $this->assertTrue($isbn->isValid());
     // Valid ISBN-13 with dashes:
     $isbn = new ISBN('978-0-12-345678-6');
     $this->assertEquals($isbn->get10(), '0123456789');
     $this->assertEquals($isbn->get13(), '9780123456786');
     $this->assertTrue($isbn->isValid());
     // Valid ISBN-13 outside of Bookland EAN:
     $isbn = new ISBN('9790123456785');
     $this->assertEquals($isbn->get10(), false);
     $this->assertEquals($isbn->get13(), '9790123456785');
     $this->assertTrue($isbn->isValid());
     // Invalid ISBN-10:
     $isbn = new ISBN('2314346323');
     $this->assertEquals($isbn->get10(), false);
     $this->assertEquals($isbn->get13(), false);
     $this->assertFalse($isbn->isValid());
 }
コード例 #2
0
function smarty_modifier_formatISBN($isbn)
{
    // @codingStandardsIgnoreEnd
    // Normalize ISBN to an array if it is not already.
    $isbns = is_array($isbn) ? $isbn : array($isbn);
    // Loop through the ISBNs, trying to find an ISBN-10 if possible, and returning
    // the first ISBN-13 encountered as a last resort:
    $isbn13 = false;
    foreach ($isbns as $isbn) {
        // Strip off any unwanted notes:
        if ($pos = strpos($isbn, ' ')) {
            $isbn = substr($isbn, 0, $pos);
        }
        // If we find an ISBN-10, return it immediately; otherwise, if we find
        // an ISBN-13, save it if it is the first one encountered.
        $isbnObj = new ISBN($isbn);
        if ($isbn10 = $isbnObj->get10()) {
            return $isbn10;
        }
        if (!$isbn13) {
            $isbn13 = $isbnObj->get13();
        }
    }
    return $isbn13;
}
コード例 #3
0
ファイル: site_plugin.php プロジェクト: horrabin/opendb
function get_isbn_code($field)
{
    $ISBN = new ISBN();
    $field = strtoupper($field);
    $isbntype = $ISBN->gettype($field);
    if ($isbntype == 10 && $ISBN->validateten($field) || $isbntype == 13 && $ISBN->validatettn($field)) {
        return $field;
    }
    return FALSE;
}
コード例 #4
0
ファイル: TFISBN.php プロジェクト: Tenifre/CommonUtilities
 public static function convertISBN($isbn)
 {
     $converted = "";
     switch (strlen($isbn)) {
         case 13:
             $converted = ISBN::convertISBNToTenDigit($isbn);
             break;
         case 10:
             $converted = ISBN::convertISBNToThirtyDigit($isbn);
             break;
         default:
             throw new Exception('ISBNは10桁または13桁で指定してください');
             break;
     }
     return $converted;
 }
コード例 #5
0
ファイル: ISBNTest.class.php プロジェクト: Gamepay/xp-contrib
 public function verifyInvalidChecksum()
 {
     $this->assertFalse(ISBN::isValid('0-8436-1072-3'));
 }
コード例 #6
0
ファイル: bookcover.php プロジェクト: BSZBW/ldu
/**
 * Retrieve a Buchhandel cover.
 *
 * @return bool      True if image displayed, false otherwise.
 */
function buchhandel()
{
    global $configArray;
    global $logger;
    // convert normalized 10 char isn to 13 digits
    $isn = $_GET['isn'];
    //$logger->log("isn: " . $isn,  PEAR_LOG_DEBUG);
    if (strlen($isn) != 13) {
        $ISBN = new ISBN($isn);
        //$logger->log("ISBN: " . print_r($ISBN,1),  PEAR_LOG_DEBUG);
        $isn = $ISBN->get13();
    }
    //$logger->log("isn: " . $isn,  PEAR_LOG_DEBUG);
    // Convert internal size value to openlibrary equivalent:
    switch ($_GET['size']) {
        case 'large':
            $size = 'L';
            break;
        case 'medium':
            $size = 'M';
            break;
        case 'small':
        default:
            $size = 'S';
            break;
    }
    $url = isset($configArray['buchhandel']['url']) ? $configArray['buchhandel']['url'] : 'http://vlb.de';
    $url .= "/GetBlob.aspx?strIsbn=" . $isn . "&size=" . $size;
    //$logger->log("Buchhandel URL: ". print_r($url,1),  PEAR_LOG_DEBUG);
    return processImageURL($url, true, 'BH');
}
コード例 #7
0
ファイル: Base.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Checks if passed string is an ISBN and converts to ISBN 13
  *
  * @param string $lookfor The query string
  *
  * @return valid ISBN 13 or false
  * @access protected
  */
 protected function normalizeIfValidISBN($lookfor = false)
 {
     if (!$lookfor) {
         return false;
     }
     if (ISBN::isValidISBN10($lookfor) || ISBN::isValidISBN13($lookfor)) {
         $isbn = new ISBN($lookfor);
         return $isbn->get13();
     }
     return false;
 }
コード例 #8
0
ファイル: Solr.php プロジェクト: bryandease/VuFind-Plus
 /**
  * Get records similar to one record
  * Uses MoreLikeThis Request Handler
  *
  * Uses SOLR MLT Query Handler
  *
  * @access	public
  * @var     string  $id             The id to retrieve similar titles for
  * @var     array   $originalResult The original record we are getting similar titles for.
  * @throws	object						PEAR Error
  * @return	array							An array of query results
  *
  */
 function getMoreLikeThis2($id, $originalResult = null)
 {
     if ($originalResult == null) {
         $originalResult = $this->getRecord($id);
     }
     // Query String Parameters
     $options = array('q' => "id:{$id}", 'qt' => 'morelikethis2', 'mlt.interestingTerms' => 'details', 'rows' => 25);
     if ($originalResult) {
         $options['fq'] = array();
         if (isset($originalResult['target_audience_full'])) {
             $options['fq'][] = 'target_audience_full:"' . $originalResult['target_audience_full'] . '"';
         }
         if (isset($originalResult['literary_form'])) {
             $options['fq'][] = 'literary_form:"' . $originalResult['literary_form'] . '"';
         }
         if (isset($originalResult['language'])) {
             $options['fq'][] = 'language:"' . $originalResult['language'][0] . '"';
         }
         //Don't want to get other editions of the same work (that's a different query)
         if (isset($originalResult['isbn'])) {
             if (is_array($originalResult['isbn'])) {
                 foreach ($originalResult['isbn'] as $isbn) {
                     $options['fq'][] = '-isbn:' . ISBN::normalizeISBN($isbn);
                 }
             } else {
                 $options['fq'][] = '-isbn:' . ISBN::normalizeISBN($originalResult['isbn']);
             }
         }
         if (isset($originalResult['upc'])) {
             if (is_array($originalResult['upc'])) {
                 foreach ($originalResult['upc'] as $upc) {
                     $options['fq'][] = '-upc:' . ISBN::normalizeISBN($upc);
                 }
             } else {
                 $options['fq'][] = '-upc:' . ISBN::normalizeISBN($originalResult['upc']);
             }
         }
     }
     $searchLibrary = Library::getSearchLibrary();
     $searchLocation = Location::getSearchLocation();
     $scopingFilters = $this->getScopingFilters($searchLibrary, $searchLocation);
     foreach ($scopingFilters as $filter) {
         $options['fq'][] = $filter;
     }
     $boostFactors = $this->getBoostFactors($searchLibrary, $searchLocation);
     $options['bf'] = $boostFactors;
     if (!empty($this->_solrShards) && is_array($this->_solrShards)) {
         $options['shards'] = implode(',', $this->_solrShards);
     }
     $result = $this->_select('GET', $options);
     if (PEAR_Singleton::isError($result)) {
         PEAR_Singleton::raiseError($result);
     }
     return $result;
 }
コード例 #9
0
ファイル: bookcover.php プロジェクト: bharatm/NDL-VuFind
/**
 * Retrieve a Summon cover.
 *
 * @param string $id Serials Solutions client key.
 *
 * @return bool      True if image displayed, false otherwise.
 */
function summon($id)
{
    global $configArray;
    // convert normalized 10 char isn to 13 digits
    $isn = $_GET['isn'];
    if (strlen($isn) != 13) {
        $ISBN = new ISBN($isn);
        $isn = $ISBN->get13();
    }
    $url = 'http://api.summon.serialssolutions.com/image/isbn/' . $id . '/' . $isn . '/' . $_GET['size'];
    return processImageURL($url);
}
コード例 #10
0
ファイル: IndexRecord.php プロジェクト: victorfcm/VuFind-Plus
 public function getCleanISBNs()
 {
     require_once ROOT_DIR . '/sys/ISBN.php';
     $cleanIsbns = array();
     // Get all the ISBNs and initialize the return value:
     $isbns = $this->getISBNs();
     // Loop through the ISBNs:
     foreach ($isbns as $isbn) {
         // Strip off any unwanted notes:
         if ($pos = strpos($isbn, ' ')) {
             $isbn = substr($isbn, 0, $pos);
         }
         // If we find an ISBN-10, return it immediately; otherwise, if we find
         // an ISBN-13, save it if it is the first one encountered.
         $isbnObj = new ISBN($isbn);
         if ($isbn10 = $isbnObj->get10()) {
             if (!array_key_exists($isbn10, $cleanIsbns)) {
                 $cleanIsbns[$isbn10] = $isbn10;
             }
         }
         $isbn13 = $isbnObj->get13();
         if (!array_key_exists($isbn10, $cleanIsbns)) {
             $cleanIsbns[$isbn13] = $isbn13;
         }
     }
     return $cleanIsbns;
 }
コード例 #11
0
ファイル: IndexRecord.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Return the first valid ISBN found in the record (favoring ISBN-10 over
  * ISBN-13 when possible).
  *
  * @return mixed
  * @access protected
  */
 protected function getCleanISBN()
 {
     include_once 'sys/ISBN.php';
     // Get all the ISBNs and initialize the return value:
     $isbns = $this->getISBNs();
     $isbn13 = false;
     // Loop through the ISBNs:
     foreach ($isbns as $isbn) {
         // Strip off any unwanted notes:
         if ($pos = strpos($isbn, ' ')) {
             $isbn = substr($isbn, 0, $pos);
         }
         // If we find an ISBN-10, return it immediately; otherwise, if we find
         // an ISBN-13, save it if it is the first one encountered.
         $isbnObj = new ISBN($isbn);
         if ($isbn10 = $isbnObj->get10()) {
             return $isbn10;
         }
         if (!$isbn13) {
             $isbn13 = $isbnObj->get13();
         }
     }
     return $isbn13;
 }
コード例 #12
0
ファイル: ItemAPI.php プロジェクト: bryandease/VuFind-Plus
 function getGoDeeperData()
 {
     require_once ROOT_DIR . '/services/Record/Enrichment.php';
     $record = $this->loadSolrRecord($_GET['id']);
     $type = $_GET['type'];
     $isbn = isset($record['isbn']) ? ISBN::normalizeISBN($record['isbn'][0]) : null;
     $upc = isset($record['upc']) ? $record['upc'][0] : null;
     //Load go deeper data
     require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
     $goDeeperOptions = GoDeeperData::getHtmlData($type, 'vufind', $isbn, $upc);
     return $goDeeperOptions;
 }
コード例 #13
0
ファイル: IsbnTest.php プロジェクト: martinlindhe/core_dev
 function test3()
 {
     // NOTE: has bad checksum
     $this->assertEquals(ISBN::isValid('978-91-7429-121-1'), false);
 }
コード例 #14
0
ファイル: Record.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Select the best available ISBN from those contained in the current record.
  *
  * @return string
  * @access private
  */
 private function _getBestISBN()
 {
     // Get ISBN for cover and review use
     $isbn13 = false;
     if ($isbnFields = $this->record->getFields('020')) {
         if (is_array($isbnFields)) {
             foreach ($isbnFields as $isbnField) {
                 if ($isbnSubField = $isbnField->getSubfield('a')) {
                     $isbn = trim($isbnSubField->getData());
                     if ($pos = strpos($this->isbn, ' ')) {
                         $isbn = substr($this->isbn, 0, $pos);
                     }
                     // If we find an ISBN-10, return it immediately; otherwise,
                     // if we find an ISBN-13, save it if it is the first one
                     // encountered.
                     $isbnObj = new ISBN($isbn);
                     if ($isbn10 = $isbnObj->get10()) {
                         return $isbn10;
                     }
                     if (!$isbn13) {
                         $isbn13 = $isbnObj->get13();
                     }
                 }
             }
         }
     }
     return $isbn13;
 }
コード例 #15
0
ファイル: mod_isbn.php プロジェクト: poef/ariadne
 function __construct($groups_csv, $isbn, $ver)
 {
     ISBN::ISBN($isbn, $ver);
     $this->groups_csv = $groups_csv;
 }
コード例 #16
0
ファイル: Base.php プロジェクト: victorfcm/VuFind-Plus
 /**
  * Initialize the object's search settings for an advanced search found in the
  * $_REQUEST superglobal.  Advanced searches have numeric subscripts on the
  * lookfor and type parameters -- this is how they are distinguished from basic
  * searches.
  *
  * @access  protected
  */
 protected function initAdvancedSearch()
 {
     $this->isAdvanced = true;
     if (isset($_REQUEST['lookfor'])) {
         if (is_array($_REQUEST['lookfor'])) {
             //Advanced search from popup form
             $this->searchType = $this->advancedSearchType;
             $group = array();
             foreach ($_REQUEST['lookfor'] as $index => $lookfor) {
                 $group[] = array('field' => $_REQUEST['searchType'][$index], 'lookfor' => $lookfor, 'bool' => $_REQUEST['join'][$index]);
                 //var_dump($_REQUEST);
                 if (isset($_REQUEST['groupEnd'])) {
                     if ($_REQUEST['groupEnd'][$index] == 1) {
                         // Add the completed group to the list
                         $this->searchTerms[] = array('group' => $group, 'join' => $_REQUEST['join'][$index]);
                         $group = array();
                     }
                 }
             }
             if (count($group) > 0) {
                 // Add the completed group to the list
                 $this->searchTerms[] = array('group' => $group, 'join' => $_REQUEST['join'][$index]);
             }
         } else {
         }
     } else {
         //********************
         // Advanced Search logic
         //  'lookfor0[]' 'type0[]'
         //  'lookfor1[]' 'type1[]' ...
         $this->searchType = $this->advancedSearchType;
         $groupCount = 0;
         // Loop through each search group
         while (isset($_REQUEST['lookfor' . $groupCount])) {
             $group = array();
             // Loop through each term inside the group
             for ($i = 0; $i < count($_REQUEST['lookfor' . $groupCount]); $i++) {
                 // Ignore advanced search fields with no lookup
                 if ($_REQUEST['lookfor' . $groupCount][$i] != '') {
                     // Use default fields if not set
                     if (isset($_REQUEST['type' . $groupCount][$i]) && $_REQUEST['type' . $groupCount][$i] != '') {
                         $type = strip_tags($_REQUEST['type' . $groupCount][$i]);
                     } else {
                         $type = $this->defaultIndex;
                     }
                     //Marmot - search both ISBN-10 and ISBN-13
                     //Check to see if the search term looks like an ISBN10 or ISBN13
                     $lookfor = strip_tags($_REQUEST['lookfor' . $groupCount][$i]);
                     if (($type == 'ISN' || $type == 'Keyword' || $type == 'AllFields') && (preg_match('/^\\d-?\\d{3}-?\\d{5}-?\\d$/', $lookfor) || preg_match('/^\\d{3}-?\\d-?\\d{3}-?\\d{5}-?\\d$/', $lookfor))) {
                         require_once ROOT_DIR . '/sys/ISBN.php';
                         $isbn = new ISBN($lookfor);
                         $lookfor = $isbn->get10() . ' OR ' . $isbn->get13();
                     }
                     // Add term to this group
                     $group[] = array('field' => $type, 'lookfor' => $lookfor, 'bool' => strip_tags($_REQUEST['bool' . $groupCount][0]));
                 }
             }
             // Make sure we aren't adding groups that had no terms
             if (count($group) > 0) {
                 // Add the completed group to the list
                 $this->searchTerms[] = array('group' => $group, 'join' => strip_tags($_REQUEST['join']));
             }
             // Increment
             $groupCount++;
         }
         // Finally, if every advanced row was empty
         if (count($this->searchTerms) == 0) {
             // Treat it as an empty basic search
             $this->searchType = $this->basicSearchType;
             $this->searchTerms[] = array('index' => $this->defaultIndex, 'lookfor' => '');
         }
     }
 }
コード例 #17
0
 /**
  * Return the first valid ISBN found in the record (favoring ISBN-10 over
  * ISBN-13 when possible).
  *
  * @return  mixed
  */
 public function getCleanISBN()
 {
     require_once ROOT_DIR . '/sys/ISBN.php';
     //Check to see if we already have NovelistData loaded with a primary ISBN
     require_once ROOT_DIR . '/sys/Novelist/NovelistData.php';
     $novelistData = new NovelistData();
     $novelistData->groupedRecordPermanentId = $this->getPermanentId();
     if (!isset($_REQUEST['reload']) && $this->getPermanentId() != null && $this->getPermanentId() != '' && $novelistData->find(true) && $novelistData->primaryISBN != null) {
         return $novelistData->primaryISBN;
     } else {
         // Get all the ISBNs and initialize the return value:
         $isbns = $this->getISBNs();
         $isbn10 = false;
         // Loop through the ISBNs:
         foreach ($isbns as $isbn) {
             // If we find an ISBN-13, return it immediately; otherwise, if we find
             // an ISBN-10, save it if it is the first one encountered.
             $isbnObj = new ISBN($isbn);
             if ($isbnObj->isValid()) {
                 if ($isbn13 = $isbnObj->get13()) {
                     return $isbn13;
                 }
                 if (!$isbn10) {
                     $isbn10 = $isbnObj->get10();
                 }
             }
         }
         return $isbn10;
     }
 }
コード例 #18
0
ファイル: OpenURL.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Parse OpenURL and return a keyed array
  *
  * @return array Parsed OpenURL values
  */
 protected function parseOpenURL()
 {
     $title = '';
     $author = '';
     $isbn = '';
     $issn = '';
     $eissn = '';
     $date = '';
     $volume = '';
     $issue = '';
     $spage = '';
     $journal = false;
     if (isset($_REQUEST['url_ver']) && $_REQUEST['url_ver'] == 'Z39.88-2004') {
         // Parse OpenURL 1.0
         if (isset($_REQUEST['rft_val_fmt']) && $_REQUEST['rft_val_fmt'] == 'info:ofi/fmt:kev:mtx:book') {
             // Book format
             if (isset($_REQUEST['rft_btitle'])) {
                 $title = $_REQUEST['rft_btitle'];
             } else {
                 if (isset($_REQUEST['rft_title'])) {
                     $title = $_REQUEST['rft_title'];
                 }
             }
             $isbn = isset($_REQUEST['rft_isbn']) ? $_REQUEST['rft_isbn'] : '';
         } else {
             // Journal / Article / something
             $journal = true;
             if (isset($_REQUEST['rft_atitle'])) {
                 $title = $_REQUEST['rft_atitle'];
             } else {
                 if (isset($_REQUEST['rft_jtitle'])) {
                     $title = $_REQUEST['rft_jtitle'];
                 } else {
                     if (isset($_REQUEST['rft_title'])) {
                         $title = $_REQUEST['rft_title'];
                     }
                 }
             }
             $eissn = isset($_REQUEST['rft_eissn']) ? $_REQUEST['rft_eissn'] : '';
         }
         if (isset($_REQUEST['rft_aulast'])) {
             $author = $_REQUEST['rft_aulast'];
         }
         if (isset($_REQUEST['rft_aufirst'])) {
             $author .= ' ' . $_REQUEST['rft_aufirst'];
         } else {
             if (isset($_REQUEST['rft_auinit'])) {
                 $author .= ' ' . $_REQUEST['rft_auinit'];
             }
         }
         $issn = isset($_REQUEST['rft_issn']) ? $_REQUEST['rft_issn'] : '';
         $date = isset($_REQUEST['rft_date']) ? $_REQUEST['rft_date'] : '';
         $volume = isset($_REQUEST['rft_volume']) ? $_REQUEST['rft_volume'] : '';
         $issue = isset($_REQUEST['rft_issue']) ? $_REQUEST['rft_issue'] : '';
         $spage = isset($_REQUEST['rft_spage']) ? $_REQUEST['rft_spage'] : '';
     } else {
         // OpenURL 0.1
         $issn = isset($_REQUEST['issn']) ? $_REQUEST['issn'] : '';
         $date = isset($_REQUEST['date']) ? $_REQUEST['date'] : '';
         $volume = isset($_REQUEST['volume']) ? $_REQUEST['volume'] : '';
         $issue = isset($_REQUEST['issue']) ? $_REQUEST['issue'] : '';
         $spage = isset($_REQUEST['spage']) ? $_REQUEST['spage'] : '';
         $isbn = isset($_REQUEST['isbn']) ? $_REQUEST['isbn'] : '';
         if (isset($_REQUEST['atitle'])) {
             $title = $_REQUEST['atitle'];
         } else {
             if (isset($_REQUEST['jtitle'])) {
                 $title = $_REQUEST['jtitle'];
             } else {
                 if (isset($_REQUEST['btitle'])) {
                     $title = $_REQUEST['btitle'];
                 } else {
                     if (isset($_REQUEST['title'])) {
                         $title = $_REQUEST['title'];
                     }
                 }
             }
         }
         if (isset($_REQUEST['aulast'])) {
             $author = $_REQUEST['aulast'];
         }
         if (isset($_REQUEST['aufirst'])) {
             $author .= ' ' . $_REQUEST['aufirst'];
         } else {
             if (isset($_REQUEST['auinit'])) {
                 $author .= ' ' . $_REQUEST['auinit'];
             }
         }
     }
     if (ISBN::isValidISBN10($isbn) || ISBN::isValidISBN13($isbn)) {
         $isbnObj = new ISBN($isbn);
         $isbn = $isbnObj->get13();
     }
     return compact('journal', 'title', 'author', 'isbn', 'issn', 'eissn', 'date', 'volume', 'issue', 'spage');
 }
コード例 #19
0
ファイル: ISBN.php プロジェクト: poef/ariadne
 /**
  * Guesses ISBN version of passed string
  *
  * Note: This is not Validation. To get the validated
  * version of an ISBN Number use ISBN::validate();
  *
  * @param string $isbn ISBN Number to guess Version of
  *
  * @return integer|false    Version Value or false if failed
  *
  * @see validate();
  */
 function guessVersion($isbn)
 {
     $r = ISBN::_isbnVersionGuess($isbn);
     return $r;
 }
コード例 #20
0
 /**
  * @param string $sourceSolrId
  * @param string $isbn
  * @param integer $numResourcesToLoad
  * @param Solr $db
  * @return null
  */
 private static function getXISBN($sourceSolrId, $isbn, $numResourcesToLoad, $db)
 {
     global $configArray;
     // Build URL
     $url = 'http://xisbn.worldcat.org/webservices/xid/isbn/' . urlencode(is_array($isbn) ? $isbn[0] : $isbn) . '?method=getEditions&format=csv';
     if (isset($configArray['WorldCat']['id'])) {
         $url .= '&ai=' . $configArray['WorldCat']['id'];
     }
     // Print Debug code
     if ($configArray['System']['debug']) {
         global $logger;
         $logger->log("<pre>XISBN: {$url}</pre>", PEAR_LOG_INFO);
     }
     // Fetch results
     $query = '';
     if ($fp = @fopen($url, "r")) {
         while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {
             // If we got an error message, don't treat it as an ISBN!
             if ($data[0] == 'overlimit') {
                 continue;
             }
             if ($query != '') {
                 $query .= ' OR isbn:' . $data[0];
             } else {
                 $query = 'isbn:' . $data[0];
             }
         }
     }
     if (strlen($query) == 0) {
         //Get ISBNs from the record itself
         $record = $db->getRecord($sourceSolrId);
         if ($record) {
             if (isset($record['isbn'])) {
                 $isbns = is_array($record['isbn']) ? $record['isbn'] : array($record['isbn']);
                 foreach ($isbns as $tmpIsbn) {
                     $tmpIsbn = ISBN::normalizeISBN($tmpIsbn);
                     if ($query != '') {
                         $query .= ' OR isbn:' . $tmpIsbn;
                     } else {
                         $query = 'isbn:' . $tmpIsbn;
                     }
                 }
             }
             if (isset($record['grouping_term'])) {
                 $query .= ' OR grouping_term:"' . $record['grouping_term'] . '"';
             }
         }
     }
     if ($query != '') {
         // Filter out current record
         $query .= ' NOT id:' . $sourceSolrId;
         $result = $db->search($query, null, null, 0, $numResourcesToLoad);
         if (!PEAR_Singleton::isError($result)) {
             if (isset($result['response']['docs']) && !empty($result['response']['docs'])) {
                 return $result['response']['docs'];
             } else {
                 return null;
             }
         } else {
             return $result;
         }
     } else {
         return null;
     }
 }
コード例 #21
0
ファイル: Solr.php プロジェクト: bryandease/VuFind-Plus
 /**
  * Initialise the object from the global
  *  search parameters in $_REQUEST.
  *
  * @access  public
  * @var string|LibrarySearchSource|LocationSearchSource $searchSource
  * @return  boolean
  */
 public function init($searchSource = null)
 {
     global $module;
     global $action;
     // Call the standard initialization routine in the parent:
     parent::init($searchSource);
     $this->indexEngine->setSearchSource($searchSource);
     //********************
     // Check if we have a saved search to restore -- if restored successfully,
     // our work here is done; if there is an error, we should report failure;
     // if restoreSavedSearch returns false, we should proceed as normal.
     $restored = $this->restoreSavedSearch(null, true, true);
     if ($restored === true) {
         return true;
     } else {
         if (PEAR_Singleton::isError($restored)) {
             return false;
         }
     }
     //********************
     // Initialize standard search parameters
     $this->initView();
     $this->initPage();
     $this->initSort();
     $this->initFilters();
     //Marmot - search both ISBN-10 and ISBN-13
     //Check to see if the search term looks like an ISBN10 or ISBN13
     if (isset($_REQUEST['type']) && isset($_REQUEST['lookfor']) && ($_REQUEST['type'] == 'ISN' || $_REQUEST['type'] == 'Keyword' || $_REQUEST['type'] == 'AllFields') && (preg_match('/^\\d-?\\d{3}-?\\d{5}-?\\d$/', $_REQUEST['lookfor']) || preg_match('/^\\d{3}-?\\d-?\\d{3}-?\\d{5}-?\\d$/', $_REQUEST['lookfor']))) {
         require_once ROOT_DIR . '/sys/ISBN.php';
         $isbn = new ISBN($_REQUEST['lookfor']);
         $_REQUEST['lookfor'] = $isbn->get10() . ' OR ' . $isbn->get13();
     }
     //********************
     // Basic Search logic
     if ($this->initBasicSearch()) {
         // If we found a basic search, we don't need to do anything further.
     } else {
         if (isset($_REQUEST['tag']) && $module != 'MyResearch') {
             // Tags, just treat them as normal searches for now.
             // The search processer knows what to do with them.
             if ($_REQUEST['tag'] != '') {
                 $this->searchTerms[] = array('index' => 'tag', 'lookfor' => strip_tags($_REQUEST['tag']));
             }
         } else {
             $this->initAdvancedSearch();
         }
     }
     //********************
     // Author screens - handled slightly differently
     if ($module == 'Author') {
         // *** Things in common to both screens
         // Log a special type of search
         $this->searchType = 'author';
         // We don't spellcheck this screen
         //   it's not for free user intput anyway
         $this->spellcheck = false;
         // *** Author/Home
         if ($action == 'Home') {
             $this->searchSubType = 'home';
             // Remove our empty basic search (default)
             $this->searchTerms = array();
             // Prepare the search as a normal author search
             $this->searchTerms[] = array('index' => 'Author', 'lookfor' => trim(strip_tags($_REQUEST['author'])));
         }
         // *** Author/Search
         if ($action == 'Search') {
             $this->searchSubType = 'search';
             // We already have the 'lookfor', just set the index
             $this->searchTerms[0]['index'] = 'Author';
             // We really want author facet data
             $this->facetConfig = array();
             $this->addFacet('authorStr');
             // Offset the facet list by the current page of results, and
             // allow up to ten total pages of results -- since we can't
             // get a total facet count, this at least allows the paging
             // mechanism to automatically add more pages to the end of the
             // list so that users can browse deeper and deeper as they go.
             // TODO: Make this better in the future if Solr offers a way
             //       to get a total facet count (currently not possible).
             $this->facetOffset = ($this->page - 1) * $this->limit;
             $this->facetLimit = $this->limit * 10;
             // Sorting - defaults to off with unlimited facets, so let's
             //           be explicit here for simplicity.
             if (isset($_REQUEST['sort']) && $_REQUEST['sort'] == 'author') {
                 $this->setFacetSortOrder('index');
             } else {
                 $this->setFacetSortOrder('count');
             }
         }
     } else {
         if ($module == 'Search' && ($action == 'NewItem' || $action == 'Reserves')) {
             // We don't need spell checking
             $this->spellcheck = false;
             $this->searchType = strtolower($action);
         } else {
             if ($module == 'MyResearch') {
                 $this->spellcheck = false;
                 $this->searchType = $action == 'Home' ? 'favorites' : 'list';
             }
         }
     }
     // If a query override has been specified, log it here
     if (isset($_REQUEST['q'])) {
         $this->query = strip_tags($_REQUEST['q']);
     }
     return true;
 }
コード例 #22
0
 public function getIsbn()
 {
     require_once ROOT_DIR . '/sys/ISBN.php';
     $isbns = $this->getPropertyArray('isbn');
     if (count($isbns) == 0) {
         return null;
     } else {
         $isbn = ISBN::normalizeISBN($isbns[0]);
         return $isbn;
     }
 }
コード例 #23
0
ファイル: BN_College.php プロジェクト: HeliWang/bookswap
 /**
  * Parses book details from the given HTML book description.
  *
  * The resulting book-details array will have a subset of the following keys:
  *  - isbn
  *  - title
  *  - authors
  *  - edition
  *  - publisher
  *  - section_id
  *  - bookstore_id
  *  - bookstore_part_number
  *  - bookstore_used_price
  *  - bookstore_new_price
  *  - type
  *  - required_status
  *
  * @param string $html HTML for a book description on the bookstore website
  * @return array An array of book details, or FALSE on error
  */
 protected function parse_book_details($html)
 {
     if (strpos($html, 'Currently no textbook') || strpos($html, 'Pre-Order')) {
         return FALSE;
     }
     $details = array();
     if (preg_match("/value\\='(\\d{8})'/", $html, $matches)) {
         $details['section_id'] = $matches[1];
     }
     if (preg_match("/ISBN\\:\\<\\/span\\>.+?(\\d+).+?\\</s", $html, $matches)) {
         $isbn = ISBN::to13(trim($matches[1]), TRUE);
         if ($isbn) {
             $details['isbn'] = $isbn;
         }
     }
     if (preg_match("/\\d{5}'\\stitle\\=\"(.+?)\"\\>.+?\\<img/s", $html, $matches)) {
         $details['title'] = $this->title_case(trim(htmlspecialchars_decode($matches[1], ENT_QUOTES)));
     }
     if (preg_match("/\\<span\\>Author:.*?\\<\\/span\\>(.+?)\\<\\/li/s", $html, $matches)) {
         $author = $this->ucname(trim($matches[1]));
         $details['authors'] = is_numeric($author) ? "" : $author;
     }
     if (preg_match("/Edition:\\<\\/span\\>(.+?)\\<br/", $html, $matches)) {
         $details['edition'] = strtolower(trim($matches[1]));
     }
     if (preg_match("/Publisher:\\<\\/span\\>(.+?)\\<br/", $html, $matches)) {
         $details['publisher'] = $this->title_case(trim($matches[1]));
     }
     if (preg_match("/productId\\=(.+?)&/", $html, $matches)) {
         $details['bookstore_id'] = trim($matches[1]);
     }
     if (preg_match("/partNumber\\=(.+?)&/", $html, $matches)) {
         $details['bookstore_part_number'] = rtrim($matches[1], "&amp;");
     }
     if (preg_match("/Used.+?(\\d{1,3}\\.\\d{2})/s", $html, $matches)) {
         $details['bookstore_used_price'] = $matches[1];
     }
     if (preg_match("/New.+?(\\d{1,3}\\.\\d{2})/s", $html, $matches)) {
         $details['bookstore_new_price'] = $matches[1];
     }
     $options = array("REQUIRED\\sPACKAGE", "RECOMMENDED\\sPACKAGE", "REQUIRED", "RECOMMENDED", "PACKAGE\\sCOMPONENT", "GO\\sTO\\sCLASS\\sFIRST", "BOOKSTORE\\sRECOMMENDED");
     preg_match("/" . implode('|', $options) . "/", $html, $matches);
     $required = trim($matches[0]);
     if ($required == "REQUIRED PACKAGE" || $required == "RECOMMENDED PACKAGE") {
         $type = Book_model::PACKAGE;
     } else {
         if ($required == "PACKAGE COMPONENT") {
             $type = Book_model::PACKAGE_COMPONENT;
         } else {
             $type = Book_model::BOOK;
         }
     }
     $details['type'] = $type;
     if ($required == "REQUIRED PACKAGE" || $required == "REQUIRED") {
         $required = Book_model::REQUIRED;
     } else {
         if ($required == "RECOMMENDED PACKAGE" || $required == "RECOMMENDED") {
             $required = Book_model::RECOMMENDED;
         } else {
             if ($required == "GO TO CLASS FIRST") {
                 $required = Book_model::GO_TO_CLASS_FIRST;
             } else {
                 if ($required == "BOOKSTORE RECOMMENDED") {
                     $required = Book_model::BOOKSTORE_RECOMMENDED;
                 } else {
                     $required = Book_model::REQUIRED;
                 }
             }
         }
     }
     $details['required_status'] = $required;
     return $details;
 }