Mercurial > hg > extraction-interface
changeset 42:c245d54eab9f extractapp
config lg server url, without port
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 12 Mar 2015 17:33:30 +0100 |
parents | 533a6c39c128 |
children | 807d3bb33da7 |
files | develop/classes/basemodel.php develop/config/config.php develop/models/extractapp.php develop/views/Extractapp/TaggingText.php |
diffstat | 4 files changed, 27 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/develop/classes/basemodel.php Tue Mar 10 14:13:21 2015 +0100 +++ b/develop/classes/basemodel.php Thu Mar 12 17:33:30 2015 +0100 @@ -2,25 +2,26 @@ abstract class BaseModel { // protected $database; - protected $systemNAME, $topic; + protected $systemNAME, $lgserver_url; - protected $get_text_from_fileId_url = "http://localgazetteers-dev:8080/LGServer/rest/text/getFileText?fileId="; - protected $get_text_from_sectionId_url = "http://localgazetteers-dev:8080/LGServer/rest/text/getSectionText?sectionId="; - protected $save_to_LGService_url = "http://localgazetteers-dev:8080/LGServer/rest/text/save"; - protected $save_new_to_LGService_url = "http://localgazetteers-dev:8080/LGServer/rest/text/saveNew"; + protected $get_text_from_fileId_url = $this->lgserver_url."rest/text/getFileText?fileId="; + protected $get_text_from_sectionId_url = $this->lgserver_url."rest/text/getSectionText?sectionId="; + protected $save_to_LGService_url = $this->lgserver_url."rest/text/save"; + protected $save_new_to_LGService_url = $this->lgserver_url."rest/text/saveNew"; + /* - // 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="; - protected $save_to_LGService_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/save"; - protected $save_new_to_LGService_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/saveNew"; + protected $get_text_from_fileId_url = "http://localgazetteers-dev/LGServer/rest/text/getFileText?fileId="; + protected $get_text_from_sectionId_url = "http://localgazetteers-dev/LGServer/rest/text/getSectionText?sectionId="; + protected $save_to_LGService_url = "http://localgazetteers-dev/LGServer/rest/text/save"; + protected $save_new_to_LGService_url = "http://localgazetteers-dev/LGServer/rest/text/saveNew"; */ public function __construct() { - global $mysql_database, $mysql_server, $mysql_user, $mysql_password, $systemNAME; + global $mysql_database, $mysql_server, $mysql_user, $mysql_password, $systemNAME, $lgserver_url; $this->systemNAME = $systemNAME; + $this->lgserver_url = $lgserver_url; // $this->database = new PDO("mysql:host=localhost;dbname=test", "username", "password"); set_time_limit(0);
--- a/develop/config/config.php Tue Mar 10 14:13:21 2015 +0100 +++ b/develop/config/config.php Thu Mar 12 17:33:30 2015 +0100 @@ -10,6 +10,7 @@ $mysql_user = "root"; $mysql_password = "admin"; $system_root_url = "http://localgazetteers-dev/extraction-interface/develop"; + $lgserver_url = "http://localgazetteers-dev/LGServer/"; } else { // localhost @@ -19,6 +20,7 @@ $mysql_user = "root"; $mysql_password = "root"; $system_root_url = "http://localhost:1080/extraction-interface/develop"; + $lgserver_url = "http://localgazetteers-dev/LGServer/"; } ?>
--- a/develop/models/extractapp.php Tue Mar 10 14:13:21 2015 +0100 +++ b/develop/models/extractapp.php Thu Mar 12 17:33:30 2015 +0100 @@ -384,7 +384,7 @@ // save tagged text (full text) by Jorge's API to lg service // -------- - if ($_postdata['text']){ + 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"); @@ -404,7 +404,6 @@ $require = preg_replace("/<br>/u", "\n", $require); //$require = preg_replace("/<br>/u", "\n", $require); - // TODO: append metadata at the beginning of file if ($_postdata['branchId'] == 0) { // -- new branch case $require = "<text_content>\n".$require."</text_content>\n"; @@ -412,7 +411,7 @@ $require = $this->AppendMetaData($require); //saving in my local machine in developing phrase - file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require); + //file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require); } // ------ @@ -431,11 +430,11 @@ } else { // -- new branch case echo "saveNew!"; + $user_id = "0"; if ($_postdata['userId']) { $user_id = $_postdata['userId']; - } else { - $user_id = "12"; } + $postfields = array( "text" => $require, "sectionId" => $_postdata['sectionId'], @@ -1196,7 +1195,11 @@ private function ParseMetaData($filename) { $text = file_get_contents($filename); - $xml = simplexml_load_string($text) or die("Error: Cannot load from xml string"); + $xml = simplexml_load_string($text); //or die("Error: Cannot load from xml string"); + if (!$xml) { + // when file created by section_id, read the plain text from file_get_contents + return $text; + } $this->topic = (string)$xml->topic; // set topic id
--- a/develop/views/Extractapp/TaggingText.php Tue Mar 10 14:13:21 2015 +0100 +++ b/develop/views/Extractapp/TaggingText.php Thu Mar 12 17:33:30 2015 +0100 @@ -87,6 +87,9 @@ if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ // -- there might be conflicts between different version + alert("Someone edited this file and saved before you."); + return; + var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)'); if( retVal == true ){ // TODO: force saving with currentFileId @@ -151,6 +154,7 @@ */ } + } return;