php8 compat fixes for entry preview

This commit is contained in:
onli 2021-05-09 16:54:27 +02:00
parent 24c02da747
commit 4c246ad426
7 changed files with 22 additions and 15 deletions

View File

@ -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);

View File

@ -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');

View File

@ -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++) {

View File

@ -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)) {

View File

@ -211,9 +211,6 @@
{/if}
{if $switched_output}
{if ($get.adminAction && $dateval)}
<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$CONST.DATE_INVALID}</span>
{/if}
{if ($get.adminAction && $use_legacy)}
{if $is_draft && ! $errors}
<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {$CONST.IFRAME_SAVE_DRAFT}</span>

View File

@ -2,7 +2,7 @@
{if $entry_vars.errMsg}
<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$entry_vars.errMsg}</span>
{/if}
<form id="serendipityEntry" name="serendipityEntry" {$entry_vars.entry.entry_form} action="{$entry_vars.targetURL}" method="post">
<form id="serendipityEntry" name="serendipityEntry" {if isset($entry_vars.entry.entry_form)}$entry_vars.entry.entry_form{/if} action="{$entry_vars.targetURL}" method="post">
{foreach $entry_vars.hiddens as $key => $value}
<input type="hidden" name="{$key}" value="{$value}">
{/foreach}

View File

@ -38,7 +38,7 @@
</head>
<body{if $template_option.webfonts != 'none'} class="{$template_option.webfonts}"{/if}>
<div id="page" class="clearfix container">
<div class="clearfix{if $leftSidebarElements > 0 && $rightSidebarElements > 0} col3{elseif $leftSidebarElements > 0 && $rightSidebarElements == 0} col2l{else} col2r{/if}">
<div class="clearfix col2r">
<main id="content"{if $template_option.imgstyle != 'none'} class="{$template_option.imgstyle}"{/if}>
{if $mode == 'preview'}
<div class="clearfix">