comparison 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
comparison
equal deleted inserted replaced
6:4b9ae7d500f9 7:23dcd1b5e9c4
105 $NO_TAG=0; 105 $NO_TAG=0;
106 $LOCUST_TEMPLE=1; 106 $LOCUST_TEMPLE=1;
107 107
108 function printTable($array,$keywordArray,$filename,$tag){ //print HTML 108 function printTable($array,$keywordArray,$filename,$tag){ //print HTML
109 global $NO_TAG, $LOCUST_TEMPLE; 109 global $NO_TAG, $LOCUST_TEMPLE;
110 $keywordStr="";
111 foreach($keywordArray as $i=>$keyword){
112 if($i!=0){
113 $keywordStr.=", ";
114 }
115 $keywordStr.=$keyword;
116 }
117
110 $header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 118 $header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
111 <html> 119 <html>
112 <head> 120 <head>
113 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 121 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
114 <link href="../search.css" type="text/css" rel="stylesheet"/> 122 <link href="../search.css" type="text/css" rel="stylesheet"/>
115 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> 123 <script src="../js/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
116 <script src="../search.js" charset="utf-8"></script> 124 <script src="../search.js" charset="utf-8"></script>
117 </head> 125 </head>
118 <body>'; 126 <body>';
119 $keywordStr=""; 127
120 foreach($keywordArray as $i=>$keyword){
121 if($i!=0){
122 $keywordStr.=", ";
123 }
124 $keywordStr.=$keyword;
125 }
126
127 128
128 global $system_root_url, $server_host, $lgserver_url; 129 global $system_root_url, $server_host, $lgserver_url;
129 130
130 if ($fp=fopen("./search_results/".$filename.".html","w")) { 131 if ($fp=fopen("./search_results/".$filename.".html","w")) {
132
133 // TODO highlight on the searched keywords. The html is a static file, difficult to add js...
134 // will incorporate LGSearch into LGServices in the near future...
135
131 136
132 //$fp=fopen("./search_results/".$filename.".html","w"); 137 //$fp=fopen("./search_results/".$filename.".html","w");
133 fwrite($fp,$header); 138 fwrite($fp,$header);
134 $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>"; 139 $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
135 $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>"; 140 $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>";
136 141
137 fwrite($fp,$str); 142 fwrite($fp,$str);
138 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; 143 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
139 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; 144 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
140 echo $str; 145 echo $str;
141 echo sizeof($array)." result(s) of \"".$keywordStr."\" "; 146 echo sizeof($array)." result(s) of \"<span id='keywords'>".$keywordStr."</span>\"";
142 fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>"); 147 fwrite($fp,sizeof($array)." result(s) of \"<span id='keywords'>".$keywordStr."</span>\"<br>");
143 $str="<table>"; 148 $str="<table>";
144 $str.="<tr>"; 149 $str.="<tr>";
145 $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"; 150 $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";
146 fwrite($fp,$str); 151 fwrite($fp,$str);
147 echo $str; 152 echo $str;
173 $str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; 178 $str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
174 */ 179 */
175 fwrite($fp,$str); 180 fwrite($fp,$str);
176 } 181 }
177 $str="<td>".$row['PAGE']; 182 $str="<td>".$row['PAGE'];
183 $str.="<td class='content'>".$row['CONTENT'];
184 /*
178 if($tag==$NO_TAG){ 185 if($tag==$NO_TAG){
179 $str.="<td>".$row['CONTENT']; 186 $str.="<td class='content'>".$row['CONTENT'];
180 }else if($tag==$LOCUST_TEMPLE){ 187 }else if($tag==$LOCUST_TEMPLE){
181 $str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0); 188 $str.="<td class='content'>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0);
182 } 189 }
190 */
183 fwrite($fp,$str); 191 fwrite($fp,$str);
184 echo $str; 192 echo $str;
185 $i++; 193 $i++;
186 } 194 }
187 195