smartified comments.inc and some minor fixes to other tpls

This commit is contained in:
Ian 2012-02-19 15:35:05 +01:00
parent ba518b7864
commit 9293e0b333
4 changed files with 364 additions and 290 deletions

View File

@ -1,6 +1,4 @@
<?php # $Id$
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
if (IN_serendipity !== true) {
die ("Don't hack!");
@ -11,26 +9,27 @@ if (!serendipity_checkPermission('adminComments')) {
}
$commentsPerPage = (int)(!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10);
$codata['commentsPerPage'] = $commentsPerPage;
$summaryLength = 200;
$errormsg = '';
if ($serendipity['POST']['formAction'] == 'multiDelete' && sizeof($serendipity['POST']['delete']) != 0 && serendipity_checkFormToken()) {
if ($serendipity['POST']['togglemoderate'] != '') {
foreach ( $serendipity['POST']['delete'] as $k => $v ) {
$ac = serendipity_approveComment($k, $v, false, 'flip');
if ($ac > 0) {
$errormsg .= DONE . ': '. sprintf(COMMENT_APPROVED, (int)$k) . '<br />';
} else {
$errormsg .= DONE . ': '. sprintf(COMMENT_MODERATED, (int)$k) . '<br />';
}
}
foreach ( $serendipity['POST']['delete'] as $k => $v ) {
$ac = serendipity_approveComment($k, $v, false, 'flip');
if ($ac > 0) {
$errormsg .= DONE . ': '. sprintf(COMMENT_APPROVED, (int)$k) . '<br />';
} else {
$errormsg .= DONE . ': '. sprintf(COMMENT_MODERATED, (int)$k) . '<br />';
}
}
} else {
foreach ( $serendipity['POST']['delete'] as $k => $v ) {
serendipity_deleteComment($k, $v);
$errormsg .= DONE . ': '. sprintf(COMMENT_DELETED, (int)$k) . '<br />';
}
}
foreach ( $serendipity['POST']['delete'] as $k => $v ) {
serendipity_deleteComment($k, $v);
$errormsg .= DONE . ': '. sprintf(COMMENT_DELETED, (int)$k) . '<br />';
}
}
}
@ -264,11 +263,12 @@ if ( $page == 0 || $page > $pages ) {
}
$linkPrevious = 'serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[page]='. ($page-1) . $searchString;
$linkNext = 'serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[page]='. ($page+1) . $searchString;
$linkNext = 'serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[page]='. ($page+1) . $searchString;
$filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL);
if ($commentsPerPage == COMMENTS_FILTER_ALL) {
$limit = '';
}else {
} else {
$limit = serendipity_db_limit_sql(serendipity_db_limit(($page-1)*(int)$commentsPerPage, (int)$commentsPerPage));
}
@ -278,148 +278,19 @@ $sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}
. (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int)$serendipity['authorid'] : '') . "
ORDER BY c.id DESC $limit");
if(!empty($errormsg)) echo '<p class="serendipityAdminMsgError serendipity_backend_msg_notice"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . $errormsg . '</p>'; // closing admin messages
?>
<script type="text/javascript">
function FT_toggle(id) {
if ( document.getElementById(id + '_full').style.display == '' ) {
document.getElementById(id + '_full').style.display='none';
document.getElementById(id + '_summary').style.display='';
document.getElementById(id + '_text').innerHTML = '<?php echo VIEW_FULL ?>';
} else {
document.getElementById(id + '_full').style.display='';
document.getElementById(id + '_summary').style.display='none';
document.getElementById(id + '_text').innerHTML = '<?php echo HIDE ?>';
}
return false;
}
function invertSelection() {
var f = document.formMultiDelete;
for (var i = 0; i < f.elements.length; i++) {
if( f.elements[i].type == 'checkbox' ) {
f.elements[i].checked = !(f.elements[i].checked);
f.elements[i].onclick();
}
}
}
var origborder = '';
var origwidth = '';
function highlightComment(id, checkvalue) {
var comment = document.getElementById(id);
if (origborder == '') {
origborder = comment.style.borderColor;
if (origborder == '') {
origborder = '#FFFFFF';
}
}
if (origwidth == '') {
origwidth = comment.style.borderWidth;
if (origwidth == '' || origwidth == 0) {
origwidth = 1;
}
}
if (checkvalue) {
comment.style.borderColor = '#FF0000';
comment.style.borderWidth = origwidth;
} else {
comment.style.borderColor = '';
comment.style.borderWidth = origwidth;
}
}
</script>
<form action="" method="GET" style="margin: 0">
<?php echo serendipity_setFormToken(); ?>
<input type="hidden" name="serendipity[adminModule]" value="comments" />
<input type="hidden" name="serendipity[page]" value="<?php echo $page ?>" />
<table class="serendipity_admin_filters" width="100%">
<tr>
<td colspan="6" class="serendipity_admin_filters_headline"><strong><?php echo FILTERS ?></strong> - <?php echo FIND_COMMENTS ?></td>
</tr>
<tr>
<td><?php echo AUTHOR ?>:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][author]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['author']) ?>" /></td>
<td><?php echo EMAIL ?>:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][email]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['email']) ?>" /></td>
<td><?php echo URL ?>:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][url]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['url']) ?>" /></td>
</tr>
<tr>
<td>IP:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][ip]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['ip']) ?>" /></td>
<td><?php echo CONTENT ?>:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][body]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['body']) ?>" /></td>
<td><?php echo REFERER ?>:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][referer]" size="15" value="<?php echo htmlspecialchars($serendipity['GET']['filter']['referer']) ?>" /></td>
</tr>
<tr>
<td><?php echo COMMENTS; ?>:</td>
<td><select name="serendipity[filter][perpage]">
<?php
$filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL);
foreach($filter_vals AS $filter_val) { ?>
<option value="<?php echo $filter_val; ?>" <?php echo ($commentsPerPage == $filter_val ? ' selected="selected"' : ''); ?>><?php echo $filter_val; ?></option>
<?php
}
?>
</select></td>
<td><?php echo COMMENTS_FILTER_SHOW ?>:</td>
<td><select name="serendipity[filter][show]">
<option value="all"<?php if ( $serendipity['GET']['filter']['show'] == 'all' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_ALL ?></option>
<option value="approved"<?php if ( $serendipity['GET']['filter']['show'] == 'approved' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_APPROVED_ONLY ?></option>
<option value="pending"<?php if ( $serendipity['GET']['filter']['show'] == 'pending' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_NEED_APPROVAL ?></option>
<option value="confirm"<?php if ( $serendipity['GET']['filter']['show'] == 'confirm' ) echo ' selected="selected"' ?>><?php echo COMMENTS_FILTER_NEED_CONFIRM ?></option>
</select></td>
<td><?php echo TYPE; ?></td>
<td><select name="serendipity[filter][type]">
<option value=""><?php echo COMMENTS_FILTER_ALL ?></option>
<option value="NORMAL"<?php if ($c_type == 'NORMAL') echo ' selected="selected"' ?>><?php echo COMMENTS; ?></option>
<option value="TRACKBACK"<?php if ($c_type == 'TRACKBACK') echo ' selected="selected"' ?>><?php echo TRACKBACKS; ?></option>
<option value="PINGBACK"<?php if ($c_type == 'PINGBACK') echo ' selected="selected"' ?>><?php echo PINGBACKS; ?></option>
</select></td>
</tr>
<tr>
<td colspan="6" align="right"><input type="submit" name="submit" value=" - <?php echo GO ?> - " class="serendipityPrettyButton input_button" /> <?php serendipity_plugin_api::hook_event('backend_comments_top', $sql); ?></td>
</tr>
</table>
</form>
<hr noshade="noshade" /><br />
<?php
if (!is_array($sql)) {
echo '<div align="center">- '. NO_COMMENTS .' -</div>';
} else {
?>
<form action="" method="POST" name="formMultiDelete" id="formMultiDelete">
<?php echo serendipity_setFormToken(); ?>
<input type="hidden" name="serendipity[formAction]" value="multiDelete" />
<table width="100%" cellpadding="3" border="0" cellspacing="0">
<tr>
<td align="center">
<table width="100%" cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
<?php if ( $page != 1 && $page <= $pages ) { ?>
<a href="<?php echo $linkPrevious; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png') ?>" /><?php echo PREVIOUS ?></a>
<?php } ?>
</td>
<td align="center"><?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?></td>
<td align="right">
<?php if ( $page != $pages ) { ?>
<a href="<?php echo $linkNext; ?>" class="serendipityIconLinkRight"><?php echo NEXT ?><img src="<?php echo serendipity_getTemplateFile('admin/img/next.png') ?>" /></a>
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
<?php
$codata['totalComments'] = $totalComments;
$codata['pages'] = $pages;
$codata['page'] = $page;
$codata['linkPrevious'] = $linkPrevious;
$codata['linkNext'] = $linkNext;
$codata['searchString'] = $searchString;
$codata['filter_vals'] = $filter_vals;
$codata['sql'] = $sql;
$codata['c_type'] = $c_type;
$i = 0;
$comments = array();
foreach ($sql as $rs) {
$i++;
$comment = array(
@ -430,6 +301,7 @@ foreach ($sql as $rs) {
'id' => $rs['id'],
'title' => $rs['title'],
'timestamp' => $rs['timestamp'],
'pubdate' => date("c", (int)$rs['timestamp']), /* added to comment array to support HTML5 time tags in tpl */
'referer' => $rs['referer'],
'url' => $rs['url'],
'ip' => $rs['ip'],
@ -455,6 +327,7 @@ foreach ($sql as $rs) {
}
serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&amp;serendipity[page]='. $page . $searchString);
$class = 'serendipity_admin_list_item_' . (($i % 2 == 0 ) ? 'even' : 'uneven');
if ($comment['status'] == 'pending') {
$class .= ' serendipity_admin_comment_pending';
@ -466,128 +339,85 @@ foreach ($sql as $rs) {
$header_class = '';
}
$comment['class'] = $class;
$comment['header_class'] = $header_class;
if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' &&
substr($comment['url'], 0, 8) != 'https://') {
$comment['url'] = 'http://' . $comment['url'];
}
?>
<tr>
<td class="<?php echo $header_class; ?>">
<?php if (!empty($header_class)) { ?>
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_note.png'); ?>" alt="" />
<?php }?>
<a name="c<?php echo $comment['id'] ?>"></a>
<?php echo ($comment['type'] == 'NORMAL' ? COMMENT : ($comment['type'] == 'TRACKBACK' ? TRACKBACK : PINGBACK )) . ' #'. $comment['id'] .', '. IN_REPLY_TO .' <strong><a href="' . $comment['entry_url'] . '">'. htmlspecialchars($comment['title']) .'</a></strong>, '. ON . ' ' . serendipity_formatTime('%b %e %Y, %H:%M', $comment['timestamp'])?>
</td>
</tr>
<tr>
<td class="serendipity_admin_list_item <?php echo $class ?>" id="comment_<?php echo $comment['id'] ?>">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td rowspan="3" width="20" align="center"><input class="input_checkbox" type="checkbox" name="serendipity[delete][<?php echo $comment['id'] ?>]" value="<?php echo $comment['entry_id'] ?>" onclick="highlightComment('comment_<?php echo $comment['id'] ?>', this.checked)" tabindex="<?php echo $i ?>" /></td>
<td width="40%"><strong><?php echo AUTHOR ?></strong>: <?php echo htmlspecialchars(serendipity_truncateString($comment['author'],30)) . $comment['action_author']; ?></td>
<td><strong><?php echo EMAIL ?></strong>:
<?php
if ( empty($comment['email']) ) {
echo 'N/A';
} else {
?>
<a href="mailto:<?php echo htmlspecialchars($comment['email']) ?>" title="<?php echo htmlspecialchars($comment['email']) ?>"><?php echo htmlspecialchars(serendipity_truncateString($comment['email'],30)) ?></a>
<?php if ($comment['subscribed'] == 'true') { echo '<span class="serendipity_subscription_on">(' . ACTIVE_COMMENT_SUBSCRIPTION . ')</span>'; } ?>
<?php } ?>
<?php echo $comment['action_email']; ?>
</td>
</tr>
<tr>
<td width="40%"><strong>IP</strong>:
<?php
if ( empty($comment['ip']) ) {
echo '0.0.0.0';
} else {
echo htmlspecialchars($comment['ip']);
}
?>
<?php echo $comment['action_ip']; ?>
</td>
<td><strong><?php echo URL; ?></strong>:
<?php
if ( empty($comment['url']) ) {
echo 'N/A';
} else {
?>
<a href="<?php echo htmlspecialchars($comment['url']) ?>" title="<?php echo htmlspecialchars($comment['url']) ?>" target="_blank"><?php echo htmlspecialchars(serendipity_truncateString($comment['url'],30)) ?></a>
<?php } ?>
<?php echo $comment['action_url']; ?>
</td>
</tr>
<tr>
<td width="40%">&nbsp;</td>
<td><strong><?php echo REFERER; ?></strong>:
<?php
if ( empty($comment['referer']) ) {
echo 'N/A';
} else {
?>
<a href="<?php echo htmlspecialchars($comment['referer']) ?>" title="<?php echo htmlspecialchars($comment['referer']) ?>" target="_blank"><?php echo htmlspecialchars(serendipity_truncateString($comment['referer'],30)) ?></a>
<?php } ?>
<?php echo $comment['action_referer']; ?>
</td>
<tr>
<td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="3">
<div id="<?php echo $comment['id'] ?>_summary"><?php echo $comment['summary'] ?></div>
<div id="<?php echo $comment['id'] ?>_full" style="display: none"><?php echo $comment['fullBody'] ?></div>
</td>
</tr>
</table>
<?php if ($comment['status'] == 'pending' || strstr($comment['status'], 'confirm')) { ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo APPROVE; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/accept.png'); ?>" alt="<?php echo APPROVE ?>" /><?php echo APPROVE ?></a>
<?php } ?>
<?php if ($comment['status'] == 'approved') { ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=pending&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" class="serendipityIconLink" title="<?php echo SET_TO_MODERATED; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?>" alt="<?php echo SET_TO_MODERATED ?>" /><?php echo SET_TO_MODERATED ?></a>
<?php } ?>
<?php if ($comment['excerpt']) { ?>
<a href="#c<?php echo $comment['id'] ?>" onclick="FT_toggle(<?php echo $comment['id'] ?>); return false;" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo TOGGLE_ALL; ?>" /><span id="<?php echo $comment['id'] ?>_text"><?php echo TOGGLE_ALL ?></span></a>
<?php } ?>
<a target="_blank" href="<?php echo $entrylink; ?>" title="<?php echo VIEW; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?>" alt="<?php echo VIEW; ?>" /><?php echo VIEW ?></a>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" title="<?php echo EDIT; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?>" alt="<?php echo EDIT; ?>" /><?php echo EDIT ?></a>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&amp;<?php echo serendipity_setFormToken('url'); ?>" onclick='return confirm("<?php echo sprintf(COMMENT_DELETE_CONFIRM, $comment['id'], htmlspecialchars($comment['author'])) ?>")' title="<?php echo DELETE ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?>" alt="<?php echo DELETE; ?>" /><?php echo DELETE ?></a>
<a target="_blank" onclick="cf = window.open(this.href, 'CommentForm', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); cf.focus(); return false;" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=reply&amp;serendipity[id]=<?php echo $comment['id'] ?>&amp;serendipity[entry_id]=<?php echo $comment['entry_id'] ?>&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;<?php echo serendipity_setFormToken('url'); ?>" title="<?php echo REPLY ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/user_editor.png'); ?>" alt="<?php echo REPLY; ?>" /><?php echo REPLY ?></a>
<?php echo $comment['action_more']; ?>
</td>
</tr>
<tr>
<td><hr noshade="noshade" /></td>
</tr>
<?php } ?>
<tr>
<td><input type="button" name="toggle" value="<?php echo INVERT_SELECTIONS ?>" onclick="invertSelection()" class="serendipityPrettyButton input_button" />
<input type="submit" name="toggle" value="<?php echo DELETE_SELECTED_COMMENTS ?>" onclick="return confirm('<?php echo COMMENTS_DELETE_CONFIRM ?>')" tabindex="<?php echo ($i+1) ?>" class="serendipityPrettyButton input_button" />
<input type="submit" name="serendipity[togglemoderate]" value="<?php echo MODERATE_SELECTED_COMMENTS ?>" class="serendipityPrettyButton input_button" />
</td>
</tr>
</table>
<table width="100%" cellpadding="3" border="0" cellspacing="0">
<tr>
<td align="center">
<table width="100%" cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
<?php if ( $page != 1 && $page <= $pages ) { ?>
<a href="<?php echo $linkPrevious; ?>" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png') ?>" /><?php echo PREVIOUS ?></a>
<?php } ?>
</td>
<td align="center"><?php printf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalComments); ?></td>
<td align="right">
<?php if ( $page != $pages ) { ?>
<a href="<?php echo $linkNext; ?>" class="serendipityIconLinkRight"><?php echo NEXT ?><img src="<?php echo serendipity_getTemplateFile('admin/img/next.png') ?>" /></a>
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
$comments[] = $comment;
}
</form>
<?php } ?>
/* This could be used instead, as i.e. there is no need for summary body here, as strip_tags, nl2br, etc could be done via smarty in the tpl - see dashboard PoC */
/* $class and $header_class would not be needed either, ... */
/**
function buildCommentList($limit) {
global $serendipity;
$comments = serendipity_fetchComments(null, $limit, 'co.id DESC', true, 'NORMAL', '');
if (!is_array($comments) || count($comments) == 0) {
return;
}
$comment = array();
foreach ($sql as $rs) {
$comment[] = array(
'body' => htmlspecialchars($rs['body']),
'status' => $rs['status'],
'type' => $rs['type'],
'id' => $rs['id'],
'title' => htmlspecialchars($rs['title']),
'timestamp' => $rs['timestamp'],
'pubdate' => date("c", (int)$rs['timestamp']),
'referer' => htmlspecialchars($rs['referer']),
'url' => htmlspecialchars($rs['url']),
'ip' => htmlspecialchars($rs['ip']),
'entry_url' => serendipity_archiveURL($rs['entry_id'], htmlspecialchars($rs['title'])),
'email' => htmlspecialchars($rs['email']),
'author' => (empty($rs['author']) ? ANONYMOUS : htmlspecialchars($rs['author'])),
'entry_id' => $rs['entry_id'],
'subscribed' => $rs['subscribed'],
'entrylink' => serendipity_archiveURL($rs['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $rs['id'],
'excerpt' => ((strlen($rs['body']) > serendipity_mb('substr', $rs['body'], 0, $summaryLength) ) ? true : false),
'delete_id' => sprintf(COMMENT_DELETE_CONFIRM, $rs['id'], htmlspecialchars($rs['author']))
);
if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' && substr($comment['url'], 0, 8) != 'https://') {
$comment['url'] = 'http://' . $comment['url'];
}
}
serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&amp;serendipity[page]='. $page . $searchString);
$serendipity['smarty']->assign(
array( 'urltoken' => serendipity_setFormToken('url'),
'formtoken' => serendipity_setFormToken()
));
return $comment;
}
**/
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign(
array( 'comments' => $comments,
'errormsg' => $errormsg,
'urltoken' => serendipity_setFormToken('url'),
'formtoken' => serendipity_setFormToken()
));
$serendipity['smarty']->assign($codata);
# do not use $data, as already used above - use i.e. $codata['filters'] = $filters;
$tfile = dirname(__FILE__) . "/tpl/comments.inc.tpl";
$content = $serendipity['smarty']->fetch('file:'. $tfile); // short notation with Smarty3 in S9y 1.7 and up
echo $content;
/* vim: set sts=4 ts=4 expandtab : */

View File

@ -1,14 +1,14 @@
{if $post_save}
{if $new}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_success.png'}" alt="" />
{$CONST.CATEGORY_SAVED}
</div>
{/if}
{if $edit}
{if isset($editPermission) && $editPermission == false}
<div class="serendipityAdminMsgError">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_error.png"}" alt="" />
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_error.png'}" alt="" />
{$CONST.PERM_DENIED}
</div>
{else}
@ -16,7 +16,7 @@
{$subcat}
{else}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_success.png'}" alt="" />
{$CONST.CATEGORY_SAVED}
</div>
{/if}
@ -27,7 +27,7 @@
{if $doDelete}
{if $deleteSuccess}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_success.png'}" alt="" />
{if $remainingCat}
{$CONST.CATEGORY_DELETED_ARTICLES_MOVED|sprintf:$remainingCat:$cid}
{else}
@ -36,7 +36,7 @@
</div>
{else}
<div class="serendipityAdminMsgError">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_error.png"}" alt="" />
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_error.png'}" alt="" />
{$CONST.INVALID_CATEGORY}
</div>
{/if}
@ -121,7 +121,7 @@
<select id="parent_cat" name="serendipity[cat][parent_cat]">
<option value="0" {if $cid == 0} selected="selected" {/if}>[ {$CONST.NO_CATEGORY} ]</option>
{foreach $categories as $cat}
{*We can't be our own parent, the universe will collapse *}
{* We can't be our own parent, the universe will collapse *}
{if $cat.categoryid == $cid}
{continue}
{/if}
@ -163,23 +163,23 @@
<tr>
<td width="16">
<a title="{$CONST.EDIT}" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=edit&amp;serendipity[cid]={$category.categoryid}">
<img src="{serendipity_getFile file="admin/img/edit.png"}" border="0" alt="{$CONST.EDIT}" />
<img src="{serendipity_getFile file='admin/img/edit.png'}" border="0" alt="{$CONST.EDIT}" />
</a>
</td>
<td width="16">
<a title="{$CONST.DELETE}" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=delete&amp;serendipity[cid]={$category.categoryid}">
<img src="{serendipity_getFile file="admin/img/delete.png"}" border="0" alt="{$CONST.DELETE}" />
<img src="{serendipity_getFile file='admin/img/delete.png'}" border="0" alt="{$CONST.DELETE}" />
</a>
</td>
<td width="16">
{if $category.category_icon}
<img src="{serendipity_getFile file="admin/img/thumbnail.png"}" alt="" />
<img src="{serendipity_getFile file='admin/img/thumbnail.png'}" alt="" />
{else}
&nbsp;
{/if}
</td>
<td width="300" style="padding-left: {$category.depth*15+20}px">
<img src="{serendipity_getFile file="admin/img/folder.png"}" style="vertical-align: bottom;">
<img src="{serendipity_getFile file='admin/img/folder.png'}" style="vertical-align: bottom;">
{$category.category_name|escape:"html"}
</td>
<td>

View File

@ -0,0 +1,244 @@
{if !empty($errormsg)}
<p class="serendipityAdminMsgError serendipity_backend_msg_notice"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_note.png'}" alt="" />{$errormsg}</p>
{/if}
<script type="text/javascript">
function FT_toggle(id) {ldelim}
if ( document.getElementById(id + '_full').style.display == '' ) {ldelim}
document.getElementById(id + '_full').style.display='none';
document.getElementById(id + '_summary').style.display='';
document.getElementById(id + '_text').innerHTML = '{$CONST.VIEW_FULL}';
{rdelim} else {ldelim}
document.getElementById(id + '_full').style.display='';
document.getElementById(id + '_summary').style.display='none';
document.getElementById(id + '_text').innerHTML = '{$CONST.HIDE}';
{rdelim}
return false;
{rdelim}
{literal}
function invertSelection() {
var f = document.formMultiDelete;
for (var i = 0; i < f.elements.length; i++) {
if( f.elements[i].type == 'checkbox' ) {
f.elements[i].checked = !(f.elements[i].checked);
f.elements[i].onclick();
}
}
}
var origborder = '';
var origwidth = '';
function highlightComment(id, checkvalue) {
var comment = document.getElementById(id);
if (origborder == '') {
origborder = comment.style.borderColor;
if (origborder == '') {
origborder = '#FFFFFF';
}
}
if (origwidth == '') {
origwidth = comment.style.borderWidth;
if (origwidth == '' || origwidth == 0) {
origwidth = 1;
}
}
if (checkvalue) {
comment.style.borderColor = '#FF0000';
comment.style.borderWidth = origwidth;
} else {
comment.style.borderColor = '';
comment.style.borderWidth = origwidth;
}
}
{/literal}
</script>
<form action="" method="GET" style="margin: 0">
{$formtoken}
<input type="hidden" name="serendipity[adminModule]" value="comments" />
<input type="hidden" name="serendipity[page]" value="{$page}" />
<table class="serendipity_admin_filters" width="100%">
<tr>
<td colspan="6" class="serendipity_admin_filters_headline"><strong>{$CONST.FILTERS}</strong> - {$CONST.FIND_COMMENTS}</td>
</tr>
{* if we change/set $serendipity{'GET'] values in the parents php file ... does $smarty.get then know about them ??? *}
<tr>
<td>{$CONST.AUTHOR}:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][author]" size="15" value="{$smarty.get.filter.author|escape}" /></td>
<td>{$CONST.EMAIL}:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][email]" size="15" value="{$smarty.get.filter.email|escape}" /></td>
<td>{$CONST.URL}:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][url]" size="15" value="{$smarty.get.filter.url|escape}" /></td>
</tr>
<tr>
<td>IP:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][ip]" size="15" value="{$smarty.get.filter.ip|escape}" /></td>
<td>{$CONST.CONTENT}:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][body]" size="15" value="{$smarty.get.filter.body|escape}" /></td>
<td>{$CONST.REFERER}:</td>
<td><input class="input_textbox" type="text" name="serendipity[filter][referer]" size="15" value="{$smarty.get.filter.referer|escape}" /></td>
</tr>
<tr>
<td>{$CONST.COMMENTS}:</td>
<td><select name="serendipity[filter][perpage]">
{* Smarty 3 does support ternary syntax e.g. {('N'==$member.is_admin)?'Yes':'No'} *}
{foreach $filter_vals AS $filter_val}
<option value="{$filter_val}" {($commentsPerPage == $filter_val) ? ' selected="selected"' : ''}>{$filter_val}</option>
{/foreach}
</select></td>
<td>{$CONST.COMMENTS_FILTER_SHOW}:</td>
<td><select name="serendipity[filter][show]">
<option value="all"{if $smarty.get.filter.show == 'all'} selected="selected"{/if}>{$CONST.COMMENTS_FILTER_ALL}</option>
<option value="approved"{if $smarty.get.filter.show == 'approved'} selected="selected"{/if}>{$CONST.COMMENTS_FILTER_APPROVED_ONLY}</option>
<option value="pending"{if $smarty.get.filter.show == 'pending'} selected="selected"{/if}>{$CONST.COMMENTS_FILTER_NEED_APPROVAL}</option>
<option value="confirm"{if $smarty.get.filter.show == 'confirm'} selected="selected"{/if}>{$CONST.COMMENTS_FILTER_NEED_CONFIRM}</option>
</select></td>
<td>{$CONST.TYPE}</td>
<td><select name="serendipity[filter][type]">
<option value="">{$CONST.COMMENTS_FILTER_ALL}</option>
<option value="NORMAL"{if $c_type == 'NORMAL'} selected="selected"{/if}>{$CONST.COMMENTS}</option>
<option value="TRACKBACK"{if $c_type == 'TRACKBACK'} selected="selected"{/if}>{$CONST.TRACKBACKS}</option>
<option value="PINGBACK"{if $c_type == 'PINGBACK'} selected="selected"{/if}>{$CONST.PINGBACKS}</option>
</select></td>
</tr>
<tr>
<td colspan="6" align="right"><input type="submit" name="submit" value=" - {$CONST.GO} - " class="serendipityPrettyButton input_button" /> {serendipity_hookPlugin hookAll=true hook="backend_comments_top" addData=$sql}</td>
</tr>
</table>
</form>
<hr noshade="noshade" /><br />
{if !is_array($sql)}
<div align="center">- {$CONST.NO_COMMENTS} -</div>
{else}
<form action="" method="POST" name="formMultiDelete" id="formMultiDelete">
{$formtoken}
<input type="hidden" name="serendipity[formAction]" value="multiDelete" />
<table width="100%" cellpadding="3" border="0" cellspacing="0">
<tr>
<td align="center">
<table width="100%" cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
{if ( $page != 1 && $page <= $pages )}
<a href="{$linkPrevious}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/previous.png'}" />{$CONST.PREVIOUS}</a>
{/if}
</td>
<td align="center">{$CONST.PAGE_BROWSE_COMMENTS|sprintf:$page:$pages:$totalComments}</td>
<td align="right">
{if $page != $pages}
<a href="{$linkNext}" class="serendipityIconLinkRight">{$CONST.NEXT}<img src="{serendipity_getFile file='admin/img/next.png'}" /></a>
{/if}
</td>
</tr>
</table>
</td>
</tr>
{if is_array($comments)}
{* see dashboard PoC :: block_comments_pending.tpl or block_comments.tpl as example *}
{foreach $comments AS $comment}
<tr>
<td class="{$comment.header_class}">
{if !empty($comment.header_class)}
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_note.png'}" alt="" />
{/if}
<a name="c{$comment.id}"></a>{* NOTE: a $comment.pubdate with 'c' is available *}
{($comment.type == 'NORMAL') ? $CONST.COMMENT : (($comment.type == 'TRACKBACK') ? $CONST.TRACKBACK : $CONST.PINGBACK )} #{$comment.id}, {$CONST.IN_REPLY_TO} <strong><a href="{$comment.entry_url}">{$comment.title|escape}</a></strong>{$CONST.ON} {$comment.timestamp|@formatTime:'%b %e %Y, %H:%M'}
</td>
</tr>
<tr>
<td class="serendipity_admin_list_item {$comment.class}" id="comment_{$comment.id}">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td rowspan="3" width="20" align="center"><input class="input_checkbox" type="checkbox" name="serendipity[delete][{$comment.id}]" value="{$comment.entry_id}" onclick="highlightComment('comment_{$comment.id}', this.checked)" tabindex="{$i}" /></td>
<td width="40%"><strong>{$CONST.AUTHOR}</strong>: {$comment.author|escape|truncate:30:"&hellip;"} {$comment.action_author}</td>
<td><strong>{$CONST.EMAIL}</strong>:
{if empty($comment.email)} N/A {else}
<a href="mailto:{$comment.email|escape}" title="{$comment.email|escape}">{$comment.email|escape|truncate:30:"&hellip;"}</a>
{if $comment.subscribed == 'true'} <span class="serendipity_subscription_on">({$CONST.ACTIVE_COMMENT_SUBSCRIPTION})</span>{/if}
{/if}
{$comment.action_email}
</td>
</tr>
<tr>
<td width="40%"><strong>IP</strong>:
{if empty($comment.ip)} 0.0.0.0 {else} {$comment.ip|escape} {/if}
{$comment.action_ip}
</td>
<td><strong>{$CONST.URL}</strong>:
{if empty($comment.url)} N/A {else} <a href="{$comment.url|escape}" title="{$comment.url|escape}" target="_blank">{$comment.url|escape|truncate:30:"&hellip;"}</a> {/if}
{$comment.action_url}
</td>
</tr>
<tr>
<td width="40%">&nbsp;</td>
<td><strong>{$CONST.REFERER}</strong>:
{if empty($comment.referer)} N/A {else} <a href="{$comment.referer|escape}" title="{$comment.referer|escape}" target="_blank">{$comment.referer|escape|truncate:30:"&hellip;"}</a> {/if}
{$comment.action_referer}
</td>
<tr>
<td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="3">
<div id="{$comment.id}_summary">{$comment.summary}</div>
<div id="{$comment.id}_full" style="display: none">{$comment.fullBody}</div>
</td>
</tr>
</table>
{if ($comment.status == 'pending') || ($comment.status == 'confirm')}
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" class="serendipityIconLink" title="{$CONST.APPROVE}"><img src="{serendipity_getFile file='admin/img/accept.png'}" alt="{$CONST.APPROVE}" />{$CONST.APPROVE}</a>
{/if}
{if ($comment.status == 'approved')}
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=pending&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" class="serendipityIconLink" title="{$CONST.SET_TO_MODERATED}"><img src="{serendipity_getFile file='admin/img/clock.png'}" alt="{$CONST.SET_TO_MODERATED}" />{$CONST.SET_TO_MODERATED}</a>
{/if}
{if $comment.excerpt}
<a href="#c{$comment.id}" onclick="FT_toggle({$comment.id}); return false;" title="{$CONST.VIEW}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/zoom.png'}" alt="{$CONST.TOGGLE_ALL}" /><span id="{$comment.id}_text">{$CONST.TOGGLE_ALL}</span></a>
{/if}
<a target="_blank" href="{$entrylink}" title="{$CONST.VIEW}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/zoom.png'}" alt="{$CONST.VIEW}" />{$CONST.VIEW}</a>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" title="{$CONST.EDIT}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/edit.png'}" alt="{$CONST.EDIT}" />{$CONST.EDIT}</a>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" onclick='return confirm("{($CONST.COMMENT_DELETE_CONFIRM|sprintf:$comment.id:$comment.author)|escape}")' title="{$CONST.DELETE}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/delete.png'}" alt="{$CONST.DELETE}" />{$CONST.DELETE}</a>
<a target="_blank" onclick="cf = window.open(this.href, 'CommentForm', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); cf.focus(); return false;" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=reply&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;{$urltoken}" title="{$CONST.REPLY}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/user_editor.png'}" alt="{$CONST.REPLY}" />{$CONST.REPLY}</a>
{$comment.action_more}
</td>
</tr>
<tr>
<td><hr noshade="noshade" /></td>
</tr>
{/foreach}
{/if}{* array $comments end *}
<tr>
<td><input type="button" name="toggle" value="{$CONST.INVERT_SELECTIONS}" onclick="invertSelection()" class="serendipityPrettyButton input_button" />
<input type="submit" name="toggle" value="{$CONST.DELETE_SELECTED_COMMENTS}" onclick="return confirm('{$CONST.COMMENTS_DELETE_CONFIRM}')" tabindex="{($i+1)}" class="serendipityPrettyButton input_button" />
<input type="submit" name="serendipity[togglemoderate]" value="{$CONST.MODERATE_SELECTED_COMMENTS}" class="serendipityPrettyButton input_button" />
</td>
</tr>
</table>
<table width="100%" cellpadding="3" border="0" cellspacing="0">
<tr>
<td align="center">
<table width="100%" cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
{if ( $page != 1 && $page <= $pages )}
<a href="{$linkPrevious}" class="serendipityIconLink"><img src="{serendipity_getFile file='admin/img/previous.png'}" />{$CONST.PREVIOUS}</a>
{/if}
</td>
<td align="center">{$CONST.PAGE_BROWSE_COMMENTS|sprintf:$page:$pages:$totalComments}</td>
<td align="right">
{if $page != $pages}
<a href="{$linkNext}" class="serendipityIconLinkRight">{$CONST.NEXT}<img src="{serendipity_getFile file='admin/img/next.png'}" /></a>
{/if}
</td>
</tr>
</table>
</td>
</tr>
</form>
{/if} {* if no comments else comments end *}

View File

@ -1,13 +1,13 @@
{if $adminAction == "install"}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_success.png'}" alt="" />
{$install_template|string_format:"{$CONST.TEMPLATE_SET}"}
</div>
{/if}
{if $deprecated}
<div class="serendipityAdminMsgNote">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_note.png"}" alt="" />
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_note.png'}" alt="" />
{$CONST.WARNING_TEMPLATE_DEPRECATED}
</div>
{/if}
@ -17,7 +17,7 @@
{if $has_config}
{if $adminAction == "configure"}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file='admin/img/admin_msg_success.png'}" alt="" />
{$CONST:DONE}: {$save_time}
</div>
{/if}
@ -50,7 +50,7 @@
{if $template != $cur_template}
{if ! $info.unmetRequirements}
<a href="?serendipity[adminModule]=templates&amp;serendipity[adminAction]=install&amp;serendipity[theme]={$template}{$info.info.customURI}">
<img src="{serendipity_getFile file="admin/img/install_now{$info.info.customIcon}.png"}" alt="{$CONST.SET_AS_TEMPLATE}" title="{$CONST.SET_AS_TEMPLATE}" border="0" />
<img src="{serendipity_getFile file='admin/img/install_now{$info.info.customIcon}.png'}" alt="{$CONST.SET_AS_TEMPLATE}" title="{$CONST.SET_AS_TEMPLATE}" border="0" />
</a>
{else}
<span class="serendipityTemplateSelectUnmetRequirements" style="color: #cccccc">{$info.unmetRequirements}></span>