/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (isset($_REQUEST['export'])) { $ml = new MetaLib(); $format = strtolower($_REQUEST['export']); return $interface->fetch($ml->export($this->record, $format, true)); } // Send basic information to the template. $interface->assign('record', $this->record); $interface->setPageTitle($this->record['Title'][0]); // Assign the ID of the last search so the user can return to it. $lastsearch = isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false; $interface->assign('lastsearch', $lastsearch); if ($lastsearch) { // Retrieve active filters and assign them to searchbox template. // Since SearchObjects use $_REQUEST to init filters, we stash the current $_REQUEST // and fill it temporarily with URL parameters from last search. $query = parse_url($lastsearch, PHP_URL_QUERY); parse_str($query, $vars); $oldReq = $_REQUEST; $_REQUEST = $vars; $searchObject = SearchObjectFactory::initSearchObject('MetaLib'); $searchObject->init(); // This is needed for facet labels $searchObject->initRecommendations(); $filterList = $searchObject->getFilterList(); $filterListOthers = $searchObject->getFilterListOthers(); $checkboxFilters = $searchObject->getCheckboxFacets(); $filterUrlParams = $searchObject->getfilterUrlParams(); if (isset($vars['lookfor'])) { $interface->assign('lookfor', $vars['lookfor']); } $interface->assign('filterUrlParam', $filterUrlParams[0]); $interface->assign(compact('filterList')); $interface->assign(compact('filterListOthers')); $interface->assign('checkboxFilters', $checkboxFilters); if (isset($_SERVER['HTTP_REFERER'])) { // Set followup module & action for next search $parts = parse_url($_SERVER['HTTP_REFERER']); $pathParts = explode('/', $parts['path']); $refAction = array_pop($pathParts); $refModule = array_pop($pathParts); $interface->assign('followupSearchModule', $refModule); $interface->assign('followupSearchAction', $refAction); } $_REQUEST = $oldReq; } // Set bX flag $interface->assign('bXEnabled', isset($configArray['bX']['token']) ? true : false); // Display Page $interface->setTemplate('record.tpl'); $interface->display('layout.tpl'); }
/** * 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; }