diff develop/models/extractapp.php @ 29:fc7342914cdf

develop_v0
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 05 Mar 2015 15:08:09 +0100
parents e6e9bdc4f256
children 4b3da4802998
line wrap: on
line diff
--- a/develop/models/extractapp.php	Tue Mar 03 18:13:20 2015 +0100
+++ b/develop/models/extractapp.php	Thu Mar 05 15:08:09 2015 +0100
@@ -17,13 +17,14 @@
     }
 
     public function GetTextFromFileId($_postdata) {
-        
+        /*
         if ($this->current_fileId != 0) {
             $this->file_id = $this->current_fileId;
         } else {
             $this->file_id = $_postdata['fileId'];
         }
-
+        */
+        $this->file_id = $_postdata['fileId'];
         $branch_id = $_postdata['branchId'];
         $section_id = $_postdata['sectionId'];
 
@@ -57,13 +58,11 @@
         $this->section_id = $section_id;
         $this->user_id = $_postdata['userId'];
 
-        // TODO: get info from LGService
         $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 = file_get_contents($lg_text_url);
@@ -106,7 +105,6 @@
             $this->topic = $_postdata['topic_id'];
         }
 
-        // TODO: LGService
         if ($_postdata['sectionName']) {
             $this->section_name = $_postdata['sectionName'];
         }
@@ -165,6 +163,36 @@
         
 
     }
+    /*
+    public function Reload($_postdata) {
+
+        // update text using $this->current_fileId
+        // getTextbyFileId
+        $current_fileId = $_postdata['currentFileId'];
+        //$this->file_id = $_postdata['currentFileId'];
+        //$this->GetTextFromFileId($_postdata);
+        //$latest_editing = $this->lg_text;
+        // get from URL with file_id
+
+        $lg_text_url = $this->get_text_from_fileId_url.$current_fileId;
+        $lg_text = file_get_contents($lg_text_url);
+
+        $stringInput = $lg_text;
+        $stringInput = preg_replace("/ /u", "○", $stringInput);
+        $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
+        $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
+        $lg_text = $stringInput;
+
+
+        //var_dump($lg_text);
+
+        echo json_encode($lg_text);
+        //var_dump($this->file_id);
+
+    }
+    */
+
+
 
     // === for tagging ===
     public function StartTagging() {
@@ -239,10 +267,15 @@
     }
 
     public function UpdateInfoByResponseFromLGService($response) {
-        
+         
+        /*
+        $response_file = $response["file"];
+        $response_branch = $response["branch"];
+
         
-        $status = $response["status"];
-        if ($response["status"] == "error") {
+        $status = (string)$response["status"];
+
+        if ((string)$response["status"] == "error") {
             $response_currentFile = $response["currentFile"];
     
             $this->current_fileId = (string)$response_currentFile['id'];
@@ -250,18 +283,17 @@
 
             
         } else {
-            
-            $response_file = $response["file"];
-            $response_branch = $response["branch"];
+           
+            $this->messages .= "saving success.";
+            var_dump((string)$response_file["id"]);
 
-            $this->messages .= "saving success.";
             $this->file_id = (string)$response_file["id"]; 
             $this->branch_id = (string)$response_branch["id"];
 
         }
-
+        */
 
-        /*
+        
         $response_file = $response["file"];
         $response_branch = $response["branch"];
 
@@ -274,9 +306,11 @@
         } else if ($status == "error") {
             // saving not success
             $this->messages .= "saving does not success! ".(string)$response["message"];
-            $this->current_fileId = $response["currentFileId"];
+            $response_currentFile = $response["currentFile"];
+            //$this->current_fileId = $response["currentFileId"];
+            $this->current_fileId = (string)$response_currentFile["id"];
+
         }
-        */
         
 
     }
@@ -351,12 +385,11 @@
         ));       
 
         // execute the request
-
-        //$output = curl_exec($ch);
+        $output = curl_exec($ch);
 
 
         // output the profile information - includes the header
-        echo($output) . PHP_EOL;
+        //echo($output) . PHP_EOL;
 
         // close curl resource to free up system resources
         curl_close($ch);