Mercurial > hg > extraction-interface
comparison models/extractapp.php @ 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 | 3ada9334ebfc |
children | 359f48d58cbc |
comparison
equal
deleted
inserted
replaced
68:6676ca451dcc | 69:edb8a2e8ce84 |
---|---|
49 } | 49 } |
50 | 50 |
51 | 51 |
52 | 52 |
53 | 53 |
54 public function GetBookMetaDataBySectionId() { | 54 public function SetBookMetaDataBySectionId() { |
55 | 55 |
56 // TODO: get book_meta from $$this->get_section_metadata_by_sectionId_url ... | 56 // get book_meta from $$this->get_section_metadata_by_sectionId_url |
57 $section_meta_url = $this->get_section_metadata_by_sectionId_url.$this->section_id; | 57 $section_meta_url = $this->get_section_metadata_by_sectionId_url.$this->section_id; |
58 $section_meta = file_get_contents($section_meta_url); | 58 $section_meta = json_decode(file_get_contents($section_meta_url), true); |
59 | 59 |
60 | 60 $b = $section_meta['section']['book']; |
61 // TODO: set $this->book_meta to an array(book_id,book_name,author,year,pagenumber,dynasty) | 61 |
62 $book_meta = array(); | 62 $book_meta = array(); |
63 array_push($book_meta, array($this->book_id,$this->book_name,"no_data","no_data","no_data","no_data")); // missing author,year,pagenumber | 63 array_push($book_meta, array($b['id'],$b['name'],$b['level1'],$b['level2'], |
64 | 64 $b['period'],$b['dynasty'], $b['start_year'], $b['end_year'],$b['line'], |
65 $b['volume'],$b['author'], $b['edition'],$b['in_jibengujiku'], $b['admin_type'])); // missing author,year,pagenumber | |
65 $this->book_meta = $book_meta; | 66 $this->book_meta = $book_meta; |
66 | 67 |
67 } | 68 } |
68 | 69 |
69 | 70 |
308 // topic | 309 // topic |
309 $text .= "<topic>".$this->topic."</topic>\n"; | 310 $text .= "<topic>".$this->topic."</topic>\n"; |
310 // book meta data | 311 // book meta data |
311 $book = $this->book_meta; | 312 $book = $this->book_meta; |
312 foreach ($book as $b) { | 313 foreach ($book as $b) { |
314 | |
313 $text .= "<book>\n"; | 315 $text .= "<book>\n"; |
314 $text .= "<id>".$b[0]."</id>\n"; | 316 $text .= "<id>".$b[0]."</id>\n"; |
315 $text .= "<name>".$b[1]."</name>\n"; | 317 $text .= "<name>".$b[1]."</name>\n"; |
316 $text .= "<author>".$b[2]."</author>\n"; | 318 $text .= "<level1>".$b[2]."</level1>\n"; |
317 $text .= "<year>".$b[3]."</year>\n"; | 319 $text .= "<level2>".$b[3]."</level2>\n"; |
318 $text .= "<pagenumber>".$b[4]."</pagenumber>\n"; | 320 $text .= "<period>".$b[4]."</period>\n"; |
319 $text .= "<dynasty>".$b[5]."</dynasty>\n"; | 321 $text .= "<dynasty>".$b[5]."</dynasty>\n"; |
322 $text .= "<start_year>".$b[6]."</start_year>\n"; | |
323 $text .= "<end_year>".$b[7]."</end_year>\n"; | |
324 $text .= "<line>".$b[8]."</line>\n"; | |
325 $text .= "<volume>".$b[9]."</volume>\n"; | |
326 $text .= "<author>".$b[10]."</author>\n"; | |
327 $text .= "<edition>".$b[11]."</edition>\n"; | |
328 $text .= "<in_jibengujiku>".$b[12]."</in_jibengujiku>\n"; | |
329 $text .= "<admin_type>".$b[13]."</admin_type>\n"; | |
320 $text .= "</book>\n"; | 330 $text .= "</book>\n"; |
331 | |
321 } | 332 } |
322 // taglist | 333 // taglist |
323 $taglist = $this->taglist_infile; | 334 $taglist = $this->taglist_infile; |
324 foreach ($taglist as $tagitem) { | 335 foreach ($taglist as $tagitem) { |
325 $text .= "<tagitem>\n"; | 336 $text .= "<tagitem>\n"; |
614 // e.g. the original version is for 'person' | 625 // e.g. the original version is for 'person' |
615 if ( !isset($arrayValue[0][$topic_tag]) ) { | 626 if ( !isset($arrayValue[0][$topic_tag]) ) { |
616 unset($outputTableArray[$arrayIndex]); | 627 unset($outputTableArray[$arrayIndex]); |
617 } | 628 } |
618 | 629 |
619 /* | |
620 if ($topic == 1) { | |
621 if ( !isset($arrayValue[0]["person"]) ) { | |
622 unset($outputTableArray[$arrayIndex]); | |
623 } | |
624 } else if ($topic == 2) { | |
625 | |
626 // for object topic | |
627 if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row | |
628 unset($outputTableArray[$arrayIndex]); | |
629 } | |
630 } | |
631 */ | |
632 | |
633 } | 630 } |
634 | 631 |
635 $data = array(); | 632 $data = array(); |
636 | 633 |
637 $data['outputTableArray'] = $outputTableArray; | 634 $data['outputTableArray'] = $outputTableArray; |
1147 | 1144 |
1148 // get book meta data from file | 1145 // get book meta data from file |
1149 $book_meta = $xml->book; | 1146 $book_meta = $xml->book; |
1150 $book_metaArray = array(); | 1147 $book_metaArray = array(); |
1151 foreach ($book_meta as $row) { | 1148 foreach ($book_meta as $row) { |
1152 array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->author,(string)$row->year,(string)$row->pagenumber,(string)$row->dynasty )); | 1149 array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->level1,(string)$row->level2, |
1150 (string)$row->period,(string)$row->dynasty,$row->start_year,$row->end_year,$row->line, | |
1151 (string)$row->volume,(string)$row->author,(string)$row->edition,(string)$row->in_jibengujiku,(string)$row->admin_type )); | |
1153 } | 1152 } |
1154 if ($book_metaArray) { | 1153 if ($book_metaArray) { |
1155 $this->book_meta = $book_metaArray; | 1154 $this->book_meta = $book_metaArray; |
1156 } | 1155 } |
1157 | 1156 |
1204 $stringInput = preg_replace("/ /u", "○", $stringInput); | 1203 $stringInput = preg_replace("/ /u", "○", $stringInput); |
1205 $stringInput = preg_replace("/\n/u", "<br>", $stringInput); | 1204 $stringInput = preg_replace("/\n/u", "<br>", $stringInput); |
1206 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput); | 1205 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput); |
1207 } | 1206 } |
1208 | 1207 |
1209 // get book_meta from books table | 1208 /* |
1209 // get book_meta from books table in db | |
1210 $book_meta = array(); | 1210 $book_meta = array(); |
1211 $books_result = $this->GetBooksByID($bookId); | 1211 $books_result = $this->GetBooksByID($bookId); |
1212 while ($row = mysql_fetch_assoc($books_result)) { | 1212 while ($row = mysql_fetch_assoc($books_result)) { |
1213 array_push($book_meta, array($row['id'],$row['name'],$row['author'],(string)$row['start_year'],(string)$row['line'],(string)$row['dynasty'])); | 1213 array_push($book_meta, array($row['id'],$row['name'],$row['author'],(string)$row['start_year'],(string)$row['line'],(string)$row['dynasty'])); |
1214 // use 'start_year' as year, 'line' is pagenumber | 1214 // use 'start_year' as year, 'line' is pagenumber |
1215 } | 1215 } |
1216 | |
1217 $this->book_meta = $book_meta; | 1216 $this->book_meta = $book_meta; |
1217 */ | |
1218 | |
1219 $this->SetBookMetaDataBySectionId(); // get book_meta by section_id from LGServices and set $this->book_meta | |
1218 | 1220 |
1219 return $stringInput; | 1221 return $stringInput; |
1220 } | 1222 } |
1221 | 1223 |
1222 private function GetDataPath() { | 1224 private function GetDataPath() { |