Mercurial > hg > extraction-interface
comparison controllers/extractapp.php @ 77:97c1e5102a22 extractapp
New: export table for a file from LGService
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 16 Apr 2015 14:53:22 +0200 |
parents | 60b5a94163c3 |
children | 960ba96efce1 |
comparison
equal
deleted
inserted
replaced
76:c49192885290 | 77:97c1e5102a22 |
---|---|
1 <?php | 1 <?php |
2 /** | |
3 * Extractapp is extended from the BaseController. | |
4 * This is where we handle the processes for every action. | |
5 * | |
6 * For example, there are five actions in Extractapp, tagging text, exporting a table, | |
7 * editing the wordlist, and configurating tags in one topic. | |
8 **/ | |
2 | 9 |
3 class Extractapp extends BaseController { | 10 class Extractapp extends BaseController { |
4 protected function Index() { | 11 protected function Index() { |
5 $viewmodel = new ExtractappModel(); | 12 $viewmodel = new ExtractappModel(); |
6 $this->ReturnView($viewmodel->Index(), true); | 13 $this->ReturnView($viewmodel->Index(), true); |
12 parent::__construct($action, $urlvalues, $postdata); | 19 parent::__construct($action, $urlvalues, $postdata); |
13 $this->viewmodel = new ExtractappModel(); | 20 $this->viewmodel = new ExtractappModel(); |
14 } | 21 } |
15 | 22 |
16 protected function TaggingText() { | 23 protected function TaggingText() { |
24 /** | |
25 * TaggingText action in Extractapp handles the taging related actions, for example, | |
26 * 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. | |
28 * | |
29 * 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. | |
31 * (default one, SaveFullTextToLGService, SmartRegexLoad, SmartRegexSave case) | |
32 * | |
33 * From extraction-interface itself, it contains the information from previous page. | |
34 * This happens when user choosing another topic in the extraction-interface, | |
35 * the page need to retrieve related information from database for the topic. | |
36 * (ContinueTagging case) | |
37 */ | |
38 | |
17 $viewmodel = $this->viewmodel; | 39 $viewmodel = $this->viewmodel; |
18 | 40 |
19 if (isset($this->postdata['func'])) { | 41 if (isset($this->postdata['func'])) { |
20 $func = $this->postdata['func']; | 42 $func = $this->postdata['func']; |
21 } | 43 } |
55 $viewmodel->GetInfoFromPreviousPage($this->postdata); | 77 $viewmodel->GetInfoFromPreviousPage($this->postdata); |
56 $this->ReturnView($viewmodel->StartTagging(), true); | 78 $this->ReturnView($viewmodel->StartTagging(), true); |
57 break; | 79 break; |
58 | 80 |
59 | 81 |
60 default: // first time visit extraction interface from LGService | 82 default: |
83 // This is where the first time user visit extraction interface from LGService | |
61 $viewmodel->messages['info'] .= "Welcome to Extraction Interface. "; | 84 $viewmodel->messages['info'] .= "Welcome to Extraction Interface. "; |
62 | 85 |
63 if (isset($this->postdata['fileId'])) { | 86 if (isset($this->postdata['fileId'])) { |
64 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { | 87 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { |
65 // --- Existing branch case --- | 88 // --- Existing branch case --- |
98 | 121 |
99 | 122 |
100 | 123 |
101 } | 124 } |
102 | 125 |
126 | |
103 protected function ExportTable() { | 127 protected function ExportTable() { |
104 $viewmodel = $this->viewmodel; | 128 /** |
105 $this->ReturnView($viewmodel->ExportTable($this->postdata), true); | 129 * ExportTable action returns "./views/Extractapp/ExportTable.php" view. |
130 */ | |
131 $viewmodel = $this->viewmodel; | |
132 | |
133 if (isset($this->postdata['func'])) { | |
134 $func = $this->postdata['func']; | |
135 } | |
136 switch ($func) { | |
137 case 'exportFromExtractionInterface': | |
138 $this->ReturnView($viewmodel->ExportTable($this->postdata, false), true); | |
139 break; | |
140 | |
141 default: // from file | |
142 $viewmodel->GetInfoFromPreviousPage($this->postdata); | |
143 $viewmodel->GetTextFromFileId(); | |
144 $this->ReturnView($viewmodel->ExportTable($this->postdata, true), true); | |
145 break; | |
146 | |
147 } | |
106 | 148 |
107 } | 149 } |
108 | 150 |
109 protected function EditWordlist() { | 151 protected function EditWordlist() { |
152 /** | |
153 * EditWordlist action returns "./views/Extractapp/EditWordlist.php" view, | |
154 * It adds or saves wordlist based on the 'func' variable in postdata. | |
155 */ | |
156 | |
110 $viewmodel = $this->viewmodel; | 157 $viewmodel = $this->viewmodel; |
111 if (isset($this->postdata['func'])) { | 158 if (isset($this->postdata['func'])) { |
112 $func = $this->postdata['func']; | 159 $func = $this->postdata['func']; |
113 } | 160 } |
114 switch ($func) { | 161 switch ($func) { |
124 } | 171 } |
125 } | 172 } |
126 | 173 |
127 | 174 |
128 protected function EditTaglist() { | 175 protected function EditTaglist() { |
176 /** | |
177 * EditTaglist action returns "./views/Extractapp/EditTaglist.php" view. | |
178 * It adds, saves or delete tag in the current topic. | |
179 */ | |
180 | |
129 $viewmodel = $this->viewmodel; | 181 $viewmodel = $this->viewmodel; |
130 if (isset($this->postdata['func'])) { | 182 if (isset($this->postdata['func'])) { |
131 $func = $this->postdata['func']; | 183 $func = $this->postdata['func']; |
132 } | 184 } |
133 switch ($func) { | 185 switch ($func) { |
146 } | 198 } |
147 } | 199 } |
148 | 200 |
149 | 201 |
150 protected function ConfigTagsInTopic() { | 202 protected function ConfigTagsInTopic() { |
203 /** | |
204 * ConfigTagsInTopic action returns "./views/Extractapp/ConfigTagsInTopic.php" view. | |
205 * It shows or updates the tags-in-topic relation. | |
206 */ | |
207 | |
151 $viewmodel = $this->viewmodel; | 208 $viewmodel = $this->viewmodel; |
152 if (isset($this->postdata['func'])) { | 209 if (isset($this->postdata['func'])) { |
153 $func = $this->postdata['func']; | 210 $func = $this->postdata['func']; |
154 } | 211 } |
155 switch ($func) { | 212 switch ($func) { |
158 break; | 215 break; |
159 default: | 216 default: |
160 $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), true); | 217 $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), true); |
161 break; | 218 break; |
162 } | 219 } |
163 } | |
164 | |
165 protected function TestAction() { | |
166 $this->ReturnView($viewmodel->Test(), true); | |
167 } | 220 } |
168 | 221 |
169 | 222 |
170 | 223 |
171 | 224 |