Example #1
0
 /**
  * Constructor
  *
  * @access public
  */
 public function __construct()
 {
     global $interface;
     global $configArray;
     // Call parent constructor
     parent::__construct();
     // Set bX flag
     $interface->assign('bXEnabled', isset($configArray['bX']['token']) ? true : false);
     // Fetch Record
     $pci = new SearchObject_PCI();
     $this->record = $record = $pci->getRecord($_REQUEST['id']);
     // Set Proxy URL
     $interface->assign('proxy', isset($configArray['EZproxy']['host']) ? $configArray['EZproxy']['host'] : false);
     $interface->assign('exportFormats', array('RefWorks', 'EndNote'));
     // Send record ID to template
     $interface->assign('id', $_REQUEST['id']);
     // Send record data to template
     $interface->assign('record', $record);
     $interface->setPageTitle(isset($record['title']) ? ': ' . $record['title'] : '');
 }
Example #2
0
 /**
  * Get record and export data
  * Display error message on terminal error or email details page on success
  *
  * @param string $format The desired export format
  * @param array  $ids    A list of bib IDs
  *
  * @return array Record data for each ID, plus an list of IDs without results
  * @access public
  */
 public function exportAll($format, $ids)
 {
     global $interface;
     global $configArray;
     $exportDetails = array();
     $errorMsgDetails = array();
     // MARC-XML needs a container at the start:
     if ($format == 'MARCXML') {
         $exportDetails[] = '<?xml version="1.0" encoding="UTF-8"?>' . '<collection xmlns="http://www.loc.gov/MARC21/slim">';
     }
     foreach ($ids as $id) {
         // Retrieve the record from the index
         list($index, $recId) = explode('.', $id, 2);
         $current = null;
         if ($index === 'pci' || $index === 'metalib') {
             $format = strtolower($format);
             if ($index === 'pci') {
                 $db = new SearchObject_PCI();
                 if ($rec = $db->getRecord($id)) {
                     $pci = new PCI();
                     $current = $interface->fetch($pci->export($rec, $format));
                 }
             } else {
                 if ($index === 'metalib') {
                     $db = new MetaLib();
                     if ($rec = $db->getRecord($id)) {
                         $current = $interface->fetch($db->export($rec, $format));
                     }
                 }
             }
             if ($current) {
                 $exportDetails[] = $current;
             } else {
                 $errorMsgDetails[] = $id;
             }
         } else {
             if (!($record = $this->db->getRecord($id))) {
                 $errorMsgDetails[] = $id;
             } else {
                 $recordDetails = RecordDriverFactory::initRecordDriver($record);
                 // Assign core metadata to be sure export has all necessary values
                 // available:
                 $recordDetails->getCoreMetadata();
                 $result = $recordDetails->getExport($format);
                 if (!empty($result)) {
                     $interface->assign('id', $id);
                     $current = $interface->fetch($result);
                     // For MARC-XML, extract <record> from <collection>:
                     if ($format == 'MARCXML') {
                         $current = $this->extractXMLRecord($current);
                     }
                     if (!empty($current)) {
                         $exportDetails[] = $current;
                     }
                 } else {
                     $errorMsgDetails[] = $id;
                 }
             }
         }
     }
     // MARC-XML needs a container close at the end:
     if ($format == 'MARCXML') {
         $exportDetails[] = '</collection>';
     }
     $results = array('exportDetails' => $exportDetails, 'errorDetails' => $errorMsgDetails);
     return $results;
 }