annotate develop/models/extractapp.php @ 46:b3ca5d2b4d3f extractapp

bug fix: edit and save regex. But a jquery issue in Chrome
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 16 Mar 2015 15:49:39 +0100
parents 3d6b8fb7335d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
2
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
3 <?php
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
4
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
5 class ExtractappModel extends BaseModel{
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
7 public function Index() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
8 return array("Index Value 1", "Value 2", "Value 3");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
9 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
10
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,
46
b3ca5d2b4d3f bug fix: edit and save regex. But a jquery issue in Chrome
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 45
diff changeset
12 $branch_id = 0, $user_id = 0, $lg_text = "", $topic, $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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
165 /*
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
166 public function Reload($_postdata) {
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
167
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
168 // update text using $this->current_fileId
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
169 // getTextbyFileId
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
170 $current_fileId = $_postdata['currentFileId'];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
171 //$this->file_id = $_postdata['currentFileId'];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
172 //$this->GetTextFromFileId($_postdata);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
173 //$latest_editing = $this->lg_text;
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
174 // get from URL with file_id
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
175
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
176 $lg_text_url = $this->get_text_from_fileId_url.$current_fileId;
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
177 $lg_text = file_get_contents($lg_text_url);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
178
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
179 $stringInput = $lg_text;
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
180 $stringInput = preg_replace("/ /u", "○", $stringInput);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
181 $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
182 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
183 $lg_text = $stringInput;
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
184
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
185
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
186 //var_dump($lg_text);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
187
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
188 echo json_encode($lg_text);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
189 //var_dump($this->file_id);
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
190
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
191 }
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
192 */
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
193
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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('/&amp;/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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
304
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
305 /*
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
306 $response_file = $response["file"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
307 $response_branch = $response["branch"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
310 $status = (string)$response["status"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
311
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
320
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
321 $this->messages .= "saving success.";
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
330
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
331 $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
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
343 $response_currentFile = $response["currentFile"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
344 //$this->current_fileId = $response["currentFileId"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
345 $this->current_fileId = (string)$response_currentFile["id"];
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
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 // --------
42
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
387 if ($_postdata['text']){
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
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('/&amp;/u', "&", $require);
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
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 if ($_postdata['branchId'] == 0) {
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
408 // -- new branch case
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
409 $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
410 }
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
411 $require = $this->AppendMetaData($require);
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
412
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
413 //saving in my local machine in developing phrase
46
b3ca5d2b4d3f bug fix: edit and save regex. But a jquery issue in Chrome
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 45
diff changeset
414 file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require);
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 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 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
421 // -- 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
422 $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
423 "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
424 "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
425 "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
426 "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
427 );
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 $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
429
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 } else {
28
e6e9bdc4f256 update the saving response from LGService between different file version
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 27
diff changeset
431 // -- 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
432 echo "saveNew!";
42
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
433 $user_id = "0";
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 }
42
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
437
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
438 $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
439 "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
440 "sectionId" => $_postdata['sectionId'],
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
441 "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
442 "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
443 );
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 $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
445 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 // 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
449 $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
450 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
451 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
452 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
453 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
454 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
455 //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
456 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
457 '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
458 ));
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 // execute the request
40
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
461 // **** commended to DEBUG ***
46
b3ca5d2b4d3f bug fix: edit and save regex. But a jquery issue in Chrome
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 45
diff changeset
462 //$output = curl_exec($ch);
40
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
463 // *****
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
464
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 // output the profile information - includes the header
29
fc7342914cdf develop_v0
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 28
diff changeset
466 //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
467
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 // 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
469 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
470
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 $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
472 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
473
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 }
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
475
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 // --- 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
477 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
478 $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
479 $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
480 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
481 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
482 }
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 $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
485 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
486 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
487 }
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 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
490 }
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 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
492
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 // 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
494 $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
495
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 // 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
497 $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
498 $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
499 $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
500 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
501 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
502 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
503 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
504 $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
505 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
506 }
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 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
511 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
512 }
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 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
516 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
517
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 // --- 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
519 $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
520 $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
521
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 // 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
523 $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
524 $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
525 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
526 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
527 }
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 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
529 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
530 // 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
531 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
532 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
533 }
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 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
538 $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
539 $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
540 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
541 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
542 }
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 // --- 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
545
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
546 /*
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 $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
548 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
549 $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
550 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
551 }
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 $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
554
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 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
556 $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
557 } 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
558 $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
559 }
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 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
562
04db1dd9d10d update topic_regex_relation table when saving (new) regex file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 19
diff changeset
563
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
564 }
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
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
568 // === 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
569 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
570 // $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
571
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
572 $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
573 $topic = $postdata['topic'];
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
574 $section_id = $postdata['sectionId'];
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
575
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
576 //$section_id = $this->section_id;
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
577
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
578
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
579 // 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
580 $sectionName = $postdata['sectionName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
581 $bookId = $postdata['bookId'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
582 $bookName = $postdata['bookName'];
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
583
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 // --- replace if get info from LGService
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
586 /*
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
587 $section_info = $this->GetSectionInfo();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
588
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
589 $sectionName = $section_info['sectionName'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
590 $bookId = $section_info['bookId'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
591
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
592 $books_info = $this->GetBooksInfo($bookId);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
593 $bookName = $books_info['bookName'];
25
4b6d2d7e706e update for the integration
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 24
diff changeset
594 */
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
595 // =====
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
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
597
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
598 $outputTableArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
599
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
600 //$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
601 $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
602
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
603 $outputTableArray[0]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
604 $outputTableArray[0][0]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
605 $outputTableArray[0][1]=array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
606 foreach ( $taglistArray as $value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
607 $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
608 $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
609 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
610 $outputTableArray[0]["other"] = "其他";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
611 $outputTableArray[0]["page"] = "頁數";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
612 $outputTableArray[0]["full"] = "全文";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
613
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
614 foreach ( $taglistArray as $tagValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
615 $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
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 }
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 $contentLineArray = explode( "<br>", $content );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
620
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
621 $count=0;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
622 $pageNow=NULL;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
623 foreach ( $contentLineArray as $value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
624 $count++;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
625 $recordString = $value;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
626 $otherString = $recordString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
627 //echo $recordString."<br>\n";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
628 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
629 $pageNow = $matches[2];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
630 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
631 foreach ( $taglistArray as $tagValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
632 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
633 foreach ( $matches as $matchesValue ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
634 $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
635 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
636 foreach ( $matches2 as $matches2Value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
637 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
638 $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
639 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
640 $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
641 }
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 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
644 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
645 $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
646 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
647 $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
648 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
649 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
650 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
651 $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
652 }
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 $otherString = preg_replace("/○/u", "", $otherString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
655 $outputTableArray[$count]["other"] = $otherString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
656 $outputTableArray[$count]["page"] = $pageNow;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
657 $value = preg_replace("/>/u", "&gt;", $value);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
658 $value = preg_replace("/</u", "&lt;", $value);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
659 $outputTableArray[$count]["full"] = $value;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
660 }
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
661 /*
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 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
663 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
664 */
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
665
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 $topic_tag = $this->GetTopicTag($topic);
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
667
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
668 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
669 // 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
670 // 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
671 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
672 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
673 }
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 /*
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
676 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
677 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
678 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
679 }
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 } 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
681
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 // 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
683 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
684 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
685 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
686 }
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
687 */
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
688
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
689 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
690
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
691 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
692
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
693 $data['outputTableArray'] = $outputTableArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
694 $data['bookId'] = $bookId;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
695 $data['section_id'] = $section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
696 $data['bookName'] = $bookName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
697 $data['sectionName'] = $sectionName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
698
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
699 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
700
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 // === 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
704 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
705 $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
706 $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
707 if (!$result) {
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
708 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
709 }
a8ae5cbc3364 update topic_tag_relation table when adding new tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 21
diff changeset
710 $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
711 $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
712
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
713
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
714 $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
715 $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
716
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 $taglistArray = array();
45
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
718
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
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
45
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
725 $topic_tag_name = $this->GetTopicTag($topic_id);
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
726
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
727 $query = "SELECT id FROM taglist WHERE taglist.tag='".$topic_tag_name."'";
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
728 $result = mysql_query($query);
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
729 if (!$result) {
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
730 echo json_encode(mysql_error());
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
731 }
45
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
732 $row = mysql_fetch_assoc($result);
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
733 $topic_tag_id = $row['id'];
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
734
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
735 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
736 $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
737 $data['topic_id'] = $topic_id;
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
738 $data['largest_id'] = $largest_id;
45
3d6b8fb7335d lock the topic tag when edit tag list
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 42
diff changeset
739 $data['topic_tag_id'] = $topic_tag_id;
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
740
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
741
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
742 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
743
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
744 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
745
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
746 private function _GetTag($_postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
747 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
748 $id = stripslashes($_postdata['id']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
749 $name = stripslashes($_postdata['name']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
750 $tag = stripslashes($_postdata['tag']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
751 $color = stripslashes($_postdata['color']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
752 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
753 $id = $_postdata['id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
754 $name = $_postdata['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
755 $tag = $_postdata['tag'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
756 $color = $_postdata['color'];
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 return array($id, $name, $tag, $color);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
759 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
760
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
761 public function NewTagElement($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
762 if ($postdata['id']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
763 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
764
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
765 $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
766 $this->GetSQLValueString($id, "int"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
767 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
768 $this->GetSQLValueString($tag, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
769 $this->GetSQLValueString($color, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
770 $this->GetSQLValueString($this->systemNAME, "text"));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
771 $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
772
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
773
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 // 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
775 $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
776
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
777 // 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
778 $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
779 $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
780 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
781 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
782 }
6
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
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
785 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
786
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
787 public function SaveTagElement($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
788 if ($postdata['id']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
789 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
790
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
791 $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
792 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
793 $this->GetSQLValueString($tag, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
794 $this->GetSQLValueString($color, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
795 $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
796 $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
797
6
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
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
800 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
801
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
802 public function DeleteTag($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
803 if ($postdata['id']) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
804 $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
805 $resultInsert = mysql_query($queryInsert);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
806 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
807
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
808 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
809
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
810 // === 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
811 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
812 $topic = $postdata['topic'];
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
813 $result = $this->GetTopicByID($topic);
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
814 $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
815 $topic_name = $row['name'];
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
816
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
817 /*
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
818 $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
819 $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
820 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
821 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
822 }
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 $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
824 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
825 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
826 }
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
827 */
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
828
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
829 // ------
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
830 $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
831 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
832 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
833 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
834 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
835
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
836 $tag_intopic = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
837 $tag_others = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
838 $tag_tmp_others = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
839 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
840 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
841 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
842 } 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
843 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
844 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
845 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
846
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
847 // --- 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
848 $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
849 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
850 $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
851 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
852 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
853 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
854 } 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
855 $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
856 }
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 }
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 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
859 $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
860 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
861 }
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 }
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
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
864 // --- 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
865 $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
866 $tag_others = array();
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
867
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
868 foreach ($tag_tmp_others as $tmp) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
869 $cnt = 0;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
870 foreach ($tag_intopic as $intopic) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
871 if ($tmp['tag'] == $intopic['tag']) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
872 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
873 } else {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
874 $cnt ++;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
875 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
876 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
877 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
878 // not appear in $tag_intopic
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
879 array_push($tag_others, $tmp);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
880 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
881 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
882
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
883 // -----
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
884
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
885
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
886 $data = array();
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
887 //$data['taglistArray'] = $taglistArray;
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
888 $data['topic'] = $topic;
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
889 $data['topic_name'] = $topic_name;
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
890
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
891 $data['tag_intopic'] = $tag_intopic;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
892 $data['tag_others'] = $tag_others;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
893
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
894 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
895 }
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
896
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
897
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
898 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
899 $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
900 $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
901
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
902 // 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
903 // --- add new topic_tag_relation ---
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
904 foreach ($tag_ids as $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
905 $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
906 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
907 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
908 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
909 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
910 $topic_tag = array();
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
911 $flag = false;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
912 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
913 if ($row['topic_id'] == $topic_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
914 $flag = true;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
915 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
916 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
917 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
918 if (!$flag) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
919 // 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
920 $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
921 $resultUpdate = mysql_query($queryUpdate);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
922 if (!$resultUpdate) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
923 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
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
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
927 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
928
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
929 // --- remove tags from this topic ---
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
930 $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
931 $result = mysql_query($query);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
932 if (!$result) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
933 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
934 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
935
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
936 while ($row = mysql_fetch_assoc($result)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
937 $cnt = 0;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
938 foreach ($tag_ids as $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
939 if ($row['tag_id'] == $tag_id) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
940 break;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
941 } else {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
942 $cnt ++;
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
943 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
944 }
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
945 $_id = $row['id'];
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
946 if ($cnt == count($tag_ids)) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
947 // 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
948 $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
949 $resultDelete = mysql_query($queryDelete);
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
950 if (!$resultDelete) {
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
951 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
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
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
956
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
957
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
958 /*
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
959 $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
960 $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
961 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
962 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
963 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
964 $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
965 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
966 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
967 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
968
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
969
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
970 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
971 $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
972 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
973 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
974 //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
975 $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
976 $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
977 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
978 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
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 $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
981 break;
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
982 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
983 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
984 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
985 // 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
986 $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
987 $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
988 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
989 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
990 }
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 }
21
c805470cefee Remove bootstrap.TaggingText UI layout modification
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 20
diff changeset
993 */
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
994
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
995 }
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
996
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
997
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
998 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
999 $taglistArray = array();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1000 // 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
1001 $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
1002 $result = mysql_query($query);
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1003 if (!$result) {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1004 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
1005 }
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1006 $taglist_ids = array();
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1007
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1008 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
1009 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
1010 }
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1011
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1012 // select taglist by tag ids
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1013 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
1014 $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
1015 $result = mysql_query($query);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1016 if (!$result) {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1017 echo mysql_error();
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1018 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
1019 }
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1020
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1021 $row = mysql_fetch_assoc($result);
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1022 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
1023
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1024 }
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1025 return $taglistArray;
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1026 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1027
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1028 public function SetTopic($topic) {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1029 $this->topic = $topic;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1030 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1031
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1032 public function GetTopic() {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1033 return $this->topic;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1034 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1035
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1036 private function GetTopiclistArray() {
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1037 $topiclistArray = array();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1038 $result = $this->GetTopiclist();
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1039 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
1040 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
1041 }
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1042 return $topiclistArray;
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1043 }
9
584b1623e9ef TOC correction list page updated
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 6
diff changeset
1044
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
1045
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 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
1047 $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
1048 $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
1049 $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
1050 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
1051
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
1052 }
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
1053 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
1054 $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
1055 $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
1056 $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
1057 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
1058
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
1059 }
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
1060
19
f60969462226 save tag modification of topic configration into topic_tag_relation table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 17
diff changeset
1061
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1062 // ===========================
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1063
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1064 // === 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
1065 public function EditWordlist() {
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1066 $result = $this->GetWordlist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1067 $wordlistArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1068 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1069 $wordlistArray[$row['id']] = $row['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1070 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1071
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1072 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1073 $data['wordlistArray'] = $wordlistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1074 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1075 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1076
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1077
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1078 public function AddNewList($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1079 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1080 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1081 $name = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1082 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1083 $name = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1084 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1085
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1086 $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
1087 $this->GetSQLValueString($name, "text"),
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1088 $this->GetSQLValueString($this->systemNAME, "text"));
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1089 $result1 = mysql_query($query1);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1090 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
1091 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1092 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1093
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1094
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1095 public function SaveWordlist($postdata) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1096
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1097 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1098 $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
1099 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
1100 $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
1101 $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
1102 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
1103 }
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
1104 /*else {
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1105 $filename = "data/wordlist/".$postdata['filename'].".txt";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1106 }
24
b55f5d3564c4 add some regular expressions and wordlist for topic ??
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 23
diff changeset
1107 */
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1108
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1109
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1110 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1111 $require = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1112 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1113 $require = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1114 }
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 $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
1117 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
1118 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1119 /*
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1120 if ($postdata['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1121 $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
1122 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
1123 $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
1124 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
1125 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1126
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1127 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1128 $require = stripslashes($postdata['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1129 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1130 $require = $postdata['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1131 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1132
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1133 // $require = preg_replace("/<br>/u", "", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1134 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
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
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1140 // =======================================
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1141
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1142 public function sortFunction($a,$b) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1143 return strlen($b)-strlen($a);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1144 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1145
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
1146 // TODO: delete this
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1147 private function SetSectionId($_urlvalues) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1148 // TODO: maybe get user info also
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1149 // get book id from url
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1150 if ($_urlvalues['id'] != "") {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1151 $section_id = $_urlvalues['id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1152 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1153 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
1154 /* ???? */
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1155 /*
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1156 $get_book_id = $urlvalues['book'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1157 $get_start = $urlvalues['start'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1158 $get_end = $urlvalues['end'];
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 $this->section_id = $section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1162
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1163 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1164
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1165 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
1166
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1167 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
1168 return $this->section_id;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1169 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1170 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
1171 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1172 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1173
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1174 private function GetSectionInfo() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1175 $section_id = $this->GetSectionId();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1176 if (!is_numeric($section_id)){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1177 return $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 $result = $this->GetSectionsByID($section_id);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1181
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1182
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1183 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1184 $bookId=$row['books_id'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1185 $startPage=$row['start_page'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1186 $endPage=$row['end_page'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1187 $sectionName = $row['name'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1188 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1189
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1190 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1191 $data['bookId'] = $bookId;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1192 $data['startPage'] = $startPage;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1193 $data['endPage'] = $endPage;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1194 $data['sectionName'] = $sectionName;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1195
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
1196
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1197 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1198 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1199
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1200 private function ParseMetaData($filename) {
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1201 $text = file_get_contents($filename);
42
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
1202 $xml = simplexml_load_string($text); //or die("Error: Cannot load from xml string");
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
1203 if (!$xml) {
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
1204 // when file created by section_id, read the plain text from file_get_contents
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
1205 return $text;
c245d54eab9f config lg server url, without port
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
1206 }
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1207
40
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1208 $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
1209
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1210 // get taglist in file
40
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1211 $taglist_infile = $xml->tagitem;
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1212 $taglistArray = array();
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1213 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
1214 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
1215 }
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1216 if ($taglistArray) {
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1217 $this->taglist_infile = $taglistArray;
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1218 }
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1219
40
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1220 // get book meta data
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1221 $book_meta = $xml->book;
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1222 $book_metaArray = array();
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1223 foreach ($book_meta as $row) {
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1224 //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
1225 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
1226 }
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1227 if ($book_metaArray) {
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1228 $this->book_meta = $book_metaArray;
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1229 }
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1230
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1231 // 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
1232 // --- 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
1233 $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
1234 //$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
1235 //$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
1236
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1237 return $contentString;
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1238 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1239 private function GetSectionContent() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1240 $section_id = $this->GetSectionId();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1241 $section_info = $this->GetSectionInfo();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1242
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1243 $bookId = $section_info['bookId'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1244 $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
1245 $endPage = $section_info['endPage'];
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1246
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1247 $contentString="";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1248 $data_path = $this->GetDataPath();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1249 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
1250 $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
1251
2e938dc046db load,save xml file with topic, etc.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
1252 // --- parsing meta data
39
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1253 $stringInput = $this->ParseMetaData($filename);
8347776a44fc embedded topic, taglist,book metadata in file
Zoe Hong <zhong@mpiwg-berlin.mpg.de
parents: 38
diff changeset
1254 // ----
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
1255
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting 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 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
1257 $stringInput = preg_replace("/ /u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1258 $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
1259 $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
1260 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1261 $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
1262 $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
1263 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
1264 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
1265 }
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1266 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1267 $contentString.="【".$row['line']."】".$row['content']."\n";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1268 }
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
1269
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
1270 // the text is from database
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1271 $stringInput = $contentString;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1272 $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1273 $stringInput = preg_replace("/ /u", "○", $stringInput);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1274 $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
1275 $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
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 return $stringInput;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1279 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1280
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1281 private function GetDataPath() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1282 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
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 private function GetTaglistArray() {
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 9
diff changeset
1286 $taglistArray = array();
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1287 $result = $this->GetTaglist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1288 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
1289 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
1290 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1291
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1292 return $taglistArray;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1293 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1294
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1295 private function GetWordlistArray() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1296 $wordlistArray="";
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1297 $result = $this->GetWordlist();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1298 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
1299 $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
1300 $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
1301 $listString = preg_replace("/<\/div>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1302 $listString = preg_replace("/<span(.*?)>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1303 $listString = preg_replace("/<\/span>/u", "", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1304 //$listString = preg_replace("/\n/u", "|", $listString);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1305
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1306 $wordlistArray2 = explode( "\n", $listString );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1307 usort($wordlistArray2,'sortFunction');
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1308 foreach ( $wordlistArray2 as $index=>$value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1309 $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
1310 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1311 foreach ( $wordlistArray2 as $index=>$value ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1312 if ($value=="") unset($wordlistArray2[$index]);
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 $listString = implode("|", $wordlistArray2);
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 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
1318 $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
1319 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1320
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1321
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1322 return $wordlistArray;
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
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1326 protected function GetBooksInfo($bookId) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1327 $result = $this->GetSectionsByID($bookId);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1328 while ($row = mysql_fetch_assoc($result)) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1329 $bookName = $row['name'];
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 $data = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1333 $data['bookName'] = $bookName;
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 return $data;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1336 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1337
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1338
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1339 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1340
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1341
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1342
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1343 ?>