Mercurial > hg > LGSearch
diff search_function.php @ 7:23dcd1b5e9c4 default tip
add keywords highlighting on searching result
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 16 Nov 2015 16:58:39 +0100 |
parents | 1cf7bb8db5dd |
children |
line wrap: on
line diff
--- a/search_function.php Wed Oct 14 11:01:26 2015 +0200 +++ b/search_function.php Mon Nov 16 16:58:39 2015 +0100 @@ -107,15 +107,6 @@ function printTable($array,$keywordArray,$filename,$tag){ //print HTML global $NO_TAG, $LOCUST_TEMPLE; - $header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> - <html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <link href="../search.css" type="text/css" rel="stylesheet"/> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> - <script src="../search.js" charset="utf-8"></script> - </head> - <body>'; $keywordStr=""; foreach($keywordArray as $i=>$keyword){ if($i!=0){ @@ -124,22 +115,36 @@ $keywordStr.=$keyword; } + $header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> + <html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link href="../search.css" type="text/css" rel="stylesheet"/> + <script src="../js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> + <script src="../search.js" charset="utf-8"></script> + </head> + <body>'; + global $system_root_url, $server_host, $lgserver_url; if ($fp=fopen("./search_results/".$filename.".html","w")) { + // TODO highlight on the searched keywords. The html is a static file, difficult to add js... + // will incorporate LGSearch into LGServices in the near future... + + //$fp=fopen("./search_results/".$filename.".html","w"); fwrite($fp,$header); - $str="<a href='".$server_host."LGMap/get_coordinates_for_listed_books.php?file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map (click here at the first time)</a><br><br>"; + $str="<a href='".$server_host."LGMap/get_coordinates_for_listed_books.php?file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map (click here at the first time)</a><br><br>"; // copy the csv file in LGSearch/csv_files/ to LGMap/datasets/, then redirect to LGMap $str.="<a href='".$server_host."LGMap/map.php?mode=1&file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map</a><br><br>"; fwrite($fp,$str); $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; echo $str; - echo sizeof($array)." result(s) of \"".$keywordStr."\" "; - fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>"); + echo sizeof($array)." result(s) of \"<span id='keywords'>".$keywordStr."</span>\""; + fwrite($fp,sizeof($array)." result(s) of \"<span id='keywords'>".$keywordStr."</span>\"<br>"); $str="<table>"; $str.="<tr>"; $str.="<td class='sequence'>#<td class='bookId'>book id<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='sectionName'>section info<td class='page'>page<td class='content'>content"; @@ -175,11 +180,14 @@ fwrite($fp,$str); } $str="<td>".$row['PAGE']; + $str.="<td class='content'>".$row['CONTENT']; + /* if($tag==$NO_TAG){ - $str.="<td>".$row['CONTENT']; + $str.="<td class='content'>".$row['CONTENT']; }else if($tag==$LOCUST_TEMPLE){ - $str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0); + $str.="<td class='content'>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0); } + */ fwrite($fp,$str); echo $str; $i++;