Mercurial > hg > extraction-interface
changeset 69:edb8a2e8ce84 extractapp
New: save book meta_data in file
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 07 Apr 2015 16:12:23 +0200 |
parents | 6676ca451dcc |
children | 359f48d58cbc |
files | controllers/extractapp.php models/extractapp.php |
diffstat | 2 files changed, 29 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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();
--- 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 .= "<book>\n"; $text .= "<id>".$b[0]."</id>\n"; $text .= "<name>".$b[1]."</name>\n"; - $text .= "<author>".$b[2]."</author>\n"; - $text .= "<year>".$b[3]."</year>\n"; - $text .= "<pagenumber>".$b[4]."</pagenumber>\n"; + $text .= "<level1>".$b[2]."</level1>\n"; + $text .= "<level2>".$b[3]."</level2>\n"; + $text .= "<period>".$b[4]."</period>\n"; $text .= "<dynasty>".$b[5]."</dynasty>\n"; + $text .= "<start_year>".$b[6]."</start_year>\n"; + $text .= "<end_year>".$b[7]."</end_year>\n"; + $text .= "<line>".$b[8]."</line>\n"; + $text .= "<volume>".$b[9]."</volume>\n"; + $text .= "<author>".$b[10]."</author>\n"; + $text .= "<edition>".$b[11]."</edition>\n"; + $text .= "<in_jibengujiku>".$b[12]."</in_jibengujiku>\n"; + $text .= "<admin_type>".$b[13]."</admin_type>\n"; $text .= "</book>\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", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $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; }