/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { $sets = $this->_application->getSets(); if (!count($sets)) { $this->_application->setError('noSetHierarchy'); } else { $metadataFormat = $this->_application->getMetadataFormat(); $output = '<ListSets>'; foreach ($sets as $v) { $setClass = org_glizy_ObjectFactory::createObject($v); if ($setClass) { $info = $setClass->getSetInfo(); $output .= '<set>'; $output .= '<setSpec>' . org_glizy_oaipmh_OaiPmh::encode($info['setSpec']) . '</setSpec>'; $output .= '<setName>' . org_glizy_oaipmh_OaiPmh::encode($info['setName']) . '</setName>'; if (!empty($info['setDescription'])) { $output .= '<setDescription>'; $output .= org_glizy_oaipmh_OaiPmh::openMetadataHeader($metadataFormat['oai_dc']); $output .= '<dc:description>' . org_glizy_oaipmh_OaiPmh::encode($info['setDescription']) . '</dc:description>'; $output .= '<dc:creator>' . org_glizy_oaipmh_OaiPmh::encode($info['setCreator']) . '</dc:creator>'; $output .= org_glizy_oaipmh_OaiPmh::closeMetadataHeader($metadataFormat['oai_dc']); $output .= '</setDescription>'; } $output .= '</set>'; } } $output .= '</ListSets>'; $this->addOutputCode($output); } }
/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { $output = '<Identify>'; $output .= '<repositoryName>' . org_glizy_oaipmh_OaiPmh::encode(__Config::get('oaipmh.title')) . '</repositoryName>'; $output .= '<baseURL>' . org_glizy_oaipmh_OaiPmh::encode(GLZ_HOST) . '</baseURL>'; $output .= '<protocolVersion>' . org_glizy_oaipmh_OaiPmh::encode(__Config::get('oaipmh.protocolVersion')) . '</protocolVersion>'; $output .= '<adminEmail>' . org_glizy_oaipmh_OaiPmh::encode(__Config::get('oaipmh.adminEmail')) . '</adminEmail>'; $output .= '<earliestDatestamp>' . org_glizy_oaipmh_OaiPmh::encode(__Config::get('oaipmh.earliestDatestamp')) . '</earliestDatestamp>'; $output .= '<deletedRecord>no</deletedRecord>'; $output .= '<granularity>' . org_glizy_oaipmh_OaiPmh::encode(__Config::get('oaipmh.granularity')) . '</granularity>'; $output .= '</Identify>'; $this->addOutputCode($output); }
/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { $metadataFormat = $this->_application->getMetadataFormat(); $output = '<ListMetadataFormats>'; foreach ($metadataFormat as $v) { $output .= '<metadataFormat>'; $output .= '<metadataPrefix>' . org_glizy_oaipmh_OaiPmh::encode($v['prefix']) . '</metadataPrefix>'; $output .= '<schema>' . org_glizy_oaipmh_OaiPmh::encode($v['schema']) . '</schema>'; $output .= '<metadataNamespace>' . org_glizy_oaipmh_OaiPmh::encode($v['namespace']) . '</metadataNamespace>'; $output .= '</metadataFormat>'; } $output .= '</ListMetadataFormats>'; $this->addOutputCode($output); }
/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { $from = ''; $until = ''; $set = ''; $limitStart = 0; if (__Request::exists('resumptionToken')) { if (!__Request::exists('from') && !__Request::exists('until') && !__Request::exists('set') && !__Request::exists('metadataPrefix')) { // TODO controllare la data di scadenza del token $tokenId = __Request::get('resumptionToken'); $fileName = __Paths::get('CACHE') . $tokenId; if (file_exists($fileName)) { $info = unserialize(file_get_contents($fileName)); $limitStart = $info['limitEnd']; $filters = $info['filters']; $metadataPrefix = $info['metadataPrefix']; } else { $this->_application->setError('badResumptionToken', '', $tokenId); return; } } else { $this->_application->setError('exclusiveArgument'); return; } } else { // controlla i parametri ricevuti if (__Request::exists('from')) { $from = __Request::get('from'); if (!org_glizy_oaipmh_OaiPmh::checkDateFormat($from)) { $this->_application->setError('badGranularity', 'from', $from); return; } } if (__Request::exists('until')) { $until = __Request::get('until'); if (!org_glizy_oaipmh_OaiPmh::checkDateFormat($until)) { $this->_application->setError('badGranularity', 'until', $until); return; } } if (__Request::exists('set')) { $set = __Request::get('set'); } if (__Request::exists('metadataPrefix')) { $metadataPrefix = __Request::get('metadataPrefix'); } else { $this->_application->setError('missingArgument', 'metadataPrefix'); return; } $filters = array(); if ($from) { $filters[] = 'picoqueue_date >= ' . org_glizy_dataAccess_DataAccess::qstr($from); } if ($until) { $filters[] = 'picoqueue_date <= ' . org_glizy_dataAccess_DataAccess::qstr($until); } if ($set) { $filters[] = 'picoqueue_recordModule = ' . org_glizy_dataAccess_DataAccess::qstr($set); } } $metadata = $this->_application->getMetadataFormat(); if (isset($metadata[$metadataPrefix])) { // TODO //$inc_record = $metadata[$metadataPrefix]['myhandler']; } else { $this->_application->setError('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix); return; } $limitLength = __Config::get('oaipmh.maxRecords'); $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.oaipmh.models.PicoQueue', 'all', array('filters' => $filters, 'limit' => array($limitStart, $limitLength), 'numRows' => true)); $num_rows = $it->count(); if ($num_rows > 0) { $oaiPrefix = __Config::get('oaipmh.oaiPrefix'); $countrec = 0; $output = '<ListRecords>'; $output .= org_glizy_oaipmh_OaiPmh::createResumptionToken('ListRecords', array('numRows' => $num_rows, 'limitStart' => $limitStart, 'limitEnd' => $limitStart + $limitLength, 'filters' => $filters, 'metadataPrefix' => $metadataPrefix)); while ($it->hasMore()) { $countrec++; $arC = $it->current(); $it->next(); $setClass = org_glizy_ObjectFactory::createObject($arC->picoqueue_recordModule, $this->_application); if (is_null($setClass)) { continue; } $setClass->loadRecord($arC->picoqueue_recordId); $identifier = $oaiPrefix . $arC->picoqueue_identifier; $datestamp = org_glizy_oaipmh_OaiPmh::formatDatestamp($arC->picoqueue_date); $status_deleted = $arC->picoqueue_action == 'delete' ? true : false; $output .= '<record>'; $output .= '<header'; if ($status_deleted) { $output .= ' status="deleted"'; } $output .= '>'; // use xmlrecord since we use stuff from database $output .= '<identifier>' . org_glizy_oaipmh_OaiPmh::encode($identifier) . '</identifier>'; $output .= '<datestamp>' . org_glizy_oaipmh_OaiPmh::encode($datestamp) . '</datestamp>'; if (!$status_deleted) { $output .= '<setSpec>' . org_glizy_oaipmh_OaiPmh::encode($arC->picoqueue_recordModule) . '</setSpec>'; } $output .= '</header>'; $output .= '<metadata>'; $output .= $setClass->getRecord($identifier); $output .= '</metadata>'; $output .= '</record>'; } $output .= '</ListRecords>'; $this->addOutputCode($output); } else { $this->_application->setError('noRecordsMatch'); } }
function setError($code, $argument = '', $value = '') { switch ($code) { case 'badArgument': $text = "The argument '{$argument}' (value='{$value}') included in the request is not valid."; break; case 'badGranularity': $text = "The value '{$value}' of the argument '{$argument}' is not valid."; // $code = 'badArgument'; break; case 'badResumptionToken': $text = "The resumptionToken '{$value}' does not exist or has already expired."; break; case 'badRequestMethod': $text = "The request method '{$argument}' is unknown."; // $code = 'badVerb'; break; case 'badVerb': $text = "The verb '{$argument}' provided in the request is illegal."; break; case 'cannotDisseminateFormat': $text = "The metadata format '{$value}' given by {$argument} is not supported by this repository."; break; case 'exclusiveArgument': $text = 'The usage of resumptionToken as an argument allows no other arguments.'; // $code = 'badArgument'; break; case 'idDoesNotExist': $text = "The value '{$value}' of the identifier is illegal for this repository."; //if (!is_valid_url($value)) { $code = 'badArgument'; //} break; case 'missingArgument': $text = "The required argument '{$argument}' is missing in the request."; // $code = 'badArgument'; break; case 'noRecordsMatch': $text = 'The combination of the given values results in an empty list.'; break; case 'noMetadataFormats': $text = 'There are no metadata formats available for the specified item.'; break; case 'noVerb': $text = 'The request does not provide any verb.'; // $code = 'badVerb'; break; case 'noSetHierarchy': $text = 'This repository does not support sets.'; break; case 'sameArgument': $text = 'Do not use them same argument more than once.'; // $code = 'badArgument'; break; case 'sameVerb': $text = 'Do not use verb more than once.'; // $code = 'badVerb'; break; default: $text = "Unknown error: code: '{$code}', argument: '{$argument}', value: '{$value}'"; $code = 'badArgument'; } $this->error = ' <error code="' . org_glizy_oaipmh_OaiPmh::encode($code) . '">' . org_glizy_oaipmh_OaiPmh::encode($text) . "</error>"; }
/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { if (__Request::exists('identifier')) { $identifier = __Request::get('identifier'); if (!org_glizy_oaipmh_OaiPmh::is_valid_uri($identifier)) { $this->_application->setError('badArgument', 'identifier', $identifier); return; } } else { $this->_application->setError('missingArgument', 'identifier'); return; } if (__Request::exists('metadataPrefix')) { $metadataPrefix = __Request::get('metadataPrefix'); $metadata = $this->_application->getMetadataFormat(); if (isset($metadata[$metadataPrefix])) { //TODO //$inc_record = $metadata[$metadataPrefix]['myhandler']; } else { $this->_application->setError('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix); return; } } else { $this->_application->setError('missingArgument', 'metadataPrefix'); return; } $id = str_replace(__Config::get('oaipmh.oaiPrefix'), '', $identifier); if ($id == '') { $this->_application->setError('idDoesNotExist', '', $identifier); return; } $this->loadeRecord($id); if ($this->arPico && $this->setClass) { if ($this->setClass->loadRecord($this->arPico->picoqueue_recordId)) { $output = '<GetRecord>'; $output .= '<record>'; // header $datestamp = org_glizy_oaipmh_OaiPmh::formatDatestamp($this->arPico->picoqueue_date); $status_deleted = $this->arPico->picoqueue_action == 'delete' ? true : false; $output .= '<header' . ($status_deleted ? ' status="deleted"' : '') . '>'; $output .= '<identifier>' . org_glizy_oaipmh_OaiPmh::encode($identifier) . '</identifier>'; $output .= '<datestamp>' . org_glizy_oaipmh_OaiPmh::encode($datestamp) . '</datestamp>'; if (!$status_deleted) { $output .= '<setSpec>' . org_glizy_oaipmh_OaiPmh::encode($this->arPico->picoqueue_recordModule) . '</setSpec>'; } $output .= '</header>'; $output .= '<metadata>'; $output .= $this->setClass->getRecord($identifier); $output .= '</metadata>'; $output .= '</record>'; $output .= '</GetRecord>'; $this->addOutputCode($output); } else { $this->_application->setError('idDoesNotExist', '', $identifier); return; } } else { $this->_application->setError('idDoesNotExist', '', $identifier); return; } }