Mercurial > hg > extraction-interface
changeset 26:579f03f8bee5
merge table books_info into table books (execute Home/Test)
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 03 Mar 2015 10:33:42 +0100 |
parents | 4b6d2d7e706e |
children | 4a29bccb6c59 |
files | develop/controllers/home.php develop/models/extractapp.php develop/models/home.php develop/views/Extractapp/taggingtext.php |
diffstat | 4 files changed, 63 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/develop/controllers/home.php Mon Mar 02 16:16:54 2015 +0100 +++ b/develop/controllers/home.php Tue Mar 03 10:33:42 2015 +0100 @@ -1,12 +1,18 @@ <?php class Home extends BaseController { + + public function __construct($action, $urlvalues, $postdata){ + parent::__construct($action, $urlvalues, $postdata); + $this->viewmodel = new ExtractappModel(); + } + protected function Index() { $viewmodel = new HomeModel(); $this->ReturnView($viewmodel->Index(), false); } - protected function TestAction() { + protected function Test() { $viewmodel = new HomeModel(); $this->ReturnView($viewmodel->Test(), true); }
--- a/develop/models/extractapp.php Mon Mar 02 16:16:54 2015 +0100 +++ b/develop/models/extractapp.php Tue Mar 03 10:33:42 2015 +0100 @@ -192,7 +192,11 @@ $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, 'book_id'=>$this->book_id, 'book_name'=>$this->book_name, 'section_name'=>$this->section_name); + $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, + 'current_fileId'=>$this->current_fileId); + $data['messages'] = $this->messages; return $data; @@ -240,7 +244,8 @@ } else if ($status == "error") { // saving not success $this->messages .= "saving does not success! ".(string)$response["message"]; - + $this->current_fileId = (string)$response['currentFileId']; + // ask to "force save" or "reload" } @@ -279,7 +284,6 @@ if ($_postdata['branchId'] != 0) { // exiting branch case $postfields = array( - //"text" => $_postdata['text'], "text" => $require, "branchId" => $_postdata['branchId'], "userId" => $_postdata['userId'], @@ -296,22 +300,15 @@ $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" => $user_id, "label" => $_postdata['label'], - // TODO: ask user for lable - //"label" => "label for section ".$_postdata['sectionId'], ); $save_url = $this->save_new_to_LGService_url; } - - // set up the curl resource $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $save_url);
--- a/develop/models/home.php Mon Mar 02 16:16:54 2015 +0100 +++ b/develop/models/home.php Tue Mar 03 10:33:42 2015 +0100 @@ -6,7 +6,32 @@ } public function Test() { - return array("Test Value 1", "Value 2", "Value 3"); + + /* uncomment to do the merge + // merge books table with books_info table + $query = "SELECT books_info.volume, books_info.author, books_info.edition, books_info.books_id FROM books INNER JOIN books_info ON books.id=books_info.books_id"; + + $result = mysql_query($query); + if (!$result) { + return json_encode("Failed during selecting books, books_info table."); + } + $query = "ALTER TABLE books_v1 ADD Column volume VARCHAR(50), ADD Column author VARCHAR(100), ADD Column edition VARCHAR(100);" + $result_alter = mysql_query($query); + + while ($row = mysql_fetch_assoc($result)) { + // insert row into books_v1 table + echo $row['volume'].$row['author'].$row['edition'].$row['books_id']; + + $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'"; + + $result_update= mysql_query($query_update); + if (!$result_update) { + echo json_encode("error"); + + } + } + */ + return; } }
--- a/develop/views/Extractapp/taggingtext.php Mon Mar 02 16:16:54 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Tue Mar 03 10:33:42 2015 +0100 @@ -8,7 +8,8 @@ $default_topic_id = $viewmodel['default_topic_id']; $topic_name = $viewmodel['topic_name']; $topic_tag = $viewmodel['topic_tag']; -$info = $viewmodel['info']; $messages = $viewmodel['messages']; +$info = $viewmodel['info']; +$messages = $viewmodel['messages']; ?> @@ -117,11 +118,31 @@ + var info = JSON.parse('<?php echo json_encode($info) ?>'); + // Popup to proceeding the saving situations + /* + if (info['current_fileId']) { + var retVal = confirm('There were something happened/someone editing in the between of time. + Please choose what you want to proceed the saving. + Click "OK" to force saving the current file.'); + if( retVal == true ){ + // TODO: force saving + alert("You do the force saving!"); + return true; + }else{ + // TODO: reload with the new file id (current_FileId) + alert("You will reload for the latest version!"); + return false; + } + + }; + + */ + // Popup choosing topic if first time to this section. without branchId - var info = JSON.parse('<?php echo json_encode($info) ?>'); if (info['file_id'] == 0) { // or info['branchId'] == 0, means new file // ask to choose topic $.ajax({