Mercurial > hg > extraction-interface
comparison 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 |
comparison
equal
deleted
inserted
replaced
16:fb948097de39 | 17:82f8c6bd2b69 |
---|---|
473 return $data; | 473 return $data; |
474 | 474 |
475 } | 475 } |
476 | 476 |
477 // === for manage tag list === | 477 // === for manage tag list === |
478 public function EditTaglist() { | 478 public function EditTaglist($_postdata) { |
479 // $this->Initialize($urlvalues); | 479 |
480 $result = $this->GetTaglist(); | 480 $topic_id = $_postdata['topic_id']; |
481 $result = $this->GetTaglistByTopicID($topic_id); | |
482 | |
481 $taglistArray = array(); | 483 $taglistArray = array(); |
484 foreach ($result as $row) { | |
485 $taglistArray[$row[0]] = array($row[1], $row[2], $row[3]); | |
486 //$taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']); | |
487 // TODO: the format is not good, so I use $row[0], $row[1],... This could be changed some time. | |
488 } | |
489 | |
490 /* | |
491 //$result = $this->GetTaglist(); | |
492 $taglistArray = array(); | |
482 while ($row = mysql_fetch_assoc($result)) { | 493 while ($row = mysql_fetch_assoc($result)) { |
483 $taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']); | 494 $taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']); |
484 } | 495 } |
496 */ | |
485 | 497 |
486 $data = array(); | 498 $data = array(); |
487 $data['taglistArray'] = $taglistArray; | 499 $data['taglistArray'] = $taglistArray; |
500 $data['topic_id'] = $topic_id; | |
488 return $data; | 501 return $data; |
489 | 502 |
490 } | 503 } |
491 | 504 |
492 private function _GetTag($_postdata) { | 505 private function _GetTag($_postdata) { |
513 $this->GetSQLValueString($name, "text"), | 526 $this->GetSQLValueString($name, "text"), |
514 $this->GetSQLValueString($tag, "text"), | 527 $this->GetSQLValueString($tag, "text"), |
515 $this->GetSQLValueString($color, "text"), | 528 $this->GetSQLValueString($color, "text"), |
516 $this->GetSQLValueString($this->systemNAME, "text")); | 529 $this->GetSQLValueString($this->systemNAME, "text")); |
517 $result1 = mysql_query($query1); | 530 $result1 = mysql_query($query1); |
531 | |
532 | |
533 // add it to topic_tag_relation table | |
534 $topic_id = $postdata['topic_id']; | |
535 | |
536 // tag_id is $id; | |
537 $query = sprintf("INSERT INTO `topic_tag_relation` (`topic_id`,`tag_id`) VALUES (%s,%s)", $topic_id, $id); | |
538 $result = mysql_query($query); | |
539 if (!$result) { | |
540 echo json_encode("error when insert into topic_tag_relation table"); | |
541 } | |
518 } | 542 } |
519 | 543 |
520 } | 544 } |
521 | 545 |
522 public function SaveTagElement($postdata) { | 546 public function SaveTagElement($postdata) { |