changeset 1:ef6d0c6a13d7

(1)Add 'sort_by' time entry in main page. (check_sections.php) Modify check_sections_details page to have level3 option. (2)Modify map to have default dataset loaded.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 21 Jan 2015 10:49:44 +0100
parents b12c99b7c3f0
children da5309d54083
files index.php index_20150120.php interface/check_sections.php interface/check_sections_20150120.php interface/check_sections_details.php interface/config.php interface/css/check_sections.css interface/edit_section_db.php interface/js/check_sections_details.js map/map.js map/map.php
diffstat 11 files changed, 344 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/index.php	Wed Jan 21 10:49:44 2015 +0100
@@ -69,7 +69,10 @@
 					<div class='name'>Or, you can get to the TOC page for a given book and begin correcting the TOC. </div>
 					<div class='note'>(Please specify a bookID in the URL by yourself.)</div>
 				</a>
-
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/check_sections.php?sort_by=time' target='_blank'>
+					<div class='name'>Correct TOCs for 中國方志庫 texts (Sorting by time)</div>
+					<div class='note'></div>
+				</a>
 				<!--<a class='entry' href='/interface/check_sections_details.php?book_id=&count=' target='_blank'>
 					Re-segment a section 
 					<div class='note'>(book id and overlapping threshold should be given in the url)</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/index_20150120.php	Wed Jan 21 10:49:44 2015 +0100
@@ -0,0 +1,148 @@
+<?php
+	/*if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
+		$uri = 'https://';
+	} else {
+		$uri = 'http://';
+	}
+	$uri .= $_SERVER['HTTP_HOST'];
+	header('Location: '.$uri.'/xampp/');
+	exit;*/
+?>
+<!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="index.css" type="text/css" rel="stylesheet"/>
+                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
+                <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
+        </head>
+        <body>
+		<div id='sysName'>Tools for Local Monographs on this machine:</div>
+		<div class="doc">Documentation: 	
+			<a href="documentation.pdf">PDF</a> / 
+			<a href="documentation.docx">WORD</a>
+		</div>
+		<div class='block'>
+			<div class='title'>Search and extract 中國方志庫</div>
+			<div class='content'>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/search/search.php' target='_blank'>
+
+					<div class='name'>Search in the full texts</div> 
+					<div class='note'>(You can specify multiple keywords to search the full texts from the 1,824 local monographs in 中國方志庫, and save the result to a html file.)</div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/search/search_results/locust_temples_2.html' target='_blank'>
+					<div class='name'>Show the search result for "locust temples"</div>
+					<div class='note'>(Show the saved search result for locust temples. From there, you can begin the tagging/extraction procedure.) </div>
+				</a>
+				<a class='entry related' href='https://localmonographs.mpiwg-berlin.mpg.de/search/search_results' target='_blank'>
+					>> All saved search results
+				</a>
+			</div>
+		</div>
+		<!--<div class='block'>
+			<div class='title'>Extract data from 中國方志庫 texts</div>
+			<div class='content'>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/tagging_text.php?id=' target='_blank'>
+					Tag a section by section Id
+					<div class='note'>(Please add the section id to the url.)</div>
+				</a>
+				<a class='entry related' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/' target='_blank'>
+					>> See all the files in this directory
+				</a>
+			</div>
+		</div>-->
+		<div class='block'>
+			<div class='title'>Correct TOCs for 中國方志庫 texts</div>
+			<div class='content'>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/check_sections.php' target='_blank'>
+					<div class='name'>Find wrongly segmented sections by inputting a threshold.</div> 
+					<div class='note'>(Use links below for predefined thresholds. From there, you can get into each book and correct the Table of Contents - TOCs.)</div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/check_sections.php?count=100&find=find' target='_blank'>
+					<div class='name'>Find wrongly segmented sections which duplicate more than 100 times. </div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/check_sections.php?count=5&find=find' target='_blank'>
+					<div class='name'>Find wrongly segmented sections which duplicate more than 5 times. </div>
+					<div class='note'>(Long list!)</div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/check_sections_details.php?count=2&book_id=' target='_blank'>
+					<div class='name'>Or, you can get to the TOC page for a given book and begin correcting the TOC. </div>
+					<div class='note'>(Please specify a bookID in the URL by yourself.)</div>
+				</a>
+
+				<!--<a class='entry' href='/interface/check_sections_details.php?book_id=&count=' target='_blank'>
+					Re-segment a section 
+					<div class='note'>(book id and overlapping threshold should be given in the url)</div>
+				</a>-->
+				<!--<a class='entry related' href='/interface/' target='_blank'>
+					>> All related files
+				</a>-->
+			</div>
+		</div>
+		<div class='block'>
+			<div class='title'>Getting coordinates from CHGIS</div>
+			<div class='content'>
+				<a class='entry' href='/map/coordinates/local_monographs_coordinates.html' target='_blank'>
+					<div class='name'>The resulting coordinates for 中國方志庫 from CHGIS</div>
+				</a>
+				<a class='entry' href='/map/coordinates/local_monographs_176_coordinates.html' target='_blank'>
+					<div class='name'>The resulting coordinates for 176 books in 中國方志庫 from CHGIS</div>
+				</a>
+				<a class='entry' href='/map/coordinates/get_coordinates_from_chgis.php' target='_blank'>
+					<div class='name'>To re-get the coordinates from CHGIS</div>
+					<div class='note'>(Warning: it will be a long wait! Append "?list=176" to the url to get coordinates for the 176 books)</div>
+				</a>
+				<a class='entry' href='/map/coordinates/map.php' target='_blank'>
+					<div class='name'>Drawing the coordinates for 中國方志庫 from CHGIS</div>
+					<div class='note'>(Append "?list=176" to the url to draw coordinates for the 176 books)</div>
+				</a>
+				<a class='entry' href='/map/coordinates/csv_files/' target='_blank'>
+					<div class='name'>Raw data of the coordinates for 中國方志庫 from CHGIS</div>
+				</a>
+				<a class='entry related' href='/map/coordinates' target='_blank'>
+					>> All related files
+				</a>
+			</div>
+		</div>
+	
+		<div class='block'>
+			<div class='title'>中國大陸各省地方志書目查詢系統</div>
+			<div class='content'>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/insert_new_columns_into_books/data_from_sinica/all_data.csv' target='_blank'>
+					<div class='name'>The list for all extant local monographs from Academia Sinica </div>
+					<div class='note'>(Click to open the CSV file. They need to be aggregated by title. )</div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/insert_new_columns_into_books/data_from_sinica/analyze_data_from_sinica.php' target='_blank'>
+					<div class='name'>The statistics for the local monographs from Academia Sinica </div>
+				</a>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/insert_new_columns_into_books/data_from_sinica/parse_data_from_sinica.php' target='_blank'>
+					<div class='name'>The list for merged extant local monographs of source 1 from Academia Sinica</div>
+				</a>
+				<a class='entry related' href='https://localmonographs.mpiwg-berlin.mpg.de/interface/insert_new_columns_into_books/data_from_sinica' target='_blank'>
+					>> All downloaded files
+				</a>
+			</div>
+		</div>
+		<div class='block'>
+			<div class='title'>Visualization</div>
+			<div class='content'>
+				<a class='entry' href='/map/map.php' target='_blank'>
+					<div class='name'>Visualize data</div>
+				</a>
+				<a class='entry related' href='/map/' target='_blank'>
+					>> All related files
+				</a>
+			</div>
+		</div>
+		<div class='block'>
+			<div class='title'>Backend Mysql Database</div>
+			<div class='content'>
+				<a class='entry' href='https://localmonographs.mpiwg-berlin.mpg.de/phpmyadmin/' target='_blank'>
+					<div class='name'>The managing interface (phpmyadmin, login required) </div>
+				</a>
+
+			</div>
+		</div>
+
+	</body>
+</html>
--- a/interface/check_sections.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/check_sections.php	Wed Jan 21 10:49:44 2015 +0100
@@ -66,8 +66,41 @@
 	echo "</table>";
 }
 
+
+// sorting by the $sort_by parameter
+function checkSections_sort_by($sort_by){
+	switch ($sort_by) {
+		case 'time':
+			$query="(SELECT name AS book_name,level1,level2,period,start_year,id from books ORDER BY start_year)";
+			$result = mysql_query($query);
+			echo mysql_num_rows($result)." result(s)<br><br>";
+			echo "<table>";
+			echo "<tr>";
+			echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='start_year'>start_year";
+		        while ($row = mysql_fetch_assoc($result)) {
+				$str="<tr>";	
+				$str.="<td>".$row['book_name'];
+				$str.="<td>".$row['level1'];
+				$str.="<td>".$row['level2'];
+				$str.="<td>".$row['period'];
+				$str.="<td>".$row['start_year'];
+				$str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=100"."' target='_blank'>"."click here"."</a>";
+				echo $str;	
+			}
+			echo "</table>";
+			break;
+		
+		default:
+			# code...
+			echo "no sorting parameter set";
+			break;
+	}
+}
+
 ?>
 
+
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
         <head>
@@ -87,6 +120,9 @@
                         if(isset($_GET['find']) && $_GET['count']!='' && is_numeric($_GET['count'])){
                                 checkSections($_GET['count']);
                         }
+                        else if(isset($_GET['sort_by'])){
+                                checkSections_sort_by($_GET['sort_by']);
+                        }
                 ?>
                 </div>
         </body>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interface/check_sections_20150120.php	Wed Jan 21 10:49:44 2015 +0100
@@ -0,0 +1,94 @@
+<?php
+include_once('Lib_mb_utf8.php');
+include_once('config.php');
+include_once('edit_section_db.php');
+set_time_limit(0);
+ini_set('memory_limit', '-1');
+
+$link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
+mysql_query("SET NAMES utf8");
+
+if (!$link_mysql) {
+    die('Could not connect: ' . mysql_error());
+}
+
+$db_selected = mysql_select_db($mysql_database, $link_mysql);
+if (!$db_selected) {
+    die ('Can\'t use foo : ' . mysql_error());
+}
+
+function checkSections($count){
+
+/*	$query="SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections.name, start_page, end_page, COUNT( * ) AS count
+		FROM sections
+		JOIN books ON sections.books_id = books.id
+		WHERE NOT EXISTS
+		(SELECT 1 FROM sections_versions WHERE books_id=sections.books_id)
+		GROUP BY books_id, start_page, end_page
+		HAVING COUNT( * ) >=".$count."
+		ORDER BY COUNT( * ) DESC ";*/
+	$query="(SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections.name, start_page, end_page, COUNT( * ) AS count
+		FROM sections
+		JOIN books ON sections.books_id = books.id
+		WHERE NOT EXISTS
+		(SELECT 1 FROM sections_versions WHERE books_id=sections.books_id)
+		GROUP BY books_id, start_page, end_page
+		HAVING COUNT( * ) >=".$count.")
+		UNION
+		(SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections_revisions.name, start_page, end_page, COUNT( * ) AS count 
+                FROM sections_revisions
+                JOIN books ON sections_revisions.books_id = books.id
+		JOIN (
+			SELECT sections_versions.id 
+			FROM sections_versions WHERE sections_versions.version=(SELECT MAX(version) FROM sections_versions) 
+			GROUP BY books_id
+		) AS t ON t.id=sections_revisions.versions_id
+		WHERE deleted=0 
+                GROUP BY books_id, versions_id,start_page, end_page
+                HAVING COUNT( * ) >=".$count.")
+		ORDER BY count DESC ";
+	$result = mysql_query($query);
+	echo mysql_num_rows($result)." result(s)<br><br>";
+	echo "<table>";
+	echo "<tr>";
+	echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='sectionName'>section name<td class='sectionName'>page<td class='page'>count";
+        while ($row = mysql_fetch_assoc($result)) {
+		$str="<tr>";	
+		$str.="<td>".$row['book_name'];
+		$str.="<td>".$row['level1'];
+		$str.="<td>".$row['level2'];
+		$str.="<td>".$row['period'];
+		$str.="<td><a href='tagging_text.php?id=".$row['id']."' target='_blank'>".$row['name']."</a>";
+		$str.="<td>p".$row['start_page']."-".$row['end_page'];
+		$str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=".$count."' target='_blank'>".$row['count']."</a>";
+		echo $str;	
+	}
+	echo "</table>";
+}
+
+?>
+
+<!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="css/search.css" type="text/css" rel="stylesheet"/>
+                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
+                <!--<script src="js/check_sections.js" charset="utf-8"></script>!-->
+        </head>
+        <body>
+                <form action='check_sections.php' method='GET'>
+                        find sections overlapping more than <input type="text" name="count"> other sections
+                        <input type="submit" name="find" value="find">
+                </form>
+                <br>
+                <div id="search_result">
+                <?php
+                        if(isset($_GET['find']) && $_GET['count']!='' && is_numeric($_GET['count'])){
+                                checkSections($_GET['count']);
+                        }
+                ?>
+                </div>
+        </body>
+</html>
+
--- a/interface/check_sections_details.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/check_sections_details.php	Wed Jan 21 10:49:44 2015 +0100
@@ -101,7 +101,8 @@
         <head>
                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                 <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" type="text/css" rel="stylesheet"/>
-                <link href="css/search.css" type="text/css" rel="stylesheet"/>
+                <!-- <link href="css/search.css" type="text/css" rel="stylesheet"/>
+            	-->
                 <link href="css/check_sections.css" type="text/css" rel="stylesheet"/>
                 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
                 <script src="js/check_sections_details.js" type="text/javascript"></script>
--- a/interface/config.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/config.php	Wed Jan 21 10:49:44 2015 +0100
@@ -2,12 +2,18 @@
 
 $systemNAME = "interface";
 
-$mysql_database="Gazetteer";
+// local machine
+$mysql_database="Gazetteers";
 $mysql_server = "localhost";
 
 $mysql_user = "root";
 $mysql_password = "root";
-/*
+
+/* 
+// MPIWG server
+$mysql_database="Gazetteer";
+$mysql_server = "localhost";
+
 $mysql_user = "Gazetteer";
 $mysql_password = "3333";
 */
--- a/interface/css/check_sections.css	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/css/check_sections.css	Wed Jan 21 10:49:44 2015 +0100
@@ -45,7 +45,7 @@
 table{
 	margin-bottom:20px;
 }
-td.level1, td.level2, td.period{
+td.level1, td.level2, td.level3, td.period{
 	width:70px;
 }
 div.entry{
@@ -63,6 +63,9 @@
 div.level2 .cell{
 	padding:5px 0px;
 }
+div.level3 .cell{
+	padding:10px 0px;
+}
 div.entry .sequence{
 	display:inline-block;
 	width:36px;
@@ -104,6 +107,11 @@
 div.level2 .name{
 	text-indent:40px;
 }
+div.level3{
+}
+div.level3 .name{
+	text-indent:80px;
+}
 div.overlapper{
 	background:#F5A9A9;
 }
--- a/interface/edit_section_db.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/edit_section_db.php	Wed Jan 21 10:49:44 2015 +0100
@@ -154,17 +154,41 @@
 		echo json_encode("Succeeded.");
 	}
 }
+
 if(isset($_POST['command']) && $_POST['command']!=''){
 	$command=$_POST['command'];
-	if($command=="write"){
-		if(isset($_POST['bookId'])&&isset($_POST['sectionArray'])&&isset($_POST['version'])&&isset($_POST['editor'])&&
+	if($command=="write"){		
+		
+		$bookId=$_POST['bookId'];
+		$sectionArray=$_POST['sectionArray'];
+		$version=$_POST['version'];
+		$editor=$_POST['editor'];
+
+		foreach ($sectionArray as $key => $value) {
+			//echo $key.',';
+			foreach ($value as $key => $inner_val) {
+				//echo $key.",".$inner_val."\n";
+			}
+		}
+		
+		//echo "bookId:".$bookId.", "."editor:".$editor;
+		if(isset($bookId)&&isset($sectionArray)&&isset($version)&&isset($editor)&&\
+			is_numeric($bookId) && sizeof($sectionArray)!=0 && is_numeric($version) && $editor!=""){
+			
+			updateSectionArray($bookId,$sectionArray,$version,$editor);
+		}
+		/*
+		if(isset($_POST['bookId'])&&isset($_POST['sectionArray'])&&isset($_POST['version'])&&isset($_POST['editor'])&&\
 			is_numeric($_POST['bookId']) && sizeof($_POST['sectionArray'])!=0 && is_numeric($_POST['version']) && $_POST['editor']!=""){
 			$bookId=$_POST['bookId'];
 			$sectionArray=$_POST['sectionArray'];
 			$version=$_POST['version'];
 			$editor=$_POST['editor'];
-			updateSectionArray($bookId,$sectionArray,$version,$editor);
+			
+			echo "updating db...";
+			// updateSectionArray($bookId,$sectionArray,$version,$editor);
 		}
+		*/
 	}
 }
 
--- a/interface/js/check_sections_details.js	Mon Jan 19 17:13:49 2015 +0100
+++ b/interface/js/check_sections_details.js	Wed Jan 21 10:49:44 2015 +0100
@@ -141,9 +141,10 @@
 	//level
 	var levelObj=$("<div/>").addClass("editLevel").append("<select/>");
 	$(".entry").append(levelObj);
-	$(".editLevel select").append("<option value='1'>1evel 1</option>");
-	$(".editLevel select").append("<option value='2'>1evel 2</option>");
-	for(var i=1; i<=2; i++){
+	$(".editLevel select").append("<option value='1'>level 1</option>");
+	$(".editLevel select").append("<option value='2'>level 2</option>");
+	$(".editLevel select").append("<option value='3'>level 3</option>");
+	for(var i=1; i<=3; i++){
 		$("div.level"+i+" .editLevel select").val(i);
 	}
 	
@@ -156,6 +157,9 @@
 		if(entryObj.hasClass("level2")){
 			className="level2";
 		}
+		if(entryObj.hasClass("level3")){
+			className="level3";
+		}
 		entryObj.removeClass(className);
 		entryObj.addClass("level"+$(this).val());
 	});
@@ -291,15 +295,17 @@
 	var sectionArray=collectSectionArray();
 	var bookId=$(".entry").first().children(".hiddenInfo").children(".booksId").html();
 	var editor=$("#saveBook .editor").val();
+	console.log("editor:"+editor);
+
 	var version=version;
 	$("#loading").show();
 	$.post("edit_section_db.php", // use ajax to post to a php then wait for return
 		{//post data
 			command:"write",
+			version:version,
+			editor:editor,
 			bookId:bookId,
-			sectionArray:sectionArray,
-			version:version,
-			editor:editor	
+			sectionArray:sectionArray	
 		},
 		function(data){//things to do after edit_section_db is done
 			if(data=="Succeeded."){
@@ -313,6 +319,7 @@
 				href=href+"?book_id="+bookId+"&"+count+"&hideDeletedChecked="+hideDeletedChecked+"&editor="+editor;
 				location.href=href; //refresh the page to load the sections saved in db
 			}else{
+				console.log("db not succeeded.");
 				
 			}
 		},
--- a/map/map.js	Mon Jan 19 17:13:49 2015 +0100
+++ b/map/map.js	Wed Jan 21 10:49:44 2015 +0100
@@ -17,7 +17,7 @@
 		}];
 var datasetArray=[{name:"distribution of local monographs",
 			file:"./datasets/books_coordinates.csv",
-			preload:false
+			preload:true
 		},
 		{
 			name:"distribution of local monographs (by province)",
--- a/map/map.php	Mon Jan 19 17:13:49 2015 +0100
+++ b/map/map.php	Wed Jan 21 10:49:44 2015 +0100
@@ -3,8 +3,8 @@
         <head>
                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                 <link href="map.css" type="text/css" rel="stylesheet"/>
-                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
-		<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
+                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
+		<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
 		<link href="../geotemco/css/platin.css" rel="stylesheet" type="text/css">
 		<link href="WindowWidget.css" rel="stylesheet" type="text/css">
         	<script src="../geotemco/platin.js"></script>