Mercurial > hg > extraction-interface
diff models/extractapp.php @ 51:840cdb52f476 extractapp
add book_meta into file
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 26 Mar 2015 15:42:50 +0100 |
parents | c98a0c6d7eb4 |
children | 94064f625650 |
line wrap: on
line diff
--- a/models/extractapp.php Thu Mar 19 09:53:26 2015 +0100 +++ b/models/extractapp.php Thu Mar 26 15:42:50 2015 +0100 @@ -33,8 +33,9 @@ // get from URL with file_id $lg_text_url = $this->get_text_from_fileId_url.$this->file_id; //$lg_text = file_get_contents($lg_text_url); - // --- parsing meta data + // --- get/set text and parsing meta data from text file $lg_text = $this->ParseMetaData($lg_text_url); + // TODO: maybe need to check if the book_meta is updated. compare the book_meta in text file and from _post (most up-to-date) // ---- @@ -62,6 +63,14 @@ $lg_text_url = $this->get_text_from_sectionId_url.$section_id; $lg_text = file_get_contents($lg_text_url); + // TODO: get book_meta from $_postdata and set $this->book_meta: book_id,book_name,author,year,pagenumber + $book_meta = array(); + array_push($book_meta, array($this->book_id,$this->book_name,"","","")); // missing author,year,pagenumber + + $this->book_meta = $book_meta; + + + $stringInput = $lg_text; $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput); $stringInput = preg_replace("/ /u", "○", $stringInput); @@ -357,10 +366,11 @@ $book = $this->book_meta; foreach ($book as $b) { $text .= "<book>\n"; - $text .= "<title>".$b[0]."</title>\n"; - $text .= "<author>".$b[1]."</author>\n"; - $text .= "<year>".$b[2]."</year>\n"; - $text .= "<pagenumber>".$b[3]."</pagenumber>\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 .= "</book>\n"; } // taglist @@ -382,7 +392,6 @@ } public function SaveFullTextToLGService($_postdata) { // save tagged text (full text) by Jorge's API to lg service - // -------- if ($_postdata['text']){ $date = date('Y_m_d_H_i_s', time()); @@ -708,7 +717,7 @@ echo json_encode(mysql_error()); } $row = mysql_fetch_assoc($result); - $largest_id = $row['AUTO_INCREMENT']; + $largest_id = $row['AUTO_INCREMENT']-1; $topic_id = $_postdata['topic_id']; @@ -1217,12 +1226,11 @@ $this->taglist_infile = $taglistArray; } - // get book meta data + // get book meta data from file $book_meta = $xml->book; $book_metaArray = array(); foreach ($book_meta as $row) { - //array_push($book_metaArray, array('title'=>(string)$row->title,'author'=>(string)$row->author,'year'=>(string)$row->year,'pagenumber'=>(string)$row->pagenumber )); - array_push($book_metaArray, array((string)$row->title,(string)$row->author,(string)$row->year,(string)$row->pagenumber )); + array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->author,(string)$row->year,(string)$row->pagenumber )); } if ($book_metaArray) { $this->book_meta = $book_metaArray; @@ -1275,6 +1283,17 @@ $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 + $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'])); + // use 'start_year' as year, 'line' is pagenumber + } + + $this->book_meta = $book_meta; + + return $stringInput; }