Пример #1
0
 function launch()
 {
     global $configArray;
     global $interface;
     $libraryName = $configArray['Site']['title'];
     //Grab the tracking data
     $store = urldecode(strip_tags($_GET['store']));
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $title = str_replace("/", "", $eContentRecord->title);
     if ($eContentRecord->purchaseUrl == null) {
         switch ($store) {
             case "Tattered Cover":
                 $purchaseLinkUrl = "http://www.tatteredcover.com/search/apachesolr_search/" . urlencode($title) . "?source=" . urlencode($libraryName);
                 break;
             case "Barnes and Noble":
                 $purchaseLinkUrl = "http://www.barnesandnoble.com/s/?title=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
             case "Amazon":
                 $purchaseLinkUrl = "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
         }
     } else {
         // Process MARC Data
         $purchaseLinkUrl = $eContentRecord->purchaseUrl;
     }
     //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 = 'econtentRecord' . $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 link for this title."));
     }
 }
Пример #2
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."));
     }
 }