# HG changeset patch # User Zoe Hong # Date 1424183111 -3600 # Node ID cc36a20a68ab16660e2e19dc2b741b447cc50956 # Parent e82ca7375e936b55039961a8051ad38f9f7ef7f6 automatically decide which rows (what data) should be shown in the exporting table based on the topic. diff -r e82ca7375e93 -r cc36a20a68ab develop/classes/basemodel.php --- a/develop/classes/basemodel.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/classes/basemodel.php Tue Feb 17 15:25:11 2015 +0100 @@ -3,6 +3,7 @@ abstract class BaseModel { // protected $database; protected $systemNAME, $topic; + // protected $lg_server_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/"; protected $get_text_from_fileId_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/getFileText?fileId="; protected $get_text_from_sectionId_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/getSectionText?sectionId="; diff -r e82ca7375e93 -r cc36a20a68ab develop/controllers/extractapp.php --- a/develop/controllers/extractapp.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/controllers/extractapp.php Tue Feb 17 15:25:11 2015 +0100 @@ -27,7 +27,7 @@ $viewmodel->GetInfoFromPreviousPage($this->postdata); $response = $viewmodel->SaveFullTextToLGService($this->postdata); - $viewmodel->UpdateInfoByResonseFromLGService($response); // update file_id, branch_id, user_id + $viewmodel->UpdateInfoByResponseFromLGService($response); // update file_id, branch_id, user_id $this->ReturnView($viewmodel->StartTagging(), false); break; @@ -47,15 +47,19 @@ if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { // get text from fileId, from LGService $viewmodel->GetTextFromFileId($this->postdata); - } else if ($this->postdata['sectionId'] != 0) { + } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) { // get text from sectionId from LGService $viewmodel->GetTextFromSectionId($this->postdata); + } else if ($this->postdata['sectionId'] != 0) { + $viewmodel->GetTextFromLocal($this->postdata['sectionId']); + } else if (is_numeric($this->urlvalues['id'])) { // get text from local file system (for development stage only) $viewmodel->GetTextFromLocal($this->urlvalues['id']); - // $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false); } else { + var_dump($this->postdata); + echo "wrong url!!"; return; } @@ -71,7 +75,7 @@ protected function ExportTable() { //$viewmodel = new ExtractappModel(); $viewmodel = $this->viewmodel; - $this->ReturnView($viewmodel->ExportTable($this->urlvalues, $this->postdata), false); + $this->ReturnView($viewmodel->ExportTable($this->postdata), false); } diff -r e82ca7375e93 -r cc36a20a68ab develop/js/taggingtext.js --- a/develop/js/taggingtext.js Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/js/taggingtext.js Tue Feb 17 15:25:11 2015 +0100 @@ -617,7 +617,7 @@ $.ajax({ type: 'POST', - url: '../../models/_extractapp_func.php', + url: '../models/_extractapp_func.php', dataType: 'json', data: "func=SmartRegexLoad", //cache: false, @@ -665,7 +665,7 @@ //MsgBox("enter function"); var form = document.createElement("form"); form.setAttribute("method", "post"); - form.setAttribute("action", "exportTable.php"); + form.setAttribute("action", "./ExportTable"); form.setAttribute("target", "_blank"); var hiddenField = document.createElement("input"); @@ -678,6 +678,11 @@ hiddenField.setAttribute("value", ""); form.appendChild(hiddenField); + var hiddenField2 = document.createElement("input"); + hiddenField2.setAttribute("name", "topic"); + hiddenField2.setAttribute("value", topic_id); + form.appendChild(hiddenField2); + if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); form.submit(); @@ -697,7 +702,7 @@ var form = document.createElement("form"); form.setAttribute("method", "post"); - form.setAttribute("action", "exportTable.php"); + form.setAttribute("action", "./ExportTable"); form.setAttribute("target", "_blank"); var hiddenField = document.createElement("input"); @@ -718,13 +723,13 @@ } } -function exportAll(section_id, topic_id) { +function exportAll(topic_id) { var el = document.getElementById("editable-area"); - var str="" + el.innerHTML; + var str= "" + el.innerHTML; var form = document.createElement("form"); form.setAttribute("method", "post"); //form.setAttribute("action", "exportTable.php"); - form.setAttribute("action", "../ExportTable/"+section_id); // hand to controller + form.setAttribute("action", "./ExportTable");//+section_id); // hand to controller form.setAttribute("target", "_blank"); var hiddenField = document.createElement("input"); @@ -732,10 +737,11 @@ hiddenField.setAttribute("value", str); form.appendChild(hiddenField); - var hiddenField2 = document.createElement("input"); - hiddenField2.setAttribute("name", "topic"); - hiddenField2.setAttribute("value", topic_id); - form.appendChild(hiddenField2); + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + console.log(topic_id); /* diff -r e82ca7375e93 -r cc36a20a68ab develop/models/_extractapp_func.php --- a/develop/models/_extractapp_func.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/models/_extractapp_func.php Tue Feb 17 15:25:11 2015 +0100 @@ -10,10 +10,6 @@ case 'SmartRegexSave': SmartRegexSave(); break; - - case 'SaveTextToLGService': - SaveTextToLGService(); - break; default: SmartRegexLoad(); diff -r e82ca7375e93 -r cc36a20a68ab develop/models/extractapp.php --- a/develop/models/extractapp.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/models/extractapp.php Tue Feb 17 15:25:11 2015 +0100 @@ -8,7 +8,7 @@ return array("Index Value 1", "Value 2", "Value 3"); } - protected $section_id, $data_path, $file_id, $branch_id, $user_id, $lg_tex; + protected $section_id=0, $data_path, $file_id=0, $branch_id=0, $user_id=0, $lg_text=""; private function Initialize($_urlvalues) { $this->SetSectionId($_urlvalues); @@ -186,7 +186,7 @@ } - public function UpdateInfoByResonseFromLGService($response) { + public function UpdateInfoByResponseFromLGService($response) { $response_file = $response["file"]; $response_branch = $response["branch"]; @@ -288,19 +288,15 @@ } // === for export table === - public function ExportTable($urlvalues, $postdata) { + public function ExportTable($postdata) { // $this->Initialize($urlvalues); + $content = $postdata['content']; $topic = $postdata['topic']; + $section_id = $this->section_id; - // outputTableArray: - // $section_id = $this->GetSectionId(); - $section_id = $this->section_id; - if (!$section_id) { - //$this->Initialize($urlvalues); - $section_id = $this->GetSectionId(); - } + // TODO: this should be get from LGServic: sectionName, bookId, bookName $section_info = $this->GetSectionInfo(); $sectionName = $section_info['sectionName']; @@ -308,11 +304,12 @@ $books_info = $this->GetBooksInfo($bookId); $bookName = $books_info['bookName']; + // ===== + $outputTableArray = array(); //$taglistArray = $this->GetTaglistArray(); - $taglistArray = $this->GetTaglistByTopicID($topic); $outputTableArray[0]=array(); @@ -377,13 +374,17 @@ echo "
"."DEBUG: outputTableArray:"."
"; var_dump($outputTableArray); */ + + $topic_tag = $this->GetTopicTag($topic); foreach ( $outputTableArray as $arrayIndex => $arrayValue ) { // output each row which the topic tag - // e.g. the original version is for 'person' - - // TODO: choose topic tag based on the topic - // for person topic + // e.g. the original version is for 'person' + if ( !isset($arrayValue[0][$topic_tag]) ) { + unset($outputTableArray[$arrayIndex]); + } + + /* if ($topic == 1) { if ( !isset($arrayValue[0]["person"]) ) { unset($outputTableArray[$arrayIndex]); @@ -395,10 +396,10 @@ unset($outputTableArray[$arrayIndex]); } } + */ } - $data = array(); $data['outputTableArray'] = $outputTableArray; @@ -565,7 +566,6 @@ // === for manage wordlist === public function EditWordlist($urlvalues) { - //$this->Initialize($urlvalues); $result = $this->GetWordlist(); $wordlistArray = array(); while ($row = mysql_fetch_assoc($result)) { diff -r e82ca7375e93 -r cc36a20a68ab develop/views/Extractapp/exporttable.php --- a/develop/views/Extractapp/exporttable.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/views/Extractapp/exporttable.php Tue Feb 17 15:25:11 2015 +0100 @@ -6,6 +6,8 @@ $bookName = $viewmodel['bookName']; $sectionName = $viewmodel['sectionName']; + + ?> diff -r e82ca7375e93 -r cc36a20a68ab develop/views/Extractapp/taggingtext.php --- a/develop/views/Extractapp/taggingtext.php Mon Feb 16 16:51:39 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Tue Feb 17 15:25:11 2015 +0100 @@ -54,6 +54,21 @@