changeset 45:3d6b8fb7335d extractapp

lock the topic tag when edit tag list
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 13 Mar 2015 14:47:23 +0100
parents 807d3bb33da7
children b3ca5d2b4d3f
files develop/classes/basemodel.php develop/models/extractapp.php develop/views/Extractapp/EditTaglist.php
diffstat 3 files changed, 65 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/develop/classes/basemodel.php	Thu Mar 12 17:58:09 2015 +0100
+++ b/develop/classes/basemodel.php	Fri Mar 13 14:47:23 2015 +0100
@@ -9,6 +9,7 @@
     protected $save_new_to_LGService_url = "http://localgazetteers-dev/LGServer/rest/text/saveNew";
 
     */
+    protected $get_text_from_fileId_url, $get_text_from_sectionId_url, $save_to_LGService_url, $save_new_to_LGService_url;
 
 	public function __construct() {
         global $mysql_database, $mysql_server, $mysql_user, $mysql_password, $systemNAME, $lgserver_url;
@@ -18,10 +19,7 @@
         $this->get_text_from_sectionId_url = $lgserver_url."rest/text/getSectionText?sectionId=";
         $this->save_to_LGService_url = $lgserver_url."rest/text/save";
         $this->save_new_to_LGService_url = $lgserver_url."rest/text/saveNew";
-
-
         
-        // $this->database = new PDO("mysql:host=localhost;dbname=test", "username", "password");
         set_time_limit(0);
         ini_set('memory_limit', '-1');
 
--- a/develop/models/extractapp.php	Thu Mar 12 17:58:09 2015 +0100
+++ b/develop/models/extractapp.php	Fri Mar 13 14:47:23 2015 +0100
@@ -715,24 +715,28 @@
         $result = $this->GetTaglistByTopicID($topic_id);
 
         $taglistArray = array();
+
         foreach ($result as $row) {
             $taglistArray[$row[0]] = array($row[1], $row[2], $row[3]);
             //$taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']);
             // TODO: the format is not good, so I use $row[0], $row[1],... This could be changed some time.
         }
 
-        /*
-        //$result = $this->GetTaglist();
-        $taglistArray = array();
-        while ($row = mysql_fetch_assoc($result)) {
-            $taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']);
+        $topic_tag_name = $this->GetTopicTag($topic_id);
+
+        $query = "SELECT id FROM taglist WHERE taglist.tag='".$topic_tag_name."'";
+        $result = mysql_query($query);
+        if (!$result) {
+            echo json_encode(mysql_error());
         }
-        */
+        $row = mysql_fetch_assoc($result);
+        $topic_tag_id = $row['id'];
 
         $data = array();
         $data['taglistArray'] = $taglistArray;
         $data['topic_id'] = $topic_id;
         $data['largest_id'] = $largest_id;
+        $data['topic_tag_id'] = $topic_tag_id;
 
 
         return $data;
--- a/develop/views/Extractapp/EditTaglist.php	Thu Mar 12 17:58:09 2015 +0100
+++ b/develop/views/Extractapp/EditTaglist.php	Fri Mar 13 14:47:23 2015 +0100
@@ -4,6 +4,8 @@
 $topic_id = $viewmodel['topic_id'];
 $largestId = $viewmodel['largest_id'];
 
+$topic_tag_id = $viewmodel['topic_tag_id'];
+
 ?>
 
 <html>
@@ -18,6 +20,7 @@
 
 <body>
 
+<h3>Topic Tag is "<?php echo $taglistArray[$topic_tag_id][1]; ?>" </h3>
 
 <table width="100%" border="1" id="tableMain"> </table>
 
@@ -26,6 +29,7 @@
 
 // var largestId = 0;
 var largestId = JSON.parse('<?php echo json_encode($largestId) ?>');
+var topic_tag_id = JSON.parse('<?php echo json_encode($topic_tag_id) ?>');
 
 function addTag( ) {
 	largestId++;
@@ -119,6 +123,7 @@
 		
 		return 0;
 	}
+
 	var row = tableMain.appendChild(document.createElement("tr"));
 	row.setAttribute("height","50");
 	row.id = "tr"+id;
@@ -149,45 +154,46 @@
 	} else {
 		row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+id+"\"><div id=\"colorSelectorB"+id+"\" style=\"background-color: "+color+"\"></div></div>";
 	}
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	if ( color=="Color") {
-		row.appendChild(newcolumn).innerHTML="Save";
-	} else {
-		row.appendChild(newcolumn).innerHTML="<button onclick=\"saveTag("+id+", 'update')\">Save</button>";
-	}
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	if ( color=="Color") {
-		row.appendChild(newcolumn).innerHTML="Delete";
-	} else {
-		row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+id+")\">Delete</button>";
-	}
-	
-	$('#colorSelector'+id).ColorPicker({
-		color: color,
-		onShow: function (colpkr) {
-			$(colpkr).fadeIn(500);
-			return false;
-		},
-		onHide: function (colpkr) {
-			$(colpkr).fadeOut(500);
-			return false;
-		},
-		onChange: function (hsb, hex, rgb) {
-			$('#colorSelector'+id+' div').css('backgroundColor', '#' + hex);
-		}
-	});
 
 
-	/* 
-	// addRule doesn't work in FF
-	document.styleSheets[0].addRule("#colorSelector"+id, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);")
-	document.styleSheets[0].addRule("#colorSelector"+id+" div", "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;")
+	if (id == topic_tag_id) {
+		// pass
+	} else {	
+
+		var newcolumn = document.createElement("td");
+		newcolumn.setAttribute("width","50");
+		if ( color=="Color") {
+			row.appendChild(newcolumn).innerHTML="Save";
+		} else {
+			row.appendChild(newcolumn).innerHTML="<button onclick=\"saveTag("+id+", 'update')\">Save</button>";
+		}
 
-	*/
+		
+		var newcolumn = document.createElement("td");
+		newcolumn.setAttribute("width","50");
+		if ( color=="Color") {
+			row.appendChild(newcolumn).innerHTML="Delete";
+		} else {
+			row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+id+")\">Delete</button>";
+		}
+		
+	
+		$('#colorSelector'+id).ColorPicker({
+			color: color,
+			onShow: function (colpkr) {
+				$(colpkr).fadeIn(500);
+				return false;
+			},
+			onHide: function (colpkr) {
+				$(colpkr).fadeOut(500);
+				return false;
+			},
+			onChange: function (hsb, hex, rgb) {
+				$('#colorSelector'+id+' div').css('backgroundColor', '#' + hex);
+			}
+		});
+	}
+
 	// insertRule works in IE9, FF, Saf, Chrome, Opera
 	var x = document.styleSheets[0];
 	var selector1 = "#colorSelector"+id;
@@ -202,7 +208,6 @@
 		x.addRule(selector2, "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;");
 	}
 	
-
 }
 
 function newTag( id ) {
@@ -287,6 +292,10 @@
 	if ( $("#input"+this.id).length > 0 ) {
 		return;
 	}
+	var topic_tag_id = JSON.parse('<?php echo json_encode($topic_tag_id) ?>');
+	if (this.id == "tdName"+topic_tag_id) {
+		return;
+	}
 	//var startPageValue = this.innerHTML;
 	var startPageValue = this.textContent;
 	this.innerHTML="";
@@ -304,6 +313,9 @@
 	if ( $("#input"+this.id).length > 0 ) {
 		return;
 	}
+	if (this.id == "tdTag"+topic_tag_id) {
+		return;
+	}
 	//var startPageValue = this.innerHTML;
 	var startPageValue = this.textContent;
 	this.innerHTML="";
@@ -341,17 +353,20 @@
 	$("#input"+this.id).remove();
 });
 
+
+<?php 
+// echo "addNode( \"".$topic_tag_id."\",\"".$taglistArray[$topic_tag_id][0]."\",\"".$taglistArray[$topic_tag_id][1]."\",\"".$taglistArray[$topic_tag_id][2]."\" );\n";
+?>
+
 addNode( "AddTag","","","" );
 addNode( "ID","Name","Tag","Color" );
 
 <?php 
 foreach ( $taglistArray as $tagId => $tagArray ) {
-
 	echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n";
 }
 ?>
 
-
 </script>
 </body>
 </html>