Mercurial > hg > extraction-interface
diff develop/models/extractapp.php @ 25:4b6d2d7e706e
update for the integration
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 02 Mar 2015 16:16:54 +0100 |
parents | b55f5d3564c4 |
children | 579f03f8bee5 |
line wrap: on
line diff
--- a/develop/models/extractapp.php Fri Feb 27 16:35:59 2015 +0100 +++ b/develop/models/extractapp.php Mon Mar 02 16:16:54 2015 +0100 @@ -25,6 +25,13 @@ $this->file_id = $file_id; $this->user_id = $_postdata['userId']; $this->section_id = $section_id; + + + // TODO: get info from LGService + $this->section_name = $_postdata['sectionName']; + $this->book_id = $_postdata['bookId']; + $this->book_name = $_postdata['bookName']; + // get from URL with file_id $lg_text_url = $this->get_text_from_fileId_url.$file_id; @@ -46,6 +53,13 @@ $this->section_id = $section_id; $this->user_id = $_postdata['userId']; + // TODO: get info from LGService + $this->section_name = $_postdata['sectionName']; + $this->book_id = $_postdata['bookId']; + $this->book_name = $_postdata['bookName']; + + + // get from URL with file_id $lg_text_url = $this->get_text_from_sectionId_url.$section_id; $lg_text = file_get_contents($lg_text_url); @@ -88,9 +102,23 @@ $this->topic = $_postdata['topic_id']; } + // TODO: LGService + if ($_postdata['sectionName']) { + $this->section_name = $_postdata['sectionName']; + } + if ($_postdata['bookName']) { + $this->book_name = $_postdata['bookName']; + } + if ($_postdata['bookId']) { + $this->book_id = $_postdata['bookId']; + } + $this->messages .= "Info: "; $this->messages .= "file_id=".$this->file_id.", section_id=".$this->section_id; - $this->messages .= ", user_id=".$this->user_id.", branch_id=".$this->branch_id.", topic_id=".$this->topic."<br>"; + $this->messages .= ", user_id=".$this->user_id.", branch_id=".$this->branch_id.", topic_id=".$this->topic; + $this->messages .= ", book_id=".$this->book_id.", book_name=".$this->book_name.", section_name=".$this->section_name."<br>"; + + } public function InitData($_postdata) { @@ -164,7 +192,7 @@ $data['topic_tag'] = $this->GetTopicTag($this->GetTopic()); $data['topic_name'] = $this->GetTopicName($this->GetTopic()); - $data['info'] = array('file_id'=>$this->file_id, 'user_id'=>$this->user_id, 'branch_id'=>$this->branch_id, 'section_id'=>$this->section_id); + $data['info'] = array('file_id'=>$this->file_id, 'user_id'=>$this->user_id, 'branch_id'=>$this->branch_id, 'section_id'=>$this->section_id, 'book_id'=>$this->book_id, 'book_name'=>$this->book_name, 'section_name'=>$this->section_name); $data['messages'] = $this->messages; return $data; @@ -202,20 +230,31 @@ $this->file_id = (string)$response_file["id"]; $this->branch_id = (string)$response_branch["id"]; + + + + $status = (string)$response["status"]; + if ($status == "ok") { + $this->messages .= "saving success."; + + } else if ($status == "error") { + // saving not success + $this->messages .= "saving does not success! ".(string)$response["message"]; - //$this->messages .= "file_id: ".$this->file_id."<br>"; - //$this->messages .= "branch_id: ".$this->branch_id."<br>"; + + } + } public function SaveFullTextToLGService($_postdata) { // save tagged text (full text) by Jorge's API to lg service // -------- - // saving in my local machine in developing phrase if ($_postdata['text']){ $date = date('Y_m_d_H_i_s', time()); if ( file_exists("data/parsing_files/".$_postdata['sectionId'].".txt") ) { $oldFile = file_get_contents("data/parsing_files/".$_postdata['sectionId'].".txt"); + //saving in my local machine in developing phrase file_put_contents("data/parsing_files/".$_postdata['sectionId']."_".$date.".txt", $oldFile); } @@ -230,6 +269,7 @@ $require = preg_replace("/○/u", " ", $require); $require = preg_replace("/<br>/u", "\n", $require); $require = preg_replace("/<br>/u", "\n", $require); + //saving in my local machine in developing phrase file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require); } @@ -250,13 +290,18 @@ } else { // new branch case echo "saveNew!"; + if ($_postdata['userId']) { + $user_id = $_postdata['userId']; + } else { + $user_id = "12"; + } $postfields = array( //"text" => $_postdata['text'], "text" => $require, "sectionId" => $_postdata['sectionId'], //"userId" => $_postdata['userId'], // TODO: change userId when we can query by sectionId from LGService using search - "userId" => "12", + "userId" => $user_id, "label" => $_postdata['label'], // TODO: ask user for lable //"label" => "label for section ".$_postdata['sectionId'], @@ -376,7 +421,14 @@ //$section_id = $this->section_id; - // TODO: this should be get from LGServic: sectionName, bookId, bookName + // TODO: this should be get from LGService: sectionName, bookId, bookName + $sectionName = $postdata['sectionName']; + $bookId = $postdata['bookId']; + $bookName = $postdata['bookName']; + + + // --- replace if get info from LGService + /* $section_info = $this->GetSectionInfo(); $sectionName = $section_info['sectionName']; @@ -384,6 +436,7 @@ $books_info = $this->GetBooksInfo($bookId); $bookName = $books_info['bookName']; + */ // =====