/** * Prepares the sets view. * * @return void */ public function setsAction() { // Get the available OAI-PMH to Omeka maps, which should correspond to // OAI-PMH metadata formats. $maps = $this->_getMaps(); $waitTime = oaipmh_harvester_config('requestThrottleSecs', 5); if ($waitTime) { $request = new OaipmhHarvester_Request_Throttler(new OaipmhHarvester_Request($this->_getParam('base_url')), array('wait' => $waitTime)); } else { $request = new OaipmhHarvester_Request($this->_getParam('base_url')); } // Catch errors such as "String could not be parsed as XML" $extraMsg = 'Please check to be certain the URL is correctly formatted ' . 'for OAI-PMH harvesting.'; try { $metadataFormats = $request->listMetadataFormats(); } catch (Zend_Uri_Exception $e) { $errorMsg = "Invalid URL given. {$extraMsg}"; } catch (Zend_Http_Client_Exception $e) { $errorMsg = $e->getMessage() . " {$extraMsg}"; } catch (OaipmhHarvester_Request_ThrottlerException $e) { $errorMsg = $e->getMessage(); } if (isset($errorMsg)) { $this->_helper->flashMessenger($errorMsg, 'error'); return $this->_helper->redirector->goto('index'); } /* Compare the available OAI-PMH metadataFormats with the available Omeka maps and extract only those that are common to both. The comparison is made between the metadata schemata, not the prefixes. */ $availableMaps = array_intersect($maps, $metadataFormats); // For a data provider that uses a resumption token for sets, see: // http://www.ajol.info/oai/ $response = $request->listSets($this->_getParam('resumption_token')); // Set the variables to the view object. $this->view->availableMaps = array_combine(array_keys($availableMaps), array_keys($availableMaps)); $this->view->sets = $response['sets']; $this->view->resumptionToken = array_key_exists('resumptionToken', $response) ? $response['resumptionToken'] : false; $this->view->baseUrl = $this->_getParam('base_url'); // Watch out for injection! $this->view->maps = $maps; }