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 = '';
$metadataPrefix = 'oai_dc';
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'];
}
} else {
if (isset($_GET['offset'])) {
$offset = (integer)$_GET['offset'];
}
if (isset($_GET['metadataPrefix'])) {
$metadataPrefix = $_GET['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 = '';
$metadataPrefix = 'oai_dc';
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'];
}
} else {
if (isset($_GET['offset'])) {
$offset = (integer)$_GET['offset'];
}
if (isset($_GET['metadataPrefix'])) {
$metadataPrefix = $_GET['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;
$from = null;
$until = null;
$where = '';
$metadataPrefix = 'oai_dc';
if (isset($_GET['resumptionToken'])) {
$elm = explode('__', $_GET['resumptionToken']);
if (isset($elm[0]) && stripos($elm[0], 'offset', 0) !== false) {
$offset = (integer)str_ireplace('offset:', '', $elm[0]);
}
if (isset($elm[1]) && stripos($elm[1], 'metadataPrefix', 0) !== false) {
$metadataPrefix = str_ireplace('metadataPrefix:', '', $elm[1]);
}
// echo 'resumption';
/*
parse_str($_GET['resumptionToken'], $resumptionToken);
if (isset($resumptionToken['offset'])) {
$offset = (integer)$resumptionToken['offset'];
}
if (isset($resumptionToken['metadataPrefix'])) {
$metadataPrefix = $resumptionToken['metadataPrefix'];
}
*/
} else {
if (isset($_GET['offset'])) {
$offset = (integer)$_GET['offset'];
}
if (isset($_GET['metadataPrefix'])) {
$metadataPrefix = $_GET['metadataPrefix'];
}
}
if (isset($_GET['from'])) {
$from = $this->db->escape_string($_GET['from']);
$date = date_create($from);
$from_date = $date->format('Y-m-d H:i:s');
}
if (isset($_GET['from']) && isset($_GET['until'])) {
$until = $this->db->escape_string($_GET['until']);
$date = date_create($until);
$until_date = $date->format('Y-m-d H:i:s');
}
if ($from && $until) {
$where = "WHERE input_date >= '$from_date' AND input_date <= '$until_date'";
}
// 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 '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;
}
}