Mercurial > hg > extraction-interface
view 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 |
line wrap: on
line source
<?php /** * Extractapp is extended from the BaseController. * This is where we handle the processes for every action. * * For example, there are five actions in Extractapp, tagging text, exporting a table, * editing the wordlist, and configurating tags in one topic. */ class Extractapp extends BaseController { protected $viewmodel; public function __construct($action, $urlvalues, $postdata){ parent::__construct($action, $urlvalues, $postdata); $this->viewmodel = new ExtractappModel(); } protected function TaggingText() { /** * TaggingText action in Extractapp handles the taging related actions, for example, * tagging itself, saving tag results, loading and saving regular expression for tagging. * They are handled by 'func' variable in postdata, which could come from LGService or from extraction-interface application itself. * * From LGService, the postdata contains essential information about the file/section of local gazetteers data. * This happens when user entering to extraction-interface the first time, or after s/he saved her/is tagging results to LGService. * (default one, SaveFullTextToLGService, SmartRegexLoad, SmartRegexSave case) * * From extraction-interface itself, it contains the information from previous page. * This happens when user choosing another topic in the extraction-interface, * the page need to retrieve related information from database for the topic. * (ContinueTagging case) */ $viewmodel = $this->viewmodel; if (isset($this->postdata['func'])) { $func = $this->postdata['func']; } switch ($func) { case 'SaveFullText': $viewmodel->SaveFullText($this->postdata); $this->ReturnView($viewmodel->StartTagging(), true); break; case 'SaveFullTextToLGService': $viewmodel->messages['info'] .= "SaveFullTextToLGService! "; $viewmodel->GetInfoFromPreviousPage($this->postdata); $response = $viewmodel->SaveFullTextToLGService($this->postdata); $viewmodel->UpdateInfoResponsedFromLGService($response); // update file_id, branch_id, user_id $viewmodel->GetTextFromFileId(); $this->ReturnView($viewmodel->StartTagging(), true); break; case 'SmartRegexLoad': $viewmodel->LoadSmartRegex($this->postdata['topic_id']); break; case 'SmartRegexSave': $viewmodel->SaveSmartRegex($this->postdata); break; case 'ReloadText': $viewmodel->messages['info'] .= "Reload the latest text "; $viewmodel->GetInfoFromPreviousPage($this->postdata); $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 $viewmodel->GetTextFromFileId(); $this->ReturnView($viewmodel->StartTagging(), true); break; case 'ContinueTagging': $viewmodel->messages['info'] .= "(Countinue tagging) "; if ($this->postdata['topic']) { $viewmodel->SetTopic($this->postdata['topic']); } $viewmodel->GetInfoFromPreviousPage($this->postdata); $this->ReturnView($viewmodel->StartTagging(), true); break; default: // This is where the first time user visit extraction interface from LGService $viewmodel->messages['info'] .= "Welcome to Extraction Interface. "; if (isset($this->postdata['fileId'])) { if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { // --- Existing branch case --- $viewmodel->GetInfoFromPreviousPage($this->postdata); $viewmodel->SetBookMetadataBySectionId(); // get text by fileId, from LGService $viewmodel->GetTextFromFileId(); } } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { // --- New branch case --- $viewmodel->GetInfoFromPreviousPage($this->postdata); $viewmodel->SetBookMetadataBySectionId(); // get text by sectionId from LGService $viewmodel->GetTextFromSectionId(); } else if ($this->postdata['sectionId'] != 0) { $viewmodel->GetTextFromLocal($this->postdata['sectionId']); $viewmodel->SetBookMetadataBySectionId(); } else if (is_numeric($this->urlvalues['id'])) { // get text from local file system (for development stage only) $viewmodel->GetTextFromLocal($this->urlvalues['id']); $viewmodel->SetBookMetadataBySectionId(); $this->ReturnView_localtest($viewmodel->StartTagging(), true); break; } else { $viewmodel->messages['error'] .= "wrong url!!"; return; } $this->ReturnView($viewmodel->StartTagging(), true); break; } } protected function ExportTable() { /** * ExportTable action returns "./views/Extractapp/ExportTable.php" view. */ $viewmodel = $this->viewmodel; if (isset($this->postdata['func'])) { $func = $this->postdata['func']; } switch ($func) { case 'exportFromExtractionInterface': $this->ReturnView($viewmodel->ExportTable($this->postdata, false), true); break; default: // from file $viewmodel->GetInfoFromPreviousPage($this->postdata); $viewmodel->GetTextFromFileId(); $this->ReturnView($viewmodel->ExportTable($this->postdata, true), true); break; } } protected function EditWordlist() { /** * EditWordlist action returns "./views/Extractapp/EditWordlist.php" view, * It adds or saves wordlist based on the 'func' variable in postdata. */ $viewmodel = $this->viewmodel; if (isset($this->postdata['func'])) { $func = $this->postdata['func']; } switch ($func) { case 'AddNewList': $this->ReturnView($viewmodel->AddNewList($this->postdata), true); break; case 'SaveWordlist': $this->ReturnView($viewmodel->SaveWordlist($this->postdata), true); break; default: // EditWordlist $this->ReturnView($viewmodel->EditWordlist(), true); break; } } protected function EditTaglist() { /** * EditTaglist action returns "./views/Extractapp/EditTaglist.php" view. * It adds, saves or delete tag in the current topic. */ $viewmodel = $this->viewmodel; if (isset($this->postdata['func'])) { $func = $this->postdata['func']; } switch ($func) { case 'NewTagElement': $this->ReturnView($viewmodel->NewTagElement($this->postdata), true); break; case 'SaveTagElement': $this->ReturnView($viewmodel->SaveTagElement($this->postdata), true); break; case 'DeleteTag': $this->ReturnView($viewmodel->DeleteTag($this->postdata), true); break; default: // EditTaglist $this->ReturnView($viewmodel->EditTaglist($this->postdata), true); break; } } protected function ConfigTagsInTopic() { /** * ConfigTagsInTopic action returns "./views/Extractapp/ConfigTagsInTopic.php" view. * It shows or updates the tags-in-topic relation. */ $viewmodel = $this->viewmodel; if (isset($this->postdata['func'])) { $func = $this->postdata['func']; } switch ($func) { case 'Update': $viewmodel->UpdateTagsInTopic($this->postdata); break; default: $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), true); break; } } } ?>