comparison controllers/extractapp.php @ 81:f1f849d31272 extractapp

book_id as string
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 23 Apr 2015 14:58:27 +0200
parents 960ba96efce1
children 0141df465205
comparison
equal deleted inserted replaced
80:c15f53afd7a5 81:f1f849d31272
1 <?php 1 <?php
2 /* extractapp.php
3 * This file is part of Extraction-interface.
4 *
5 * Extraction-interface is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * Extraction-interface is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>.
17 */
18
2 /** 19 /**
3 * Extractapp is extended from the BaseController. 20 * Extractapp class is extended from the BaseController class.
4 * This is where we handle the processes for every action. 21 * It sends commands to the ExtractappModel to process or update the ExtractappModel's state.
22 * It can also pass the commands or data (from ExtractappModel) to the associated view (files in views/Extractapp/),
23 * for example views/Extractapp/TaggingText.php , to change the view's presentation.
5 * 24 *
6 * For example, there are five actions in Extractapp, tagging text, exporting a table, 25 * There are five actions in Extractapp: tagging text, exporting a table,
7 * editing the wordlist, and configurating tags in one topic. 26 * editing the wordlist, editing the taglist, and configurating tags in one topic.
27 * Each action is one of the methods in Extractapp.
28 *
8 */ 29 */
9 30
10 class Extractapp extends BaseController { 31 class Extractapp extends BaseController {
11 32
12 33
44 $viewmodel->SaveFullText($this->postdata); 65 $viewmodel->SaveFullText($this->postdata);
45 $this->ReturnView($viewmodel->StartTagging(), true); 66 $this->ReturnView($viewmodel->StartTagging(), true);
46 break; 67 break;
47 case 'SaveFullTextToLGService': 68 case 'SaveFullTextToLGService':
48 $viewmodel->messages['info'] .= "SaveFullTextToLGService! "; 69 $viewmodel->messages['info'] .= "SaveFullTextToLGService! ";
49 $viewmodel->GetInfoFromPreviousPage($this->postdata); 70 $viewmodel->SetInfoFromPreviousPage($this->postdata);
50 $response = $viewmodel->SaveFullTextToLGService($this->postdata); 71 $response = $viewmodel->SaveFullTextToLGService($this->postdata);
51 $viewmodel->UpdateInfoResponsedFromLGService($response); // update file_id, branch_id, user_id 72 $viewmodel->UpdateInfoResponsedFromLGService($response); // update file_id, branch_id, user_id
52 $viewmodel->GetTextFromFileId(); 73 $viewmodel->SetTextFromFileId();
53 $this->ReturnView($viewmodel->StartTagging(), true); 74 $this->ReturnView($viewmodel->StartTagging(), true);
54 break; 75 break;
55 76
56 case 'SmartRegexLoad': 77 case 'SmartRegexLoad':
57 $viewmodel->LoadSmartRegex($this->postdata['topic_id']); 78 $viewmodel->LoadSmartRegex($this->postdata['topic_id']);
59 case 'SmartRegexSave': 80 case 'SmartRegexSave':
60 $viewmodel->SaveSmartRegex($this->postdata); 81 $viewmodel->SaveSmartRegex($this->postdata);
61 break; 82 break;
62 case 'ReloadText': 83 case 'ReloadText':
63 $viewmodel->messages['info'] .= "Reload the latest text "; 84 $viewmodel->messages['info'] .= "Reload the latest text ";
64 $viewmodel->GetInfoFromPreviousPage($this->postdata); 85 $viewmodel->SetInfoFromPreviousPage($this->postdata);
65 $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 86 $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0
66 $viewmodel->GetTextFromFileId(); 87 $viewmodel->SetTextFromFileId();
67 $this->ReturnView($viewmodel->StartTagging(), true); 88 $this->ReturnView($viewmodel->StartTagging(), true);
68 break; 89 break;
69 90
70 case 'ContinueTagging': 91 case 'ContinueTagging':
71 $viewmodel->messages['info'] .= "(Countinue tagging) "; 92 $viewmodel->messages['info'] .= "(Countinue tagging) ";
72 if ($this->postdata['topic']) { 93 if ($this->postdata['topic']) {
73 $viewmodel->SetTopic($this->postdata['topic']); 94 $viewmodel->SetTopic($this->postdata['topic']);
74 } 95 }
75 $viewmodel->GetInfoFromPreviousPage($this->postdata); 96 $viewmodel->SetInfoFromPreviousPage($this->postdata);
76 $this->ReturnView($viewmodel->StartTagging(), true); 97 $this->ReturnView($viewmodel->StartTagging(), true);
77 break; 98 break;
78 99
79 100
80 default: 101 default:
82 $viewmodel->messages['info'] .= "Welcome to Extraction Interface. "; 103 $viewmodel->messages['info'] .= "Welcome to Extraction Interface. ";
83 104
84 if (isset($this->postdata['fileId'])) { 105 if (isset($this->postdata['fileId'])) {
85 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { 106 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) {
86 // --- Existing branch case --- 107 // --- Existing branch case ---
87 $viewmodel->GetInfoFromPreviousPage($this->postdata); 108 $viewmodel->SetInfoFromPreviousPage($this->postdata);
88 $viewmodel->SetBookMetadataBySectionId(); 109 $viewmodel->SetBookMetadataBySectionId();
89 // get text by fileId, from LGService 110 // get text by fileId, from LGService
90 $viewmodel->GetTextFromFileId(); 111 $viewmodel->SetTextFromFileId();
91 } 112 }
92 113
93 } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { 114 } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) {
94 // --- New branch case --- 115 // --- New branch case ---
95 $viewmodel->GetInfoFromPreviousPage($this->postdata); 116 $viewmodel->SetInfoFromPreviousPage($this->postdata);
96 $viewmodel->SetBookMetadataBySectionId(); 117 $viewmodel->SetBookMetadataBySectionId();
97 // get text by sectionId from LGService 118 // get text by sectionId from LGService
98 $viewmodel->GetTextFromSectionId(); 119 $viewmodel->SetTextFromSectionId();
99 120
100 } else if ($this->postdata['sectionId'] != 0) { 121 } else if ($this->postdata['sectionId'] != 0) {
101 $viewmodel->GetTextFromLocal($this->postdata['sectionId']); 122 $viewmodel->SetTextFromLocal($this->postdata['sectionId']);
102 $viewmodel->SetBookMetadataBySectionId(); 123 $viewmodel->SetBookMetadataBySectionId();
103 124
104 } else if (is_numeric($this->urlvalues['id'])) { 125 } else if (is_numeric($this->urlvalues['id'])) {
105 // get text from local file system (for development stage only) 126 // get text from local file system (for development stage only)
106 $viewmodel->GetTextFromLocal($this->urlvalues['id']); 127 $viewmodel->SetTextFromLocal($this->urlvalues['id']);
107 $viewmodel->SetBookMetadataBySectionId(); 128 $viewmodel->SetBookMetadataBySectionId();
108 $this->ReturnView_localtest($viewmodel->StartTagging(), true); 129 $this->ReturnView_localtest($viewmodel->StartTagging(), true);
109 break; 130 break;
110 131
111 } else { 132 } else {
135 case 'exportFromExtractionInterface': 156 case 'exportFromExtractionInterface':
136 $this->ReturnView($viewmodel->ExportTable($this->postdata, false), true); 157 $this->ReturnView($viewmodel->ExportTable($this->postdata, false), true);
137 break; 158 break;
138 159
139 default: // from file 160 default: // from file
140 $viewmodel->GetInfoFromPreviousPage($this->postdata); 161 $viewmodel->SetInfoFromPreviousPage($this->postdata);
141 $viewmodel->GetTextFromFileId(); 162 $viewmodel->SetTextFromFileId();
142 $this->ReturnView($viewmodel->ExportTable($this->postdata, true), true); 163 $this->ReturnView($viewmodel->ExportTable($this->postdata, true), true);
143 break; 164 break;
144 165
145 } 166 }
146 167