📄 search.php
字号:
<?include "include/db.php";include "include/authenticate.php";include "include/general.php";include "include/search_functions.php";include "include/collections_functions.php";$search=getvalescaped("search","");# Append extra search parameters$country=getvalescaped("country","");if ($country!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "country:" . $country;}$year=getvalescaped("year","");if ($year!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "year:" . $year;}$month=getvalescaped("month","");if ($month!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "month:" . $month;}$day=getvalescaped("day","");if ($day!="") {$search=(($search=="")?"":join(", ",split_keywords($search)) . ", ") . "day:" . $day;}hook("searchstringprocessing");if (strpos($search,"!")===false) {setcookie("search",$search);} # store the search in a cookie if not a special search$offset=getvalescaped("offset",0);if (strpos($search,"!")===false) {setcookie("saved_offset",$offset);}if ((!is_numeric($offset)) || ($offset<0)) {$offset=0;}$order_by=getvalescaped("order_by","relevance");if (strpos($search,"!")===false) {setcookie("saved_order_by",$order_by);}$display=getvalescaped("display","thumbs");setcookie("display",$display);$per_page=getvalescaped("per_page",$default_perpage);setcookie("per_page",$per_page);$archive=getvalescaped("archive",0);if (strpos($search,"!")===false) {setcookie("saved_archive",$archive);}$jumpcount=0;# Enable/disable the reordering feature. Just for collections for now.$allow_reorder=false;if (substr($search,0,11)=="!collection" && $collection_reorder_caption) { # Check to see if this user can edit (and therefore reorder) this resource $collection=substr($search,11); $collectiondata=get_collection($collection); if (($userref==$collectiondata["user"]) || ($collectiondata["allow_changes"]==1) || (checkperm("h"))) { $allow_reorder=true; } }# fetch resource types from query string and generate a resource types cookieif (getval("resetrestypes","")=="") { $restypes=getvalescaped("restypes",""); }else { $restypes=""; reset($_GET);foreach ($_GET as $key=>$value) { if (substr($key,0,8)=="resource") {if ($restypes!="") {$restypes.=",";} $restypes.=substr($key,8);} } setcookie("restypes",$restypes); # This is a new search, log this activity if ($archive==2) {daily_stat("Archive search",0);} else {daily_stat("Search",0);} } # If returning to an old search, restore the page/order byif (!array_key_exists("search",$_GET)) { $offset=getvalescaped("saved_offset",0);setcookie("saved_offset",$offset); $order_by=getvalescaped("saved_order_by","relevance");setcookie("saved_order_by",$order_by); $archive=getvalescaped("saved_archive",0);setcookie("saved_archive",$archive); } # If requested, refresh the collection frame (for redirects from saves)if (getval("refreshcollectionframe","")!="") { refresh_collection_frame(); }# Include scriptaculous for infobox panels.$headerinsert.="<script src=\"js/prototype.js\" type=\"text/javascript\"></script><script src=\"js/scriptaculous.js\" type=\"text/javascript\"></script><script src=\"js/infobox.js\" type=\"text/javascript\"></script>";if ($infobox) $bodyattribs="OnMouseMove='InfoBoxMM(event);'";# Include function for reorderingif ($allow_reorder) { $url="search.php?search=" . urlencode($search) . "&order_by=" . urlencode($order_by) . "&archive=" . $archive . "&offset=" . $offset; ?> <script type="text/javascript"> function ReorderResources(id1,id2) { document.location='<?=$url?>&reorder=' + id1 + '-' + id2; } </script> <? # Also check for the parameter and reorder as necessary. $reorder=getvalescaped("reorder",""); if ($reorder!="") { $r=explode("-",$reorder); swap_collection_order(substr($r[0],13),$r[1],substr($search,11)); refresh_collection_frame(); } }include "include/header.php";if (true) #search condition { $refs=array(); #echo "search=$search"; # Special query? Ignore restypes if (strpos($search,"!")!==false) {$restypes="";} # Story only? Display as list #if ($restypes=="2") {$display="list";} $result=do_search($search,$restypes,$order_by,$archive,$per_page+$offset); if (is_array($result)) { $url="search.php?search=" . urlencode($search) . "&order_by=" . $order_by . "&offset=" . $offset . "&archive=" . $archive; ?> <div class="TopInpageNav TopInpageNav"> <div class="InpageNavLeftBlock"><?=$lang["youfound"]?>:<br /><span class="Selected"><?=number_format(count($result))?><?=(count($result)==$max_results)?"+":""?></span> <?=$lang["youfoundresources"]?></div> <div class="InpageNavLeftBlock"><?=$lang["display"]?>:<br /> <? if ($display=="thumbs") { ?><span class="Selected"><?=$lang["largethumbs"]?></span><? } else { ?><a href="<?=$url?>&display=thumbs"><?=$lang["largethumbs"]?></a><? } ?> | <? if ($smallthumbs==true) { ?> <? if ($display=="smallthumbs") { ?><span class="Selected"><?=$lang["smallthumbs"]?></span><? } else { ?><a href="<?=$url?>&display=smallthumbs"><?=$lang["smallthumbs"]?></a><? } ?> | <? } ?> <? if ($display=="list") { ?><span class="Selected"><?=$lang["list"]?></span><? } else { ?><a href="<?=$url?>&display=list"><?=$lang["list"]?></a><? } ?> <? hook("adddisplaymode"); ?> </div> <? # order by #if (strpos($search,"!")===false) if (true) # Ordering enabled for collections/themes too now at the request of N Ward / Oxfam { $rel=$lang["relevance"]; if (strpos($search,"!")!==false) {$rel=$lang["asadded"];} ?> <div class="InpageNavLeftBlock "><?=$lang["sortorder"]?>:<br /><? if ($order_by=="relevance") {?><span class="Selected"><?=$rel?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=relevance&archive=<?=$archive?>"><?=$rel?></a><? } ?> | <? if ($order_by=="popularity") {?><span class="Selected"><?=$lang["popularity"]?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=popularity&archive=<?=$archive?>"><?=$lang["popularity"]?></a><? } ?> <? if ($orderbyrating) { ?> | <? if ($order_by=="rating") {?><span class="Selected"><?=$lang["rating"]?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=rating&archive=<?=$archive?>"><?=$lang["rating"]?></a><? } ?> <? } ?> | <? if ($order_by=="date") {?><span class="Selected"><?=$lang["date"]?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=date&archive=<?=$archive?>"><?=$lang["date"]?></a><? } ?> | <? if ($order_by=="colour") {?><span class="Selected"><?=$lang["colour"]?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=colour&archive=<?=$archive?>"><?=$lang["colour"]?></a><? } ?> <? if ($country_sort) { ?> | <? if ($order_by=="country") {?><span class="Selected"><?=$lang["country"]?></span><? } else { ?><a href="search.php?search=<?=urlencode($search)?>&order_by=country&archive=<?=$archive?>"><?=$lang["country"]?></a><? } ?> <? } ?> </div> <? } $results=count($result); $totalpages=ceil($results/$per_page); if ($offset>$results) {$offset=0;} $curpage=floor($offset/$per_page)+1; $url="search.php?search=" . urlencode($search) . "&order_by=" . urlencode($order_by) . "&archive=" . $archive; pager(); $draw_pager=true; ?></div> <? hook("beforesearchresults"); if ($display=="list") { ?> <!--list--> <div class="Listview"> <table border="0" cellspacing="0" cellpadding="0" class="ListviewStyle"> <!--Title row--> <tr class="ListviewTitleStyle"> <td><?=$lang["titleandcountry"]?></td> <td> </td> <td><?=$lang["id"]?></td> <td><?=$lang["type"]?></td> <td><?=$lang["date"]?> </td> <td><div class="ListTools"><?=$lang["tools"]?></div></td> </tr> <? } # work out common keywords among the results if ((count($result)>$suggest_threshold) && (strpos($search,"!")===false) && ($suggest_threshold!=-1)) { for ($n=0;$n<count($result);$n++) { if ($result[$n]["ref"]) {$refs[]=$result[$n]["ref"];} # add this to a list of results, for query refining later } $suggest=suggest_refinement($refs,$search); if (count($suggest)>0) { ?><p><?=$lang["torefineyourresults"]?>: <? for ($n=0;$n<count($suggest);$n++) { if ($n>0) {echo ", ";} ?><a href="search.php?search=<?= urlencode(strip_tags($suggest[$n])) ?>"><?=stripslashes($suggest[$n])?></a><? } ?></p><? } } # Work out which resources we will be showing and pre-fetch data for those resources
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -