Пример #1
0
 private function _getCheckedOutEContentLinks($eContentRecord, $eContentItem, $eContentCheckout)
 {
     global $configArray;
     global $user;
     $links = array();
     $addDefaultTypeLinks = false;
     if ($eContentItem != null) {
         if ($eContentRecord->accessType == 'acs' && ($eContentItem->item_type == 'epub' || $eContentItem->item_type == 'pdf')) {
             //Protected by ACS server
             //Links to read the title online or checkout from ACS server
             if ($eContentItem->item_type == 'pdf') {
                 $links = array_merge($links, $this->_getACSPdfLinks($eContentItem, $eContentCheckout));
             } elseif ($eContentItem->item_type == 'epub') {
                 $links = array_merge($links, $this->_getACSEpubLinks($eContentItem, $eContentCheckout));
             }
         } else {
             //Single usage or free
             //default links to read the title or download
             $links = array_merge($links, $this->getDefaultEContentLinks($eContentRecord, $eContentItem));
         }
     } else {
         $eContentItems = $eContentRecord->getItems();
         foreach ($eContentItems as $item) {
             if ($eContentRecord->accessType == 'acs' && ($item->item_type == 'epub' || $item->item_type == 'pdf')) {
                 //Protected by ACS server
                 //Links to read the title online or checkout from ACS server
                 if ($item->item_type == 'pdf') {
                     $links = array_merge($links, $this->_getACSPdfLinks($item, $eContentCheckout));
                 } elseif ($item->item_type == 'epub') {
                     $links = array_merge($links, $this->_getACSEpubLinks($item, $eContentCheckout));
                 }
             } else {
                 //Single usage or free
                 //default links to read the title or download
                 $links = array_merge($links, $this->getDefaultEContentLinks($eContentRecord, $item));
             }
             $links[ArrayUtils::getLastKey($links)]['item_type'] = $item->item_type;
         }
     }
     //Add a link to return the title
     if ($eContentCheckout->downloadedToReader == 0) {
         $links[] = array('text' => 'Return Now', 'onclick' => "if (confirm('Are you sure you want to return this title?')){returnEpub('{$configArray['Site']['path']}/EcontentRecord/{$eContentRecord->id}/ReturnTitle')};return false;", 'typeReturn' => 0);
     } else {
         $links[] = array('text' => 'Return Now', 'onclick' => "alert('Please return this title from your digital reader.');return false;", 'typeReturn' => 1);
     }
     return $links;
 }