comparison search_function.php @ 2:45cbafdec56e

modified code for updated db tables
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 25 Mar 2015 16:03:54 +0100
parents 38851c894301
children bc6ce492f15d
comparison
equal deleted inserted replaced
1:38851c894301 2:45cbafdec56e
35 } 35 }
36 $condition.=" contents.content LIKE '%".$keyword."%' "; 36 $condition.=" contents.content LIKE '%".$keyword."%' ";
37 } 37 }
38 //books.name AS book_name, books.level1, books.level2, books.period, contents.books_id, contents.line, contents.content 38 //books.name AS book_name, books.level1, books.level2, books.period, contents.books_id, contents.line, contents.content
39 39
40 // TODO: book_info is now merged to books table
41 $query="SELECT books.level1 AS LEVEL1, books.level2 AS LEVEL2, 40 $query="SELECT books.level1 AS LEVEL1, books.level2 AS LEVEL2,
42 books.name AS Name, books.period AS PERIOD, 41 books.name AS Name, books.period AS PERIOD,
43 books.start_year AS 'TimeSpan:begin', books.end_year AS 'TimeSpan:end', 42 books.start_year AS 'TimeSpan:begin', books.end_year AS 'TimeSpan:end',
44 books.id AS BOOK_ID, contents.line AS PAGE, contents.content AS CONTENT, 43 books.id AS BOOK_ID, contents.line AS PAGE, contents.content AS CONTENT,
45 books.volume AS VOLUME, books.author AS AUTHOR, books.edition AS EDITION 44 books.volume AS VOLUME, books.author AS AUTHOR, books.edition AS EDITION
66 FROM sections_revisions 65 FROM sections_revisions
67 WHERE books_id=".$row['BOOK_ID']." AND start_page<=".$row['PAGE']." AND end_page>=".$row['PAGE']." AND sections_revisions.deleted=0 AND sections_revisions.versions_id=".$max_version_id; 66 WHERE books_id=".$row['BOOK_ID']." AND start_page<=".$row['PAGE']." AND end_page>=".$row['PAGE']." AND sections_revisions.deleted=0 AND sections_revisions.versions_id=".$max_version_id;
68 67
69 } else { 68 } else {
70 $subQuery="SELECT id, name, start_page, end_page 69 $subQuery="SELECT id, name, start_page, end_page
71 FROM sections 70 FROM sections_index
72 WHERE books_id=".$row['BOOK_ID']." AND start_page<=".$row['PAGE']." AND end_page>=".$row['PAGE']; 71 WHERE books_id=".$row['BOOK_ID']." AND start_page<=".$row['PAGE']." AND end_page>=".$row['PAGE'];
73 } 72 }
74 73
75 $subResult=mysql_query($subQuery); 74 $subResult=mysql_query($subQuery);
76 $sectionArray=array(); 75 $sectionArray=array();
109 108
110 global $system_root_url, $server_host, $lgserver_url; 109 global $system_root_url, $server_host, $lgserver_url;
111 110
112 $fp=fopen("./search_results/".$filename.".html","w"); 111 $fp=fopen("./search_results/".$filename.".html","w");
113 fwrite($fp,$header); 112 fwrite($fp,$header);
114 $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</a><br><br>"; 113 $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>";
115 fwrite($fp,$str); 114 $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>";
115
116 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; 116 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
117 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; 117 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
118 echo $str; 118 echo $str;
119 fwrite($fp,$str);
119 echo sizeof($array)." result(s) of \"".$keywordStr."\" "; 120 echo sizeof($array)." result(s) of \"".$keywordStr."\" ";
120 fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>"); 121 fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>");
121 $str="<table>"; 122 $str="<table>";
122 $str.="<tr>"; 123 $str.="<tr>";
123 $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"; 124 $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";
134 $str.="<td>".$row['PERIOD']; 135 $str.="<td>".$row['PERIOD'];
135 $str.="<td>"; 136 $str.="<td>";
136 fwrite($fp,$str); 137 fwrite($fp,$str);
137 echo $str; 138 echo $str;
138 foreach($row['SECTION'] as $section){ 139 foreach($row['SECTION'] as $section){
139 // TODO: config to current extraction-interface OR Toc OR not at all?? 140
140 // redirect to LGServer 141 $str="<div class='section'><a>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
142 echo $str;
143 /*
144 // redirect to LGServer?
141 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; 145 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
142 echo $str; 146 echo $str;
143 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; 147 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
144 fwrite($fp,$str); 148 */
145 /* 149 /* origial
146 $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>"; 150 $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>";
147 echo $str; 151 echo $str;
148 $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>"; 152 $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>";
153 */
149 fwrite($fp,$str); 154 fwrite($fp,$str);
150 */
151 } 155 }
152 $str="<td>".$row['PAGE']; 156 $str="<td>".$row['PAGE'];
153 if($tag==$NO_TAG){ 157 if($tag==$NO_TAG){
154 $str.="<td>".$row['CONTENT']; 158 $str.="<td>".$row['CONTENT'];
155 }else if($tag==$LOCUST_TEMPLE){ 159 }else if($tag==$LOCUST_TEMPLE){