site = &Request::getSite(); $this->conference = &Request::getConference(); $this->conferenceId = isset($this->conference) ? $this->conference->getConferenceId() : null; $this->dao = &DAORegistry::getDAO('OAIDAO'); $this->dao->setOAI($this); } /** * Convert paper ID to OAI identifier. * @param $paperId int * @return string */ function paperIdToIdentifier($paperId) { return 'oai:' . $this->config->repositoryId . ':' . 'paper/' . $paperId; } /** * Convert OAI identifier to paper ID. * @param $identifier string * @return int */ function identifierToPaperId($identifier) { $prefix = 'oai:' . $this->config->repositoryId . ':' . 'paper/'; if (strstr($identifier, $prefix)) { return (int) str_replace($prefix, '', $identifier); } else { return false; } } /** * Get the conference ID and track ID corresponding to a set specifier. * @return int */ function setSpecToTrackId($setSpec, $conferenceId = null) { $tmpArray = split(':', $setSpec); if (count($tmpArray) == 1) { list($conferenceSpec) = $tmpArray; $trackSpec = null; } else if (count($tmpArray) == 2) { list($conferenceSpec, $trackSpec) = $tmpArray; } else { return array(0, 0); } return $this->dao->getSetConferenceTrackId($conferenceSpec, $trackSpec, $this->conferenceId); } // // OAI interface functions // /** * @see OAI#repositoryInfo */ function &repositoryInfo() { $info = &new OAIRepository(); if (isset($this->conference)) { $info->repositoryName = $this->conference->getConferenceTitle(); $info->adminEmail = $this->conference->getSetting('contactEmail'); } else { $info->repositoryName = $this->site->getSiteTitle(); $info->adminEmail = $this->site->getSiteContactEmail(); } $info->sampleIdentifier = $this->paperIdToIdentifier(1); $info->earliestDatestamp = $this->dao->getEarliestDatestamp($this->conferenceId); return $info; } /** * @see OAI#validIdentifier */ function validIdentifier($identifier) { return $this->identifierToPaperId($identifier) !== false; } /** * @see OAI#identifierExists */ function identifierExists($identifier) { $recordExists = false; $paperId = $this->identifierToPaperId($identifier); if ($paperId) { $recordExists = $this->dao->recordExists($paperId, $this->conferenceId); } return $recordExists; } /** * @see OAI#record */ function &record($identifier) { $paperId = $this->identifierToPaperId($identifier); if ($paperId) { $record = &$this->dao->getRecord($paperId, $this->conferenceId); } if (!isset($record)) { $record = false; } return $record; } /** * @see OAI#records */ function &records($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) { $trackId = null; if (isset($set)) { list($conferenceId, $trackId) = $this->setSpecToTrackId($set); } else { $conferenceId = $this->conferenceId; } $records = &$this->dao->getRecords($conferenceId, $trackId, $from, $until, $offset, $limit, $total); return $records; } /** * @see OAI#identifiers */ function &identifiers($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) { $trackId = null; if (isset($set)) { list($conferenceId, $trackId) = $this->setSpecToTrackId($set); } else { $conferenceId = $this->conferenceId; } $records = &$this->dao->getIdentifiers($conferenceId, $trackId, $from, $until, $offset, $limit, $total); return $records; } /** * @see OAI#sets */ function &sets($offset, &$total) { $sets = &$this->dao->getConferenceSets($this->conferenceId, $offset, $total); return $sets; } /** * @see OAI#resumptionToken */ function &resumptionToken($tokenId) { $this->dao->clearTokens(); $token = $this->dao->getToken($tokenId); if (!isset($token)) { $token = false; } return $token; } /** * @see OAI#saveResumptionToken */ function &saveResumptionToken($offset, $params) { $token = &new OAIResumptionToken(null, $offset, $params, time() + $this->config->tokenLifetime); $this->dao->insertToken($token); return $token; } } ?>