<?php
/*
VERSION : 3.0
CODENAME : SENAYAN
AUTHOR :
Code and Programming : ARIE NUGRAHA (hide@address.com)
Database Design : HENDRO WICAKSONO (hide@address.com) & WARDIYONO (hide@address.com)
SENAYAN Library Automation System
Copyright (C) 2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (GPL License.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Showing list of catalogues and also for searching handling */
// include required class class
require LIB_DIR.'biblio_list.inc.php';
require SIMBIO_BASE_DIR.'simbio_GUI/paging/simbio_paging.inc.php';
// create biblio list object
$biblio_list = new biblio_list();
if (!$sysconf['enable_xml_detail']) {
$biblio_list->xml_detail = false;
}
// if we are in searching mode
if (isset($_GET['search']) AND !empty($_GET['search'])) {
// default vars
$is_adv = false;
$keywords = '';
$criteria = '';
// simple search
if (isset($_GET['keywords'])) {
$keywords = trim(urldecode($_GET['keywords']));
}
if ($keywords) {
$words = trim($dbs->escape_string($keywords));
$criteria = 'title{'.$words.'} authors{'.$words.'}';
$biblio_list->setSQLcriteria($criteria);
}
// advanced search
if (isset($_GET['title']) OR isset($_GET['author']) OR isset($_GET['subject']) OR isset($_GET['location'])) {
$is_adv = true;
$title = '';
if (isset($_GET['title'])) {
$title = trim(urldecode($_GET['title']));
}
$author = '';
if (isset($_GET['author'])) {
$author = trim(urldecode($_GET['author']));
}
$subject = '';
if (isset($_GET['subject'])) {
$subject = trim(urldecode($_GET['subject']));
}
$location = '';
if (isset($_GET['location'])) {
$location = trim(urldecode($_GET['location']));
}
// dont do search if all search field is empty
if ($title OR $author OR $subject OR $location) {
if ($title) {
$title = $dbs->escape_string($title);
$criteria .= ' title{'.$title.'}';
}
if ($author) {
$author = $dbs->escape_string($author);
$criteria .= ' authors{'.$author.'}';
}
if ($subject) {
$subject = $dbs->escape_string($subject);
$criteria .= ' subject{'.$subject.'}';
}
if ($location) {
$location = $dbs->escape_string($location);
$criteria .= ' location{'.$location.'}';
}
$criteria = trim($criteria);
$biblio_list->setSQLcriteria($criteria, 'AND');
}
}
}
// check if we are on xml resultset mode
if (isset($_GET['resultXML'])) {
$biblio_list->getDocumentList($dbs, $sysconf['opac_result_num'], false);
if ($biblio_list->num_rows > 0) {
$biblio_ids = $biblio_list->getDocumentIds();
}
} else {
// show the list
echo $biblio_list->getDocumentList($dbs, $sysconf['opac_result_num']);
echo '<br />'."\n";
}
// count total pages
$total_pages = ceil($biblio_list->num_rows/$sysconf['opac_result_num']);
// search result info
if (isset($_GET['search']) AND !empty($_GET['search'])) {
if ($is_adv) {
$info .= '<div style="clear: both;">'.lang_opac_search_result_info.' : </div>';
if (!empty($_GET['title'])) {
$info .= 'Title : <strong><cite>'.$_GET['title'].'</cite></strong>, ';
}
if (!empty($_GET['author'])) {
$info .= 'Author : <strong><cite>'.$_GET['author'].'</cite></strong>, ';
}
if (!empty($_GET['subject'])) {
$info .= 'Subject : <strong><cite>'.$_GET['subject'].'</cite></strong>, ';
}
if (!empty($_GET['location'])) {
$info .= 'Location : <strong><cite>'.$_GET['location'].'</cite></strong>, ';
}
// strip last comma
$info = substr_replace($info, '', -2);
} else {
$info .= '<div style="clear: both;">'.lang_opac_search_result_info.': <strong><cite>'.$_GET['keywords'].'</cite></strong></div>';
}
$info = str_replace('{biblio_list->num_rows}', $biblio_list->num_rows, $info);
}
// page number info
if (isset($_GET['page']) AND $_GET['page'] > 1) {
$page = intval($_GET['page']);
$msg = str_replace('{page}', $page, lang_opac_page_info);
$msg = str_replace('{total_pages}', $total_pages, $msg);
$info .= '<div style="clear: both;">'.$msg.'</div>';
} else {
$page = 1;
}
if (isset($biblio_list) AND $sysconf['enable_xml_result']) {
$info .= '<br /><a href="index.php?resultXML=true&'.$_SERVER['QUERY_STRING'].'" class="xmlResultLink" target="_blank" title="View Result in XML Format" style="clear: both;">XML Result</a>';
}
// check if we are on xml resultset mode
if (isset($_GET['resultXML']) AND isset($biblio_ids)) {
if (!$sysconf['enable_xml_result']) {
die('XML Result is disabled');
}
// send http header
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
echo '<senayan>'."\n";
echo '<generate_time>'.date("D, Y-m-d H:i:s").'</generate_time>'."\n";
echo '<result_page>'.$page.'</result_page>'."\n";
echo '<total_result_pages>'.$total_pages.'</total_result_pages>'."\n";
// include detail library and template
include LIB_DIR.'detail.inc.php';
include $sysconf['template']['dir'].'/detail_xml_template.php';
// loop biblio ID array
foreach ($biblio_ids as $detail_id) {
// create detail object
$detail = new detail($dbs, $detail_id, true);
$detail->setListTemplate($detail_template);
$xml_detail = $detail->showDetail();
echo $xml_detail;
}
echo '</senayan>';
exit();
}
?>