Mercurial > hg > extraction-interface
comparison controllers/extractapp.php @ 78:960ba96efce1 extractapp
Update: click to popup remove-tag-window; select to popup tag-window
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 20 Apr 2015 15:44:54 +0200 |
parents | 97c1e5102a22 |
children | f1f849d31272 |
comparison
equal
deleted
inserted
replaced
77:97c1e5102a22 | 78:960ba96efce1 |
---|---|
1 <?php | 1 <?php |
2 /** | 2 /** |
3 * Extractapp is extended from the BaseController. | 3 * Extractapp is extended from the BaseController. |
4 * This is where we handle the processes for every action. | 4 * This is where we handle the processes for every action. |
5 * | 5 * |
6 * For example, there are five actions in Extractapp, tagging text, exporting a table, | 6 * For example, there are five actions in Extractapp, tagging text, exporting a table, |
7 * editing the wordlist, and configurating tags in one topic. | 7 * editing the wordlist, and configurating tags in one topic. |
8 **/ | 8 */ |
9 | 9 |
10 class Extractapp extends BaseController { | 10 class Extractapp extends BaseController { |
11 protected function Index() { | 11 |
12 $viewmodel = new ExtractappModel(); | 12 |
13 $this->ReturnView($viewmodel->Index(), true); | |
14 } | |
15 protected $viewmodel; | 13 protected $viewmodel; |
16 | 14 |
17 | 15 |
18 public function __construct($action, $urlvalues, $postdata){ | 16 public function __construct($action, $urlvalues, $postdata){ |
19 parent::__construct($action, $urlvalues, $postdata); | 17 parent::__construct($action, $urlvalues, $postdata); |
20 $this->viewmodel = new ExtractappModel(); | 18 $this->viewmodel = new ExtractappModel(); |
21 } | 19 } |
22 | 20 |
23 protected function TaggingText() { | 21 protected function TaggingText() { |
24 /** | 22 /** |
25 * TaggingText action in Extractapp handles the taging related actions, for example, | 23 * TaggingText action in Extractapp handles the taging related actions, for example, |
26 * tagging itself, saving tag results, loading and saving regular expression for tagging. | 24 * tagging itself, saving tag results, loading and saving regular expression for tagging. |
27 * They are handled by 'func' variable in postdata, which could come from LGService or from extraction-interface application itself. | 25 * They are handled by 'func' variable in postdata, which could come from LGService or from extraction-interface application itself. |
28 * | 26 * |
29 * From LGService, the postdata contains essential information about the file/section of local gazetteers data. | 27 * From LGService, the postdata contains essential information about the file/section of local gazetteers data. |
30 * This happens when user entering to extraction-interface the first time, or after s/he saved her/is tagging results to LGService. | 28 * This happens when user entering to extraction-interface the first time, or after s/he saved her/is tagging results to LGService. |
31 * (default one, SaveFullTextToLGService, SmartRegexLoad, SmartRegexSave case) | 29 * (default one, SaveFullTextToLGService, SmartRegexLoad, SmartRegexSave case) |
32 * | 30 * |
33 * From extraction-interface itself, it contains the information from previous page. | 31 * From extraction-interface itself, it contains the information from previous page. |
34 * This happens when user choosing another topic in the extraction-interface, | 32 * This happens when user choosing another topic in the extraction-interface, |
35 * the page need to retrieve related information from database for the topic. | 33 * the page need to retrieve related information from database for the topic. |
36 * (ContinueTagging case) | 34 * (ContinueTagging case) |
37 */ | 35 */ |
38 | 36 |
39 $viewmodel = $this->viewmodel; | 37 $viewmodel = $this->viewmodel; |
40 | 38 |
41 if (isset($this->postdata['func'])) { | 39 if (isset($this->postdata['func'])) { |
42 $func = $this->postdata['func']; | 40 $func = $this->postdata['func']; |
48 break; | 46 break; |
49 case 'SaveFullTextToLGService': | 47 case 'SaveFullTextToLGService': |
50 $viewmodel->messages['info'] .= "SaveFullTextToLGService! "; | 48 $viewmodel->messages['info'] .= "SaveFullTextToLGService! "; |
51 $viewmodel->GetInfoFromPreviousPage($this->postdata); | 49 $viewmodel->GetInfoFromPreviousPage($this->postdata); |
52 $response = $viewmodel->SaveFullTextToLGService($this->postdata); | 50 $response = $viewmodel->SaveFullTextToLGService($this->postdata); |
53 $viewmodel->UpdateInfoByResponseFromLGService($response); // update file_id, branch_id, user_id | 51 $viewmodel->UpdateInfoResponsedFromLGService($response); // update file_id, branch_id, user_id |
54 $viewmodel->GetTextFromFileId(); | 52 $viewmodel->GetTextFromFileId(); |
55 $this->ReturnView($viewmodel->StartTagging(), true); | 53 $this->ReturnView($viewmodel->StartTagging(), true); |
56 break; | 54 break; |
57 | 55 |
58 case 'SmartRegexLoad': | 56 case 'SmartRegexLoad': |
59 $viewmodel->SmartRegexLoad($this->postdata['topic_id']); | 57 $viewmodel->LoadSmartRegex($this->postdata['topic_id']); |
60 break; | 58 break; |
61 case 'SmartRegexSave': | 59 case 'SmartRegexSave': |
62 $viewmodel->SmartRegexSave($this->postdata); | 60 $viewmodel->SaveSmartRegex($this->postdata); |
63 break; | 61 break; |
64 case 'ReloadText': | 62 case 'ReloadText': |
65 $viewmodel->messages['info'] .= "Reload the latest text "; | 63 $viewmodel->messages['info'] .= "Reload the latest text "; |
66 $viewmodel->GetInfoFromPreviousPage($this->postdata); | 64 $viewmodel->GetInfoFromPreviousPage($this->postdata); |
67 $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 | 65 $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 |
85 | 83 |
86 if (isset($this->postdata['fileId'])) { | 84 if (isset($this->postdata['fileId'])) { |
87 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { | 85 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { |
88 // --- Existing branch case --- | 86 // --- Existing branch case --- |
89 $viewmodel->GetInfoFromPreviousPage($this->postdata); | 87 $viewmodel->GetInfoFromPreviousPage($this->postdata); |
90 $viewmodel->SetBookMetaDataBySectionId(); | 88 $viewmodel->SetBookMetadataBySectionId(); |
91 // get text by fileId, from LGService | 89 // get text by fileId, from LGService |
92 $viewmodel->GetTextFromFileId(); | 90 $viewmodel->GetTextFromFileId(); |
93 } | 91 } |
94 | 92 |
95 } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { | 93 } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { |
96 // --- New branch case --- | 94 // --- New branch case --- |
97 $viewmodel->GetInfoFromPreviousPage($this->postdata); | 95 $viewmodel->GetInfoFromPreviousPage($this->postdata); |
98 $viewmodel->SetBookMetaDataBySectionId(); | 96 $viewmodel->SetBookMetadataBySectionId(); |
99 // get text by sectionId from LGService | 97 // get text by sectionId from LGService |
100 $viewmodel->GetTextFromSectionId(); | 98 $viewmodel->GetTextFromSectionId(); |
101 | 99 |
102 } else if ($this->postdata['sectionId'] != 0) { | 100 } else if ($this->postdata['sectionId'] != 0) { |
103 $viewmodel->GetTextFromLocal($this->postdata['sectionId']); | 101 $viewmodel->GetTextFromLocal($this->postdata['sectionId']); |
104 $viewmodel->SetBookMetaDataBySectionId(); | 102 $viewmodel->SetBookMetadataBySectionId(); |
105 | 103 |
106 } else if (is_numeric($this->urlvalues['id'])) { | 104 } else if (is_numeric($this->urlvalues['id'])) { |
107 // get text from local file system (for development stage only) | 105 // get text from local file system (for development stage only) |
108 $viewmodel->GetTextFromLocal($this->urlvalues['id']); | 106 $viewmodel->GetTextFromLocal($this->urlvalues['id']); |
109 $viewmodel->SetBookMetaDataBySectionId(); | 107 $viewmodel->SetBookMetadataBySectionId(); |
110 $this->ReturnView_localtest($viewmodel->StartTagging(), true); | 108 $this->ReturnView_localtest($viewmodel->StartTagging(), true); |
111 break; | 109 break; |
112 | 110 |
113 } else { | 111 } else { |
114 $viewmodel->messages['error'] .= "wrong url!!"; | 112 $viewmodel->messages['error'] .= "wrong url!!"; |
124 } | 122 } |
125 | 123 |
126 | 124 |
127 protected function ExportTable() { | 125 protected function ExportTable() { |
128 /** | 126 /** |
129 * ExportTable action returns "./views/Extractapp/ExportTable.php" view. | 127 * ExportTable action returns "./views/Extractapp/ExportTable.php" view. |
130 */ | 128 */ |
131 $viewmodel = $this->viewmodel; | 129 $viewmodel = $this->viewmodel; |
132 | 130 |
133 if (isset($this->postdata['func'])) { | 131 if (isset($this->postdata['func'])) { |
134 $func = $this->postdata['func']; | 132 $func = $this->postdata['func']; |
135 } | 133 } |
148 | 146 |
149 } | 147 } |
150 | 148 |
151 protected function EditWordlist() { | 149 protected function EditWordlist() { |
152 /** | 150 /** |
153 * EditWordlist action returns "./views/Extractapp/EditWordlist.php" view, | 151 * EditWordlist action returns "./views/Extractapp/EditWordlist.php" view, |
154 * It adds or saves wordlist based on the 'func' variable in postdata. | 152 * It adds or saves wordlist based on the 'func' variable in postdata. |
155 */ | 153 */ |
156 | 154 |
157 $viewmodel = $this->viewmodel; | 155 $viewmodel = $this->viewmodel; |
158 if (isset($this->postdata['func'])) { | 156 if (isset($this->postdata['func'])) { |
159 $func = $this->postdata['func']; | 157 $func = $this->postdata['func']; |
160 } | 158 } |
172 } | 170 } |
173 | 171 |
174 | 172 |
175 protected function EditTaglist() { | 173 protected function EditTaglist() { |
176 /** | 174 /** |
177 * EditTaglist action returns "./views/Extractapp/EditTaglist.php" view. | 175 * EditTaglist action returns "./views/Extractapp/EditTaglist.php" view. |
178 * It adds, saves or delete tag in the current topic. | 176 * It adds, saves or delete tag in the current topic. |
179 */ | 177 */ |
180 | 178 |
181 $viewmodel = $this->viewmodel; | 179 $viewmodel = $this->viewmodel; |
182 if (isset($this->postdata['func'])) { | 180 if (isset($this->postdata['func'])) { |
183 $func = $this->postdata['func']; | 181 $func = $this->postdata['func']; |
184 } | 182 } |
199 } | 197 } |
200 | 198 |
201 | 199 |
202 protected function ConfigTagsInTopic() { | 200 protected function ConfigTagsInTopic() { |
203 /** | 201 /** |
204 * ConfigTagsInTopic action returns "./views/Extractapp/ConfigTagsInTopic.php" view. | 202 * ConfigTagsInTopic action returns "./views/Extractapp/ConfigTagsInTopic.php" view. |
205 * It shows or updates the tags-in-topic relation. | 203 * It shows or updates the tags-in-topic relation. |
206 */ | 204 */ |
207 | 205 |
208 $viewmodel = $this->viewmodel; | 206 $viewmodel = $this->viewmodel; |
209 if (isset($this->postdata['func'])) { | 207 if (isset($this->postdata['func'])) { |
210 $func = $this->postdata['func']; | 208 $func = $this->postdata['func']; |
211 } | 209 } |