diff models/extractapp.php @ 86:0141df465205 extractapp_dev

New: add chinese characters to pinyin
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 30 Apr 2015 10:52:05 +0200
parents ecc4b22e9b05
children fb5049fc5dd7
line wrap: on
line diff
--- a/models/extractapp.php	Thu Apr 23 17:08:31 2015 +0200
+++ b/models/extractapp.php	Thu Apr 30 10:52:05 2015 +0200
@@ -76,11 +76,38 @@
         $section_meta = json_decode(file_get_contents($section_meta_url), true);
 
         $b = $section_meta['section']['book'];
-
+        
+        $this->book_name = $b['name'];
+        $this->book_id = $b['id'];
+        /*
         $book_meta = array();
         array_push($book_meta, array($b['id'],$b['name'],$b['level1'],$b['level2'],
                     $b['period'],$b['dynasty'], $b['start_year'], $b['end_year'],$b['line'],
                     $b['volume'],$b['author'], $b['edition'],$b['in_jibengujiku'], $b['admin_type']));    // missing author,year,pagenumber
+        */
+        /*
+        $book_meta = array('id'=>$b['id'],'name'=>$b['name'],'level1'=>$b['level1'],'level2'=>$b['level2'],
+                    'period'=>$b['period'],'dynasty'=>$b['dynasty'],'start_year'=>$b['start_year'], 'end_year'=>$b['end_year'],'line'=>$b['line'],
+                    'volume'=>$b['volume'],'author'=>$b['author'],'edition'=>$b['edition'],
+                    'in_jibengujiku'=>$b['in_jibengujiku'],'admin_type'=>$b['admin_type']);    // missing author,year,pagenumber
+        */
+
+        $book_meta->id = $b['id'];
+        $book_meta->name = $b['name'];
+        $book_meta->level1 = $b['level1'];
+        $book_meta->level2 = $b['level2'];
+        $book_meta->period = $b['period'];
+        $book_meta->dynasty = $b['dynasty'];
+        $book_meta->start_year = $b['start_year'];
+        $book_meta->end_year = $b['end_year'];
+        $book_meta->line = $b['line'];
+        $book_meta->volume = $b['volume'];
+        $book_meta->author = $b['author'];
+        $book_meta->edition = $b['edition'];
+        $book_meta->in_jibengujiku = $b['in_jibengujiku'];
+        $book_meta->admin_type = $b['admin_type'];
+
+
         $this->book_meta = $book_meta;
 
     }
@@ -213,7 +240,7 @@
         return true;
        
     }
-
+    
     // === for tagging ===
     public function StartTagging() {
         /**
@@ -229,7 +256,7 @@
         //$taglistArray = $this->GetTaglistArray();
         //for GetTaglistByTopicId: 
         $taglistArray = $this->GetTaglistByTopicId($this->GetTopic());
-        
+
         // $this->taglist_infile is set (1) from file or (2) from _postdata['taglistArray'] which comes from frontend that user decided
         // $this->taglist_infile is the most up-to-date taglist decided by user. Should be written into file.
         if( $this->TaglistSubsetIn($this->taglist_infile, $taglistArray) ) {    // TaglistSubsetIn($l1,$l2): $l1 is a subset of $l2 or not
@@ -253,13 +280,16 @@
         $data['section_id'] = $section_id;
         $data['topiclistArray'] = $topiclistArray;
         $data['default_topic_id'] = $this->GetTopic();
-        $data['topic_tag'] = $this->GetTopicTag($this->GetTopic());
-        $data['topic_name'] = $this->GetTopicName($this->GetTopic());
+        $topic_id = $this->GetTopic();
+
+        $data['topic_tag'] = $this->GetTopicTag($topic_id);
+        $data['topic_name'] = $this->GetTopicName($topic_id);
+        $data['topic_tag_ch'] = $this->GetTopicTagName($topic_id);
 
 
         $data['info'] = array('file_id'=>$this->file_id, 'user_id'=>$this->user_id,
                 'branch_id'=>$this->branch_id, 'section_id'=>$this->section_id, 'book_id'=>$this->book_id, 
-                'book_name'=>$this->book_name, 'section_name'=>$this->section_name,
+                'book_name'=>$this->book_name,'section_name'=>$this->section_name, 'period'=>$this->book_meta->period,
                 'current_fileId'=>$this->current_fileId);
 
         $this->messages['debug'] .= "[Debug] ";
@@ -272,6 +302,7 @@
         $this->messages['info'] .= ", section id: ". $this->section_id;
         $this->messages['info'] .= ", branch id: ".$this->branch_id;
         $this->messages['info'] .= ", file id: ".$this->file_id;
+        $this->messages['info'] .= ", period: ".$this->book_meta->period;
         $this->messages['info'] .= "<br>";
 
 
@@ -308,10 +339,9 @@
 
     public function UpdateInfoResponsedFromLGService($response) {
         /**
-         *
+         * 
          */
 
-
         if (isset($response["file"])) {
             $response_file = $response["file"];
         }
@@ -353,6 +383,26 @@
         $text .= "<topic>".$this->topic."</topic>\n";
         // --- book meta data ---
         $book = $this->book_meta;
+       
+        $text .= "<book>\n";
+        $text .= "<id>".$book->id."</id>\n";
+        $text .= "<name>".$book->name."</name>\n";
+        $text .= "<level1>".$book->level1."</level1>\n";
+        $text .= "<level2>".$book->level2."</level2>\n";
+        $text .= "<period>".$book->period."</period>\n";
+        $text .= "<dynasty>".$book->dynasty."</dynasty>\n";
+        $text .= "<start_year>".$book->start_year."</start_year>\n";
+        $text .= "<end_year>".$book->end_year."</end_year>\n";
+        $text .= "<line>".$book->line."</line>\n";
+        $text .= "<volume>".$book->volume."</volume>\n";
+        $text .= "<author>".$book->author."</author>\n";
+        $text .= "<edition>".$book->edition."</edition>\n";
+        $text .= "<in_jibengujiku>".$book->in_jibengujiku."</in_jibengujiku>\n";
+        $text .= "<admin_type>".$book->admin_type."</admin_type>\n";
+        $text .= "</book>\n";
+        
+   
+        /*
         foreach ($book as $b) {
             $text .= "<book>\n";
             $text .= "<id>".$b[0]."</id>\n";
@@ -372,6 +422,8 @@
             $text .= "</book>\n";
             
         }
+        */ 
+
         // --- section info ---
         $text .= "<section>\n";
         $text .= "<id>".$this->section_id."</id>\n";
@@ -1086,7 +1138,6 @@
         $row = mysql_fetch_assoc($result);
         $tag = $row['tag'];
         return $tag;
-
     }
     private function GetTopicName($topic_id) {
         $result = $this->GetTopicById($topic_id);
@@ -1094,10 +1145,19 @@
         //$name = $row['name'];
         $name = array('name_en'=>$row['name_en'], 'name_ch'=>$row['name_ch'], 'name_pinyin'=>$row['name_pinyin']);
         return $name;
+    }
+    private function GetTopicTagName($topic_id) {
+        $topic_tag = $this->GetTopicTag($topic_id);
+        $query = "SELECT * FROM `taglist` WHERE tag='".$topic_tag."'";
+        $result = mysql_query($query);
+        $row = mysql_fetch_assoc($result);
 
+        return $row['name'];
     }
 
 
+
+
     // =========================== 
 
     // === for manage wordlist ===
@@ -1290,6 +1350,8 @@
         $bookId = $section_info['bookId'];
         $startPage = $section_info['startPage'];
         $endPage = $section_info['endPage'];
+        $this->section_name = $section_info['sectionName'];
+
 
         $contentString="";
         $data_path = $this->GetDataPath();