Mercurial > hg > extraction-interface
changeset 13:cc36a20a68ab
automatically decide which rows (what data) should be shown in the exporting table based on the topic.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 17 Feb 2015 15:25:11 +0100 |
parents | e82ca7375e93 |
children | ac77748bb813 |
files | develop/classes/basemodel.php develop/controllers/extractapp.php develop/js/taggingtext.js develop/models/_extractapp_func.php develop/models/extractapp.php develop/views/Extractapp/exporttable.php develop/views/Extractapp/taggingtext.php |
diffstat | 7 files changed, 67 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- 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=";
--- 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); }
--- 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", "<?php echo $section_id; ?>"); 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); /*
--- 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();
--- 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 "<br>"."DEBUG: outputTableArray:"."<br>"; 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)) {
--- 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']; + + ?> <html>
--- 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 @@ <script type="text/javascript"> +// === This is only for developing on local machine ==== +var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); +if (_GET['id']) { + + var info = JSON.parse('<?php echo json_encode($info) ?>'); + var redirectUrl = "http://141.14.239.50:1080/localmonographs/develop/Extractapp/TaggingText"; + var section_id = info['section_id']; + + var form = $('<form action="' + redirectUrl + '" method="post">' + + '<input type="hidden" name="sectionId" value="'+section_id+'" />' + + '</form>'); + $('body').append(form); + $(form).submit(); +} +// ==== <?php @@ -237,7 +252,7 @@ if (name!=null){ $.ajax({ type : 'POST', - url : '../../models/_extractapp_func.php', + url : '../models/_extractapp_func.php', async : false, data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name }).done(function(result) { @@ -290,13 +305,15 @@ } + + // === for config tags in topic === function configTagsInTopic(topic_id) { var form = document.createElement("form"); form.setAttribute("method", "post"); //form.setAttribute("action", "exportTable.php"); - form.setAttribute("action", "../ConfigTagsInTopic"); // hand to controller + form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller form.setAttribute("target", "_blank"); @@ -418,7 +435,7 @@ var form = document.createElement("form"); form.setAttribute("method", "post"); - form.setAttribute("action", "./"+info['section_id']); // hand to controller + form.setAttribute("action", "./TaggingText"); // hand to controller //form.setAttribute("action", "./"+section_id); // hand to controller form.setAttribute("target", "_self"); @@ -546,15 +563,15 @@ <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> </br> - <button onclick="window.open('../EditWordlist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Word List</button></br> - <button onclick="window.open('../EditTaglist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Tag List</button></br> + <button onclick="window.open('./EditWordlist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Word List</button></br> + <button onclick="window.open('./EditTaglist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Tag List</button></br> </fieldset> <fieldset> <legend>Export:</legend> Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br> <button onclick="exportPage()" style="height: 30px; width: 220px">Export</button></br> - <button onclick="exportAll(<?php echo $section_id;?>,<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br> + <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br> </fieldset> <fieldset>