db = $obj_db;
}
/**
* Menampilkan seluruh ID (Identifiers) record/dokumen yang ada repositori
*/
public function ListIdentifiers($metadataPrefix = 'oai_dc') {
global $sysconf;
$resumptionToken = array();
$offset = 0;
$where = '';
if (isset($_GET['resumptionToken'])) {
echo 'resumption';
parse_str($_GET['resumptionToken'], $resumptionToken);
if (isset($resumptionToken['offset'])) {
$offset = (integer)$resumptionToken['offset'];
}
if (isset($resumptionToken['metadataPrefix'])) {
$metadataPrefix = $resumptionToken['metadataPrefix'];
}
}
// total query
$num_rec_q = $this->db->query("SELECT COUNT(*) FROM biblio $where");
$num_data = $num_rec_q->fetch_row();
$completeListSize = $num_data[0];
$rec_q = $this->db->query("SELECT biblio_id, last_update FROM biblio $where
ORDER BY biblio_id DESC LIMIT ".$sysconf['OAI']['ListRecords']['RecordPerSet']." OFFSET $offset");
ob_start();
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo "\n";
// mulai iterasi record
while ($rec_data = $rec_q->fetch_assoc()) {
echo "\n".$sysconf['OAI']['identifierPrefix'].$rec_data['biblio_id']."".$rec_data['last_update']."\n";
}
// resumptionToken
if ($completeListSize > $sysconf['OAI']['ListRecords']['RecordPerSet']) {
$next_offset = $offset+$sysconf['OAI']['ListRecords']['RecordPerSet'];
if ($next_offset < $completeListSize) {
echo ''.urlencode("offset=$next_offset").''."\n";
}
}
echo "\n";
$ListIdentifiers = ob_get_clean();
return $ListIdentifiers;
}
/**
* Menampilkan seluruh Set/Kategori yang ada pada repositori
*/
public function ListSets() {
global $sysconf;
$resumptionToken = array();
$offset = 0;
$where = '';
if (isset($_GET['resumptionToken'])) {
echo 'resumption';
parse_str($_GET['resumptionToken'], $resumptionToken);
if (isset($resumptionToken['offset'])) {
$offset = (integer)$resumptionToken['offset'];
}
if (isset($resumptionToken['metadataPrefix'])) {
$metadataPrefix = $resumptionToken['metadataPrefix'];
}
}
// total query
$num_rec_q = $this->db->query("SELECT COUNT(*) FROM mst_topic $where");
$num_data = $num_rec_q->fetch_row();
$completeListSize = $num_data[0];
$set_q = $this->db->query("SELECT * FROM mst_topic $where ORDER BY topic ASC LIMIT ".$sysconf['OAI']['ListRecords']['RecordPerSet']." OFFSET $offset");
ob_start();
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo "\n";
// mulai iterasi record
while ($set_data = $set_q->fetch_assoc()) {
echo "\n".
"".$set_data['topic_id']."\n".
"Subject = ".$set_data['topic']."\n".
"\n";
}
// resumptionToken
if ($completeListSize > $sysconf['OAI']['ListRecords']['RecordPerSet']) {
$next_offset = $offset+$sysconf['OAI']['ListRecords']['RecordPerSet'];
if ($next_offset < $completeListSize) {
echo ''.urlencode("offset=$next_offset").''."\n";
}
}
echo "\n";
$ListSets = ob_get_clean();
return $ListSets;
}
/**
* Menampilkan seluruh Deskripsi Record pada repositori
*/
public function ListRecords($metadataPrefix = 'oai_dc') {
global $sysconf;
$resumptionToken = array();
$offset = 0;
$where = '';
if (isset($_GET['resumptionToken'])) {
echo 'resumption';
parse_str($_GET['resumptionToken'], $resumptionToken);
if (isset($resumptionToken['offset'])) {
$offset = (integer)$resumptionToken['offset'];
}
if (isset($resumptionToken['metadataPrefix'])) {
$metadataPrefix = $resumptionToken['metadataPrefix'];
}
}
// total query
$num_rec_q = $this->db->query("SELECT COUNT(*) FROM biblio $where");
$num_data = $num_rec_q->fetch_row();
$completeListSize = $num_data[0];
$rec_q = $this->db->query("SELECT biblio_id FROM biblio $where ORDER BY biblio_id DESC LIMIT ".$sysconf['OAI']['ListRecords']['RecordPerSet']." OFFSET $offset");
ob_start();
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo "\n";
// mulai iterasi record
while ($rec_data = $rec_q->fetch_row()) {
echo $this->outputRecordXML($rec_data[0], $metadataPrefix);
}
// resumptionToken
if ($completeListSize > $sysconf['OAI']['ListRecords']['RecordPerSet']) {
$next_offset = $offset+$sysconf['OAI']['ListRecords']['RecordPerSet'];
if ($next_offset < $completeListSize) {
echo ''.urlencode("offset=$next_offset&metadataPrefix=$metadataPrefix").''."\n";
}
}
echo "\n";
$ListRecords = ob_get_clean();
return $ListRecords;
}
/**
* Menampilkan data sebuah record pada repositori
*/
public function GetRecord($recordID, $metadataPrefix = 'oai_dc') {
global $sysconf;
ob_start();
// check record ID
/*
if (strpos($recordID, $sysconf['OAI']['identifierPrefix']) !== true) {
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo 'No matching identifier in our Repository';
return ob_get_clean();
}
*/
$recordID = str_ireplace($sysconf['OAI']['identifierPrefix'], '', $recordID);
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo "\n";
echo $this->outputRecordXML($recordID, $metadataPrefix);
echo "\n";
$GetRecord = ob_get_clean();
return $GetRecord;
}
/**
* Menampilkan data mengenai repository ini
*/
public function Identify() {
global $sysconf;
$earliestDatestamp = '';
ob_start();
echo ''.$sysconf['OAI']['Identify']['baseURL'].''."\n";
?>
2.0
'.$sysconf['OAI']['Identify']['baseURL'].''."\n";
echo "\n";
// query ke database
foreach ($sysconf['OAI']['MetadataFormats'] as $metadataformat) {
echo "\n";
echo "".$metadataformat['oai_prefix']."\n".
"".$metadataformat['schema_xsd']."\n".
"".$metadataformat['namespace']."\n";
}
echo "\n";
echo "\n";
$ListMetadataFormats = ob_get_clean();
return $ListMetadataFormats;
}
/**
* Menampilkan detil record metadata dalam bentuk XML
*
* @param mixed $recordID: ID atau Identifier OAI dari record
* @param string $metadataPrefix: Prefix dari skema metadata yang diinginkan
* @param boolean $headerOnly: tampilkan hanya header dari record XML OAI
*
*/
protected function outputRecordXML($recordID, $metadataPrefix = 'oai_dc') {
global $sysconf;
// berikut adalah entitas yang dilarang oleh XML, tambahkan dalam array apabila diperlukan
$xmlForbiddenSymbols = array('Â', 'Ã', '¶',
'¸', '©', '', '£', '±',
'®', '§', '·', '¡');
// ambil detail record
if ($metadataPrefix == 'oai_dc') {
$detail = new detail($this->db, $recordID, 'dc');
$rec_detail = $detail->DublinCoreOutput();
}
// mulai output XML
ob_start();
echo ''
."".$sysconf['OAI']['identifierPrefix'].$recordID."";
echo "";
if ($metadataPrefix == 'oai_dc') {
echo '';
}
echo $rec_detail;
if ($metadataPrefix == 'oai_dc') {
echo '';
}
echo "\n";
echo "\n";
$recordXML = ob_get_clean();
return $recordXML;
}
}