From 5aff506911cb83a688ecf60c42a0e1abc83ab0e7 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 1 Dec 2017 19:36:42 -0700 Subject: [PATCH] Add tile metadata editing and preview button (see #2) --- lib/gencontent.php | 32 ++++++++++++++++++++++---- pages/content.php | 39 ++++++++++++++++++++++++++++++++ pages/editpub.php | 6 ++--- static/js/content.js | 53 +++++++++++++++++++++++++++++++++++--------- 4 files changed, 113 insertions(+), 17 deletions(-) diff --git a/lib/gencontent.php b/lib/gencontent.php index be19dd9..9b46a71 100644 --- a/lib/gencontent.php +++ b/lib/gencontent.php @@ -3,7 +3,16 @@ require_once __DIR__ . "/../required.php"; dieifnotloggedin(); if (!defined("IN_NEWSPEN")) { - die("Please don't do that."); + if (is_numeric($VARS['pubid'])) { + if ($database->has('publications', ['pubid' => $VARS['pubid']])) { + $pub = $VARS['pubid']; + $pubdata = $database->get("publications", ["pubname", "pubdate", "styleid", "columns"], ["pubid" => $pub]); + } else { + die(lang("invalid parameters", false)); + } + } else { + die(lang("invalid parameters", false)); + } } ob_end_flush(); ob_start(); @@ -22,7 +31,7 @@ $tiles = $database->select("tiles", ["tileid", "page", "styleid", "content", "wi foreach ($styles as $style) { ?> .tile-style- { - + } -
" data-tileid="" data-styleid="" data-page="" data-styleid="" data-width="" data-order=""> +
" data-tileid="" data-page="" data-styleid="" data-width="" data-order="">
+
-content" class="tile-style-"> @@ -66,11 +76,25 @@ foreach ($tiles as $tile) { \n" . "\n" . "\n" . "\n" + . "\n" . "$content"; + // Credit: https://stackoverflow.com/a/709684 + $content = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $content); + // End credit + $content = str_replace("\t", " ", $content); + // TODO: replace this loop with something less freshman + while (strpos($content, " ") !== FALSE) { + $content = str_replace(" ", " ", $content); + } +} + +if (!defined("IN_NEWSPEN")) { + echo $content; } ?> \ No newline at end of file diff --git a/pages/content.php b/pages/content.php index 5adf468..0b486eb 100644 --- a/pages/content.php +++ b/pages/content.php @@ -40,8 +40,47 @@ if ($pub === false) { } else { ?> + +
+
diff --git a/pages/editpub.php b/pages/editpub.php index f87d6e5..3bd5962 100644 --- a/pages/editpub.php +++ b/pages/editpub.php @@ -9,7 +9,7 @@ $pubdata = [ 'styleid' => '', 'columns' => '', 'permid' => '' - ]; +]; $editing = false; $cloning = false; @@ -21,8 +21,7 @@ if (!is_empty($VARS['id'])) { $cloning = true; } $pubdata = $database->select( - 'publications', - [ + 'publications', [ 'pubname (name)', 'pubdate', 'styleid', @@ -118,6 +117,7 @@ if (!is_empty($VARS['id'])) {