diff 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
line wrap: on
line diff
--- a/controllers/extractapp.php	Mon Apr 13 15:43:59 2015 +0200
+++ b/controllers/extractapp.php	Thu Apr 16 14:53:22 2015 +0200
@@ -1,4 +1,11 @@
 <?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 function Index() {
@@ -14,6 +21,21 @@
     }
 
     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'])) {
@@ -57,7 +79,8 @@
                 break;
 
 
-            default:    // first time visit extraction interface from LGService
+            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'])) {
@@ -100,13 +123,37 @@
         
     }
 
+
     protected function ExportTable() {
+        /**
+            * ExportTable action returns "./views/Extractapp/ExportTable.php" view.
+        */
         $viewmodel = $this->viewmodel;
-        $this->ReturnView($viewmodel->ExportTable($this->postdata), true);
+
+        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'];
@@ -126,6 +173,11 @@
 
 
     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'];
@@ -148,6 +200,11 @@
 
  
     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'];
@@ -162,10 +219,6 @@
          } 
     }
 
-    protected function TestAction() {
-        $this->ReturnView($viewmodel->Test(), true);
-    }
-