Archived
1
0

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
+12 -6
View File
@@ -39,12 +39,12 @@ switch($serendipity['GET']['adminAction']) {
'timestamp' => $serendipity['POST']['timestamp'], 'timestamp' => $serendipity['POST']['timestamp'],
'body' => $serendipity['POST']['body'], 'body' => $serendipity['POST']['body'],
'extended' => $serendipity['POST']['extended'], 'extended' => $serendipity['POST']['extended'],
'categories' => $serendipity['POST']['categories'], 'categories' => $serendipity['POST']['categories'] ?? null,
'isdraft' => $serendipity['POST']['isdraft'], 'isdraft' => $serendipity['POST']['isdraft'],
'allow_comments' => $serendipity['POST']['allow_comments'], '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), '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 // Messing with other attributes causes problems when entry is saved
// Attributes need to explicitly matched/addressed in serendipity_updertEntry! // Attributes need to explicitly matched/addressed in serendipity_updertEntry!
@@ -69,7 +69,6 @@ switch($serendipity['GET']['adminAction']) {
if ($entry['timestamp'] == -1) { if ($entry['timestamp'] == -1) {
$data['switched_output'] = true; $data['switched_output'] = true;
$data['dateval'] = false;
// The date given by the user is not convertable. Reset the timestamp. // The date given by the user is not convertable. Reset the timestamp.
$entry['timestamp'] = $serendipity['POST']['timestamp']; $entry['timestamp'] = $serendipity['POST']['timestamp'];
} }
@@ -108,7 +107,7 @@ switch($serendipity['GET']['adminAction']) {
// Only display the preview // Only display the preview
$serendipity['hidefooter'] = true; $serendipity['hidefooter'] = true;
// Advanced templates use this to show update status and elapsed time // 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(); $entry['last_modified'] = time();
} }
@@ -183,7 +182,7 @@ switch($serendipity['GET']['adminAction']) {
'serendipity[timestamp]' => serendipity_specialchars($entry['timestamp']) 'serendipity[timestamp]' => serendipity_specialchars($entry['timestamp'])
), ),
$entry, $entry,
$errors $errors ?? null
); );
} }
@@ -345,6 +344,7 @@ switch($serendipity['GET']['adminAction']) {
$qString .= '&serendipity[filter]['. $k .']='. $v; $qString .= '&serendipity[filter]['. $k .']='. $v;
} }
} }
$data['linkFirst'] = $qString . '&serendipity[page]=' . 0; $data['linkFirst'] = $qString . '&serendipity[page]=' . 0;
$data['linkPrevious'] = $qString . '&serendipity[page]=' . ($page-1); $data['linkPrevious'] = $qString . '&serendipity[page]=' . ($page-1);
$data['linkNext'] = $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['sort_import'])) { $data['sort_import'] = null; }
if (! isset($data['count'])) { $data['count'] = null; } if (! isset($data['count'])) { $data['count'] = null; }
if (! isset($data['is_entries'])) { $data['is_entries'] = 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); echo serendipity_smarty_show('admin/entries.inc.tpl', $data);
+2
View File
@@ -204,6 +204,8 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data
'commentform_entry' => $entry 'commentform_entry' => $entry
); );
if (! isset($commentform_data['required_fields'])) { $commentform_data['required_fields'] = ['name' => false, 'comment' => false]; }
$serendipity['smarty']->assign($commentform_data); $serendipity['smarty']->assign($commentform_data);
serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl'); serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl');
+1 -1
View File
@@ -2195,7 +2195,7 @@ function serendipity_loadGlobalThemeOptions(&$template_config, &$template_loaded
// Check if we are currently inside the admin interface. // Check if we are currently inside the admin interface.
if ($serendipity['POST']['adminModule'] ?? '' == 'templates' && $serendipity['POST']['adminAction'] == 'configure' && !empty($serendipity['POST']['template']['amount'])) { 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++) { for ($i = 0; $i < $template_loaded_config['amount']; $i++) {
+5 -3
View File
@@ -1186,8 +1186,8 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
$authorData = array( $authorData = array(
'authorid' => $entry['authorid'], 'authorid' => $entry['authorid'],
'username' => $entry['loginname'], 'username' => $entry['loginname'] ?? null,
'email' => $entry['email'], 'email' => $entry['email'] ?? null,
'realname' => $entry['author'] 'realname' => $entry['author']
); );
@@ -1221,12 +1221,14 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
} }
$entry['link_author'] = serendipity_authorURL($authorData); $entry['link_author'] = serendipity_authorURL($authorData);
if (is_array($entry['categories'])) { if (is_array($entry['categories'] ?? null)) {
foreach ($entry['categories'] as $k => $v) { foreach ($entry['categories'] as $k => $v) {
if (!isset($entry['categories'][$k]['category_link'])) { if (!isset($entry['categories'][$k]['category_link'])) {
$entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]); $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]);
} }
} }
} else {
$entry['categories'] = null;
} }
if (strlen($entry['extended'] ?? null)) { if (strlen($entry['extended'] ?? null)) {
-3
View File
@@ -211,9 +211,6 @@
{/if} {/if}
{if $switched_output} {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 ($get.adminAction && $use_legacy)}
{if $is_draft && ! $errors} {if $is_draft && ! $errors}
<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {$CONST.IFRAME_SAVE_DRAFT}</span> <span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {$CONST.IFRAME_SAVE_DRAFT}</span>
+1 -1
View File
@@ -2,7 +2,7 @@
{if $entry_vars.errMsg} {if $entry_vars.errMsg}
<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$entry_vars.errMsg}</span> <span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$entry_vars.errMsg}</span>
{/if} {/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} {foreach $entry_vars.hiddens as $key => $value}
<input type="hidden" name="{$key}" value="{$value}"> <input type="hidden" name="{$key}" value="{$value}">
{/foreach} {/foreach}
+1 -1
View File
@@ -38,7 +38,7 @@
</head> </head>
<body{if $template_option.webfonts != 'none'} class="{$template_option.webfonts}"{/if}> <body{if $template_option.webfonts != 'none'} class="{$template_option.webfonts}"{/if}>
<div id="page" class="clearfix container"> <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}> <main id="content"{if $template_option.imgstyle != 'none'} class="{$template_option.imgstyle}"{/if}>
{if $mode == 'preview'} {if $mode == 'preview'}
<div class="clearfix"> <div class="clearfix">