# HG changeset patch # User Zoe Hong # Date 1428415943 -7200 # Node ID edb8a2e8ce842e1de6541a330d0fff93e5a7a0f9 # Parent 6676ca451dcc141f7829c8541c5f0b114bbb4621 New: save book meta_data in file diff -r 6676ca451dcc -r edb8a2e8ce84 controllers/extractapp.php --- a/controllers/extractapp.php Tue Apr 07 14:59:39 2015 +0200 +++ b/controllers/extractapp.php Tue Apr 07 16:12:23 2015 +0200 @@ -66,7 +66,7 @@ } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { // --- New branch case --- $viewmodel->GetInfoFromPreviousPage($this->postdata); - $viewmodel->GetBookMetaDataBySectionId(); + $viewmodel->SetBookMetaDataBySectionId(); // get text by sectionId from LGService $viewmodel->GetTextFromSectionId(); diff -r 6676ca451dcc -r edb8a2e8ce84 models/extractapp.php --- a/models/extractapp.php Tue Apr 07 14:59:39 2015 +0200 +++ b/models/extractapp.php Tue Apr 07 16:12:23 2015 +0200 @@ -51,17 +51,18 @@ - public function GetBookMetaDataBySectionId() { + public function SetBookMetaDataBySectionId() { - // TODO: get book_meta from $$this->get_section_metadata_by_sectionId_url ... + // get book_meta from $$this->get_section_metadata_by_sectionId_url $section_meta_url = $this->get_section_metadata_by_sectionId_url.$this->section_id; - $section_meta = file_get_contents($section_meta_url); + $section_meta = json_decode(file_get_contents($section_meta_url), true); + $b = $section_meta['section']['book']; - // TODO: set $this->book_meta to an array(book_id,book_name,author,year,pagenumber,dynasty) $book_meta = array(); - array_push($book_meta, array($this->book_id,$this->book_name,"no_data","no_data","no_data","no_data")); // missing author,year,pagenumber - + 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 $this->book_meta = $book_meta; } @@ -310,14 +311,24 @@ // book meta data $book = $this->book_meta; foreach ($book as $b) { + $text .= "\n"; $text .= "".$b[0]."\n"; $text .= "".$b[1]."\n"; - $text .= "".$b[2]."\n"; - $text .= "".$b[3]."\n"; - $text .= "".$b[4]."\n"; + $text .= "".$b[2]."\n"; + $text .= "".$b[3]."\n"; + $text .= "".$b[4]."\n"; $text .= "".$b[5]."\n"; + $text .= "".$b[6]."\n"; + $text .= "".$b[7]."\n"; + $text .= "".$b[8]."\n"; + $text .= "".$b[9]."\n"; + $text .= "".$b[10]."\n"; + $text .= "".$b[11]."\n"; + $text .= "".$b[12]."\n"; + $text .= "".$b[13]."\n"; $text .= "\n"; + } // taglist $taglist = $this->taglist_infile; @@ -616,20 +627,6 @@ unset($outputTableArray[$arrayIndex]); } - /* - if ($topic == 1) { - if ( !isset($arrayValue[0]["person"]) ) { - unset($outputTableArray[$arrayIndex]); - } - } else if ($topic == 2) { - - // for object topic - if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row - unset($outputTableArray[$arrayIndex]); - } - } - */ - } $data = array(); @@ -1149,7 +1146,9 @@ $book_meta = $xml->book; $book_metaArray = array(); foreach ($book_meta as $row) { - array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->author,(string)$row->year,(string)$row->pagenumber,(string)$row->dynasty )); + array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->level1,(string)$row->level2, + (string)$row->period,(string)$row->dynasty,$row->start_year,$row->end_year,$row->line, + (string)$row->volume,(string)$row->author,(string)$row->edition,(string)$row->in_jibengujiku,(string)$row->admin_type )); } if ($book_metaArray) { $this->book_meta = $book_metaArray; @@ -1206,15 +1205,18 @@ $stringInput = preg_replace("/【(.*?)】/u", "【\\1】", $stringInput); } - // get book_meta from books table + /* + // get book_meta from books table in db $book_meta = array(); $books_result = $this->GetBooksByID($bookId); while ($row = mysql_fetch_assoc($books_result)) { array_push($book_meta, array($row['id'],$row['name'],$row['author'],(string)$row['start_year'],(string)$row['line'],(string)$row['dynasty'])); // use 'start_year' as year, 'line' is pagenumber } + $this->book_meta = $book_meta; + */ - $this->book_meta = $book_meta; + $this->SetBookMetaDataBySectionId(); // get book_meta by section_id from LGServices and set $this->book_meta return $stringInput; }