From 4c246ad42657430c6a0b4be6f9263a0eb2abeb09 Mon Sep 17 00:00:00 2001 From: onli Date: Sun, 9 May 2021 16:54:27 +0200 Subject: [PATCH] php8 compat fixes for entry preview --- include/admin/entries.inc.php | 18 ++++++++++++------ include/functions_comments.inc.php | 2 ++ include/functions_config.inc.php | 2 +- include/functions_entries.inc.php | 8 +++++--- templates/2k11/admin/entries.inc.tpl | 3 --- templates/2k11/admin/entries.tpl | 2 +- templates/2k11/preview_iframe.tpl | 2 +- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/admin/entries.inc.php b/include/admin/entries.inc.php index 2f49ed51..7c0f34a8 100644 --- a/include/admin/entries.inc.php +++ b/include/admin/entries.inc.php @@ -39,12 +39,12 @@ switch($serendipity['GET']['adminAction']) { 'timestamp' => $serendipity['POST']['timestamp'], 'body' => $serendipity['POST']['body'], 'extended' => $serendipity['POST']['extended'], - 'categories' => $serendipity['POST']['categories'], + 'categories' => $serendipity['POST']['categories'] ?? null, 'isdraft' => $serendipity['POST']['isdraft'], 'allow_comments' => $serendipity['POST']['allow_comments'], - 'moderate_comments' => $serendipity['POST']['moderate_comments'], + 'moderate_comments' => $serendipity['POST']['moderate_comments'] ?? null, 'exflag' => (!empty($serendipity['POST']['extended']) ? true : false), - 'had_categories' => $serendipity['POST']['had_categories'] + 'had_categories' => $serendipity['POST']['had_categories'] ?? null // Messing with other attributes causes problems when entry is saved // Attributes need to explicitly matched/addressed in serendipity_updertEntry! @@ -69,7 +69,6 @@ switch($serendipity['GET']['adminAction']) { if ($entry['timestamp'] == -1) { $data['switched_output'] = true; - $data['dateval'] = false; // The date given by the user is not convertable. Reset the timestamp. $entry['timestamp'] = $serendipity['POST']['timestamp']; } @@ -108,7 +107,7 @@ switch($serendipity['GET']['adminAction']) { // Only display the preview $serendipity['hidefooter'] = true; // Advanced templates use this to show update status and elapsed time - if (!is_numeric($entry['last_modified'])) { + if (!is_numeric($entry['last_modified'] ?? null)) { $entry['last_modified'] = time(); } @@ -183,7 +182,7 @@ switch($serendipity['GET']['adminAction']) { 'serendipity[timestamp]' => serendipity_specialchars($entry['timestamp']) ), $entry, - $errors + $errors ?? null ); } @@ -345,6 +344,7 @@ switch($serendipity['GET']['adminAction']) { $qString .= '&serendipity[filter]['. $k .']='. $v; } } + $data['linkFirst'] = $qString . '&serendipity[page]=' . 0; $data['linkPrevious'] = $qString . '&serendipity[page]=' . ($page-1); $data['linkNext'] = $qString . '&serendipity[page]=' . ($page+1); @@ -458,6 +458,12 @@ if (! isset($data['filter_import'])) { $data['filter_import'] = null; } if (! isset($data['sort_import'])) { $data['sort_import'] = null; } if (! isset($data['count'])) { $data['count'] = null; } if (! isset($data['is_entries'])) { $data['is_entries'] = null; } +if (! isset($data['is_draft'])) { $data['is_draft'] = null; } +if (! isset($data['is_iframe'])) { $data['is_iframe'] = null; } +if (! isset($data['is_doDelete'])) { $data['is_doDelete'] = null; } +if (! isset($data['is_doMultiDelete'])) { $data['is_doMultiDelete'] = null; } +if (! isset($data['is_delete'])) { $data['is_delete'] = null; } +if (! isset($data['is_multidelete'])) { $data['is_multidelete'] = null; } echo serendipity_smarty_show('admin/entries.inc.tpl', $data); diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php index 34b0a2ec..225138df 100644 --- a/include/functions_comments.inc.php +++ b/include/functions_comments.inc.php @@ -204,6 +204,8 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data 'commentform_entry' => $entry ); + if (! isset($commentform_data['required_fields'])) { $commentform_data['required_fields'] = ['name' => false, 'comment' => false]; } + $serendipity['smarty']->assign($commentform_data); serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl'); diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index a5473d73..342bbce7 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -2195,7 +2195,7 @@ function serendipity_loadGlobalThemeOptions(&$template_config, &$template_loaded // Check if we are currently inside the admin interface. if ($serendipity['POST']['adminModule'] ?? '' == 'templates' && $serendipity['POST']['adminAction'] == 'configure' && !empty($serendipity['POST']['template']['amount'])) { - $template_loaded_config['amount'] = (int)$serendipity['POST']['template']['amount']; + $template_loaded_config['amount'] = (int)($serendipity['POST']['template']['amount'] ?? 0); } for ($i = 0; $i < $template_loaded_config['amount']; $i++) { diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 95de3002..a740cb7e 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -1186,8 +1186,8 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm $authorData = array( 'authorid' => $entry['authorid'], - 'username' => $entry['loginname'], - 'email' => $entry['email'], + 'username' => $entry['loginname'] ?? null, + 'email' => $entry['email'] ?? null, 'realname' => $entry['author'] ); @@ -1221,12 +1221,14 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm } $entry['link_author'] = serendipity_authorURL($authorData); - if (is_array($entry['categories'])) { + if (is_array($entry['categories'] ?? null)) { foreach ($entry['categories'] as $k => $v) { if (!isset($entry['categories'][$k]['category_link'])) { $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]); } } + } else { + $entry['categories'] = null; } if (strlen($entry['extended'] ?? null)) { diff --git a/templates/2k11/admin/entries.inc.tpl b/templates/2k11/admin/entries.inc.tpl index 02e27e66..c4c0f9d1 100644 --- a/templates/2k11/admin/entries.inc.tpl +++ b/templates/2k11/admin/entries.inc.tpl @@ -211,9 +211,6 @@ {/if} {if $switched_output} - {if ($get.adminAction && $dateval)} - {$CONST.DATE_INVALID} - {/if} {if ($get.adminAction && $use_legacy)} {if $is_draft && ! $errors} {$CONST.IFRAME_SAVE_DRAFT} diff --git a/templates/2k11/admin/entries.tpl b/templates/2k11/admin/entries.tpl index f436d261..51b32b9f 100644 --- a/templates/2k11/admin/entries.tpl +++ b/templates/2k11/admin/entries.tpl @@ -2,7 +2,7 @@ {if $entry_vars.errMsg} {$entry_vars.errMsg} {/if} -
+ {foreach $entry_vars.hiddens as $key => $value} {/foreach} diff --git a/templates/2k11/preview_iframe.tpl b/templates/2k11/preview_iframe.tpl index 7e998bec..a11ab1f2 100644 --- a/templates/2k11/preview_iframe.tpl +++ b/templates/2k11/preview_iframe.tpl @@ -38,7 +38,7 @@
-
+
{if $mode == 'preview'}