output_format = trim($str_output_format);
} else { $this->output_format = $str_output_format; }
$this->db = $dbs;
$this->detail_id = $int_detail_id;
$this->biblio = new Biblio($this->db, $int_detail_id);
$this->record_detail = $this->biblio->detail();
$this->record_title = $this->record_detail['title'];
$this->notes = $this->record_detail['notes'];
$this->subjects = $this->record_detail['subjects'];
}
public function setTemplate($str_template_path)
{
$this->template = $str_template_path;
}
/**
* Method to print out the document detail based on template
*
* @return void
*/
public function showDetail()
{
global $sysconf;
if ($this->error) {
return '
Error Fetching data for record detail. Server return error message: '.$this->error.'
';
} else {
if ($this->output_format == 'html') {
ob_start();
$detail = $this->htmlOutput();
extract($detail, EXTR_OVERWRITE);
include $this->template;
$detail_html = ob_get_clean();
return $detail_html;
} else if ($this->output_format == 'mods') {
return $this->MODSoutput();
} else if ($this->output_format == 'json-ld') {
return $this->JSONLDoutput();
} else {
// external output function
if (function_exists($this->output_format)) {
$_ext_func = $this->output_format;
return $_ext_func();
}
return null;
}
}
}
/**
* Method to get file attachments information of biblio
*
* @param boolean $bool_return_raw
*
* @return mix
*/
public function getAttachments() {
$_output = '';
$_output .= '';
if (!$this->record_detail['attachments']) {
return false;
}
foreach ($this->record_detail['attachments'] as $attachment_d) {
// check member type privileges
if ($attachment_d['access_limit']) {
if (utility::isMemberLogin()) {
$allowed_mem_types = @unserialize($attachment_d['access_limit']);
if (!in_array($_SESSION['m_member_type_id'], $allowed_mem_types)) {
continue;
}
} else {
continue;
}
}
#if (preg_match('@(video|audio|image)/.+@i', $attachment_d['mime_type'])) {
if ($attachment_d['mime_type'] == 'application/pdf') {
$_output .= '';
$_output .= ''.$attachment_d['file_desc'].'
';
if (trim($attachment_d['file_url']) != '') { $_output .= ''; }
$_output .= ' ';
} else if (preg_match('@(video)/.+@i', $attachment_d['mime_type'])) {
$_output .= ''
.'';
$_output .= ''.$attachment_d['file_desc'].'
';
if (trim($attachment_d['file_url']) != '') { $_output .= ''; }
$_output .= ' ';
} else if (preg_match('@(audio)/.+@i', $attachment_d['mime_type'])) {
$_output .= ''
.'';
$_output .= ''.$attachment_d['file_desc'].'
';
if (trim($attachment_d['file_url']) != '') { $_output .= ''; }
$_output .= ' ';
} else if ($attachment_d['mime_type'] == 'text/uri-list') {
$_output .= ''.$attachment_d['file_title'].' '.$attachment_d['file_desc'].'
';
} else if (preg_match('@(image)/.+@i', $attachment_d['mime_type'])) {
$file_loc = REPOBS.'/'.$attachment_d['file_dir'].'/'.$attachment_d['file_name'];
$imgsize = GetImageSize($file_loc);
$imgwidth = $imgsize[0] + 16;
if ($imgwidth > 600) {
$imgwidth = 600;
}
$imgheight = $imgsize[1] + 16;
if ($imgheight > 400) {
$imgheight = 400;
}
$_output .= '';
if (trim($attachment_d['file_url']) != '') { $_output .= ' [Other Resource Link ]'; }
$_output .= ''.$attachment_d['file_desc'].'
';
} else {
$_output .= ''.$attachment_d['file_title'].' ';
if (trim($attachment_d['file_url']) != '') { $_output .= ' [Other Resource Link ]'; }
$_output .= ''.$attachment_d['file_desc'].'
';
}
}
$_output .= ' ';
return $_output;
}
/**
* Method to get items/copies information of biblio
*
*
* @return string
*/
public function getItemCopy() {
global $sysconf;
$_output = '';
$copies = $this->record_detail['copies'];
if (!$copies) {
return false;
}
$_output = '';
foreach ($copies as $copy_d) {
// check if this collection is on loan
$loan_stat_q = $this->db->query('SELECT due_date FROM loan AS l
LEFT JOIN item AS i ON l.item_code=i.item_code
WHERE l.item_code=\''.$copy_d['item_code'].'\' AND is_lent=1 AND is_return=0');
$_output .= '';
$_output .= ''.$copy_d['item_code'].' ';
$_output .= ''.$copy_d['call_number'].' ';
$_output .= ''.$copy_d['location_name'];
if (trim($copy_d['site']) != "") {
$_output .= ' ('.$copy_d['site'].')';
}
$_output .= ' ';
$_output .= '';
if ($loan_stat_q->num_rows > 0) {
$loan_stat_d = $loan_stat_q->fetch_row();
$_output .= ''.__('Currently On Loan (Due on').date($sysconf['date_format'], strtotime($loan_stat_d[0])).') '; //mfc
} else if ($copy_d['no_loan']) {
$_output .= ''.__('Available but not for loan').' - '.$copy_d['item_status_name'].' ';
} else {
$_output .= ''.__('Available').(trim($copy_d['item_status_name'])?' - '.$copy_d['item_status_name']:'').' ';
}
$loan_stat_q->free_result();
$_output .= ' ';
$_output .= ' ';
}
$_output .= '
';
return $_output;
}
/**
* Method to get other version of biblio
*
* @return string
*/
public function getRelatedBiblio() {
$_output = '';
$_output .= '';
$_output .= ''.__('Title').' ';
$_output .= ''.__('Edition').' ';
$_output .= ''.__('Language').' ';
$_output .= ' ';
// get parent id
$parent_q = $this->db->query(sprintf('SELECT b.biblio_id, title, edition, language_id
FROM biblio_relation AS br INNER JOIN biblio AS b ON br.biblio_id=b.biblio_id
WHERE rel_biblio_id=%d', $this->detail_id));
$parent_d = $parent_q->fetch_assoc();
if ($parent_d) {
$_output .= '';
$_output .= ''.$parent_d['title'].' ';
$_output .= ''.$parent_d['edition'].' ';
$_output .= ''.$parent_d['language_id'].' ';
$_output .= ' ';
}
// check related data
$rel_q = $this->db->query(sprintf('SELECT b.biblio_id, title, edition, language_id FROM biblio_relation AS br
INNER JOIN biblio AS b ON br.rel_biblio_id=b.biblio_id
WHERE br.biblio_id IN (SELECT biblio_id FROM biblio_relation WHERE rel_biblio_id=%d) OR br.biblio_id=%d',
$this->detail_id, $this->detail_id));
if ($rel_q->num_rows < 1) {
return null;
}
while ($rel_d = $rel_q->fetch_assoc()) {
if ($rel_d['biblio_id'] == $this->detail_id) {
continue;
}
$_output .= '';
$_output .= ''.$rel_d['title'].' ';
$_output .= ''.$rel_d['edition'].' ';
$_output .= ''.$rel_d['language_id'].' ';
$_output .= ' ';
}
$_output .= '
';
return $_output;
}
/**
* Record detail output in HTML mode
* @return array
*
*/
protected function htmlOutput()
{
// get global configuration vars array
global $sysconf;
$_detail_link = SWB.'index.php?p=show_detail&id='.$this->detail_id;
foreach ($this->record_detail as $idx => $data) {
if ($idx == 'notes') {
$data = nl2br($data);
} else {
if (is_string($data)) {
$data = trim(strip_tags($data));
}
}
$this->record_detail[$idx] = $data;
}
// get title and set it to public record_title property
$this->record_title = $this->record_detail['title'];
$this->metadata = ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
$this->metadata .= ' ';
// check image
if (!empty($this->record_detail['image'])) {
if ($sysconf['tg']['type'] == 'minigalnano') {
$this->record_detail['image_src'] = 'lib/minigalnano/createthumb.php?filename='.$sysconf['tg']['relative_url'].'images/docs/'.urlencode($this->record_detail['image']).'&width=200';
$this->record_detail['image'] = ' ';
}
} else {
$this->record_detail['image_src'] = "images/default/image.png";
$this->record_detail['image'] = ' ';
}
// get image source
$this->image_src = $this->record_detail['image_src'];
// get the authors data
$authors = '';
$data = array();
// authors for metadata
$this->metadata .= ' '.$data['author_name']." - ".$data['authority_type']." ";
$this->metadata .= $data['author_name'].'; ';
}
$this->metadata .= '" />';
$this->record_detail['authors'] = $authors;
// get the topics data
$topics = '';
$data = array();
$this->metadata .= ' '.$data['topic']." ";
$this->metadata .= $data['topic'].'; ';
}
$this->metadata .= '" />';
$this->record_detail['subjects'] = $topics;
$this->record_detail['availability'] = $this->getItemCopy();
$this->record_detail['file_att'] = $this->getAttachments();
$this->record_detail['related'] = $this->getRelatedBiblio();
if ($sysconf['social_shares']) {
// share buttons
$_detail_link_encoded = urlencode('http://'.$_SERVER['SERVER_NAME'].$_detail_link);
$_share_btns = "\n".''."\n";
$this->record_detail['social_shares'] = $_share_btns;
}
return $this->record_detail;
}
/**
* Record detail output in MODS (Metadata Object Description Schema) XML mode
* @return array
*
*/
public function MODSoutput()
{
// get global configuration vars array
global $sysconf;
$mods_version = '3.3';
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
// set prefix and suffix
$this->detail_prefix = ''."\n";
$this->detail_suffix = ' ';
// $_xml_output = ''."\n";
// MODS main tag
$xml->startElement('mods');
$xml->writeAttribute('version', $mods_version);
$xml->writeAttribute('id', $this->detail_id);
// parse title
$_title_sub = '';
$_title_statement_resp = '';
if (stripos($this->record_detail['title'], ':') !== false) {
$_title_main = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], ':')+1));
$_title_sub = trim(substr_replace($this->record_detail['title'], '', 0, stripos($this->record_detail['title'], ':')+1));
} else if (stripos($this->record_detail['title'], '/') !== false) {
$_title_statement_resp = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], '/')+1));
} else {
$_title_main = trim($this->record_detail['title']);
}
// $_xml_output .= ''."\n".' '."\n";
$xml->startElement('titleInfo');
$xml->startElement('title');
$xml->writeCData($_title_main);
$xml->endElement();
if ($_title_sub) {
// $_xml_output .= ' '."\n";
$xml->startElement('subTitle');
$xml->writeCData($_title_sub);
$xml->endElement();
}
// $_xml_output .= ' '."\n";
$xml->endElement();
// personal name
// get the authors data
foreach ($this->record_detail['authors'] as $_auth_d) {
/*
$_xml_output .= ''."\n"
.' '."\n"
.' '."\n"
.' '."\n";
*/
// $xml->startElement('name'); $xml->writeAttribute('type', $sysconf['authority_type'][$_auth_d['authority_type']]); $xml->writeAttribute('authority', $_auth_d['auth_list']);
$xml->startElement('name'); $xml->writeAttribute('type', $_auth_d['authority_type']); $xml->writeAttribute('authority', $_auth_d['auth_list']);
$xml->startElement('namePart'); $xml->writeCData($_auth_d['author_name']); $xml->endElement();
$xml->startElement('role');
$xml->startElement('roleTerm'); $xml->writeAttribute('type', 'text');
$xml->writeCData($sysconf['authority_level'][$_auth_d['level']]);
$xml->endElement();
$xml->endElement();
$xml->endElement();
}
// resources type
// $_xml_output .= ' '."\n";
$xml->startElement('typeOfResource'); $xml->writeAttribute('manuscript', 'no'); $xml->writeAttribute('collection', 'yes'); $xml->writeCData('mixed material'); $xml->endElement();
// $_xml_output .= ' '."\n";
$xml->startElement('genre'); $xml->writeAttribute('authority', 'marcgt'); $xml->writeCData('bibliography'); $xml->endElement();
// imprint/publication data
/*
$_xml_output .= ''."\n";
$_xml_output .= 'record_detail['publish_place'].']]> '."\n"
.'record_detail['publisher_name'].']]> '."\n"
.'record_detail['publish_year'].']]> '."\n";
if ((integer)$this->record_detail['frequency_id'] > 0) {
$_xml_output .= 'continuing '."\n";
$_xml_output .= 'record_detail['frequency'].']]> '."\n";
} else {
$_xml_output .= ' '."\n";
}
$_xml_output .= 'record_detail['edition'].']]> '."\n";
$_xml_output .= ' '."\n";
*/
$xml->startElement('originInfo');
$xml->startElement('place');
$xml->startElement('placeTerm'); $xml->writeAttribute('type', 'text'); $xml->writeCData($this->record_detail['publish_place']); $xml->endElement();
$xml->startElement('publisher'); $xml->writeCData($this->record_detail['publisher_name']); $xml->endElement();
$xml->startElement('dateIssued'); $xml->writeCData($this->record_detail['publish_year']); $xml->endElement();
$xml->endElement();
$xml->endElement();
// language
/*
$_xml_output .= ''."\n";
$_xml_output .= 'record_detail['language_id'].']]> '."\n";
$_xml_output .= 'record_detail['language_name'].']]> '."\n";
$_xml_output .= ' '."\n";
*/
$xml->startElement('language');
$xml->startElement('languageTerm'); $xml->writeAttribute('type', 'code'); $xml->writeCData($this->record_detail['language_id']); $xml->endElement();
$xml->startElement('languageTerm'); $xml->writeAttribute('type', 'text'); $xml->writeCData($this->record_detail['language_name']); $xml->endElement();
$xml->endElement();
// Physical Description/Collation
/*
$_xml_output .= ''."\n";
$_xml_output .= ''."\n";
$_xml_output .= 'record_detail['collation'].']]> '."\n";
$_xml_output .= ' '."\n";
*/
$xml->startElement('physicalDescription');
$xml->startElement('form'); $xml->writeAttribute('authority', 'gmd'); $xml->writeCData($this->record_detail['gmd_name']); $xml->endElement();
$xml->startElement('extent'); $xml->writeCData($this->record_detail['collation']); $xml->endElement();
$xml->endElement();
// Series title
if ($this->record_detail['series_title']) {
/*
$_xml_output .= ''."\n";
$_xml_output .= ''."\n";
$_xml_output .= 'record_detail['series_title'].']]> '."\n";
$_xml_output .= ' '."\n";
$_xml_output .= ' '."\n";
*/
$xml->startElement('relatedItem'); $xml->writeAttribute('type', 'series');
$xml->startElement('titleInfo'); $xml->endElement();
$xml->startElement('title'); $xml->writeCData($this->record_detail['series_title']); $xml->endElement();
$xml->endElement();
$xml->endElement();
}
// Note
// $_xml_output .= ''.$this->record_detail['notes'].' '."\n";
$xml->startElement('note'); $xml->writeCData($this->record_detail['notes']); $xml->endElement();
if (isset($this->record_detail['sor'])) {
$xml->startElement('note'); $xml->writeAttribute('type', 'statement of responsibility'); $xml->writeCData($this->record_detail['sor']); $xml->endElement();
// $_xml_output .= ' ';
}
// subject/topic
foreach ($this->record_detail['subjects'] as $_topic_d) {
$_subject_type = strtolower($sysconf['subject_type'][$_topic_d['topic_type']]);
/*
$_xml_output .= '';
$_xml_output .= '<'.$_subject_type.'>'.$_subject_type.'>';
$_xml_output .= ' '."\n";
*/
$xml->startElement('subject'); $xml->writeAttribute('authority', $_topic_d['auth_list']);
$xml->startElement($_subject_type); $xml->writeCData($_topic_d['topic']); $xml->endElement();
$xml->endElement();
}
// classification
// $_xml_output .= 'record_detail['classification'].']]> ';
$xml->startElement('classification'); $xml->writeCData($this->record_detail['classification']); $xml->endElement();
// ISBN/ISSN
// $_xml_output .= 'record_detail['isbn_issn']).']]> ';
$xml->startElement('identifier'); $xml->writeAttribute('type', 'isbn'); $xml->writeCData(str_replace(array('-', ' '), '', $this->record_detail['isbn_issn'])); $xml->endElement();
// Location and Copies information
$_copy_q = $this->db->query(sprintf('SELECT i.item_code, i.call_number, stat.item_status_name, loc.location_name, stat.rules, i.site FROM item AS i '
.'LEFT JOIN mst_item_status AS stat ON i.item_status_id=stat.item_status_id '
.'LEFT JOIN mst_location AS loc ON i.location_id=loc.location_id '
.'WHERE i.biblio_id=%d', $this->detail_id));
/*
$_xml_output .= ''."\n";
$_xml_output .= ' '."\n";
$_xml_output .= 'record_detail['call_number'].']]> '."\n";
if ($_copy_q->num_rows > 0) {
$_xml_output .= ''."\n";
while ($_copy_d = $_copy_q->fetch_assoc()) {
$_xml_output .= ''."\n";
$_xml_output .= ' '."\n";
$_xml_output .= ' '."\n";
$_xml_output .= ' '."\n";
$_xml_output .= ' '."\n";
}
$_xml_output .= ' '."\n";
}
$_xml_output .= ' '."\n";
*/
$xml->startElement('location');
$xml->startElement('physicalLocation'); $xml->writeCData($sysconf['library_name'].' '.$sysconf['library_subname']); $xml->endElement();
$xml->startElement('shelfLocator'); $xml->writeCData($this->record_detail['call_number']); $xml->endElement();
if ($_copy_q->num_rows > 0) {
$xml->startElement('holdingSimple');
while ($_copy_d = $_copy_q->fetch_assoc()) {
$xml->startElement('copyInformation');
$xml->startElement('numerationAndChronology'); $xml->writeAttribute('type', '1'); $xml->writeCData($_copy_d['item_code']); $xml->endElement();
$xml->startElement('sublocation'); $xml->writeCData($_copy_d['location_name'].( $_copy_d['site']?' ('.$_copy_d['site'].')':'' )); $xml->endElement();
$xml->startElement('shelfLocator'); $xml->writeCData($_copy_d['call_number']); $xml->endElement();
$xml->endElement();
}
$xml->endElement();
}
$xml->endElement();
// digital files
$attachment_q = $this->db->query('SELECT att.*, f.* FROM biblio_attachment AS att
LEFT JOIN files AS f ON att.file_id=f.file_id WHERE att.biblio_id='.$this->detail_id.' AND att.access_type=\'public\' LIMIT 20');
if ($attachment_q->num_rows > 0) {
/*
$_xml_output .= ''."\n";
while ($attachment_d = $attachment_q->fetch_assoc()) {
// check member type privileges
if ($attachment_d['access_limit']) { continue; }
$_xml_output .= '';
$_xml_output .= '';
$_xml_output .= ' '."\n";
}
$_xml_output .= ' ';
*/
$xml->startElementNS('slims','digitals', null);
while ($attachment_d = $attachment_q->fetch_assoc()) {
// check member type privileges
if ($attachment_d['access_limit']) { continue; }
$xml->startElementNS('slims','digital_item', null);
$xml->writeAttribute('id', $attachment_d['file_id']);
$xml->writeAttribute('url', trim($attachment_d['file_url']));
$xml->writeAttribute('path', $attachment_d['file_dir'].'/'.$attachment_d['file_name']);
$xml->writeAttribute('mimetype', $attachment_d['mime_type']);
$xml->writeCData($attachment_d['file_title']);
$xml->endElement();
}
$xml->endElement();
}
// image
if (!empty($this->record_detail['image'])) {
$_image = urlencode($this->record_detail['image']);
$xml->startElementNS('slims','image', null);
$xml->writeCData(urlencode($_image));
$xml->endElement();
}
// record info
/*
$_xml_output .= ''."\n";
$_xml_output .= 'detail_id.']]> '."\n";
$_xml_output .= 'record_detail['input_date'].']]> '."\n";
$_xml_output .= 'record_detail['last_update'].']]> '."\n";
$_xml_output .= ' '."\n";
$_xml_output .= ' ';
*/
$xml->startElement('recordInfo');
$xml->startElement('recordIdentifier'); $xml->writeCData($this->detail_id); $xml->endElement();
$xml->startElement('recordCreationDate'); $xml->writeAttribute('encoding', 'w3cdtf'); $xml->writeCData($this->record_detail['input_date']); $xml->endElement();
$xml->startElement('recordChangeDate'); $xml->writeAttribute('encoding', 'w3cdtf'); $xml->writeCData($this->record_detail['last_update']); $xml->endElement();
$xml->startElement('recordOrigin'); $xml->writeCData('machine generated'); $xml->endElement();
$xml->endElement();
// $_xml_output .= ' ';
$xml->endElement();
return $xml->outputMemory();
}
/**
* Record detail output in Dublin Core XML
* @return string
*
*/
public function DublinCoreOutput()
{
// get global configuration vars array
global $sysconf;
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
// set prefix and suffix
$this->detail_prefix = '';
$this->detail_suffix = '';
$_xml_output = '';
$_title_main = utf8_encode($this->record_detail['title']);
// title
$xml->startElementNS('dc', 'title', null);
$xml->writeCdata($_title_main);
$xml->endElement();
// get the authors data
$_biblio_authors_q = $this->db->query('SELECT a.*,ba.level FROM mst_author AS a'
.' LEFT JOIN biblio_author AS ba ON a.author_id=ba.author_id WHERE ba.biblio_id='.$this->detail_id);
while ($_auth_d = $_biblio_authors_q->fetch_assoc()) {
$xml->startElementNS('dc', 'creator', null);
$xml->writeCdata($_auth_d['author_name']);
$xml->endElement();
}
$_biblio_authors_q->free_result();
// imprint/publication data
$xml->startElementNS('dc', 'publisher', null);
$xml->writeCdata($this->record_detail['publisher_name']);
$xml->endElement();
if ($this->record_detail['publish_year']) {
$xml->startElementNS('dc', 'date', null);
$xml->writeCdata($this->record_detail['publish_year']);
$xml->endElement();
} else {
$xml->startElementNS('dc', 'date', null);
$xml->fullEndElement();
}
// edition
$xml->startElementNS('dc', 'hasVersion', null);
$xml->writeCdata($this->record_detail['edition']);
$xml->endElement();
// language
$xml->startElementNS('dc', 'language', null);
$xml->writeCdata($this->record_detail['language_name']);
$xml->endElement();
// Physical Description/Collation
$xml->startElementNS('dc', 'medium', null);
$xml->writeCdata($this->record_detail['gmd_name']);
$xml->endElement();
$xml->startElementNS('dc', 'format', null);
$xml->writeCdata($this->record_detail['gmd_name']);
$xml->endElement();
$xml->startElementNS('dc', 'extent', null);
$xml->writeCdata($this->record_detail['collation']);
$xml->endElement();
if ((integer)$this->record_detail['frequency_id'] > 0) {
$xml->startElementNS('dc', 'format', null);
$xml->writeCdata('serial');
$xml->endElement();
}
// Series title
if ($this->record_detail['series_title']) {
$xml->startElementNS('dc', 'isPartOf', null);
$xml->writeCdata($this->record_detail['series_title']);
$xml->endElement();
}
// Note
$xml->startElementNS('dc', 'description', null);
$xml->writeCdata($this->record_detail['notes']);
$xml->endElement();
$xml->startElementNS('dc', 'abstract', null);
$xml->writeCdata($this->record_detail['notes']);
$xml->endElement();
// subject/topic
$_biblio_topics_q = $this->db->query('SELECT t.topic, t.topic_type, t.auth_list, bt.level FROM mst_topic AS t
LEFT JOIN biblio_topic AS bt ON t.topic_id=bt.topic_id WHERE bt.biblio_id='.$this->detail_id.' ORDER BY t.auth_list');
while ($_topic_d = $_biblio_topics_q->fetch_assoc()) {
$xml->startElementNS('dc', 'subject', null);
$xml->writeCdata($_topic_d['topic']);
$xml->endElement();
}
$_biblio_topics_q->free_result();
// classification
$xml->startElementNS('dc', 'subject', null);
$xml->writeCdata($this->record_detail['classification']);
$xml->endElement();
// Permalink
$permalink = $protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].SWB.'index.php?p=show_detail&id='.$this->detail_id;
$xml->startElementNS('dc', 'identifier', null);
$xml->writeCdata($permalink);
$xml->endElement();
// ISBN/ISSN
$xml->startElementNS('dc', 'identifier', null);
$xml->writeCdata(str_replace(array('-', ' '), '', $this->record_detail['isbn_issn']));
$xml->endElement();
// Call Number
$xml->startElementNS('dc', 'identifier', null);
$xml->writeCdata($this->record_detail['call_number']);
$xml->endElement();
$_copy_q = $this->db->query('SELECT i.item_code, i.call_number, stat.item_status_name, loc.location_name, stat.rules, i.site FROM item AS i '
.'LEFT JOIN mst_item_status AS stat ON i.item_status_id=stat.item_status_id '
.'LEFT JOIN mst_location AS loc ON i.location_id=loc.location_id '
.'WHERE i.biblio_id='.$this->detail_id);
if ($_copy_q->num_rows > 0) {
while ($_copy_d = $_copy_q->fetch_assoc()) {
$xml->startElementNS('dc', 'hasPart', null);
$xml->writeCdata($_copy_d['item_code']);
$xml->endElement();
}
}
$_copy_q->free_result();
// digital files
$attachment_q = $this->db->query('SELECT att.*, f.* FROM biblio_attachment AS att
LEFT JOIN files AS f ON att.file_id=f.file_id WHERE att.biblio_id='.$this->detail_id.' AND att.access_type=\'public\' LIMIT 20');
if ($attachment_q->num_rows > 0) {
while ($attachment_d = $attachment_q->fetch_assoc()) {
$dir = '';
if ($attachment_d['file_dir']) {
$dir = $attachment_d['file_dir'].'/';
}
// check member type privileges
if ($attachment_d['access_limit']) { continue; }
$xml->startElementNS('dc', 'relation', null);
$xml->writeCdata($protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].REPO_WBS.$dir.trim(urlencode($attachment_d['file_name'])));
$xml->endElement();
}
}
// image
if (!empty($this->record_detail['image'])) {
$_image = $protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].SWB.'images/docs/'.urlencode($this->record_detail['image']);
$xml->startElementNS('dc', 'relation', null);
$xml->writeCdata($_image);
$xml->endElement();
}
return $xml->outputMemory();
}
/**
* Record detail output in JSON-LD (JSON-Linked Data)
* @return string
*
*/
public function JSONLDoutput() {
// get global configuration vars array
global $sysconf;
// set prefix and suffix
$this->detail_prefix = '';
$this->detail_suffix = '';
$jsonld['@context'] = 'http://schema.org';
$jsonld['@type'] = 'Book';
// parse title
$_title_sub = '';
$_title_statement_resp = '';
if (stripos($this->record_detail['title'], ':') !== false) {
$_title_main = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], ':')+1));
$_title_sub = trim(substr_replace($this->record_detail['title'], '', 0, stripos($this->record_detail['title'], ':')+1));
} else if (stripos($this->record_detail['title'], '/') !== false) {
$_title_statement_resp = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], '/')+1));
} else {
$_title_main = trim($this->record_detail['title']);
}
$jsonld['name'] = $_title_main;
if ($_title_sub) {
$jsonld['alternativeHeadline'] = $_title_sub;
}
// get the authors data
$jsonld['author']['@type'] = 'Person';
$_biblio_authors_q = $this->db->query('SELECT a.*,ba.level FROM mst_author AS a'
.' LEFT JOIN biblio_author AS ba ON a.author_id=ba.author_id WHERE ba.biblio_id='.$this->detail_id);
while ($_auth_d = $_biblio_authors_q->fetch_assoc()) {
$jsonld['author']['name'][] = $_auth_d['author_name'];
}
$_biblio_authors_q->free_result();
// imprint/publication data
$jsonld['publisher']['@type'] = 'Organization';
$jsonld['publisher']['name'] = $this->record_detail['publisher_name'];
// date
$jsonld['dateCreated'] = $this->record_detail['publish_year'];
// edition
$jsonld['version'] = $this->record_detail['edition'];
// language
$jsonld['inLanguage'] = $this->record_detail['language_name'];
// Physical Description/Collation
$jsonld['bookFormat'] = $this->record_detail['gmd_name'];
// collation
$jsonld['numberOfPages'] = $this->record_detail['collation'];
// Series title
if ($this->record_detail['series_title']) {
$jsonld['alternativeHeadline'] = $this->record_detail['series_title'];
}
// Note
$jsonld['description'] = $this->record_detail['notes'];
// subject/topic
$jsonld['keywords'] = '';
$_biblio_topics_q = $this->db->query('SELECT t.topic, t.topic_type, t.auth_list, bt.level FROM mst_topic AS t
LEFT JOIN biblio_topic AS bt ON t.topic_id=bt.topic_id WHERE bt.biblio_id='.$this->detail_id.' ORDER BY t.auth_list');
while ($_topic_d = $_biblio_topics_q->fetch_assoc()) {
$jsonld['keywords'] .= $_topic_d['topic'].' ';
}
// classification
$jsonld['keywords'] .= $this->record_detail['classification'];
// Permalink
$jsonld['url'] = 'http://'.$_SERVER['SERVER_NAME'].SWB.'index.php?p=show_detail&id='.$this->detail_id;
// ISBN/ISSN
$jsonld['isbn'] = str_replace(array('-', ' '), '', $this->record_detail['isbn_issn']);
// digital files
$jsonld['associatedMedia']['@type'] = 'MediaObject';
$attachment_q = $this->db->query('SELECT att.*, f.* FROM biblio_attachment AS att
LEFT JOIN files AS f ON att.file_id=f.file_id WHERE att.biblio_id='.$this->detail_id.' AND att.access_type=\'public\' LIMIT 20');
if ($attachment_q->num_rows > 0) {
while ($attachment_d = $attachment_q->fetch_assoc()) {
$_xml_output .= 'record_detail['image'])) {
$_image = urlencode($this->record_detail['image']);
$jsonld['image'] = 'http://'.$_SERVER['SERVER_NAME'].IMGBS.'docs/'.urlencode($_image);
}
return json_encode($jsonld);
}
/**
* Get Record detail prefix
*/
public function getPrefix()
{
return $this->detail_prefix;
}
/**
* Get Record detail suffix
*/
public function getSuffix()
{
return $this->detail_suffix;
}
}