Ejemplo n.º 1
0
 /**
  * Implements response for OAI-PMH verb 'ListSets'.
  *
  * @param  array &$oaiRequest Contains full request information
  * @return void
  */
 private function __handleListSets()
 {
     $repIdentifier = $this->_configuration->getRepositoryIdentifier();
     $this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
     $this->_xml->appendChild($this->_xml->createElement('Documents'));
     $sets = array('bibliography:true' => 'Set for bibliographic entries', 'bibliography:false' => 'Set for non-bibliographic entries');
     $logger = $this->getLogger();
     $setSpecPattern = '[A-Za-z0-9\\-_\\.!~\\*\'\\(\\)]+';
     $finder = new Opus_DocumentFinder();
     $finder->setServerState('published');
     foreach ($finder->groupedTypesPlusCount() as $doctype => $row) {
         if (0 == preg_match("/^{$setSpecPattern}\$/", $doctype)) {
             $msg = "Invalid SetSpec (doctype='" . $doctype . "')." . " Allowed characters are [{$setSpecPattern}].";
             $logger->err("OAI-PMH: {$msg}");
             continue;
         }
         $setSpec = 'doc-type:' . $doctype;
         // $count = $row['count'];
         $sets[$setSpec] = "Set for document type '{$doctype}'";
     }
     $oaiRolesSets = Opus_CollectionRole::fetchAllOaiEnabledRoles();
     foreach ($oaiRolesSets as $result) {
         if ($result['oai_name'] == 'doc-type') {
             continue;
         }
         if (0 == preg_match("/^{$setSpecPattern}\$/", $result['oai_name'])) {
             $msg = "Invalid SetSpec (oai_name='" . $result['oai_name'] . "'). " . " Please check collection role " . $result['id'] . ". " . " Allowed characters are {$setSpecPattern}.";
             $logger->err("OAI-PMH: {$msg}");
             continue;
         }
         $setSpec = $result['oai_name'];
         // $count = $result['count'];
         $sets[$setSpec] = "Set for collection '" . $result['oai_name'] . "'";
         $role = new Opus_CollectionRole($result['id']);
         foreach ($role->getOaiSetNames() as $subset) {
             $subSetSpec = "{$setSpec}:" . $subset['oai_subset'];
             // $subSetCount = $subset['count'];
             if (0 == preg_match("/^{$setSpecPattern}\$/", $subset['oai_subset'])) {
                 $msg = "Invalid SetSpec (oai_name='" . $subset['oai_subset'] . "')." . " Please check collection " . $subset['id'] . ". " . " Allowed characters are [{$setSpecPattern}].";
                 $logger->err("OAI-PMH: {$msg}");
                 continue;
             }
             $sets[$subSetSpec] = "Subset '" . $subset['oai_subset'] . "'" . " for collection '" . $result['oai_name'] . "'" . ': "' . trim($subset['name']) . '"';
         }
     }
     foreach ($sets as $type => $name) {
         $opusDoc = $this->_xml->createElement('Opus_Sets');
         $typeAttr = $this->_xml->createAttribute('Type');
         $typeValue = $this->_xml->createTextNode($type);
         $typeAttr->appendChild($typeValue);
         $opusDoc->appendChild($typeAttr);
         $nameAttr = $this->_xml->createAttribute('TypeName');
         $nameValue = $this->_xml->createTextNode($name);
         $nameAttr->appendChild($nameValue);
         $opusDoc->appendChild($nameAttr);
         $this->_xml->documentElement->appendChild($opusDoc);
     }
 }