set_main_record('recordList'); $objects->make_list_searchable("search_objects.ini"); $books=new Create_list("adlib_boeken.xml"); $books->set_main_record('recordList'); $books->make_list_searchable("search_books.ini"); ////////////////////////////////// //INTRODUCE XAJAX require ('xajax/xajax.inc.php'); /////////////////////////////////// ////////////////////////////////// function decomp($str,$tok='@') { return explode($tok, $str); } ////////////////////////////////// //basic search function: initiate_search //define xajax search-function function initiate_search($string) { $ini=decomp($string); if (count($ini)===1) { global $categories; $type=$categories[0]; // for the first search $type is not defined } else $type=$ini[1]; /// if we do the search for the second or third type $string=$ini[0]; //!!make string safe $text="searching all $type, please wait..."; $objResponse = new xajaxResponse(); $objResponse->assign("searchresults_$type_init","innerHTML",$text); $objResponse->loadCommands(show_list("$string@$type@0")); return $objResponse; } // function continue_search($info_str) // //This function loops the search and orders to print the results. // { // list($string,$type,$currentPage) = decomp($info_str); // $dataset=$GLOBALS[$type]; // $dataset->search->find($string); // $dataset->search->create_print($type); // $objResponse = new xajaxResponse(); // $objResponse->loadCommands(show_list("$string@$type@0")); // // return $objResponse; // } ////////////////////////////////// function show_list($info_str) { list($string,$type,$currentpage) = decomp($info_str); $dataset=$GLOBALS[$type]; $dataset->search->find($string); $dataset->search->create_print($type); $R=$dataset->search->print_arr; $txt_open=array_shift($R); //R = array $txt_close=array_pop($R); $maxpages=count($R); $itemsppage=$dataset->search->getItemsPerPage(); //$currentpage=$dataset->search->getCurrentPage(); $loopnr=($itemsppage+$currentpage>$maxpages) ? $maxpages : $itemsppage+$currentpage; $text.=$txt_open; for ($i=$currentpage; $i<$loopnr;$i++) { $txt=$R[$i]; //print("txt: $txt \n"); if ($txt) $text.=$txt; } $link_text_prev="<< vorige";// (naar $previous2) prev2: $previous2 - next2: $next2"; $link_text_next="volgende >>";// (naar $next2)"; $text.="
"; if ($currentpage>0) $text.="$link_text_prev  "; if ($currentpage+$dataset->search->getItemsPerPage()<$maxpages) $text.="$link_text_next"; $text.="
".$txt_close; $objResponse= new xajaxResponse(); $objResponse->assign("searchresults_$type","innerHTML",$text); global $categories; // now check if $type is the latest type we have in the categories. If not we run the entire procedure again for the other type(s) if ($newkey=array_search($type,$categories)+1!==count($categories)) $objResponse->loadCommands(initiate_search("$string@".$categories[$newkey])); return $objResponse; } function goto_prev_list($info_str) { list($string,$type,$currentPage) = decomp($info_str); $dataset=$GLOBALS[$type]; $currentPage-=$dataset->search->getItemsPerPage(); $dataset->search->setCurrentPage($currentPage); $objResponse = new xajaxResponse(); $objResponse->loadCommands(show_list("$string@$type@$currentPage")); return $objResponse; } function goto_next_list($info_str) { list($string,$type,$currentPage) = decomp($info_str); $dataset=$GLOBALS[$type]; $currentPage+=$dataset->search->getItemsPerPage(); $dataset->search->setCurrentPage($currentPage); $objResponse = new xajaxResponse(); $objResponse->loadCommands(show_list("$string@$type@$currentPage")); return $objResponse; } ////////////////////////////////// //////////////////////////////////// $xajax = new xajax(); $xajax->registerFunction("initiate_search"); // $xajax->registerFunction("continue_search"); $xajax->registerFunction("show_list"); $xajax->registerFunction("goto_prev_list"); $xajax->registerFunction("goto_next_list"); $xajax->processRequests(); ?> Hertboom Molen Museum - Collectie - Objecten Database