/**
  * Appends the record's header to the XML response.
  *
  * Adds the identifier, datestamp and setSpec to a header element, and
  * appends in to the document.
  *
  * @param DOMElement $parentElement
  */
 public function appendHeader($parentElement)
 {
     $headerData['identifier'] = OaiPmhRepository_OaiIdentifier::itemToOaiId($this->item->id);
     $headerData['datestamp'] = OaiPmhRepository_Date::dbToUtc($this->item->modified);
     $collectionId = $this->item->collection_id;
     if ($collectionId) {
         $headerData['setSpec'] = $collectionId;
     }
     $this->createElementWithChildren($parentElement, 'header', $headerData);
 }
 /**
  * Deletes the rows for expired tokens from the table.
  */
 public function purgeExpiredTokens()
 {
     $db = $this->getDb();
     $db->delete($this->getTableName(), 'expiration <= ' . $db->quote(OaiPmhRepository_Date::unixToDb(time())));
 }
 /**
  * Stores a new resumption token record in the database
  *
  * @param string $verb OAI-PMH verb for the request
  * @param string $metadataPrefix Metadata prefix
  * @param int $cursor Offset in response to begin output at
  * @param mixed $set Optional set argument
  * @param string $from Optional from date argument
  * @param string $until Optional until date argument
  * @return OaiPmhRepositoryToken Token model object
  */
 private function createResumptionToken($verb, $metadataPrefix, $cursor, $set, $from, $until)
 {
     $tokenTable = get_db()->getTable('OaiPmhRepositoryToken');
     $resumptionToken = new OaiPmhRepositoryToken();
     $resumptionToken->verb = $verb;
     $resumptionToken->metadata_prefix = $metadataPrefix;
     $resumptionToken->cursor = $cursor;
     if ($set) {
         $resumptionToken->set = $set;
     }
     if ($from) {
         $resumptionToken->from = $from;
     }
     if ($until) {
         $resumptionToken->until = $until;
     }
     $resumptionToken->expiration = OaiPmhRepository_Date::unixToDb(time() + $this->_tokenExpirationTime * 60);
     $resumptionToken->save();
     return $resumptionToken;
 }
Example #4
0
 /**
  * Helper to get the earlieast datestamp of the repository.
  *
  * @return string OAI-PMH date stamp.
  */
 private function _getEarliestDatestamp()
 {
     $earliestItem = get_record('Item', array('public' => 1, 'sort_field' => 'added', 'sort_dir' => 'a'));
     return $earliestItem ? OaiPmhRepository_Date::dbToUtc($earliestItem->added) : OaiPmhRepository_Date::unixToUtc(0);
 }