# HG changeset patch # User Zoe Hong # Date 1427792392 -7200 # Node ID a11f9103b8db5cf74ee12d7fb671563a9d7abb31 # Parent 5cf9720a2e25a73875b8f32436fb976436f3478a New: 1.display messages 2.handle saving conflict:up-to-date or reload text diff -r 5cf9720a2e25 -r a11f9103b8db config/config.php --- a/config/config.php Mon Mar 30 17:23:47 2015 +0200 +++ b/config/config.php Tue Mar 31 10:59:52 2015 +0200 @@ -1,8 +1,8 @@ ReturnView($viewmodel->StartTagging(), true); break; case 'SaveFullTextToLGService': - $viewmodel->messages .= "SaveFullTextToLGService! "."
"; + $viewmodel->messages['info'] .= "SaveFullTextToLGService! "."
"; $viewmodel->GetInfoFromPreviousPage($this->postdata); $response = $viewmodel->SaveFullTextToLGService($this->postdata); $viewmodel->UpdateInfoByResponseFromLGService($response); // update file_id, branch_id, user_id @@ -38,7 +38,7 @@ $viewmodel->SmartRegexSave($this->postdata); break; case 'ReloadText': - $viewmodel->messages .= "Reload the latest text "."
"; + $viewmodel->messages['info'] .= "Reload the latest text "."
"; $viewmodel->GetInfoFromPreviousPage($this->postdata); $viewmodel->ReloadSetting(); // set file_id = current_fileId, current_fileId = 0 $viewmodel->GetTextFromFileId(); @@ -46,7 +46,7 @@ break; case 'ContinueTagging': - $viewmodel->messages .= "(Countinue tagging) "."
"; + $viewmodel->messages['info'] .= "(Countinue tagging) "."
"; if ($this->postdata['topic']) { $viewmodel->SetTopic($this->postdata['topic']); } @@ -56,7 +56,7 @@ default: // first time visit extraction interface from LGService - $viewmodel->messages .= "Welcome to Extraction Interface. "."
"; + $viewmodel->messages['info'] .= "Welcome to Extraction Interface. "."
"; if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) { // get text from fileId, from LGService @@ -78,7 +78,7 @@ break; } else { - $viewmodel->messages .= "wrong url!!"; + $viewmodel->messages['error'] .= "wrong url!!"; return; } diff -r 5cf9720a2e25 -r a11f9103b8db data/regex_files/test_regex.txt --- a/data/regex_files/test_regex.txt Mon Mar 30 17:23:47 2015 +0200 +++ b/data/regex_files/test_regex.txt Tue Mar 31 10:59:52 2015 +0200 @@ -1,1 +1,1 @@ -物產 testwdfvvvv234QQQ空白v222vQQQ空白wdfw \ No newline at end of file +物產 testwdfvvvv234testQQQ空白v222vQQQ空白wdfw \ No newline at end of file diff -r 5cf9720a2e25 -r a11f9103b8db data/wordlist/4.txt --- a/data/wordlist/4.txt Mon Mar 30 17:23:47 2015 +0200 +++ b/data/wordlist/4.txt Tue Mar 31 10:59:52 2015 +0200 @@ -1,1 +1,1 @@ -一test
\ No newline at end of file +一
\ No newline at end of file diff -r 5cf9720a2e25 -r a11f9103b8db models/extractapp.php --- a/models/extractapp.php Mon Mar 30 17:23:47 2015 +0200 +++ b/models/extractapp.php Tue Mar 31 10:59:52 2015 +0200 @@ -10,7 +10,7 @@ protected $section_id = 0, $data_path, $file_id = 0, $current_fileId=0, $branch_id = 0, $user_id = 0, $lg_text = "", $topic, $taglist_infile = "", $book_meta = ""; - public $messages = ""; + public $messages = array('info'=>"",'error'=>"",'warning'=>"",'debug'=>""); private function Initialize($_urlvalues) { $this->SetSectionId($_urlvalues); @@ -89,7 +89,8 @@ public function GetTextFromLocal($_id){ $this->section_id = $_id; $this->branch_id = 1; // local test sets branch_id to 1 - $this->messages .= "DEBUG: from my local"."
"; + // $this->messages .= "DEBUG: from my local"."
"; + $this->messages['debug'] .= "[Debug] from my local"."
"; $this->lg_text = $this->GetSectionContent(); } @@ -279,11 +280,24 @@ //'current_fileId'=>$this->file_id); //'current_fileId'=>'123'); + $this->messages['debug'] .= "[Debug] "; + $this->messages['debug'] .= "file_id=".$this->file_id.", section_id=".$this->section_id; + $this->messages['debug'] .= ", user_id=".$this->user_id.", branch_id=".$this->branch_id.", topic_id=".$this->topic; + $this->messages['debug'] .= ", book_id=".$this->book_id.", book_name=".$this->book_name.", section_name=".$this->section_name; + $this->messages['debug'] .= ", current_fileId=".$this->current_fileId."
"; + + $this->messages['info'] .= "[Info] book name: ".$this->book_name; + $this->messages['info'] .= ", section id: ". $this->section_id; + $this->messages['info'] .= ", branch id: ".$this->branch_id; + $this->messages['info'] .= "
"; + + /* $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; $this->messages .= ", book_id=".$this->book_id.", book_name=".$this->book_name.", section_name=".$this->section_name; $this->messages .= ", current_fileId=".$this->current_fileId."
"; + */ $data['messages'] = $this->messages; @@ -348,15 +362,20 @@ $status = (string)$response["status"]; if ($status == "ok") { - $this->messages .= "Saving success."; + $this->messages['info'] .= "[Info] Saving success.
"; + //$this->messages .= "Saving success."; $this->file_id = (string)$response_file["id"]; $this->branch_id = (string)$response_branch["id"]; } else if ($status == "error") { // saving not success + $this->messages['warning'] .= "[Warning] Saving Failed! ".(string)$response["message"]."
"; + $this->messages['warning'] .= "[Warning] Please check branch ".$this->branch_id." in LGService, and modify from the latest version.
"; + + /* $this->messages .= "Saving Failed! ".(string)$response["message"]."
"; $this->messages .= "Please check branch ".$this->branch_id." in LGService, and modify from the latest version.
"; - + */ $response_currentFile = $response["currentFile"]; //$this->current_fileId = $response["currentFileId"]; $this->current_fileId = (string)$response_currentFile["id"]; @@ -409,12 +428,16 @@ public function SaveFullTextToLGService($_postdata) { // save tagged text (full text) by Jorge's API to lg service // -------- + global $AT_LOCAL; + 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); + if ($AT_LOCAL) { + file_put_contents("data/parsing_files/".$_postdata['sectionId']."_".$date.".txt", $oldFile); + } } if (get_magic_quotes_gpc()) { @@ -437,7 +460,9 @@ $require = $this->AppendMetaData($require); //saving in my local machine in developing phrase - //file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require); + if ($AT_LOCAL) { + file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require); + } } // ------ @@ -483,10 +508,11 @@ 'Content-type: multipart/form-data;charset=utf-8' )); - // execute the request - // **** commended to DEBUG *** - $output = curl_exec($ch); - // ***** + if (!$AT_LOCAL) { + // execute the request + $output = curl_exec($ch); + } + // output the profile information - includes the header //echo($output) . PHP_EOL; diff -r 5cf9720a2e25 -r a11f9103b8db views/Extractapp/ConfigTagsInTopic.php --- a/views/Extractapp/ConfigTagsInTopic.php Mon Mar 30 17:23:47 2015 +0200 +++ b/views/Extractapp/ConfigTagsInTopic.php Tue Mar 31 10:59:52 2015 +0200 @@ -85,7 +85,7 @@ -
+

Topic:

diff -r 5cf9720a2e25 -r a11f9103b8db views/Extractapp/TaggingText.php --- a/views/Extractapp/TaggingText.php Mon Mar 30 17:23:47 2015 +0200 +++ b/views/Extractapp/TaggingText.php Tue Mar 31 10:59:52 2015 +0200 @@ -107,14 +107,16 @@ } -// TODO: Popup to proceeding the saving situations function handleFileVersionConflict() { var info = JSON.parse(''); console.log("currentFileId="+info['current_fileId']); - if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ + // if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ + if (info['current_fileId'] != 0){ // -- there might be conflicts between different version alert("Your saving failed! Someone edited this file and saved before you."); + $('#reloadTextButton').css("display", "block"); + return; } return; @@ -794,7 +796,6 @@ } -// --- for config tags in topic --- function _postForContineTagging(form) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "text"); @@ -930,7 +931,14 @@
-

+
+

+

+

+ + +

+
@@ -977,9 +985,6 @@
- -
-
Config Topic:
current topic is @@ -990,14 +995,14 @@
Replace By Smart Regex©:

-
+
Range: to
- -
-
- - -
+ +
+
+ + +
@@ -1005,17 +1010,17 @@
Tag by rule:
-
-
+
+
- +
Edit:
-
+
@@ -1023,20 +1028,20 @@
--> -
+

-
+
-
+
Export:
Page: to
-
-
+
+
diff -r 5cf9720a2e25 -r a11f9103b8db views/maintemplate.php --- a/views/maintemplate.php Mon Mar 30 17:23:47 2015 +0200 +++ b/views/maintemplate.php Tue Mar 31 10:59:52 2015 +0200 @@ -7,18 +7,15 @@ - - - \ No newline at end of file diff -r 5cf9720a2e25 -r a11f9103b8db views/maintemplate_local.php --- a/views/maintemplate_local.php Mon Mar 30 17:23:47 2015 +0200 +++ b/views/maintemplate_local.php Tue Mar 31 10:59:52 2015 +0200 @@ -1,20 +1,18 @@ - - -