Mercurial > hg > extraction-interface
changeset 74:60b5a94163c3 extractapp
New: retrieve book meta data from LGService
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 09 Apr 2015 10:59:31 +0200 |
parents | 2daef8e36214 |
children | 75233b09c580 |
files | controllers/extractapp.php models/extractapp.php |
diffstat | 2 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/controllers/extractapp.php Wed Apr 08 16:17:50 2015 +0200 +++ b/controllers/extractapp.php Thu Apr 09 10:59:31 2015 +0200 @@ -64,6 +64,7 @@ if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { // --- Existing branch case --- $viewmodel->GetInfoFromPreviousPage($this->postdata); + $viewmodel->SetBookMetaDataBySectionId(); // get text by fileId, from LGService $viewmodel->GetTextFromFileId(); } @@ -77,10 +78,12 @@ } else if ($this->postdata['sectionId'] != 0) { $viewmodel->GetTextFromLocal($this->postdata['sectionId']); + $viewmodel->SetBookMetaDataBySectionId(); } else if (is_numeric($this->urlvalues['id'])) { // get text from local file system (for development stage only) $viewmodel->GetTextFromLocal($this->urlvalues['id']); + $viewmodel->SetBookMetaDataBySectionId(); $this->ReturnView_localtest($viewmodel->StartTagging(), true); break;
--- a/models/extractapp.php Wed Apr 08 16:17:50 2015 +0200 +++ b/models/extractapp.php Thu Apr 09 10:59:31 2015 +0200 @@ -32,10 +32,7 @@ $lg_text_url = $this->get_text_from_fileId_url.$this->file_id; //$lg_text = file_get_contents($lg_text_url); // --- 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) - - // ---- + $lg_text = $this->ParseDataInFile($lg_text_url); $stringInput = $lg_text; @@ -95,13 +92,15 @@ $this->lg_text = $lg_text; } - public function GetTextFromLocal($_id){ + + // This is only used on localhost + public function GetTextFromLocal($_id){ $this->section_id = $_id; //$this->branch_id = 1; // local test sets branch_id to 1 $this->messages['debug'] .= "[Debug] from my local"."<br>"; $this->lg_text = $this->GetSectionContent(); + } - } public function GetInfoFromPreviousPage($_postdata) { @@ -1121,7 +1120,7 @@ return $data; } - private function ParseMetaData($filename) { + private function ParseDataInFile($filename) { $text = file_get_contents($filename); $xml = simplexml_load_string($text); //or die("Error: Cannot load from xml string"); if (!$xml) { @@ -1141,7 +1140,8 @@ $this->taglist_infile = $taglistArray; } - // get book meta data from file + // --- get book meta data from file, replaced by SetBookMetaDataBySectionId(), which retrives book meta data from LGService + /* $book_meta = $xml->book; $book_metaArray = array(); foreach ($book_meta as $row) { @@ -1152,17 +1152,16 @@ if ($book_metaArray) { $this->book_meta = $book_metaArray; } - - // echo $taglist->name.", ".$taglist->tag."," .$taglist->color; - // --- detect if the taglist set is up-to-date or not --- + */ + // ----- $contentString = (string)($xml->text_content->asXML()); - //$removed_str = array("<text_content>","</text_content>"); - //$new_contentString = str_replace($removed_str, "", $contentString); return $contentString; } - private function GetSectionContent() { + + + private function GetSectionContent() { // called only by GetTextFromLocal() $section_id = $this->GetSectionId(); $section_info = $this->GetSectionInfo(); @@ -1176,7 +1175,7 @@ $filename = $data_path."parsing_files/".$section_id.".txt"; // --- parsing meta data - $stringInput = $this->ParseMetaData($filename); + $stringInput = $this->ParseDataInFile($filename); // ---- // if the text is from file system @@ -1205,7 +1204,7 @@ } /* - // get book_meta from books table in db + // get book_meta from books table in db on localhost $book_meta = array(); $books_result = $this->GetBooksByID($bookId); while ($row = mysql_fetch_assoc($books_result)) { @@ -1215,8 +1214,6 @@ $this->book_meta = $book_meta; */ - $this->SetBookMetaDataBySectionId(); // get book_meta by section_id from LGServices and set $this->book_meta - return $stringInput; }