annotate develop/models/extractapp.php @ 28:e6e9bdc4f256

update the saving response from LGService between different file version
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 03 Mar 2015 18:13:20 +0100
parents 4a29bccb6c59
children fc7342914cdf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
2
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
3 <?php
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
4
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
5 class ExtractappModel extends BaseModel{
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
7 public function Index() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
8 return array("Index Value 1", "Value 2", "Value 3");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
9 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
10
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
11 protected $section_id = 0, $data_path, $file_id = 0, $current_fileId=0, $branch_id = 0, $user_id = 0, $lg_text = "", $topic = 0;
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
12 public $messages = "";
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
13
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
14 private function Initialize($_urlvalues) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
15 $this->SetSectionId($_urlvalues);
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
16
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
17 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
18
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
19 public function GetTextFromFileId($_postdata) {
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
20
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
21 if ($this->current_fileId != 0) {
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
22 $this->file_id = $this->current_fileId;
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
23 } else {
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
24 $this->file_id = $_postdata['fileId'];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
25 }
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
26
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
27 $branch_id = $_postdata['branchId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
28 $section_id = $_postdata['sectionId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
29
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
30 $this->branch_id = $branch_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
31 $this->user_id = $_postdata['userId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
32 $this->section_id = $section_id;
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
33
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
34
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
35 $this->section_name = $_postdata['sectionName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
36 $this->book_id = $_postdata['bookId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
37 $this->book_name = $_postdata['bookName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
38
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
39
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
40 // get from URL with file_id
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
41 $lg_text_url = $this->get_text_from_fileId_url.$this->file_id;
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
42 $lg_text = file_get_contents($lg_text_url);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
43
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
44 $stringInput = $lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
45 $stringInput = preg_replace("/ /u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
46 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
47 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
48 $lg_text = $stringInput;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
49
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
50 $this->lg_text = $lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
51
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
52 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
53
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
54 public function GetTextFromSectionId($_postdata) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
55
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
56 $section_id = $_postdata['sectionId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
57 $this->section_id = $section_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
58 $this->user_id = $_postdata['userId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
59
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
60 // TODO: get info from LGService
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
61 $this->section_name = $_postdata['sectionName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
62 $this->book_id = $_postdata['bookId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
63 $this->book_name = $_postdata['bookName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
64
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
65
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
66
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
67 // get from URL with file_id
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
68 $lg_text_url = $this->get_text_from_sectionId_url.$section_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
69 $lg_text = file_get_contents($lg_text_url);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
70
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
71 $stringInput = $lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
72 $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
73 $stringInput = preg_replace("/ /u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
74 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
75 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
76 $lg_text = $stringInput;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
77
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
78 $this->lg_text = $lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
79 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
80
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
81 public function GetTextFromLocal($_id){
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
82 $this->section_id = $_id;
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
83 $this->messages .= "DEBUG: from my local"."<br>";
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
84 $this->lg_text = $this->GetSectionContent();
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
85
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
86 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
87
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
88 public function GetInfoFromPreviousPage($_postdata) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
89
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
90 if ($_postdata['fileId']) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
91 $this->file_id = $_postdata['fileId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
92 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
93 if ($_postdata['sectionId']) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
94 $this->section_id = $_postdata['sectionId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
95 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
96 if ($_postdata['text']) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
97 $this->lg_text = $_postdata['text'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
98 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
99 if ($_postdata['branchId']) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
100 $this->branch_id = $_postdata['branchId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
101 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
102 if ($_postdata['userId']) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
103 $this->user_id = $_postdata['userId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
104 }
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
105 if ($_postdata['topic_id']) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
106 $this->topic = $_postdata['topic_id'];
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
107 }
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
108
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
109 // TODO: LGService
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
110 if ($_postdata['sectionName']) {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
111 $this->section_name = $_postdata['sectionName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
112 }
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
113 if ($_postdata['bookName']) {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
114 $this->book_name = $_postdata['bookName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
115 }
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
116 if ($_postdata['bookId']) {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
117 $this->book_id = $_postdata['bookId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
118 }
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
119 if ($_postdata['currentFileId']) {
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
120 $this->current_fileId = $_postdata['currentFileId'];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
121 }
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
122
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
123
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
124
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
125 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
126 public function InitData($_postdata) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
127 $file_id = $_postdata['fileId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
128 $branch_id = $_postdata['branchId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
129 $section_id = $_postdata['sectionId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
130
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
131 $this->branch_id = $branch_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
132 $this->file_id = $file_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
133 $this->user_id = $_postdata['userId'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
134 $this->section_id = $section_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
135
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
136 if ($file_id != 0 && $branch_id != 0) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
137 // get from URL with file_id
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
138 $lg_text_url = $this->get_text_from_fileId_url.$file_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
139 } else if ($section_id != 0) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
140 // get from URL with section_id
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
141 $lg_text_url = $this->get_text_from_sectionId_url.$section_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
142 } else {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
143 echo "wrong url!!";
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
144 return;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
145 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
146
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
147
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
148 $lg_text = file_get_contents($lg_text_url);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
149
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
150 /*
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
151 $stringInput = preg_replace("/ /u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
152 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
153 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
154 */
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
155
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
156 // the text is from database
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
157 $stringInput = $lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
158 $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
159 $stringInput = preg_replace("/ /u", "○", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
160 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
161 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
162 $lg_text = $stringInput;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
163
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
164 $this->lg_text = $lg_text;
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
165
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
166
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
167 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
168
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
169 // === for tagging ===
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
170 public function StartTagging() {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
171
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
172 // $this->Initialize($urlvalues);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
173
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
174 $section_id = $this->section_id;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
175 $stringInput = $this->lg_text;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
176
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
177
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
178 //$taglistArray = $this->GetTaglistArray();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
179 //for GetTaglistByTopicID:
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
180 $taglistArray = $this->GetTaglistByTopicID($this->GetTopic());
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
181 // topic list
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
182 $topiclistArray = $this->GetTopiclistArray();
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
183
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
184
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
185 $wordlistArray = $this->GetWordlistArray();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
186
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
187 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
188 $data['stringInput'] = $stringInput;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
189 $data['taglistArray'] = $taglistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
190 $data['wordlistArray'] = $wordlistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
191 $data['section_id'] = $section_id;
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
192 $data['topiclistArray'] = $topiclistArray;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
193 $data['default_topic_id'] = $this->GetTopic();
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
194 $data['topic_tag'] = $this->GetTopicTag($this->GetTopic());
15
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
195 $data['topic_name'] = $this->GetTopicName($this->GetTopic());
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
196
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
197
26
579f03f8bee5 merge table books_info into table books (execute Home/Test)
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 25
diff changeset
198 $data['info'] = array('file_id'=>$this->file_id, 'user_id'=>$this->user_id,
579f03f8bee5 merge table books_info into table books (execute Home/Test)
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 25
diff changeset
199 'branch_id'=>$this->branch_id, 'section_id'=>$this->section_id, 'book_id'=>$this->book_id,
579f03f8bee5 merge table books_info into table books (execute Home/Test)
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 25
diff changeset
200 'book_name'=>$this->book_name, 'section_name'=>$this->section_name,
579f03f8bee5 merge table books_info into table books (execute Home/Test)
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 25
diff changeset
201 'current_fileId'=>$this->current_fileId);
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
202 //'current_fileId'=>$this->file_id);
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
203 //'current_fileId'=>'123');
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
204
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
205 $this->messages .= "Info: ";
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
206 $this->messages .= "file_id=".$this->file_id.", section_id=".$this->section_id;
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
207 $this->messages .= ", user_id=".$this->user_id.", branch_id=".$this->branch_id.", topic_id=".$this->topic;
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
208 $this->messages .= ", book_id=".$this->book_id.", book_name=".$this->book_name.", section_name=".$this->section_name;
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
209 $this->messages .= ", current_fileId=".$this->current_fileId."<br>";
27
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
210
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
211 $data['messages'] = $this->messages;
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
212
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
213 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
214
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
215 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
216
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
217 public function SaveFullText($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
218 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
219 $date = date('Y_m_d_H_i_s', time());
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
220 if ( file_exists("data/parsing_files/".$postdata['filename'].".txt") ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
221 $oldFile = file_get_contents("data/parsing_files/".$postdata['filename'].".txt");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
222 file_put_contents("data/parsing_files/".$postdata['filename']."_".$date.".txt", $oldFile);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
223 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
224
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
225 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
226 $require = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
227 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
228 $require = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
229 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
230
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
231 $require = preg_replace("/【<a(.*?)>(.*?)<\/a>】/u", "【\\2】", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
232 $require = preg_replace('/&amp;/u', "&", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
233 $require = preg_replace("/○/u", " ", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
234 $require = preg_replace("/<br>/u", "\n", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
235 $require = preg_replace("/<br>/u", "\n", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
236 file_put_contents("data/parsing_files/".$postdata['filename'].".txt", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
237 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
238
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
239 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
240
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
241 public function UpdateInfoByResponseFromLGService($response) {
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
242
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
243
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
244 $status = $response["status"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
245 if ($response["status"] == "error") {
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
246 $response_currentFile = $response["currentFile"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
247
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
248 $this->current_fileId = (string)$response_currentFile['id'];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
249 $this->messages .= "saving does not success! ".(string)$response["message"];
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
250
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
251
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
252 } else {
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
253
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
254 $response_file = $response["file"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
255 $response_branch = $response["branch"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
256
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
257 $this->messages .= "saving success.";
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
258 $this->file_id = (string)$response_file["id"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
259 $this->branch_id = (string)$response_branch["id"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
260
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
261 }
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
262
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
263
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
264 /*
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
265 $response_file = $response["file"];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
266 $response_branch = $response["branch"];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
267
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
268 $status = (string)$response["status"];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
269 if ($status == "ok") {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
270 $this->messages .= "saving success.";
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
271 $this->file_id = (string)$response_file["id"];
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
272 $this->branch_id = (string)$response_branch["id"];
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
273
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
274 } else if ($status == "error") {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
275 // saving not success
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
276 $this->messages .= "saving does not success! ".(string)$response["message"];
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
277 $this->current_fileId = $response["currentFileId"];
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
278 }
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
279 */
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
280
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
281
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
282 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
283 public function SaveFullTextToLGService($_postdata) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
284 // save tagged text (full text) by Jorge's API to lg service
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
285
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
286 // --------
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
287 if ($_postdata['text']){
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
288 $date = date('Y_m_d_H_i_s', time());
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
289 if ( file_exists("data/parsing_files/".$_postdata['sectionId'].".txt") ) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
290 $oldFile = file_get_contents("data/parsing_files/".$_postdata['sectionId'].".txt");
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
291 //saving in my local machine in developing phrase
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
292 file_put_contents("data/parsing_files/".$_postdata['sectionId']."_".$date.".txt", $oldFile);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
293 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
294
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
295 if (get_magic_quotes_gpc()) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
296 $require = stripslashes($_postdata['text']);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
297 } else {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
298 $require = $_postdata['text'];
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
299 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
300
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
301 $require = preg_replace("/【<a(.*?)>(.*?)<\/a>】/u", "【\\2】", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
302 $require = preg_replace('/&amp;/u', "&", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
303 $require = preg_replace("/○/u", " ", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
304 $require = preg_replace("/<br>/u", "\n", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
305 $require = preg_replace("/<br>/u", "\n", $require);
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
306 //saving in my local machine in developing phrase
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
307 file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
308 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
309
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
310 // ------
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
311
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
312
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
313 if ($_postdata['branchId'] != 0) {
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
314 // -- exiting branch case
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
315 $postfields = array(
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
316 "text" => $require,
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
317 "branchId" => $_postdata['branchId'],
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
318 "userId" => $_postdata['userId'],
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
319 "userPreviousFileId" => $_postdata['fileId'],
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
320 );
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
321 $save_url = $this->save_to_LGService_url;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
322
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
323 } else {
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
324 // -- new branch case
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
325 echo "saveNew!";
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
326 if ($_postdata['userId']) {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
327 $user_id = $_postdata['userId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
328 } else {
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
329 $user_id = "12";
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
330 }
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
331 $postfields = array(
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
332 "text" => $require,
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
333 "sectionId" => $_postdata['sectionId'],
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
334 "userId" => $user_id,
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
335 "label" => $_postdata['label'],
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
336 );
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
337 $save_url = $this->save_new_to_LGService_url;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
338 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
339
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
340
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
341 // set up the curl resource
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
342 $ch = curl_init();
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
343 curl_setopt($ch, CURLOPT_URL, $save_url);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
344 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
345 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
346 curl_setopt($ch, CURLOPT_POST, true);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
347 curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
348 //curl_setopt($ch, CURLOPT_HEADER, true);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
349 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
350 'Content-type: multipart/form-data;charset=utf-8'
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
351 ));
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
352
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
353 // execute the request
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
354
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
355 //$output = curl_exec($ch);
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
356
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
357
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
358 // output the profile information - includes the header
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
359 echo($output) . PHP_EOL;
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
360
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
361 // close curl resource to free up system resources
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
362 curl_close($ch);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
363
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
364 $response = json_decode($output, true);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
365 return $response;
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
366
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
367 }
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
368
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
369 // --- for regex ----
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
370 public function GetRegexFilenameById($topic_id) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
371 $query = sprintf("SELECT regex_filename FROM `topic_regex_relation` WHERE topic_id=\"%s\"", $topic_id);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
372 $result = mysql_query($query);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
373 if (!$result) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
374 return json_encode("Failed during selecting topic_regex_relation table.");
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
375 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
376
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
377 $filenames = array();
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
378 while ($row = mysql_fetch_assoc($result)) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
379 array_push($filenames, $row['regex_filename']);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
380 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
381
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
382 return $filenames;
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
383 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
384 public function SmartRegexLoad($topic_id) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
385
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
386 // Load regex file based on current topic. Only shows the regex in this topic --
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
387 $filenames = $this->GetRegexFilenameById($topic_id);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
388
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
389 // Get regex file from filesystem ----
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
390 $data_path = "./data/"; // get the current file path, which is getcwd(), and concatenate with "/data/"
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
391 $returnArray = array();
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
392 $files1 = scandir($data_path."regex_files");
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
393 foreach ( $files1 as $file ) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
394 if ( $file != "." && $file != ".." && $file != ".DS_Store") {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
395 foreach ($filenames as $filename) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
396 if ($file == $filename) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
397 $returnArray[preg_replace("/\.txt/", "", $file)] = file_get_contents( $data_path."regex_files/".$file );
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
398 break;
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
399 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
400 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
401 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
402 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
403 echo json_encode($returnArray);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
404 return;
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
405 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
406
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
407
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
408 public function SmartRegexSave($_postdata) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
409 if ($_postdata['text']){
27
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
410
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
411 // --- update topic_regex_relation table ---
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
412 $topic_id = $_postdata['topic_id'];
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
413 $filename = $_postdata['filename'].'.txt';
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
414
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
415 // check if already existing a record for this regex file
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
416 $query = "SELECT * FROM topic_regex_relation WHERE topic_id=".$topic_id." AND regex_filename='".$filename."'";
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
417 $result = mysql_query($query);
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
418 if (!$result) {
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
419 echo json_encode("ErrorDB");
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
420 }
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
421 while ($row = mysql_fetch_assoc($result)) {
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
422 if ($row && !$_postdata['forcesave']) {
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
423 // promt user a comfirm to force saving or not
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
424 echo json_encode("ForceSave");
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
425 return;
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
426 }
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
427 }
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
428
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
429
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
430 if (!$_postdata['forcesave']) {
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
431 $query = "INSERT INTO topic_regex_relation (topic_id, regex_filename) VALUES (".$topic_id.",'".$filename."')";
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
432 $result = mysql_query($query);
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
433 if (!$result) {
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
434 echo json_encode("ErrorDB");
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
435 }
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
436 }
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
437 // --- write to filesystem ---
4a29bccb6c59 modify the SmartRegexSave method to prevent duplicated records in topic_regex_relation table and provide better promting to user to force saving regex file or not
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
438
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
439 /*
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
440 $date = date('Y_m_d_H_i_s', time());
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
441 if ( file_exists("regex_files/".$_POST['filename'].".txt") ) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
442 $oldFile = file_get_contents("regex_files/".$_POST['filename'].".txt");
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
443 file_put_contents("regex_files/".$_POST['filename']."_".$date.".txt", $oldFile);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
444 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
445 */
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
446 $data_path = "./data/"; // get the current file path, which is getcwd(), and concatenate with "/data/"
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
447
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
448 if (get_magic_quotes_gpc()) {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
449 $require = stripslashes($_postdata['text']);
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
450 } else {
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
451 $require = $_postdata['text'];
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
452 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
453
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
454 file_put_contents( $data_path."regex_files/".$_postdata['filename'].".txt", $require);
20
04db1dd9d10d update topic_regex_relation table when saving (new) regex file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 19
diff changeset
455
04db1dd9d10d update topic_regex_relation table when saving (new) regex file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 19
diff changeset
456
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
457 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
458 }
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
459
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
460
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
461 // === for export table ===
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
462 public function ExportTable($postdata) {
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
463 // $this->Initialize($urlvalues);
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
464
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
465 $content = $postdata['content'];
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
466 $topic = $postdata['topic'];
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
467 $section_id = $postdata['sectionId'];
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
468
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
469 //$section_id = $this->section_id;
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
470
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
471
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
472 // TODO: this should be get from LGService: sectionName, bookId, bookName
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
473 $sectionName = $postdata['sectionName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
474 $bookId = $postdata['bookId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
475 $bookName = $postdata['bookName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
476
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
477
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
478 // --- replace if get info from LGService
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
479 /*
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
480 $section_info = $this->GetSectionInfo();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
481
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
482 $sectionName = $section_info['sectionName'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
483 $bookId = $section_info['bookId'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
484
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
485 $books_info = $this->GetBooksInfo($bookId);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
486 $bookName = $books_info['bookName'];
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
487 */
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
488 // =====
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
489
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
490
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
491 $outputTableArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
492
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
493 //$taglistArray = $this->GetTaglistArray();
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
494 $taglistArray = $this->GetTaglistByTopicID($topic);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
495
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
496 $outputTableArray[0]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
497 $outputTableArray[0][0]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
498 $outputTableArray[0][1]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
499 foreach ( $taglistArray as $value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
500 $outputTableArray[0][0][$value[2]] = $value[1];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
501 $outputTableArray[0][1][$value[2]] = $value[1]."(Title)";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
502 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
503 $outputTableArray[0]["other"] = "其他";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
504 $outputTableArray[0]["page"] = "頁數";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
505 $outputTableArray[0]["full"] = "全文";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
506
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
507 foreach ( $taglistArray as $tagValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
508 $content = preg_replace("/<\/".$tagValue[2].">○*<".$tagValue[2].">/u", "", $content);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
509 $content = preg_replace("/<".$tagValue[2].">[ ]*<\/".$tagValue[2].">/u", "", $content);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
510 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
511
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
512 $contentLineArray = explode( "<br>", $content );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
513
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
514 $count=0;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
515 $pageNow=NULL;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
516 foreach ( $contentLineArray as $value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
517 $count++;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
518 $recordString = $value;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
519 $otherString = $recordString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
520 //echo $recordString."<br>\n";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
521 if ( preg_match("/【<a(.*?)>(.*?)<\/a>】/u", $recordString, $matches) ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
522 $pageNow = $matches[2];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
523 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
524 foreach ( $taglistArray as $tagValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
525 if ( preg_match_all("/<".$tagValue[2].">(.*?)<\/".$tagValue[2].">/u", $recordString, $matches, PREG_SET_ORDER) ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
526 foreach ( $matches as $matchesValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
527 $matchesValue[1] = preg_replace("/○/u", "", $matchesValue[1]);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
528 if ( preg_match_all("/〈(.*?)〉/u", $matchesValue[1], $matches2, PREG_SET_ORDER) ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
529 foreach ( $matches2 as $matches2Value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
530 if ( isset($outputTableArray[$count][0][$tagValue[2]]) ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
531 $outputTableArray[$count][0][$tagValue[2]] .= ";".$matches2Value[1];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
532 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
533 $outputTableArray[$count][0][$tagValue[2]] = $matches2Value[1];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
534 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
535 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
536 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
537 if ( isset($outputTableArray[$count][0][$tagValue[2]]) ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
538 $outputTableArray[$count][0][$tagValue[2]] .= ";".$matchesValue[1];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
539 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
540 $outputTableArray[$count][0][$tagValue[2]] = $matchesValue[1];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
541 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
542 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
543 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
544 $otherString = preg_replace("/<".$tagValue[2].">(.*?)<\/".$tagValue[2].">/u", " ", $otherString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
545 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
546 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
547 $otherString = preg_replace("/○/u", "", $otherString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
548 $outputTableArray[$count]["other"] = $otherString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
549 $outputTableArray[$count]["page"] = $pageNow;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
550 $value = preg_replace("/>/u", "&gt;", $value);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
551 $value = preg_replace("/</u", "&lt;", $value);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
552 $outputTableArray[$count]["full"] = $value;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
553 }
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
554 /*
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
555 echo "<br>"."DEBUG: outputTableArray:"."<br>";
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
556 var_dump($outputTableArray);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
557 */
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
558
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
559 $topic_tag = $this->GetTopicTag($topic);
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
560
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
561 foreach ( $outputTableArray as $arrayIndex => $arrayValue ) {
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
562 // output each row which the topic tag
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
563 // e.g. the original version is for 'person'
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
564 if ( !isset($arrayValue[0][$topic_tag]) ) {
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
565 unset($outputTableArray[$arrayIndex]);
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
566 }
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
567
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
568 /*
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
569 if ($topic == 1) {
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
570 if ( !isset($arrayValue[0]["person"]) ) {
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
571 unset($outputTableArray[$arrayIndex]);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
572 }
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
573 } else if ($topic == 2) {
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
574
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
575 // for object topic
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
576 if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
577 unset($outputTableArray[$arrayIndex]);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
578 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
579 }
13
cc36a20a68ab automatically decide which rows (what data) should be shown in the exporting table based on the topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 12
diff changeset
580 */
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
581
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
582 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
583
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
584 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
585
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
586 $data['outputTableArray'] = $outputTableArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
587 $data['bookId'] = $bookId;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
588 $data['section_id'] = $section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
589 $data['bookName'] = $bookName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
590 $data['sectionName'] = $sectionName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
591
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
592 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
593
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
594 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
595
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
596 // === for manage tag list ===
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
597 public function EditTaglist($_postdata) {
22
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
598 $query = "SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='taglist'";
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
599 $result = mysql_query($query);
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
600 if (!$result) {
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
601 echo json_encode(mysql_error());
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
602 }
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
603 $row = mysql_fetch_assoc($result);
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
604 $largest_id = $row['AUTO_INCREMENT'];
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
605
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
606
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
607 $topic_id = $_postdata['topic_id'];
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
608 $result = $this->GetTaglistByTopicID($topic_id);
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
609
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
610 $taglistArray = array();
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
611 foreach ($result as $row) {
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
612 $taglistArray[$row[0]] = array($row[1], $row[2], $row[3]);
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
613 //$taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']);
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
614 // TODO: the format is not good, so I use $row[0], $row[1],... This could be changed some time.
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
615 }
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
616
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
617 /*
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
618 //$result = $this->GetTaglist();
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
619 $taglistArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
620 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
621 $taglistArray[$row['id']] = array($row['name'], $row['tag'], $row['color']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
622 }
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
623 */
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
624
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
625 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
626 $data['taglistArray'] = $taglistArray;
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
627 $data['topic_id'] = $topic_id;
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
628 $data['largest_id'] = $largest_id;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
629
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
630
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
631 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
632
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
633 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
634
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
635 private function _GetTag($_postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
636 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
637 $id = stripslashes($_postdata['id']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
638 $name = stripslashes($_postdata['name']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
639 $tag = stripslashes($_postdata['tag']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
640 $color = stripslashes($_postdata['color']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
641 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
642 $id = $_postdata['id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
643 $name = $_postdata['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
644 $tag = $_postdata['tag'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
645 $color = $_postdata['color'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
646 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
647 return array($id, $name, $tag, $color);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
648 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
649
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
650 public function NewTagElement($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
651 if ($postdata['id']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
652 list($id, $name, $tag, $color) = $this->_GetTag($postdata);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
653
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
654 $query1 = sprintf("INSERT INTO `taglist` (`id`, `name`, `tag`, `color`, `systemName`) VALUES (%s, %s, %s, %s, %s)",
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
655 $this->GetSQLValueString($id, "int"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
656 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
657 $this->GetSQLValueString($tag, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
658 $this->GetSQLValueString($color, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
659 $this->GetSQLValueString($this->systemNAME, "text"));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
660 $result1 = mysql_query($query1);
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
661
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
662
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
663 // add it to topic_tag_relation table
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
664 $topic_id = $postdata['topic_id'];
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
665
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
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
666 // tag_id is $id;
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
667 $query = sprintf("INSERT INTO `topic_tag_relation` (`topic_id`,`tag_id`) VALUES (%s,%s)", $topic_id, $id);
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
668 $result = mysql_query($query);
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
669 if (!$result) {
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
670 echo json_encode("error when insert into topic_tag_relation table");
82f8c6bd2b69 add new tag will based on the current topic_id, insert new element into (1)taglist table and (2)topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 15
diff changeset
671 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
672 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
673
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
674 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
675
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
676 public function SaveTagElement($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
677 if ($postdata['id']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
678 list($id, $name, $tag, $color) = $this->_GetTag($postdata);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
679
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
680 $query = sprintf("UPDATE taglist SET `name`=%s, `tag`=%s, `color`=%s WHERE `id`=%s",
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
681 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
682 $this->GetSQLValueString($tag, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
683 $this->GetSQLValueString($color, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
684 $this->GetSQLValueString($id, "int"));
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
685 $result = mysql_query($query);
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
686
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
687 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
688
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
689 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
690
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
691 public function DeleteTag($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
692 if ($postdata['id']) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
693 $queryInsert = sprintf("DELETE FROM `taglist` WHERE `id` = %s", stripslashes($postdata['id']));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
694 $resultInsert = mysql_query($queryInsert);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
695 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
696
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
697 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
698
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
699 // === for config topic ===
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
700 public function ConfigTagsInTopic($postdata) {
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
701 $topic = $postdata['topic'];
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
702 $result = $this->GetTopicByID($topic);
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
703 $row = mysql_fetch_assoc($result);
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
704 $topic_name = $row['name'];
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
705
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
706 /*
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
707 $query = "SELECT taglist.*, topic_tag_relation.topic_id FROM taglist LEFT JOIN topic_tag_relation ON taglist.id = topic_tag_relation.tag_id ORDER BY `topic_id`";
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
708 $result = mysql_query($query);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
709 if (!$result) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
710 return json_encode("Failed during selecting/joining taglist and topic_tag_relation table.");
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
711 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
712 $taglistArray = array();
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
713 while ($row = mysql_fetch_assoc($result)) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
714 array_push($taglistArray, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']) );
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
715 }
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
716 */
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
717
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
718 // ------
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
719 $query = "SELECT taglist.*, topic_tag_relation.topic_id FROM taglist LEFT JOIN topic_tag_relation ON taglist.id = topic_tag_relation.tag_id ORDER BY `topic_id`";
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
720 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
721 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
722 return json_encode("Failed during selecting/joining taglist and topic_tag_relation table.");
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
723 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
724
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
725 $tag_intopic = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
726 $tag_others = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
727 $tag_tmp_others = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
728 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
729 if ($row['topic_id'] == $topic) {
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
730 array_push($tag_intopic, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
731 } else {
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
732 array_push($tag_tmp_others, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
733 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
734 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
735
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
736 // --- check if there's any duplicated tags in tag_tmp_others. remove the duplicated tags
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
737 $num_others = count($tag_tmp_others);
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
738 for ($i=0; $i < $num_others; $i++) {
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
739 $cnt = 0;
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
740 for ($j=$i+1; $j < $num_others; $j++) {
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
741 if ($tag_tmp_others[$i]['tag'] == $tag_tmp_others[$j]['tag']) {
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
742 break;
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
743 } else {
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
744 $cnt++;
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
745 }
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
746 }
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
747 if ($cnt == ($num_others-$i-1) ) {
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
748 $row = $tag_tmp_others[$i];
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
749 array_push($tag_others, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']) );
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
750 }
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
751 }
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
752
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
753 // --- remove duplicated tags in tag_others that is duplicated with tags in tag_intopic
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
754 $tag_tmp_others = $tag_others;
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
755 $tag_others = array();
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
756
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
757 foreach ($tag_tmp_others as $tmp) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
758 $cnt = 0;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
759 foreach ($tag_intopic as $intopic) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
760 if ($tmp['tag'] == $intopic['tag']) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
761 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
762 } else {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
763 $cnt ++;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
764 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
765 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
766 if ($cnt == count($tag_intopic)) {
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
767 // not appear in $tag_intopic
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
768 array_push($tag_others, $tmp);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
769 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
770 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
771
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
772 // -----
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
773
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
774
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
775 $data = array();
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
776 //$data['taglistArray'] = $taglistArray;
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
777 $data['topic'] = $topic;
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
778 $data['topic_name'] = $topic_name;
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
779
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
780 $data['tag_intopic'] = $tag_intopic;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
781 $data['tag_others'] = $tag_others;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
782
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
783 return $data;
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
784 }
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
785
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
786
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
787 public function UpdateTagsInTopic($_postdata) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
788 $topic_id = $_postdata['topic_id'];
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
789 $tag_ids = json_decode(str_replace('\\', '', $_postdata['ids']));
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
790
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
791 // update topic_tag_relation by tags_ids array as `tag_id` and topic_id as `topic_id`
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
792 // --- add new topic_tag_relation ---
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
793 foreach ($tag_ids as $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
794 $query = "SELECT * FROM topic_tag_relation WHERE tag_id=".$tag_id;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
795 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
796 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
797 echo json_encode("error when select from topic_tag_relation");
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
798 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
799 $topic_tag = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
800 $flag = false;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
801 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
802 if ($row['topic_id'] == $topic_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
803 $flag = true;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
804 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
805 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
806 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
807 if (!$flag) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
808 // insert a row into topic_tag_relation table
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
809 $queryUpdate = "INSERT INTO topic_tag_relation (topic_id, tag_id) VALUES (".$topic_id.",".$tag_id.")";
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
810 $resultUpdate = mysql_query($queryUpdate);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
811 if (!$resultUpdate) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
812 return json_encode("error when insert topic_tag_relation table");
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
813 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
814 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
815
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
816 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
817
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
818 // --- remove tags from this topic ---
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
819 $query = "SELECT * FROM topic_tag_relation WHERE topic_id=".$topic_id;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
820 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
821 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
822 echo json_encode("error when select from topic_tag_relation");
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
823 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
824
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
825 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
826 $cnt = 0;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
827 foreach ($tag_ids as $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
828 if ($row['tag_id'] == $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
829 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
830 } else {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
831 $cnt ++;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
832 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
833 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
834 $_id = $row['id'];
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
835 if ($cnt == count($tag_ids)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
836 // delete row with (topic_id, tag_ids)
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
837 $queryDelete = "DELETE FROM topic_tag_relation WHERE id=".$_id;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
838 $resultDelete = mysql_query($queryDelete);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
839 if (!$resultDelete) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
840 echo json_encode("error when delete from topic_tag_relation");
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
841 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
842 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
843 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
844
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
845
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
846
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
847 /*
23
a879f6b9d166 modification for select-move-taglist: tags don't appear to be duplicated in other topics.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 22
diff changeset
848 $query = "SELECT * FROM topic_tag_relation";
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
849 $result = mysql_query($query);
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
850 if (!$result) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
851 echo json_encode("error when select from topic_tag_relation");
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
852 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
853 $topic_tag = array();
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
854 while ($row = mysql_fetch_assoc($result)) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
855 array_push($topic_tag, array('tag_id'=>$row['tag_id'], 'topic_id'=>$row['topic_id']));
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
856 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
857
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
858
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
859 foreach ($topic_tag as $value) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
860 $flag = false;
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
861 foreach ($tag_ids as $tag_id) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
862 if ($value['tag_id'] == $tag_id) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
863 //update its topic_id to $topic_id
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
864 $queryUpdate = "UPDATE topic_tag_relation SET topic_id=".$topic_id." WHERE tag_id=".$tag_id;
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
865 $resultUpdate = mysql_query($queryUpdate);
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
866 if (!$resultUpdate) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
867 return json_encode("error when update topic_tag_relation table");
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
868 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
869 $flag = true;
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
870 break;
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
871 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
872 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
873 if (!$flag && $value['topic_id'] == $topic_id) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
874 // set its topic_id to 0, indicating unsigned
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
875 $queryUpdate = "UPDATE topic_tag_relation SET topic_id=0 WHERE tag_id=".$value['tag_id'];
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
876 $resultUpdate = mysql_query($queryUpdate);
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
877 if (!$resultUpdate) {
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
878 return json_encode("error when update topic_tag_relation table");
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
879 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
880 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
881 }
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
882 */
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
883
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
884 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
885
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
886
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
887 private function GetTaglistByTopicID($topic_id) {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
888 $taglistArray = array();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
889 // select taglist ids from topic_tag_relation table
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
890 $query = sprintf("SELECT * FROM `topic_tag_relation` WHERE `topic_id`='%s'", $topic_id);
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
891 $result = mysql_query($query);
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
892 if (!$result) {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
893 return json_encode("Failed during selecting topic_tag_relation table.");
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
894 }
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
895 $taglist_ids = array();
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
896
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
897 while ($row = mysql_fetch_assoc($result)) {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
898 array_push($taglist_ids, $row['tag_id']);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
899 }
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
900
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
901 // select taglist by tag ids
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
902 foreach ($taglist_ids as $tag_id) {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
903 $query = sprintf("SELECT * FROM `taglist` WHERE `id`='%s'", $tag_id);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
904 $result = mysql_query($query);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
905 if (!$result) {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
906 echo mysql_error();
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
907 return json_encode("Failed during selecting taglist table.");
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
908 }
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
909
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
910 $row = mysql_fetch_assoc($result);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
911 array_push($taglistArray, array( $row['id'], $row['name'], $row['tag'], $row['color'] ));
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
912
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
913 }
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
914 return $taglistArray;
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
915 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
916
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
917 public function SetTopic($topic) {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
918 $this->topic = $topic;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
919 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
920
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
921 public function GetTopic() {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
922 return $this->topic;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
923 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
924
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
925 private function GetTopiclistArray() {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
926 $topiclistArray = array();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
927 $result = $this->GetTopiclist();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
928 while ($row = mysql_fetch_assoc($result)) {
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
929 array_push($topiclistArray, array('id'=>$row['id'],'name'=>$row['name'],'tag'=>$row['tag']));
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
930 }
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
931 return $topiclistArray;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
932 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
933
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
934
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
935 private function GetTopicTag($topic_id) {
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
936 $result = $this->GetTopicByID($topic_id);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
937 $row = mysql_fetch_assoc($result);
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
938 $tag = $row['tag'];
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
939 return $tag;
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
940
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
941 }
15
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
942 private function GetTopicName($topic_id) {
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
943 $result = $this->GetTopicByID($topic_id);
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
944 $row = mysql_fetch_assoc($result);
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
945 $name = $row['name'];
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
946 return $name;
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
947
1f98c92ebbfb first version of UI layout. Very roughly, but works in the fixed sidebar, head line, popups and so on.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 14
diff changeset
948 }
11
3d6fba07bfbd implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
949
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
950
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
951 // ===========================
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
952
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
953 // === for manage wordlist ===
14
ac77748bb813 - Load regex files based on current topic. Only show the regex in this topic.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 13
diff changeset
954 public function EditWordlist() {
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
955 $result = $this->GetWordlist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
956 $wordlistArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
957 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
958 $wordlistArray[$row['id']] = $row['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
959 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
960
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
961 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
962 $data['wordlistArray'] = $wordlistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
963 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
964 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
965
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
966
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
967 public function AddNewList($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
968 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
969 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
970 $name = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
971 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
972 $name = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
973 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
974
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
975 $query1 = sprintf("INSERT INTO `wordlist` (`name`, `systemName`) VALUES (%s, %s)",
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
976 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
977 $this->GetSQLValueString($this->systemNAME, "text"));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
978 $result1 = mysql_query($query1);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
979 file_put_contents( "data/wordlist/".mysql_insert_id().".txt", "(empty now)");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
980 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
981 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
982
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
983
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
984 public function SaveWordlist($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
985
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
986 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
987 $date = date('Y_m_d_H_i_s', time());
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
988 if ( file_exists("data/wordlist/".$postdata['filename'].".txt") ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
989 $filename = "data/wordlist/".$postdata['filename']."_".$date.".txt";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
990 $oldFile = file_get_contents("data/wordlist/".$postdata['filename'].".txt");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
991 file_put_contents($filename, $oldFile);
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
992 }
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
993 /*else {
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
994 $filename = "data/wordlist/".$postdata['filename'].".txt";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
995 }
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
996 */
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
997
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
998
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
999 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1000 $require = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1001 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1002 $require = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1003 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1004
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1005 $require = preg_replace("/<br>/u", "<br>", $require);
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
1006 file_put_contents("data/wordlist/".$postdata['filename'].".txt", $require);
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1007 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1008 /*
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1009 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1010 $date = date('Y_m_d_H_i_s', time());
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1011 if ( file_exists("data/wordlist/".$postdata['filename'].".txt") ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1012 $oldFile = file_get_contents("data/wordlist/".$postdata['filename'].".txt");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1013 file_put_contents("data/wordlist/".$postdata['filename']."_".$date.".txt", $oldFile);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1014 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1015
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1016 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1017 $require = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1018 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1019 $require = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1020 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1021
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1022 // $require = preg_replace("/<br>/u", "", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1023 file_put_contents("data/wordlist/".$postdata['filename'].".txt", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1024 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1025 */
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1026 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1027
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1028
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1029 // =======================================
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1030
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1031 public function sortFunction($a,$b) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1032 return strlen($b)-strlen($a);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1033 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1034
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1035 // TODO: delete this
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1036 private function SetSectionId($_urlvalues) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1037 // TODO: maybe get user info also
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1038 // get book id from url
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1039 if ($_urlvalues['id'] != "") {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1040 $section_id = $_urlvalues['id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1041 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1042 return json_encode("Error: No section id");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1043 /* ???? */
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1044 /*
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1045 $get_book_id = $urlvalues['book'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1046 $get_start = $urlvalues['start'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1047 $get_end = $urlvalues['end'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1048 */
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1049 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1050 $this->section_id = $section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1051
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1052 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1053
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1054 private function GetSectionId() {
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1055
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1056 if (is_numeric($this->section_id)) {
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1057 return $this->section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1058 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1059 return json_encode("Error: No section id");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1060 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1061 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1062
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1063 private function GetSectionInfo() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1064 $section_id = $this->GetSectionId();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1065 if (!is_numeric($section_id)){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1066 return $section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1067 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1068
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1069 $result = $this->GetSectionsByID($section_id);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1070
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1071
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1072 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1073 $bookId=$row['books_id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1074 $startPage=$row['start_page'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1075 $endPage=$row['end_page'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1076 $sectionName = $row['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1077 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1078
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1079 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1080 $data['bookId'] = $bookId;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1081 $data['startPage'] = $startPage;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1082 $data['endPage'] = $endPage;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1083 $data['sectionName'] = $sectionName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1084
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1085
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1086 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1087 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1088
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1089 private function GetSectionContent() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1090 $section_id = $this->GetSectionId();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1091 $section_info = $this->GetSectionInfo();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1092
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1093 $bookId = $section_info['bookId'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1094 $startPage = $section_info['startPage'];
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1095 $endPage = $section_info['endPage'];
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1096
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1097 $contentString="";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1098 $data_path = $this->GetDataPath();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1099 if ( file_exists($data_path."parsing_files/".$section_id.".txt") ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1100 $contentString=file_get_contents($data_path."parsing_files/".$section_id.".txt");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1101 $stringInput = $contentString;
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1102
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1103 // if the text is from file system
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1104 $stringInput = preg_replace("/ /u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1105 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1106 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1107 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1108 $query = sprintf("SELECT `content`, `line`, `books_id` FROM `contents` WHERE `books_id`=\"%s\" AND `line`>=%d AND `line`<=%d", $bookId, $startPage, $endPage);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1109 $result = mysql_query($query);
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1110 if (!$result) {
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1111 return json_encode("Failed during selecting content table.");
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1112 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1113 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1114 $contentString.="【".$row['line']."】".$row['content']."\n";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1115 }
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1116
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1117 // the text is from database
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1118 $stringInput = $contentString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1119 $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1120 $stringInput = preg_replace("/ /u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1121 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1122 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1123 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1124
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1125 return $stringInput;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1126 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1127
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1128 private function GetDataPath() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1129 return getcwd()."/data/"; // get the current file path, which is getcwd(), and concatenate with "/data/"
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1130 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1131
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1132 private function GetTaglistArray() {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1133 $taglistArray = array();
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1134 $result = $this->GetTaglist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1135 while ($row = mysql_fetch_assoc($result)) {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1136 array_push($taglistArray, array( $row['id'], $row['name'], $row['tag'], $row['color'] ));
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1137 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1138
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1139 return $taglistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1140 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1141
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1142 private function GetWordlistArray() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1143 $wordlistArray="";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1144 $result = $this->GetWordlist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1145 while ($row = mysql_fetch_assoc($result)) {
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
1146 $listString = file_get_contents("data/wordlist/".$row['id'].".txt");
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1147 $listString = preg_replace("/<div>/u", "\n", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1148 $listString = preg_replace("/<\/div>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1149 $listString = preg_replace("/<span(.*?)>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1150 $listString = preg_replace("/<\/span>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1151 //$listString = preg_replace("/\n/u", "|", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1152
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1153 $wordlistArray2 = explode( "\n", $listString );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1154 usort($wordlistArray2,'sortFunction');
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1155 foreach ( $wordlistArray2 as $index=>$value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1156 $wordlistArray2[$index] = implode("○?", preg_split("/(?<!^)(?!$)/u", $value));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1157 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1158 foreach ( $wordlistArray2 as $index=>$value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1159 if ($value=="") unset($wordlistArray2[$index]);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1160
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1161 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1162 $listString = implode("|", $wordlistArray2);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1163
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1164 if ( $listString[0]=="|" ) $listString = substr($listString, 1);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1165 $wordlistArray[] = array( $row['id'], $row['name'], $listString );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1166 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1167
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1168
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1169 return $wordlistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1170
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1171 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1172
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1173 protected function GetBooksInfo($bookId) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1174 $result = $this->GetSectionsByID($bookId);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1175 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1176 $bookName = $row['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1177 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1178
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1179 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1180 $data['bookName'] = $bookName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1181
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1182 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1183 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1184
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1185
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1186 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1187
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1188
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1189
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1190 ?>