From d3abf62c3b8aaedd845ef9d7b9cd8201f72cb01a Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Mon, 6 Jun 2016 17:41:02 -0600 Subject: [PATCH] Move the view page into the main index.php. Prepare for viewing individual words. --- .htaccess | 12 +++- index.php | 169 ++++++++++++++++++++++++++++++++++------------ php/display.php | 11 +++ php/functions.php | 1 + view/index.php | 169 ---------------------------------------------- 5 files changed, 147 insertions(+), 215 deletions(-) create mode 100644 php/display.php delete mode 100644 view/index.php diff --git a/.htaccess b/.htaccess index 78e1d27..7320c0a 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,9 @@ -RewriteEngine On # Turn on the rewriting engine -RewriteRule ^view/([0-9]+)/?$ view/index.php?dict=$1 [NC,L] # Handle dictionary ids. -RewriteRule ^([0-9]+)/?$ view/index.php?dict=$1 [NC,L] # Handle dictionary ids. \ No newline at end of file +RewriteEngine On # Turn on the rewriting engine + +RewriteRule ^view/([0-9]+)/([0-9]+)/?$ index.php?dict=$1&word=$2 [NC,L] # Handle word ids. + +RewriteRule ^([0-9]+)/([0-9]+)/?$ index.php?dict=$1&word=$2 [NC,L] # Handle word ids. + +RewriteRule ^view/([0-9]+)/?$ index.php?dict=$1 [NC,L] # Handle dictionary ids. + +RewriteRule ^([0-9]+)/?$ index.php?dict=$1 [NC,L] # Handle dictionary ids. \ No newline at end of file diff --git a/index.php b/index.php index 4138407..b63e575 100644 --- a/index.php +++ b/index.php @@ -4,6 +4,16 @@ require_once('required.php'); session_start(); $current_user = isset($_SESSION['user']) ? $_SESSION['user'] : 0; +$dictionary_to_load = (isset($_GET['dict'])) ? intval($_GET['dict']) : 0; +$the_public_dictionary = '"That dictionary doesn\'t exist."'; +$dictionary_name = 'ERROR'; +$dictionary_creator = 'nobody'; +$is_viewing = $dictionary_to_load > 0; + +$word_to_load = (isset($_GET['word'])) ? intval($_GET['word']) : 0; +$the_public_word = '"That word doesn\'t exist."'; +$word_name = 'ERROR'; + $announcement = get_include_contents(SITE_LOCATION . '/announcement.php'); $notificationMessage = ""; @@ -17,6 +27,37 @@ if ($current_user > 0 || !isset($_SESSION['loginfailures']) || (isset($_SESSION[ require_once(SITE_LOCATION . '/php/notificationconditiontree.php'); +if ($is_viewing) { + $query = "SELECT `d`.`id`, `d`.`name`, `d`.`description`, `u`.`public_name`, `d`.`words`, `d`.`parts_of_speech`, `d`.`is_complete` "; + $query .= "FROM `dictionaries` AS `d` LEFT JOIN `users` AS `u` ON `d`.`user`=`u`.`id` WHERE `d`.`is_public`=1 AND `d`.`id`=" . $dictionary_to_load . ";"; + + $dbconnection = new PDO('mysql:host=' . DATABASE_SERVERNAME . ';dbname=' . DATABASE_NAME . ';charset=utf8', DATABASE_USERNAME, DATABASE_PASSWORD); + $dbconnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $dbconnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + $dbconnection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + try { + $queryResults = $dbconnection->prepare($query); + $queryResults->execute(); + if ($queryResults) { + if (num_rows($queryResults) === 1) { + while ($dict = fetch($queryResults)) { + $dictionary_name = $dict['name']; + $dictionary_creator = $dict['public_name']; + $the_public_dictionary = '{"name":"' . $dict['name'] . '",'; + $the_public_dictionary .= '"description":"' . $dict['description'] . '",'; + $the_public_dictionary .= '"createdBy":"' . $dict['public_name'] . '",'; + $the_public_dictionary .= '"words":' . $dict['words'] . ','; + $the_public_dictionary .= '"settings":{'; + $the_public_dictionary .= '"partsOfSpeech":"' . $dict['parts_of_speech'] . '",'; + $the_public_dictionary .= '"isComplete":' . (($dict['is_complete'] == 1) ? 'true' : 'false') . '},'; + $the_public_dictionary .= '}'; + } + } + } + } + catch (PDOException $ex) {} +} + ?> @@ -24,7 +65,17 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php'); - Lexiconga Dictionary Builder + + <?php echo $dictionary_name; ?> Dictionary on Lexiconga + + + + + + + + Lexiconga Dictionary Builder + @@ -48,6 +99,7 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php'); +
;margin-bottom:10px;"> Close
@@ -57,60 +109,68 @@ require_once(SITE_LOCATION . '/php/notificationconditiontree.php');
-
-
🔒
- - - - - - - -
- -
- - -
- + +
+
🔒
+ + + + + + + +
+ +
+ + +
+
+
+ Settings - +

+ + +

+
+ - Show Description - + HideShow Description +
- Search/Filter Options - + + + + +