示例#1
0
 /**
  * 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.  
  *
  * @uses appendHeader
  * @uses appendMetadata
  */
 public function appendHeader()
 {
     $table = new OaiFinds();
     if (array_key_exists('0', $this->item)) {
         $itemid = $this->item['0']['id'];
         $updated = $this->item['0']['created'];
         $collectionId = $this->item['0']['institution'];
     } else {
         $itemid = $this->item['id'];
         $updated = $this->item['created'];
         $collectionId = $this->item['institution'];
     }
     $item = $table->fetchRow($table->select()->where('finds.id = ?', $itemid));
     $object = new Pas_OaiPmhRepository_OaiIdentifier();
     $itemNumber = $object->itemToOaiId($itemid);
     $headerData['identifier'] = $itemNumber;
     $headerData['datestamp'] = self::dbToUtc($updated);
     if ($collectionId) {
         $headerData['setSpec'] = $collectionId;
     }
     $this->createElementWithChildren($this->parentElement, 'header', $headerData);
 }
示例#2
0
 /**
  * Appends CDWALite metadata. 
  *
  * Appends a metadata element, an child element with the required format,
  * and further children for each of the Dublin Core fields present in the
  * item.
  */
 public function appendMetadata()
 {
     $metadataElement = $this->document->createElement('metadata');
     $this->parentElement->appendChild($metadataElement);
     $cdwaliteWrap = $this->document->createElementNS(self::METADATA_NAMESPACE, 'cdwalite:cdwaliteWrap');
     $metadataElement->appendChild($cdwaliteWrap);
     $cdwaliteWrap->setAttribute('xmlns:cdwalite', self::METADATA_NAMESPACE);
     $cdwaliteWrap->setAttribute('xmlns:xsi', self::XML_SCHEMA_NAMESPACE_URI);
     $cdwaliteWrap->setAttribute('xsi:schemaLocation', self::METADATA_NAMESPACE . ' ' . self::METADATA_SCHEMA);
     $cdwalite = $this->appendNewElement($cdwaliteWrap, 'cdwalite:cdwalite');
     $descriptive = $this->appendNewElement($cdwalite, 'cdwalite:descriptiveMetadata');
     $types = array('Archaeological artefact record');
     $objectWorkTypeWrap = $this->appendNewElement($descriptive, 'cdwalite:objectWorkTypeWrap');
     if (count($types) == 0) {
         $types[] = 'Unknown';
     }
     foreach ($types as $type) {
         $this->appendNewElement($objectWorkTypeWrap, 'cdwalite:objectWorkType', $type);
     }
     $subjects = array('Archaeology');
     $classificationWrap = $this->appendNewElement($descriptive, 'cdwalite:classificationWrap');
     foreach ($subjects as $subject) {
         $this->appendNewElement($classificationWrap, 'cdwalite:classification', $subject);
     }
     $titles = array('A ' . ucfirst(strtolower($this->item['broadperiod'])) . ' ' . ucfirst(strtolower($this->item['objecttype'])));
     $titleWrap = $this->appendNewElement($descriptive, 'cdwalite:titleWrap');
     if (count($titles) == 0) {
         $titles[] = 'Unknown';
     }
     foreach ($titles as $title) {
         $titleSet = $this->appendNewElement($titleWrap, 'cdwalite:titleSet');
         $this->appendNewElement($titleSet, 'cdwalite:title', $title);
     }
     $creators = array($this->item['recorder']);
     foreach ($creators as $creator) {
         $creatorTexts[] = $creator;
     }
     $creatorText = count($creators) >= 1 ? implode(',', $creatorTexts) : 'Unknown';
     $this->appendNewElement($descriptive, 'cdwalite:displayCreator', $creatorText);
     $indexingCreatorWrap = $this->appendNewElement($descriptive, 'cdwalite:indexingCreatorWrap');
     if (count($creators) == 0) {
         $creators[] = 'Unknown';
     }
     foreach ($creators as $creator) {
         $indexingCreatorSet = $this->appendNewElement($indexingCreatorWrap, 'cdwalite:indexingCreatorSet');
         $nameCreatorSet = $this->appendNewElement($indexingCreatorSet, 'cdwalite:nameCreatorSet');
         $this->appendNewElement($nameCreatorSet, 'cdwalite:nameCreator', $creator);
         $this->appendNewElement($indexingCreatorSet, 'cdwalite:roleCreator', 'Unknown');
     }
     $materials = array($this->item['primaryMaterial'], $this->item['secondaryMaterial']);
     if (count($materials) == 0) {
         $materials[] = 'Unknown';
     }
     $indexingMaterialsTechWrap = $this->appendNewElement($descriptive, 'cdwalite:indexingMaterialsTechWrap');
     $displayMaterialsSet = $this->appendNewElement($indexingMaterialsTechWrap, 'cdwalite:indexingMaterialsTechSet');
     $termMaterialsTech = $this->appendNewElement($displayMaterialsSet, 'cdwalite:termMaterialsTech');
     foreach ($materials as $material) {
         if (!is_null($material)) {
             $this->appendNewElement($termMaterialsTech, 'cdwalite:termMaterialsTech', $material);
         }
     }
     /* Date => displayCreationDate
      * Required. Fill with 'Unknown' if omitted.
      * Non-repeatable, include only first date.
      */
     $dates = array($this->item['numdate1'], $this->item['numdate2']);
     $dateText = count($dates) > 0 ? $dates[0] : 'Unknown';
     $this->appendNewElement($descriptive, 'cdwalite:displayCreationDate', $dateText);
     /* Date => indexingDatesWrap->indexingDatesSet
      * Map to both earliest and latest date
      * Required.  Fill with 'Unknown' if omitted.
      */
     $indexingDatesWrap = $this->appendNewElement($descriptive, 'cdwalite:indexingDatesWrap');
     $indexingDatesSet = $this->appendNewElement($indexingDatesWrap, 'cdwalite:indexingDatesSet');
     $this->appendNewElement($indexingDatesSet, 'cdwalite:earliestDate', $dates['0']);
     $this->appendNewElement($indexingDatesSet, 'cdwalite:latestDate', $dates['1']);
     /* locationWrap->locationSet->locationName
      * Required. No corresponding metadata, fill with 'location unknown'.
      */
     $locationWrap = $this->appendNewElement($descriptive, 'cdwalite:locationWrap');
     $locationSet = $this->appendNewElement($locationWrap, 'cdwalite:locationSet');
     $this->appendNewElement($locationSet, 'cdwalite:locationName', 'location unknown');
     /* Description => descriptiveNoteWrap->descriptiveNoteSet->descriptiveNote
      * Not required.
      */
     $descriptions = array($this->item['description']);
     if (count($descriptions) > 0) {
         $descriptiveNoteWrap = $this->appendNewElement($descriptive, 'cdwalite:descriptiveNoteWrap');
         foreach ($descriptions as $description) {
             $descriptiveNoteSet = $this->appendNewElement($descriptiveNoteWrap, 'cdwalite:descriptiveNoteSet');
             $this->appendNewElement($descriptiveNoteSet, 'cdwalite:descriptiveNote', $this->_xmlEscape($description));
         }
     }
     /* =======================
      * ADMINISTRATIVE METADATA
      * =======================
      */
     $administrative = $this->appendNewElement($cdwalite, 'cdwalite:administrativeMetadata');
     /* Rights => rightsWork
      * Not required.
      */
     $rights = array('Creative Commons BY-SA');
     foreach ($rights as $right) {
         $this->appendNewElement($administrative, 'cdwalite:rightsWork', $right);
     }
     /* id => recordWrap->recordID
      * 'item' => recordWrap-recordType
      * Required.
      */
     $recordWrap = $this->appendNewElement($descriptive, 'cdwalite:recordWrap');
     $this->appendNewElement($recordWrap, 'cdwalite:recordID', $this->item['id']);
     $this->appendNewElement($recordWrap, 'cdwalite:recordType', 'item');
     $recordMetadataWrap = $this->appendNewElement($recordWrap, 'cdwalite:recordMetadataWrap');
     $recordInfoID = $this->appendNewElement($recordMetadataWrap, 'cdwalite:recordInfoID', Pas_OaiPmhRepository_OaiIdentifier::itemToOaiId($this->item['id']));
     $recordInfoID->setAttribute('type', 'oai');
 }
 /**
  * Responds to the ListMetadataFormats verb.
  *
  * Outputs records for all of the items in the database in the specified
  * metadata format.
  *
  * @todo extend for additional metadata formats
  */
 private function listMetadataFormats()
 {
     if (isset($this->query['identifier'])) {
         $identifier = $this->query['identifier'];
         $findItem = new Pas_OaiPmhRepository_OaiIdentifier();
         $itemId = $findItem->oaiIdToItem($identifier);
         if (!$itemId && !is_int($itemId)) {
             $this->throwError(self::OAI_ERR_ID_DOES_NOT_EXIST);
         }
         $solr = new Pas_OaiPmhRepository_SolrResponse();
         $item = $solr->getRecord($itemId);
         if (!$item['finds'][0]) {
             $this->throwError(self::OAI_ERR_ID_DOES_NOT_EXIST);
         }
     }
     if (!$this->_error) {
         $listMetadataFormats = $this->document->createElement('ListMetadataFormats');
         $this->document->documentElement->appendChild($listMetadataFormats);
         foreach ($this->metadataFormats as $format) {
             $method = $format;
             $formatObject = new $method(null, $listMetadataFormats);
             $formatObject->declareMetadataFormat();
         }
     }
 }