Mercurial > hg > extraction-interface
diff develop/models/extractapp.php @ 17:82f8c6bd2b69
add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 20 Feb 2015 17:57:02 +0100 |
parents | 1f98c92ebbfb |
children | f60969462226 |
line wrap: on
line diff
--- a/develop/models/extractapp.php Fri Feb 20 16:39:08 2015 +0100 +++ b/develop/models/extractapp.php Fri Feb 20 17:57:02 2015 +0100 @@ -475,16 +475,29 @@ } // === for manage tag list === - public function EditTaglist() { - // $this->Initialize($urlvalues); - $result = $this->GetTaglist(); + public function EditTaglist($_postdata) { + + $topic_id = $_postdata['topic_id']; + $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']); } + */ $data = array(); $data['taglistArray'] = $taglistArray; + $data['topic_id'] = $topic_id; return $data; } @@ -515,6 +528,17 @@ $this->GetSQLValueString($color, "text"), $this->GetSQLValueString($this->systemNAME, "text")); $result1 = mysql_query($query1); + + + // add it to topic_tag_relation table + $topic_id = $postdata['topic_id']; + + // tag_id is $id; + $query = sprintf("INSERT INTO `topic_tag_relation` (`topic_id`,`tag_id`) VALUES (%s,%s)", $topic_id, $id); + $result = mysql_query($query); + if (!$result) { + echo json_encode("error when insert into topic_tag_relation table"); + } } }