# HG changeset patch # User Zoe Hong # Date 1426254443 -3600 # Node ID 3d6b8fb7335def24ac0a4f07ed71980d216934c6 # Parent 807d3bb33da7c7caf8edc306467324c8bd85626f lock the topic tag when edit tag list diff -r 807d3bb33da7 -r 3d6b8fb7335d develop/classes/basemodel.php --- 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'); diff -r 807d3bb33da7 -r 3d6b8fb7335d develop/models/extractapp.php --- 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; diff -r 807d3bb33da7 -r 3d6b8fb7335d develop/views/Extractapp/EditTaglist.php --- 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']; + ?> @@ -18,6 +20,7 @@ +

Topic Tag is ""

@@ -26,6 +29,7 @@ // var largestId = 0; var largestId = JSON.parse(''); +var topic_tag_id = JSON.parse(''); 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="
"; } - - var newcolumn = document.createElement("td"); - newcolumn.setAttribute("width","50"); - if ( color=="Color") { - row.appendChild(newcolumn).innerHTML="Save"; - } else { - row.appendChild(newcolumn).innerHTML=""; - } - - var newcolumn = document.createElement("td"); - newcolumn.setAttribute("width","50"); - if ( color=="Color") { - row.appendChild(newcolumn).innerHTML="Delete"; - } else { - row.appendChild(newcolumn).innerHTML=""; - } - - $('#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=""; + } - */ + + var newcolumn = document.createElement("td"); + newcolumn.setAttribute("width","50"); + if ( color=="Color") { + row.appendChild(newcolumn).innerHTML="Delete"; + } else { + row.appendChild(newcolumn).innerHTML=""; + } + + + $('#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(''); + 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(); }); + + + addNode( "AddTag","","","" ); addNode( "ID","Name","Tag","Color" ); $tagArray ) { - echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n"; } ?> -