Author: Tom Walder (twalder@gmail.com)
Inheritance: extends GDS\Store
 static function getDefaultBookStores()
 {
     $store = new BookStore();
     $store->showByDefault = 1;
     $store->find();
     $list = array();
     while ($store->fetch()) {
         $list[] = clone $store;
     }
     return $list;
 }
示例#2
0
 public function testBookStore()
 {
     $bookStore = new BookStore();
     $bookStore->addBook(new NovelBook('平凡的世界', 58, '路遥'));
     $bookStore->show();
 }
示例#3
0
 function getObjectStructure()
 {
     return BookStore::getObjectStructure();
 }
示例#4
0
 function launch()
 {
     global $configArray;
     global $interface;
     //Grab the tracking data
     $store = urldecode(strip_tags($_GET['store']));
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     $field856Index = isset($_REQUEST['index']) ? $_REQUEST['index'] : null;
     $libraryName = $configArray['Site']['title'];
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     if ($configArray['System']['debugSolr']) {
         $this->db->debug = true;
     }
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($recordId))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $this->record = $record;
     $interface->assign('record', $record);
     $titleTerm = $record["title"];
     $title = str_replace(":", " ", $titleTerm);
     $authorTerm = $record["auth_author"];
     $author = str_replace("/", "", $authorTerm);
     if ($field856Index == null) {
         // Find the store in the database
         require_once ROOT_DIR . '/Drivers/marmot_inc/BookStore.php';
         $storeDbObj = new BookStore();
         $storeDbObj->storeName = $store;
         $storeDbObj->find();
         if ($storeDbObj->N > 0) {
             $storeDbObj->fetch();
             $purchaseLinkUrl = self::getPurchaseLinkForTitle($storeDbObj->link, $title, $author, $libraryName);
         }
     } else {
         // Process MARC Data
         require_once ROOT_DIR . '/sys/MarcLoader.php';
         $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
         if ($marcRecord) {
             $this->marcRecord = $marcRecord;
         } else {
             PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the MAC record for this title."));
         }
         $linkFields = $marcRecord->getFields('856');
         if ($linkFields) {
             $cur856Index = 0;
             foreach ($linkFields as $marcField) {
                 $cur856Index++;
                 if ($cur856Index == $field856Index) {
                     //Get the link
                     if ($marcField->getSubfield('u')) {
                         $link = $marcField->getSubfield('u')->getData();
                         $purchaseLinkUrl = $link;
                     }
                 }
             }
         }
     }
     //Do not track purchases from Bots
     require_once ROOT_DIR . '/sys/BotChecker.php';
     if (!BotChecker::isRequestFromBot()) {
         require_once ROOT_DIR . '/sys/PurchaseLinkTracking.php';
         $tracking = new PurchaseLinkTracking();
         $tracking->ipAddress = $ipAddress;
         $tracking->recordId = $recordId;
         $tracking->store = $store;
         $insertResult = $tracking->insert();
     }
     //redirects them to the link they clicked
     if ($purchaseLinkUrl != "") {
         header("Location:" . $purchaseLinkUrl);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the store information for this title."));
     }
 }