classes/oai/ocs/ConferenceOAI.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00021 //$Id$
00022 
00023 import('oai.OAI');
00024 import('oai.ocs.OAIDAO');
00025 
00026 class ConferenceOAI extends OAI {
00028    var $site;
00029 
00031    var $conference;
00032 
00034    var $conferenceId;
00035 
00037    var $dao;
00038 
00039 
00043    function ConferenceOAI($config) {
00044       parent::OAI($config);
00045 
00046       $this->site =& Request::getSite();
00047       $this->conference =& Request::getConference();
00048       $this->conferenceId = isset($this->conference) ? $this->conference->getId() : null;
00049       $this->dao =& DAORegistry::getDAO('OAIDAO');
00050       $this->dao->setOAI($this);
00051    }
00052 
00057    function getNonPathInfoParams() {
00058       return array('conference', 'schedConf', 'page');
00059    }
00060 
00066    function paperIdToIdentifier($paperId) {
00067       return 'oai:' . $this->config->repositoryId . ':' . 'paper/' . $paperId;
00068    }
00069 
00075    function identifierToPaperId($identifier) {
00076       $prefix = 'oai:' . $this->config->repositoryId . ':' . 'paper/';
00077       if (strstr($identifier, $prefix)) {
00078          return (int) str_replace($prefix, '', $identifier);
00079       } else {
00080          return false;
00081       }
00082    }
00083 
00088    function setSpecToTrackId($setSpec, $conferenceId = null) {
00089       $tmpArray = split(':', $setSpec);
00090       if (count($tmpArray) == 1) {
00091          list($conferenceSpec) = $tmpArray;
00092          $trackSpec = null;
00093       } else if (count($tmpArray) == 3) {
00094          list($conferenceSpec, $schedConfSpec, $trackSpec) = $tmpArray;
00095       } else {
00096          return array(0, 0);
00097       }
00098       return $this->dao->getSetConferenceTrackId($conferenceSpec, $schedConfSpec, $trackSpec, $this->conferenceId);
00099    }
00100 
00101 
00102    //
00103    // OAI interface functions
00104    //
00105 
00109    function &repositoryInfo() {
00110       $info = new OAIRepository();
00111 
00112       if (isset($this->conference)) {
00113          $info->repositoryName = $this->conference->getConferenceTitle();
00114          $info->adminEmail = $this->conference->getSetting('contactEmail');
00115 
00116       } else {
00117          $info->repositoryName = $this->site->getLocalizedTitle();
00118          $info->adminEmail = $this->site->getLocalizedContactEmail();
00119       }
00120 
00121       $info->sampleIdentifier = $this->paperIdToIdentifier(1);
00122       $info->earliestDatestamp = $this->dao->getEarliestDatestamp($this->conferenceId);
00123 
00124       return $info;
00125    }
00126 
00130    function validIdentifier($identifier) {
00131       return $this->identifierToPaperId($identifier) !== false;
00132    }
00133 
00137    function identifierExists($identifier) {
00138       $recordExists = false;
00139       $paperId = $this->identifierToPaperId($identifier);
00140       if ($paperId) {
00141          $recordExists = $this->dao->recordExists($paperId, $this->conferenceId);
00142       }
00143       return $recordExists;
00144    }
00145 
00149    function &record($identifier) {
00150       $paperId = $this->identifierToPaperId($identifier);
00151       if ($paperId) {
00152          $record =& $this->dao->getRecord($paperId, $this->conferenceId);
00153       }
00154       if (!isset($record)) {
00155          $record = false;
00156       }
00157       return $record;      
00158    }
00159 
00163    function &records($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) {
00164       if (isset($set)) {
00165          list($conferenceId, $schedConfId, $trackId) = $this->setSpecToTrackId($set);
00166       } else {
00167          $conferenceId = $this->conferenceId;
00168          $trackId = null;
00169          $schedConfId = null;
00170       }
00171       $records =& $this->dao->getRecords($conferenceId, $schedConfId, $trackId, $from, $until, $offset, $limit, $total);
00172       return $records;
00173    }
00174 
00178    function &identifiers($metadataPrefix, $from, $until, $set, $offset, $limit, &$total) {
00179       $trackId = null;
00180       if (isset($set)) {
00181          list($conferenceId, $schedConfId, $trackId) = $this->setSpecToTrackId($set);
00182       } else {
00183          $conferenceId = $this->conferenceId;
00184       }
00185       $records =& $this->dao->getIdentifiers($conferenceId, $schedConfId, $trackId, $from, $until, $offset, $limit, $total);
00186       return $records;
00187    }
00188 
00192    function &sets($offset, &$total) {
00193       $sets =& $this->dao->getConferenceSets($this->conferenceId, $offset, $total);
00194       return $sets;
00195    }
00196 
00200    function &resumptionToken($tokenId) {
00201       $this->dao->clearTokens();
00202       $token = $this->dao->getToken($tokenId);
00203       if (!isset($token)) {
00204          $token = false;
00205       }
00206       return $token;
00207    }
00208 
00212    function &saveResumptionToken($offset, $params) {
00213       $token = new OAIResumptionToken(null, $offset, $params, time() + $this->config->tokenLifetime);
00214       $this->dao->insertToken($token);
00215       return $token;
00216    }
00217 }
00218 
00219 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7