diff interface/check_sections_details.php @ 0:b12c99b7c3f0

commit for previous development
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 19 Jan 2015 17:13:49 +0100
parents
children ef6d0c6a13d7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interface/check_sections_details.php	Mon Jan 19 17:13:49 2015 +0100
@@ -0,0 +1,146 @@
+<?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 getBookInfo($bookId){
+        $query="SELECT * FROM books WHERE id=".$bookId;
+	$result=mysql_query($query);
+	$bookInfo=mysql_fetch_assoc($result);
+	return $bookInfo;
+}
+function printBookInfo($bookInfo){
+	$str="<table>";
+	$str.="<tr><td class='bookId'>book id
+		<td class='bookName'>book name
+		<td class='level1'>level1
+		<td class='level2'>level2
+		<td class='period'>period
+		<td class='bookId'>pages
+		<td class='bookId'>version
+		<td class='bookName'>editor
+		<td class='bookName'>date";
+	$str.="<tr>";
+	$str.="<td>".$bookInfo['id'];
+	$str.="<td>".$bookInfo['name'];
+	$str.="<td>".$bookInfo['level1'];
+	$str.="<td>".$bookInfo['level2'];
+	$str.="<td>".$bookInfo['period'];
+	$str.="<td>".$bookInfo['line'];
+	$str.="<td>".$bookInfo['version'];
+	$str.="<td>".$bookInfo['editor'];
+	$str.="<td>".$bookInfo['date'];
+	$str.="</table>";
+	echo $str;
+}
+function printSectionArray($sectionArray,$missingPageArray){
+	$str="<div id='bookContainer'>";
+	echo $str;
+	$i=0;
+	foreach($sectionArray as $idx=>$row){
+		/*
+		$flag="";
+		if($i!=sizeof($pageArray) && $pageArray[$i]['start_page']==$row['start_page'] && $pageArray[$i]['end_page']==$row['end_page']){
+			$flag="overlapper";
+			$i++;
+		}
+		if($i!=0 && $pageArray[$i-1]['start_page']==$row['start_page'] && $pageArray[$i-1]['end_page']==$row['end_page']){
+			$flag="overlapper";
+		}*/
+		if(!($idx!=0 && $sectionArray[$idx-1]['start_page']==$row['start_page'] && $sectionArray[$idx-1]['end_page']==$row['end_page'])
+			&& $i<sizeof($missingPageArray) && $missingPageArray[$i]['end_page']==$row['start_page']){
+			$str="<div class='missingPageContainer'><div class='missingPage'>Missing pages: ".$missingPageArray[$i]['start_page']." - ".$missingPageArray[$i]['end_page']."</div></div>";
+			//$str.="<br>";
+			$i++;
+			echo $str;
+		}
+		
+		$str="<div class='entry level".$row['level']." ".$row['flag']." ".$row['deleted']."'>";
+			$str.="<div class='hiddenInfo'>";
+				$str.="<div class='id'>".$row['id']."</div>";
+				$str.="<div class='booksId'>".sprintf("%05d",$row['books_id'])."</div>";
+				$str.="<div class='splitFrom'>".$row['split_from']."</div>";
+				$str.="<div class='sectionAfter'>".$row['section_after']."</div>";
+			$str.="</div>";//end of hiddenInfo
+			$str.="<div class='sequence'>".($idx+1)."</div>";
+			$str.="<div class='name'>".$row['name']."</div>";
+			$str.="<div class='page'>";
+				$str.="<div class='startPage'>".$row['start_page']."</div>";
+				$str.=" - ";
+				$str.="<div class='endPage'>".$row['end_page']."</div>";
+			$str.="</div>";//end of page
+		$str.="</div>";	//end of class entry
+		echo $str;
+		
+	}
+	if($i<sizeof($missingPageArray)){
+		$str="<div class='missingPage'>Missing pages: ".$missingPageArray[$i]['start_page']." - ".$missingPageArray[$i]['end_page']."</div>";
+                echo $str;
+	}
+	$str="</div>";
+	echo $str;
+}
+
+?>
+
+<!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="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/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>
+                <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js" type="text/javascript"></script>
+                <!--<script src="js/check_sections.js" charset="utf-8"></script>!-->
+        </head>
+        <body>
+		<div id="loading">...</div>
+		<div id="container">
+                <?php
+			$version=0;
+			$editor="";
+			$date="";
+                        if(isset($_GET['book_id']) && isset($_GET['count']) && is_numeric($_GET['count'])){
+				$bookId=$_GET['book_id'];
+				$count=$_GET['count'];
+				$bookInfo=getBookInfo($bookId);
+				$info=checkSectionInfo($bookId);
+				$version=$info['version'];
+				$editor=$info['editor'];
+				$date=$info['date'];
+				$bookInfo=array_merge($bookInfo,["version"=>$version,"editor"=>$editor,"date"=>$date]);
+                                printBookInfo($bookInfo);
+				//echo "version: ".$version."<br>last editor: ".$editor;
+				$missingPageArray=checkMissingPage($bookInfo,$info);
+		?>
+                	<div id="searchResults">
+		<?php
+				$sectionArray=getSectionArray($bookId,$count,$info);
+				printSectionArray($sectionArray,$missingPageArray);
+                        }else{
+				echo "Cannot process the data due to incomplete input.";
+			}
+                ?>
+                	</div>
+		</div>
+		<div id="panel"></div>
+		<script>var version=<?php echo $version;?>;</script>
+        </body>
+
+</html>
+