changeset 53:f9594c240826 extractapp

get/update text after saving, for xml file consistency
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 26 Mar 2015 17:25:46 +0100
parents 94064f625650
children f9e7119339b2
files controllers/extractapp.php models/extractapp.php
diffstat 2 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/controllers/extractapp.php	Thu Mar 26 16:23:33 2015 +0100
+++ b/controllers/extractapp.php	Thu Mar 26 17:25:46 2015 +0100
@@ -27,6 +27,8 @@
                 $viewmodel->GetInfoFromPreviousPage($this->postdata);
                 $response = $viewmodel->SaveFullTextToLGService($this->postdata);
                 $viewmodel->UpdateInfoByResponseFromLGService($response);    // update file_id, branch_id, user_id
+                // TODO: GetTextFromFileId?? reload saved file from LGService, necessary!
+                $viewmodel->GetTextFromFileId();     
                 $this->ReturnView($viewmodel->StartTagging(), true); 
                 break;
 
@@ -55,10 +57,14 @@
 
                 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) {
                     // get text from fileId, from LGService
-                    $viewmodel->GetTextFromFileId($this->postdata);
+                    $viewmodel->GetInfoFromPreviousPage($this->postdata);
+                    $viewmodel->GetTextFromFileId();
+
                 } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) {
                     // get text from sectionId from LGService
-                    $viewmodel->GetTextFromSectionId($this->postdata); 
+                    $viewmodel->GetInfoFromPreviousPage($this->postdata);
+                    $viewmodel->GetTextFromSectionId();  
+
                 } else if ($this->postdata['sectionId'] != 0) { 
                     $viewmodel->GetTextFromLocal($this->postdata['sectionId']);
 
--- a/models/extractapp.php	Thu Mar 26 16:23:33 2015 +0100
+++ b/models/extractapp.php	Thu Mar 26 17:25:46 2015 +0100
@@ -17,7 +17,8 @@
 
     }
 
-    public function GetTextFromFileId($_postdata) {
+    public function GetTextFromFileId() {   // remove $_postdata as input
+        /*
         $this->file_id = $_postdata['fileId'];
         $branch_id = $_postdata['branchId'];
         $section_id = $_postdata['sectionId'];
@@ -29,6 +30,7 @@
         $this->section_name = $_postdata['sectionName'];
         $this->book_id = $_postdata['bookId'];
         $this->book_name = $_postdata['bookName'];
+        */
 
         // get from URL with file_id
         $lg_text_url = $this->get_text_from_fileId_url.$this->file_id;
@@ -50,7 +52,8 @@
 
     }
 
-    public function GetTextFromSectionId($_postdata) {
+    public function GetTextFromSectionId() {  // remove $_postdata as input
+        /*
         $section_id = $_postdata['sectionId'];
         $this->section_id = $section_id;
         $this->user_id = $_postdata['userId'];
@@ -58,14 +61,16 @@
         $this->section_name = $_postdata['sectionName'];
         $this->book_id = $_postdata['bookId'];
         $this->book_name = $_postdata['bookName'];
+        */
 
         // get from URL with file_id
-        $lg_text_url = $this->get_text_from_sectionId_url.$section_id;
+        // $lg_text_url = $this->get_text_from_sectionId_url.$section_id;
+        $lg_text_url = $this->get_text_from_sectionId_url.$this->section_id;
         $lg_text = file_get_contents($lg_text_url);
 
         // TODO: get book_meta from $_postdata and set $this->book_meta: book_id,book_name,author,year,pagenumber
         $book_meta = array();
-        array_push($book_meta, array($this->book_id,$this->book_name,"NULL","NULL","NULL"));    // missing author,year,pagenumber
+        array_push($book_meta, array($this->book_id,$this->book_name,"no_data","no_data","no_data"));    // missing author,year,pagenumber
         
         $this->book_meta = $book_meta;