Mercurial > hg > extraction-interface
annotate develop/models/extractapp.php @ 41:533a6c39c128 extractapp
save xml file to LGService
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 10 Mar 2015 14:13:21 +0100 |
parents | 2e938dc046db |
children | c245d54eab9f |
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 |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
11 protected $section_id = 0, $data_path, $file_id = 0, $current_fileId=0, |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
12 $branch_id = 0, $user_id = 0, $lg_text = "", $topic = 0, $taglist_infile = "", $book_meta = ""; |
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
|
13 public $messages = ""; |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
14 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
15 private function Initialize($_urlvalues) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
16 $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
|
17 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
18 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
19 |
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
|
20 public function GetTextFromFileId($_postdata) { |
29 | 21 $this->file_id = $_postdata['fileId']; |
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
|
22 $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
|
23 $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
|
24 |
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
|
25 $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
|
26 $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
|
27 $this->section_id = $section_id; |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
28 |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
29 $this->section_name = $_postdata['sectionName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
30 $this->book_id = $_postdata['bookId']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
31 $this->book_name = $_postdata['bookName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
32 |
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
|
33 // 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
|
34 $lg_text_url = $this->get_text_from_fileId_url.$this->file_id; |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
35 //$lg_text = file_get_contents($lg_text_url); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
36 // --- parsing meta data |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
37 $lg_text = $this->ParseMetaData($lg_text_url); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
38 |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
39 // ---- |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
40 |
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
|
41 |
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 $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
|
43 $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
|
44 $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
|
45 $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
|
46 $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
|
47 |
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 $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
|
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 } |
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 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
|
53 $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
|
54 $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
|
55 $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
|
56 |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
57 $this->section_name = $_postdata['sectionName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
58 $this->book_id = $_postdata['bookId']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
59 $this->book_name = $_postdata['bookName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
60 |
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
|
61 // 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
|
62 $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
|
63 $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
|
64 |
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
|
65 $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
|
66 $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
|
67 $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
|
68 $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
|
69 $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
|
70 $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
|
71 |
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 $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
|
73 } |
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 |
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 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
|
76 $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
|
77 $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
|
78 $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
|
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 |
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 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
|
83 |
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 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
|
85 $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
|
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 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
|
88 $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
|
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['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
|
91 $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
|
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['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
|
94 $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
|
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['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
|
97 $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
|
98 } |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
99 if ($_postdata['topic_id']) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
100 $this->topic = $_postdata['topic_id']; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
101 } |
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
|
102 |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
103 if ($_postdata['sectionName']) { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
104 $this->section_name = $_postdata['sectionName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
105 } |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
106 if ($_postdata['bookName']) { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
107 $this->book_name = $_postdata['bookName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
108 } |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
109 if ($_postdata['bookId']) { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
110 $this->book_id = $_postdata['bookId']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
111 } |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
112 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
|
113 $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
|
114 } |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
115 if ($_postdata['taglistArray']) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
116 $this->taglist_infile = json_decode($_postdata['taglistArray']); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
117 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
118 if ($_postdata['book_meta']) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
119 $this->book_meta = json_decode($_postdata['book_meta']); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
120 } |
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
|
121 |
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
|
122 } |
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
|
123 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
|
124 $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
|
125 $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
|
126 $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
|
127 |
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 $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
|
129 $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
|
130 $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
|
131 $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
|
132 |
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 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
|
134 // 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
|
135 $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
|
136 } 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
|
137 // 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
|
138 $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
|
139 } 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
|
140 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
|
141 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
|
142 } |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
143 |
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
|
144 |
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 $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
|
146 |
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 $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
|
149 $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
|
150 $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
|
151 */ |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
152 |
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
|
153 // 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
|
154 $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
|
155 $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
|
156 $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
|
157 $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
|
158 $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
|
159 $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
|
160 |
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 $this->lg_text = $lg_text; |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
162 |
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
|
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 } |
29 | 165 /* |
166 public function Reload($_postdata) { | |
167 | |
168 // update text using $this->current_fileId | |
169 // getTextbyFileId | |
170 $current_fileId = $_postdata['currentFileId']; | |
171 //$this->file_id = $_postdata['currentFileId']; | |
172 //$this->GetTextFromFileId($_postdata); | |
173 //$latest_editing = $this->lg_text; | |
174 // get from URL with file_id | |
175 | |
176 $lg_text_url = $this->get_text_from_fileId_url.$current_fileId; | |
177 $lg_text = file_get_contents($lg_text_url); | |
178 | |
179 $stringInput = $lg_text; | |
180 $stringInput = preg_replace("/ /u", "○", $stringInput); | |
181 $stringInput = preg_replace("/\n/u", "<br>", $stringInput); | |
182 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput); | |
183 $lg_text = $stringInput; | |
184 | |
185 | |
186 //var_dump($lg_text); | |
187 | |
188 echo json_encode($lg_text); | |
189 //var_dump($this->file_id); | |
190 | |
191 } | |
192 */ | |
193 | |
194 | |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
195 // TODO: comparison not correct |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
196 private function Taglist_infileUpToDate($taglistArray) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
197 // compare $this->taglist_infile is the same as $taglistArray |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
198 $taglist_infile = $this->taglist_infile; |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
199 if (count($taglist_infile) != count($taglistArray)) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
200 return false; |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
201 } |
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
|
202 |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
203 foreach ($taglistArray as $row_indb) { |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
204 $cnt = 0; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
205 foreach ($taglist_infile as $row) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
206 //$taglistArray: array( $row['id'], $row['name'], $row['tag'], $row['color'] ) |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
207 if ($row[0] == $row_indb[0] && $row[1] == $row_indb[1] && $row[2] == $row_indb[2] && $row[3] == $row_indb[3]) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
208 |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
209 } else { |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
210 $cnt ++; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
211 } |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
212 } |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
213 if ($cnt == count($row)) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
214 return false; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
215 } |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
216 } |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
217 return true; |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
218 } |
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
|
219 // === 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
|
220 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
|
221 |
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
|
222 $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
|
223 $stringInput = $this->lg_text; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
224 |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
225 $data = array(); // data array to be passed to view |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
226 |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
227 //$taglistArray = $this->GetTaglistArray(); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
228 //for GetTaglistByTopicID: |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
229 $taglistArray = $this->GetTaglistByTopicID($this->GetTopic()); |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
230 |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
231 $data['taglist_infile'] = $this->taglist_infile; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
232 // TODO: check if taglist_infile is up-to-date |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
233 /* |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
234 if ( !$this->Taglist_infileUpToDate($taglistArray)) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
235 $data['taglist_infile'] = $this->taglist_infile; |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
236 } else { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
237 $data['taglist_infile'] = ""; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
238 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
239 */ |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
240 |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
241 // book_meta |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
242 $data['book_meta'] = $this->book_meta; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
243 |
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
|
244 // topic list |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
245 $topiclistArray = $this->GetTopiclistArray(); |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
246 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
247 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
248 $wordlistArray = $this->GetWordlistArray(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
249 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
250 $data['stringInput'] = $stringInput; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
251 $data['taglistArray'] = $taglistArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
252 $data['wordlistArray'] = $wordlistArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
253 $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
|
254 $data['topiclistArray'] = $topiclistArray; |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
255 $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
|
256 $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
|
257 $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
|
258 |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
259 |
26
579f03f8bee5
merge table books_info into table books (execute Home/Test)
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
25
diff
changeset
|
260 $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
|
261 '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
|
262 '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
|
263 '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
|
264 //'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
|
265 //'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
|
266 |
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
267 $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
|
268 $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
|
269 $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
|
270 $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
|
271 $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
|
272 |
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
|
273 $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
|
274 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
275 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
276 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
277 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
278 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
279 public function SaveFullText($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
280 if ($postdata['text']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
281 $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
|
282 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
|
283 $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
|
284 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
|
285 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
286 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
287 if (get_magic_quotes_gpc()) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
288 $require = stripslashes($postdata['text']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
289 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
290 $require = $postdata['text']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
291 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
292 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
293 $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
|
294 $require = preg_replace('/&/u', "&", $require); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
295 $require = preg_replace("/○/u", " ", $require); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
296 $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
|
297 $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
|
298 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
|
299 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
300 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
301 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
302 |
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
|
303 public function UpdateInfoByResponseFromLGService($response) { |
29 | 304 |
305 /* | |
306 $response_file = $response["file"]; | |
307 $response_branch = $response["branch"]; | |
308 | |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
309 |
29 | 310 $status = (string)$response["status"]; |
311 | |
312 if ((string)$response["status"] == "error") { | |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
313 $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
|
314 |
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
315 $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
|
316 $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
|
317 |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
318 |
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
319 } else { |
29 | 320 |
321 $this->messages .= "saving success."; | |
322 var_dump((string)$response_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
|
323 |
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
324 $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
|
325 $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
|
326 |
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
327 } |
29 | 328 */ |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
329 |
29 | 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 $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
|
332 $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
|
333 |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
334 $status = (string)$response["status"]; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
335 if ($status == "ok") { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
336 $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
|
337 $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
|
338 $this->branch_id = (string)$response_branch["id"]; |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
339 |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
340 } else if ($status == "error") { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
341 // saving not success |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
342 $this->messages .= "saving does not success! ".(string)$response["message"]; |
29 | 343 $response_currentFile = $response["currentFile"]; |
344 //$this->current_fileId = $response["currentFileId"]; | |
345 $this->current_fileId = (string)$response_currentFile["id"]; | |
346 | |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
347 } |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
348 |
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
|
349 |
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 } |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
351 private function AppendMetaData($text_content) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
352 $text = '<?xml version="1.0" encoding="UTF-8"?>'; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
353 $text .= "\n<text>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
354 // topic |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
355 $text .= "<topic>".$this->topic."</topic>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
356 // book meta data |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
357 $book = $this->book_meta; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
358 foreach ($book as $b) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
359 $text .= "<book>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
360 $text .= "<title>".$b[0]."</title>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
361 $text .= "<author>".$b[1]."</author>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
362 $text .= "<year>".$b[2]."</year>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
363 $text .= "<pagenumber>".$b[3]."</pagenumber>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
364 $text .= "</book>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
365 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
366 // taglist |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
367 $taglist = $this->taglist_infile; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
368 foreach ($taglist as $tagitem) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
369 $text .= "<tagitem>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
370 $text .= "<id>".$tagitem[0]."</id>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
371 $text .= "<name>".$tagitem[1]."</name>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
372 $text .= "<tag>".$tagitem[2]."</tag>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
373 $text .= "<color>".$tagitem[3]."</color>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
374 $text .= "</tagitem>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
375 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
376 |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
377 // text_content |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
378 $text .= $text_content; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
379 $text .= "\n</text>"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
380 |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
381 return $text; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
382 } |
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
|
383 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
|
384 // 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
|
385 |
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
|
386 // -------- |
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
|
387 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
|
388 $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
|
389 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
|
390 $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
|
391 //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
|
392 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
|
393 } |
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
|
394 |
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
|
395 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
|
396 $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
|
397 } 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
|
398 $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
|
399 } |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
400 |
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
|
401 $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
|
402 $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
|
403 $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
|
404 $require = preg_replace("/<br>/u", "\n", $require); |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
405 //$require = preg_replace("/<br>/u", "\n", $require); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
406 |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
407 // TODO: append metadata at the beginning of file |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
408 if ($_postdata['branchId'] == 0) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
409 // -- new branch case |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
410 $require = "<text_content>\n".$require."</text_content>\n"; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
411 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
412 $require = $this->AppendMetaData($require); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
413 |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
414 //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
|
415 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
|
416 } |
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
|
417 |
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
|
418 // ------ |
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
|
419 |
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
|
420 |
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
|
421 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
|
422 // -- 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
|
423 $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
|
424 "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
|
425 "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
|
426 "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
|
427 "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
|
428 ); |
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
|
429 $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
|
430 |
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
|
431 } else { |
28
e6e9bdc4f256
update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
27
diff
changeset
|
432 // -- 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
|
433 echo "saveNew!"; |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
434 if ($_postdata['userId']) { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
435 $user_id = $_postdata['userId']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
436 } else { |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
437 $user_id = "12"; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
438 } |
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
|
439 $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
|
440 "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
|
441 "sectionId" => $_postdata['sectionId'], |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
442 "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
|
443 "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
|
444 ); |
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
|
445 $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
|
446 } |
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
|
447 |
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
|
448 |
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
|
449 // 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
|
450 $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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 //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
|
457 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
|
458 '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
|
459 )); |
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
|
460 |
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
|
461 // execute the request |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
462 // **** commended to DEBUG *** |
41
533a6c39c128
save xml file to LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
40
diff
changeset
|
463 $output = curl_exec($ch); |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
464 // ***** |
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
|
465 |
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
|
466 // output the profile information - includes the header |
29 | 467 //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
|
468 |
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
|
469 // 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
|
470 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
|
471 |
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
|
472 $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
|
473 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
|
474 |
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
|
475 } |
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
|
476 |
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
|
477 // --- 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
|
478 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
|
479 $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
|
480 $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
|
481 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
|
482 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
|
483 } |
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
|
484 |
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
|
485 $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
|
486 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
|
487 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
|
488 } |
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
|
489 |
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
|
490 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
|
491 } |
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
|
492 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
|
493 |
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
|
494 // 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
|
495 $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
|
496 |
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
|
497 // 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
|
498 $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
|
499 $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
|
500 $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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 $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
|
506 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
|
507 } |
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
|
508 } |
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
|
509 } |
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
|
510 } |
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
|
511 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
|
512 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
|
513 } |
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
|
514 |
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
|
515 |
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
|
516 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
|
517 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
|
518 |
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
|
519 // --- 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
|
520 $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
|
521 $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
|
522 |
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
|
523 // 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
|
524 $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
|
525 $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
|
526 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
|
527 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
|
528 } |
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
|
529 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
|
530 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
|
531 // 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
|
532 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
|
533 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
|
534 } |
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
|
535 } |
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
|
536 |
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
|
537 |
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
|
538 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
|
539 $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
|
540 $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
|
541 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
|
542 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
|
543 } |
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
|
544 } |
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
|
545 // --- 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
|
546 |
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
|
547 /* |
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
|
548 $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
|
549 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
|
550 $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
|
551 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
|
552 } |
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
|
553 */ |
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
|
554 $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
|
555 |
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
|
556 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
|
557 $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
|
558 } 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
|
559 $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
|
560 } |
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
|
561 |
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
|
562 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
|
563 |
04db1dd9d10d
update topic_regex_relation table when saving (new) regex file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
19
diff
changeset
|
564 |
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
|
565 } |
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
|
566 } |
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
|
567 |
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
|
568 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
569 // === 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
|
570 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
|
571 // $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
|
572 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
573 $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
|
574 $topic = $postdata['topic']; |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
575 $section_id = $postdata['sectionId']; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
576 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
577 //$section_id = $this->section_id; |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
578 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
579 |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
580 // 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
|
581 $sectionName = $postdata['sectionName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
582 $bookId = $postdata['bookId']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
583 $bookName = $postdata['bookName']; |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
584 |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
585 |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
586 // --- replace if get info from LGService |
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
587 /* |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
588 $section_info = $this->GetSectionInfo(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
589 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
590 $sectionName = $section_info['sectionName']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
591 $bookId = $section_info['bookId']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
592 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
593 $books_info = $this->GetBooksInfo($bookId); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
594 $bookName = $books_info['bookName']; |
25
4b6d2d7e706e
update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
24
diff
changeset
|
595 */ |
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
|
596 // ===== |
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
|
597 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
598 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
599 $outputTableArray = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
600 |
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
|
601 //$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
|
602 $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
|
603 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
604 $outputTableArray[0]=array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
605 $outputTableArray[0][0]=array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
606 $outputTableArray[0][1]=array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
607 foreach ( $taglistArray as $value ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
608 $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
|
609 $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
|
610 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
611 $outputTableArray[0]["other"] = "其他"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
612 $outputTableArray[0]["page"] = "頁數"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
613 $outputTableArray[0]["full"] = "全文"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
614 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
615 foreach ( $taglistArray as $tagValue ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
616 $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
|
617 $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
|
618 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
619 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
620 $contentLineArray = explode( "<br>", $content ); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
621 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
622 $count=0; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
623 $pageNow=NULL; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
624 foreach ( $contentLineArray as $value ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
625 $count++; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
626 $recordString = $value; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
627 $otherString = $recordString; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
628 //echo $recordString."<br>\n"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
629 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
|
630 $pageNow = $matches[2]; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
631 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
632 foreach ( $taglistArray as $tagValue ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
633 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
|
634 foreach ( $matches as $matchesValue ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
635 $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
|
636 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
|
637 foreach ( $matches2 as $matches2Value ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
638 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
|
639 $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
|
640 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
641 $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
|
642 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
643 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
644 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
645 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
|
646 $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
|
647 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
648 $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
|
649 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
650 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
651 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
652 $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
|
653 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
654 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
655 $otherString = preg_replace("/○/u", "", $otherString); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
656 $outputTableArray[$count]["other"] = $otherString; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
657 $outputTableArray[$count]["page"] = $pageNow; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
658 $value = preg_replace("/>/u", ">", $value); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
659 $value = preg_replace("/</u", "<", $value); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
660 $outputTableArray[$count]["full"] = $value; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
661 } |
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
|
662 /* |
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
|
663 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
|
664 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
|
665 */ |
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
|
666 |
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
|
667 $topic_tag = $this->GetTopicTag($topic); |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
668 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
669 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
|
670 // 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
|
671 // 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
|
672 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
|
673 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
|
674 } |
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
|
675 |
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
|
676 /* |
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
|
677 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
|
678 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
|
679 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
|
680 } |
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
|
681 } 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
|
682 |
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
|
683 // 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
|
684 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
|
685 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
|
686 } |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
687 } |
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
|
688 */ |
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
|
689 |
6
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 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
692 $data = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
693 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
694 $data['outputTableArray'] = $outputTableArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
695 $data['bookId'] = $bookId; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
696 $data['section_id'] = $section_id; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
697 $data['bookName'] = $bookName; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
698 $data['sectionName'] = $sectionName; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
699 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
700 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
701 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
702 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
703 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
704 // === 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
|
705 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
|
706 $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
|
707 $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
|
708 if (!$result) { |
a8ae5cbc3364
update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
21
diff
changeset
|
709 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
|
710 } |
a8ae5cbc3364
update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
21
diff
changeset
|
711 $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
|
712 $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
|
713 |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
714 |
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
|
715 $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
|
716 $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
|
717 |
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
|
718 $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
|
719 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
|
720 $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
|
721 //$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
|
722 // 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
|
723 } |
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
|
724 |
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
|
725 /* |
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
|
726 //$result = $this->GetTaglist(); |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
727 $taglistArray = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
728 while ($row = mysql_fetch_assoc($result)) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
729 $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
|
730 } |
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
|
731 */ |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
732 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
733 $data = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
734 $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
|
735 $data['topic_id'] = $topic_id; |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
736 $data['largest_id'] = $largest_id; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
737 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
738 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
739 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
740 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
741 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
742 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
743 private function _GetTag($_postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
744 if (get_magic_quotes_gpc()) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
745 $id = stripslashes($_postdata['id']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
746 $name = stripslashes($_postdata['name']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
747 $tag = stripslashes($_postdata['tag']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
748 $color = stripslashes($_postdata['color']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
749 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
750 $id = $_postdata['id']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
751 $name = $_postdata['name']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
752 $tag = $_postdata['tag']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
753 $color = $_postdata['color']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
754 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
755 return array($id, $name, $tag, $color); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
756 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
757 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
758 public function NewTagElement($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
759 if ($postdata['id']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
760 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
|
761 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
762 $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
|
763 $this->GetSQLValueString($id, "int"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
764 $this->GetSQLValueString($name, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
765 $this->GetSQLValueString($tag, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
766 $this->GetSQLValueString($color, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
767 $this->GetSQLValueString($this->systemNAME, "text")); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
768 $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
|
769 |
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
|
770 |
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
|
771 // 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
|
772 $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
|
773 |
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
|
774 // 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
|
775 $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
|
776 $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
|
777 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
|
778 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
|
779 } |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
780 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
781 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
782 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
783 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
784 public function SaveTagElement($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
785 if ($postdata['id']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
786 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
|
787 |
19
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
788 $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
|
789 $this->GetSQLValueString($name, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
790 $this->GetSQLValueString($tag, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
791 $this->GetSQLValueString($color, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
792 $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
|
793 $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
|
794 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
795 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
796 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
797 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
798 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
799 public function DeleteTag($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
800 if ($postdata['id']) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
801 $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
|
802 $resultInsert = mysql_query($queryInsert); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
803 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
804 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
805 } |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
806 |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
807 // === 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
|
808 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
|
809 $topic = $postdata['topic']; |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
810 $result = $this->GetTopicByID($topic); |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
811 $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
|
812 $topic_name = $row['name']; |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
813 |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
814 /* |
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
|
815 $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
|
816 $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
|
817 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
|
818 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
|
819 } |
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
|
820 $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
|
821 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
|
822 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
|
823 } |
24
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
824 */ |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
825 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
826 // ------ |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
827 $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
|
828 $result = mysql_query($query); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
829 if (!$result) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
830 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
|
831 } |
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 $tag_intopic = array(); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
834 $tag_others = array(); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
835 $tag_tmp_others = array(); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
836 while ($row = mysql_fetch_assoc($result)) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
837 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
|
838 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
|
839 } 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
|
840 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
|
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 |
24
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
844 // --- 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
|
845 $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
|
846 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
|
847 $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
|
848 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
|
849 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
|
850 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
|
851 } 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
|
852 $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
|
853 } |
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
|
854 } |
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
|
855 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
|
856 $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
|
857 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
|
858 } |
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
|
859 } |
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
|
860 |
24
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
861 // --- 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
|
862 $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
|
863 $tag_others = array(); |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
864 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
865 foreach ($tag_tmp_others as $tmp) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
866 $cnt = 0; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
867 foreach ($tag_intopic as $intopic) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
868 if ($tmp['tag'] == $intopic['tag']) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
869 break; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
870 } else { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
871 $cnt ++; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
872 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
873 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
874 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
|
875 // not appear in $tag_intopic |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
876 array_push($tag_others, $tmp); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
877 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
878 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
879 |
24
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
880 // ----- |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
881 |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
882 |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
883 $data = array(); |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
884 //$data['taglistArray'] = $taglistArray; |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
885 $data['topic'] = $topic; |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
886 $data['topic_name'] = $topic_name; |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
887 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
888 $data['tag_intopic'] = $tag_intopic; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
889 $data['tag_others'] = $tag_others; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
890 |
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
|
891 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
|
892 } |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
893 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
894 |
19
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
895 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
|
896 $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
|
897 $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
|
898 |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
899 // 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
|
900 // --- add new topic_tag_relation --- |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
901 foreach ($tag_ids as $tag_id) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
902 $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
|
903 $result = mysql_query($query); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
904 if (!$result) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
905 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
|
906 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
907 $topic_tag = array(); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
908 $flag = false; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
909 while ($row = mysql_fetch_assoc($result)) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
910 if ($row['topic_id'] == $topic_id) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
911 $flag = true; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
912 break; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
913 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
914 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
915 if (!$flag) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
916 // 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
|
917 $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
|
918 $resultUpdate = mysql_query($queryUpdate); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
919 if (!$resultUpdate) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
920 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
|
921 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
922 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
923 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
924 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
925 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
926 // --- remove tags from this topic --- |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
927 $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
|
928 $result = mysql_query($query); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
929 if (!$result) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
930 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
|
931 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
932 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
933 while ($row = mysql_fetch_assoc($result)) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
934 $cnt = 0; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
935 foreach ($tag_ids as $tag_id) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
936 if ($row['tag_id'] == $tag_id) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
937 break; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
938 } else { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
939 $cnt ++; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
940 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
941 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
942 $_id = $row['id']; |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
943 if ($cnt == count($tag_ids)) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
944 // 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
|
945 $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
|
946 $resultDelete = mysql_query($queryDelete); |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
947 if (!$resultDelete) { |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
948 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
|
949 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
950 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
951 } |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
952 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
953 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
954 |
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
955 /* |
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
|
956 $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
|
957 $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
|
958 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
|
959 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
|
960 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
961 $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
|
962 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
|
963 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
|
964 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
965 |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
966 |
19
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
967 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
|
968 $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
|
969 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
|
970 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
|
971 //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
|
972 $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
|
973 $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
|
974 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
|
975 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
|
976 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
977 $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
|
978 break; |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
979 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
980 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
981 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
|
982 // 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
|
983 $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
|
984 $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
|
985 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
|
986 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
|
987 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
988 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
989 } |
21
c805470cefee
Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
20
diff
changeset
|
990 */ |
19
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
991 |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
992 } |
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
993 |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
994 |
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
995 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
|
996 $taglistArray = array(); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
997 // 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
|
998 $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
|
999 $result = mysql_query($query); |
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1000 if (!$result) { |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1001 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
|
1002 } |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1003 $taglist_ids = array(); |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1004 |
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1005 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
|
1006 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
|
1007 } |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1008 |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1009 // select taglist by tag ids |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1010 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
|
1011 $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
|
1012 $result = mysql_query($query); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1013 if (!$result) { |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1014 echo mysql_error(); |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1015 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
|
1016 } |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1017 |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1018 $row = mysql_fetch_assoc($result); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1019 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
|
1020 |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1021 } |
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1022 return $taglistArray; |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1023 } |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1024 |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1025 public function SetTopic($topic) { |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1026 $this->topic = $topic; |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1027 } |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1028 |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1029 public function GetTopic() { |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1030 return $this->topic; |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1031 } |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1032 |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1033 private function GetTopiclistArray() { |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1034 $topiclistArray = array(); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1035 $result = $this->GetTopiclist(); |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1036 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
|
1037 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
|
1038 } |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1039 return $topiclistArray; |
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1040 } |
9
584b1623e9ef
TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
6
diff
changeset
|
1041 |
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
|
1042 |
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
|
1043 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
|
1044 $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
|
1045 $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
|
1046 $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
|
1047 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
|
1048 |
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
|
1049 } |
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
|
1050 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
|
1051 $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
|
1052 $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
|
1053 $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
|
1054 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
|
1055 |
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
|
1056 } |
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
|
1057 |
19
f60969462226
save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
17
diff
changeset
|
1058 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1059 // =========================== |
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 // === 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
|
1062 public function EditWordlist() { |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1063 $result = $this->GetWordlist(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1064 $wordlistArray = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1065 while ($row = mysql_fetch_assoc($result)) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1066 $wordlistArray[$row['id']] = $row['name']; |
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 $data = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1070 $data['wordlistArray'] = $wordlistArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1071 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1072 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1073 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1074 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1075 public function AddNewList($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1076 if ($postdata['text']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1077 if (get_magic_quotes_gpc()) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1078 $name = stripslashes($postdata['text']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1079 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1080 $name = $postdata['text']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1081 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1082 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1083 $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
|
1084 $this->GetSQLValueString($name, "text"), |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1085 $this->GetSQLValueString($this->systemNAME, "text")); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1086 $result1 = mysql_query($query1); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1087 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
|
1088 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1089 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1090 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1091 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1092 public function SaveWordlist($postdata) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1093 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1094 if ($postdata['text']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1095 $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
|
1096 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
|
1097 $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
|
1098 $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
|
1099 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
|
1100 } |
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
1101 /*else { |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1102 $filename = "data/wordlist/".$postdata['filename'].".txt"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1103 } |
24
b55f5d3564c4
add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
23
diff
changeset
|
1104 */ |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1105 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1106 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1107 if (get_magic_quotes_gpc()) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1108 $require = stripslashes($postdata['text']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1109 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1110 $require = $postdata['text']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1111 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1112 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1113 $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
|
1114 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
|
1115 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1116 /* |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1117 if ($postdata['text']){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1118 $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
|
1119 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
|
1120 $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
|
1121 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
|
1122 } |
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 if (get_magic_quotes_gpc()) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1125 $require = stripslashes($postdata['text']); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1126 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1127 $require = $postdata['text']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1128 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1129 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1130 // $require = preg_replace("/<br>/u", "", $require); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1131 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
|
1132 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1133 */ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1134 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1135 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1136 |
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 public function sortFunction($a,$b) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1140 return strlen($b)-strlen($a); |
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 |
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
|
1143 // TODO: delete this |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1144 private function SetSectionId($_urlvalues) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1145 // TODO: maybe get user info also |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1146 // get book id from url |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1147 if ($_urlvalues['id'] != "") { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1148 $section_id = $_urlvalues['id']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1149 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1150 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
|
1151 /* ???? */ |
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 $get_book_id = $urlvalues['book']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1154 $get_start = $urlvalues['start']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1155 $get_end = $urlvalues['end']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1156 */ |
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 $this->section_id = $section_id; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1159 |
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 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
|
1163 |
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
|
1164 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
|
1165 return $this->section_id; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1166 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1167 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
|
1168 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1169 } |
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 private function GetSectionInfo() { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1172 $section_id = $this->GetSectionId(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1173 if (!is_numeric($section_id)){ |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1174 return $section_id; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1175 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1176 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1177 $result = $this->GetSectionsByID($section_id); |
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 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1180 while ($row = mysql_fetch_assoc($result)) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1181 $bookId=$row['books_id']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1182 $startPage=$row['start_page']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1183 $endPage=$row['end_page']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1184 $sectionName = $row['name']; |
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 $data = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1188 $data['bookId'] = $bookId; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1189 $data['startPage'] = $startPage; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1190 $data['endPage'] = $endPage; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1191 $data['sectionName'] = $sectionName; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1192 |
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
|
1193 |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1194 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1195 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1196 |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1197 private function ParseMetaData($filename) { |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1198 $text = file_get_contents($filename); |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1199 $xml = simplexml_load_string($text) or die("Error: Cannot load from xml string"); |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1200 |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1201 $this->topic = (string)$xml->topic; // set topic id |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1202 |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1203 // get taglist in file |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1204 $taglist_infile = $xml->tagitem; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1205 $taglistArray = array(); |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1206 foreach ($taglist_infile as $row) { |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1207 array_push($taglistArray, array((string)$row->id,(string)$row->name,(string)$row->tag,(string)$row->color )); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1208 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1209 if ($taglistArray) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1210 $this->taglist_infile = $taglistArray; |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1211 } |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1212 |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1213 // get book meta data |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1214 $book_meta = $xml->book; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1215 $book_metaArray = array(); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1216 foreach ($book_meta as $row) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1217 //array_push($book_metaArray, array('title'=>(string)$row->title,'author'=>(string)$row->author,'year'=>(string)$row->year,'pagenumber'=>(string)$row->pagenumber )); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1218 array_push($book_metaArray, array((string)$row->title,(string)$row->author,(string)$row->year,(string)$row->pagenumber )); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1219 } |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1220 if ($book_metaArray) { |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1221 $this->book_meta = $book_metaArray; |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1222 } |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1223 |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1224 // echo $taglist->name.", ".$taglist->tag."," .$taglist->color; |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1225 // --- detect if the taglist set is up-to-date or not --- |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1226 $contentString = (string)$xml->text_content->asXML(); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1227 //$removed_str = array("<text_content>","</text_content>"); |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1228 //$new_contentString = str_replace($removed_str, "", $contentString); |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1229 |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1230 return $contentString; |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1231 } |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1232 private function GetSectionContent() { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1233 $section_id = $this->GetSectionId(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1234 $section_info = $this->GetSectionInfo(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1235 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1236 $bookId = $section_info['bookId']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1237 $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
|
1238 $endPage = $section_info['endPage']; |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1239 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1240 $contentString=""; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1241 $data_path = $this->GetDataPath(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1242 if ( file_exists($data_path."parsing_files/".$section_id.".txt") ) { |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1243 $filename = $data_path."parsing_files/".$section_id.".txt"; |
40
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1244 |
2e938dc046db
load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
1245 // --- parsing meta data |
39
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1246 $stringInput = $this->ParseMetaData($filename); |
8347776a44fc
embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents:
38
diff
changeset
|
1247 // ---- |
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
|
1248 |
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
|
1249 // 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
|
1250 $stringInput = preg_replace("/ /u", "○", $stringInput); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1251 $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
|
1252 $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
|
1253 } else { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1254 $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
|
1255 $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
|
1256 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
|
1257 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
|
1258 } |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1259 while ($row = mysql_fetch_assoc($result)) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1260 $contentString.="【".$row['line']."】".$row['content']."\n"; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1261 } |
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
|
1262 |
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
|
1263 // the text is from database |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1264 $stringInput = $contentString; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1265 $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1266 $stringInput = preg_replace("/ /u", "○", $stringInput); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1267 $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
|
1268 $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
|
1269 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1270 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1271 return $stringInput; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1272 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1273 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1274 private function GetDataPath() { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1275 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
|
1276 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1277 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1278 private function GetTaglistArray() { |
10
54a235d43694
add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
9
diff
changeset
|
1279 $taglistArray = array(); |
6
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1280 $result = $this->GetTaglist(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1281 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
|
1282 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
|
1283 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1284 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1285 return $taglistArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1286 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1287 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1288 private function GetWordlistArray() { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1289 $wordlistArray=""; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1290 $result = $this->GetWordlist(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1291 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
|
1292 $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
|
1293 $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
|
1294 $listString = preg_replace("/<\/div>/u", "", $listString); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1295 $listString = preg_replace("/<span(.*?)>/u", "", $listString); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1296 $listString = preg_replace("/<\/span>/u", "", $listString); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1297 //$listString = preg_replace("/\n/u", "|", $listString); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1298 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1299 $wordlistArray2 = explode( "\n", $listString ); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1300 usort($wordlistArray2,'sortFunction'); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1301 foreach ( $wordlistArray2 as $index=>$value ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1302 $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
|
1303 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1304 foreach ( $wordlistArray2 as $index=>$value ) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1305 if ($value=="") unset($wordlistArray2[$index]); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1306 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1307 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1308 $listString = implode("|", $wordlistArray2); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1309 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1310 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
|
1311 $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
|
1312 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1313 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1314 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1315 return $wordlistArray; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1316 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1317 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1318 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1319 protected function GetBooksInfo($bookId) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1320 $result = $this->GetSectionsByID($bookId); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1321 while ($row = mysql_fetch_assoc($result)) { |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1322 $bookName = $row['name']; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1323 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1324 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1325 $data = array(); |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1326 $data['bookName'] = $bookName; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1327 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1328 return $data; |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1329 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1330 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1331 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1332 } |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1333 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1334 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1335 |
63e08b98032f
rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1336 ?> |