getMessage()); } if (isset($sysconf['enable_xml_detail']) && !$sysconf['enable_xml_detail']) { $biblio_list->xml_detail = false; } // search result info $search_result_info = ''; // if we are in searching mode if (isset($_GET['search']) && !empty($_GET['search'])) { // default vars $is_adv = false; $keywords = ''; $criteria = ''; // simple search if (isset($_GET['keywords'])) { $keywords = trim(strip_tags(urldecode($_GET['keywords']))); } if ($keywords && !preg_match('@[a-z0-9_.]+=[^=]+\s+@i', $keywords.' ')) { //echo "atau next kesini"; $criteria = 'title='.$keywords.' OR author='.$keywords.' OR subject='.$keywords; $biblio_list->setSQLcriteria($criteria); } else { //echo "atau next kesini"; $biblio_list->setSQLcriteria($keywords); } // advanced search $is_adv = isset($_GET['title']) || isset($_GET['author']) || isset($_GET['isbn']) || isset($_GET['subject']) || isset($_GET['location']) || isset($_GET['gmd']) || isset($_GET['colltype']) || isset($_GET['publisher']) || isset($_GET['callnumber']) || isset($_GET['institution']) || isset($_GET['year']); if ($is_adv) { $title = ''; if (isset($_GET['title'])) { $title = trim(strip_tags(urldecode($_GET['title']))); } $author = ''; if (isset($_GET['author'])) { $author = trim(strip_tags(urldecode($_GET['author']))); } $subject = ''; if (isset($_GET['subject'])) { $subject = trim(strip_tags(urldecode($_GET['subject']))); } $isbn = ''; if (isset($_GET['isbn'])) { $isbn = trim(strip_tags(urldecode($_GET['isbn']))); } $gmd = ''; if (isset($_GET['gmd'])) { $gmd = trim(strip_tags(urldecode($_GET['gmd']))); } $colltype = ''; if (isset($_GET['colltype'])) { $colltype = trim(strip_tags(urldecode($_GET['colltype']))); } $location = ''; if (isset($_GET['location'])) { $location = trim(strip_tags(urldecode($_GET['location']))); } $publisher = ''; if (isset($_GET['publisher'])) { $publisher = trim(strip_tags(urldecode($_GET['publisher']))); } $callnumber = ''; if (isset($_GET['callnumber'])) { $callnumber = trim(strip_tags(urldecode($_GET['callnumber']))); } $institution = ''; if (isset($_GET['institution'])) { $institution = trim(strip_tags(urldecode($_GET['institution']))); } $year = ''; if (isset($_GET['year'])) { $year = trim(strip_tags(urldecode($_GET['year']))); } // don't do search if all search field is empty if ($title || $author || $subject || $isbn || $gmd || $colltype || $location || $publisher || $callnumber || $institution || $year) { $criteria = ''; if ($title) { $criteria .= ' title='.$title; } if ($author) { $criteria .= ' author='.$author; } if ($subject) { $criteria .= ' subject='.$subject; } if ($isbn) { $criteria .= ' isbn='.$isbn; } if ($gmd) { $criteria .= ' gmd="'.$gmd.'"'; } if ($colltype) { $criteria .= ' colltype="'.$colltype.'"'; } if ($location) { $criteria .= ' location="'.$location.'"'; } if ($publisher) { $criteria .= ' publisher="'.$publisher.'"'; } if ($callnumber) { $criteria .= ' callnumber="'.$callnumber.'"'; } if ($institution) { $criteria .= ' institution="'.$institution.'"'; } if ($year) { $criteria .= ' publishyear="'.$year.'"'; } $criteria = trim($criteria); $biblio_list->setSQLcriteria($criteria); } } // searched words $searched_words = implode(' ', $biblio_list->words); if ($biblio_list->words) { $searched_words_js_array = '['; foreach($biblio_list->words as $word) { $searched_words_js_array .= "'$word',"; } $searched_words_js_array = substr_replace($searched_words_js_array, '', -1); $searched_words_js_array .= ']'; } // search result info construction $keywords_info = ''.((strlen($keywords)>30)?substr($keywords, 0, 30).'...':$keywords).''; $search_result_info .= '
'; if ($is_adv) { $search_result_info .= __('Found {biblio_list->num_rows} from your keywords').': '.$keywords_info.' '; if ($title) { $search_result_info .= 'Title : '.$title.', '; } if ($author) { $search_result_info .= 'Author : '.$author.', '; } if ($subject) { $search_result_info .= 'Subject : '.$subject.', '; } if ($isbn) { $search_result_info .= 'ISBN/ISSN : '.$isbn.', '; } if ($gmd) { $search_result_info .= 'GMD : '.$gmd.', '; } if ($colltype) { $search_result_info .= 'Collection Type : '.$colltype.', '; } if ($location) { $search_result_info .= 'Location : '.$location.', '; } if ($publisher) { $search_result_info .= 'Publisher : '.$publisher.', '; } if ($callnumber) { $search_result_info .= 'Call Number : '.$callnumber.', '; } if ($institution) { $search_result_info .= 'Institution : '.$institution.', '; } if ($year) { $search_result_info .= 'Year : '.$year.', '; } // strip last comma $search_result_info = substr_replace($search_result_info, '', -2); } else { $search_result_info .= __('Found {biblio_list->num_rows} from your keywords').': '.$keywords_info.''; } $search_result_info .= '
'; // show promoted titles if (isset($sysconf['enable_promote_titles']) && $sysconf['enable_promote_titles']) { $biblio_list->only_promoted = true; } if (!isset($_GET['resultXML'])) { // show the list echo $biblio_list->getDocumentList(); echo '
'."\n"; } // set result number info $search_result_info = str_replace('{biblio_list->num_rows}', $biblio_list->num_rows, $search_result_info); // count total pages $total_pages = ceil($biblio_list->num_rows/$sysconf['opac_result_num']); // page number info if (isset($_GET['page']) AND $_GET['page'] > 1) { $page = intval($_GET['page']); $msg = str_replace('{page}', $page, __('You currently on page {page} of {total_pages} page(s)')); //mfc $msg = str_replace('{total_pages}', $total_pages, $msg); $search_result_info .= '
'.$msg.'
'; } else { $page = 1; } // query time if (!isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = ''; } $search_result_info .= '
'.__('Query took').' '.$biblio_list->query_time.' '.__('second(s) to complete').'
'; if ($biblio_list->num_rows < 1 && $keywords != '') { // word suggestion with enchant if (function_exists('enchant_broker_init') && $sysconf['spellchecker_enabled']) { $enc = enchant_broker_init(); if (enchant_broker_dict_exists($enc,$sysconf['default_lang'])) { $dict = enchant_broker_request_dict($enc,$sysconf['default_lang']); } else { $dict = enchant_broker_request_dict($enc,'en_US'); } $search_result_info .= '
'.__('Did you mean:').' '; $word = strtok($keywords, " \t\n"); $keywords_suggest = array(); while ($word !== false) { // check if we are inside quote if (stripos($word, '"', 0) === true) { $search_result_info .= preg_replace('@[a-z]@i', '', $word); $word = str_replace('"', '', $word); } $wordcorrect = enchant_dict_check($dict, $word); if (!$wordcorrect) { $closest = null; $wordsuggest = enchant_dict_suggest($dict, $word); $shortest = -1; // loop through words to find the closest with levenshtein foreach ($wordsuggest as $wordsg) { $lev = levenshtein($word, $wordsg); if ($lev == 0) { $closest = $wordsg; $shortest = 0; break; } if ($lev <= $shortest || $shortest < 0) { // set the closest match, and shortest distance $closest = $wordsg; $shortest = $lev; } } $keywords_suggest[] = ''.$closest.''; $keywords_suggest_plain[] = $closest; } else { $keywords_suggest[] = ''.$word.''; $keywords_suggest_plain[] = $word; } $word = strtok(" \t\n"); } $keywords_suggest_plain_str = implode(' ', $keywords_suggest_plain); $search_result_info .= ''; $search_result_info .= implode(' ', $keywords_suggest); $search_result_info .= '?
'; enchant_broker_free_dict($dict); } } if (isset($biblio_list) && isset($sysconf['enable_xml_result']) && $sysconf['enable_xml_result']) { $search_result_info .= '
XML Result
'; } } // check if we are on xml resultset mode if ( (isset($_GET['rss']) || isset($_GET['resultXML'])) && $sysconf['enable_xml_result']) { // get document list but don't output the result $biblio_list->getDocumentList(false); if ($biblio_list->num_rows > 0) { // send http header header('Content-Type: text/xml'); echo ''."\n"; if (isset($_GET['rss'])) { echo $biblio_list->RSSresult(); } else { echo $biblio_list->XMLresult(); } } exit(); }