Mercurial > hg > LGToc
changeset 5:26ed9d1d6957
New: get user name from LGService by sessionId
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 21 Apr 2015 14:53:09 +0200 |
parents | 373c8ecad8b4 |
children | 4d59439c8b46 |
files | check_sections_details.php config/config.php js/check_sections_details.js |
diffstat | 3 files changed, 67 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/check_sections_details.php Tue Mar 24 11:32:31 2015 +0100 +++ b/check_sections_details.php Tue Apr 21 14:53:09 2015 +0200 @@ -94,27 +94,39 @@ echo $str; } +if (isset($_GET['sessionId'])) { + // check if get session info from LGService, to get username as editor + $session_id = $_GET['sessionId']; + $lg_url = "http://localgazetteers-dev/LGServices/rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService + $output = file_get_contents($lg_url); + $user_info = json_decode($output, true); + $current_editor = $user_info['userName']; + +} else { + // test locally +} + ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <link href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" type="text/css" rel="stylesheet"/> - <link href="css/check_sections.css" type="text/css" rel="stylesheet"/> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> - <script src="js/check_sections_details.js" type="text/javascript"></script> - <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js" type="text/javascript"></script> - <!--<script src="js/check_sections.js" charset="utf-8"></script>!--> - </head> - <body> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" type="text/css" rel="stylesheet"/> + <link href="css/check_sections.css" type="text/css" rel="stylesheet"/> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> + <script src="js/check_sections_details.js" type="text/javascript"></script> + <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js" type="text/javascript"></script> + <!--<script src="js/check_sections.js" charset="utf-8"></script>!--> + </head> + <body> <div id="loading">...</div> <div id="container"> - <?php + <?php $version=0; $editor=""; $date=""; - if(isset($_GET['book_id']) && isset($_GET['count']) && is_numeric($_GET['count'])){ + if(isset($_GET['book_id']) && isset($_GET['count']) && is_numeric($_GET['count'])){ $bookId=$_GET['book_id']; $count=$_GET['count']; $bookInfo=getBookInfo($bookId); @@ -126,41 +138,46 @@ printBookInfo($bookInfo); //echo "version: ".$version."<br>last editor: ".$editor; $missingPageArray=checkMissingPage($bookInfo,$info); - ?> + ?> - <table> - <thead>Show editing records: - <button id="show_all">Show all</button> - <button id="close">Close</button> - </thead> - <tbody> - <tr> - <td id="editor_th"></td> - <td id="date_th"></td> - </tr> - <tr> - <td><div id="editor"></div></td> - <td><div id="date"></div></td> - </tr> - </tbody> - </table> + <table> + <thead>Show editing records: + <button id="show_all">Show all</button> + <button id="close">Close</button> + </thead> + <tbody> + <tr> + <td id="editor_th"></td> + <td id="date_th"></td> + </tr> + <tr> + <td><div id="editor"></div></td> + <td><div id="date"></div></td> + </tr> + </tbody> + </table> - - - <div id="searchResults"> - <?php + <div id="searchResults"> + <?php $sectionArray=getSectionArray($bookId,$count,$info); printSectionArray($sectionArray,$missingPageArray); - }else{ + }else{ echo "Cannot process the data due to incomplete input."; } - ?> - </div> + ?> + </div> </div> <div id="panel"></div> <script>var version=<?php echo $version;?>;</script> <script type="text/javascript"> + function setCurrentEditor() { + // current_editor is gotten from LGService + var current_editor = JSON.parse('<?php echo json_encode($current_editor) ?>'); + if (current_editor != "") { + $("#saveBook .editor").val(current_editor); + } + } document.getElementById("show_all").onclick = function(){showAll()}; @@ -197,10 +214,13 @@ document.getElementById("editor").innerHTML = ""; document.getElementById("date").innerHTML = ""; } - </script> + + + + </script> - </body> + </body> </html>
--- a/config/config.php Tue Mar 24 11:32:31 2015 +0100 +++ b/config/config.php Tue Apr 21 14:53:09 2015 +0200 @@ -4,23 +4,24 @@ if (!$at_local) { // host at localgazetteers-dev server - $systemNAME = "interface"; $mysql_database = "Gazetteer"; $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = "admin"; - $system_root_url = "http://localgazetteers-dev/LGToc"; - $lgserver_url = "http://localgazetteers-dev/LGServer/"; + $server_host = "http://localgazetteers-dev/"; + $lgserver_url = $server_host."LGServer/"; } else { // localhost - $systemNAME = "interface"; $mysql_database = "Gazetteers"; $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = "root"; - $system_root_url = "http://localhost:1080/localgazetteers-dev/LGToc"; + $server_host = "http://localhost:1080/localgazetteers-dev/"; $lgserver_url = "http://localgazetteers-dev/LGServer/"; } +$systemNAME = "interface"; +$system_root_url = $server_host."LGToc/"; + ?>
--- a/js/check_sections_details.js Tue Mar 24 11:32:31 2015 +0100 +++ b/js/check_sections_details.js Tue Apr 21 14:53:09 2015 +0200 @@ -297,8 +297,11 @@ editor=editor[0].replace("editor=",""); editor=editor.replace("%20"," "); $("#saveBook .editor").val(editor); + } else { + setCurrentEditor(); // get from LGService, if user linked this TOC from LGService (the firsttime) } } + function saveBook(version){ var sectionArray=collectSectionArray(); var bookId=$(".entry").first().children(".hiddenInfo").children(".booksId").html();