From 31d160d25b3186d8143fdc6d29f735cb585bf6e6 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Fri, 3 Apr 2015 15:37:55 +0800 Subject: [PATCH] Make it so you can edit/remove embed, post preview --- inc/mod/pages.php | 21 ++++++++++++++++++--- templates/mod/edit_post_form.html | 26 +++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index ffa3fa34..9de2fdfd 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1615,10 +1615,17 @@ function mod_edit_post($board, $edit_raw_html, $postID) { $_POST['body'] .= "$value"; } + // Handle embed edits... + foreach ($config['embedding'] as &$embed) { + if (preg_match($embed[0], $_POST['embed'])) { + $embed_link = $_POST['embed']; + } + } + if ($edit_raw_html) - $query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body` = :body, `body_nomarkup` = :body_nomarkup, `edited_at` = UNIX_TIMESTAMP(NOW()) WHERE `id` = :id', $board)); + $query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body` = :body, `body_nomarkup` = :body_nomarkup, `embed` = :embed `edited_at` = UNIX_TIMESTAMP(NOW()) WHERE `id` = :id', $board)); else - $query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body_nomarkup` = :body, `edited_at` = UNIX_TIMESTAMP(NOW()) WHERE `id` = :id', $board)); + $query = prepare(sprintf('UPDATE ``posts_%s`` SET `name` = :name,'. $trip .' `email` = :email, `subject` = :subject, `body_nomarkup` = :body, `embed` = :embed, `edited_at` = UNIX_TIMESTAMP(NOW()) WHERE `id` = :id', $board)); $query->bindValue(':id', $postID); $query->bindValue(':name', $_POST['name'] ? $_POST['name'] : $config['anonymous']); $query->bindValue(':email', $_POST['email']); @@ -1628,6 +1635,11 @@ function mod_edit_post($board, $edit_raw_html, $postID) { $body_nomarkup = $_POST['body'] . "\n1"; $query->bindValue(':body_nomarkup', $body_nomarkup); } + if (isset($embed_link)) { + $query->bindValue(':embed', $embed_link); + } else { + $query->bindValue(':embed', NULL, PDO::PARAM_NULL); + } $query->execute() or error(db_error($query)); if( $config['clean']['edits_remove_local'] || $config['clean']['edits_remove_global'] ) { @@ -1686,7 +1698,10 @@ function mod_edit_post($board, $edit_raw_html, $postID) { $post['body'] = str_replace("\t", ' ', $post['body']); } - mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); + $preview = new Post($post); + $html = $preview->build(true); + + mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post, 'preview' => $html)); } } diff --git a/templates/mod/edit_post_form.html b/templates/mod/edit_post_form.html index d40d9b05..b36044f8 100644 --- a/templates/mod/edit_post_form.html +++ b/templates/mod/edit_post_form.html @@ -1,3 +1,5 @@ +
+
@@ -15,7 +17,7 @@ {% trans %}Tripcode{% endtrans %} - Remove? + {% trans %}Remove tripcode?{% endtrans %} @@ -43,7 +45,28 @@ + {# + + {% trans %}Files{% endtrans %}
+

{% trans %}Note: Changing files
deletes all previous ones.{% endtrans %}

+ + + {% for i in range(0, config.max_images - 1) %} +
+ {% endfor %} + + #} + + + {% trans %}Embed{% endtrans %} + + + + + +

{% trans %}Existing post{% endtrans %}

+ {{ preview }}

{% if mod|hasPermission(config.mod.rawhtml) %} {% if raw %} @@ -55,3 +78,4 @@ {% endif %}

+