1
0

consistent plugin usage - comments

this and followup commits touches:
    class method parenthesis "\n{\n    <code>\n}\n",
    case break switches,
    consistent boolean usage,
    append css to eventData
    and other cleanups
This commit is contained in:
Ian
2016-01-26 14:03:02 +01:00
parent 99d488d1be
commit 926da9c59a

View File

@ -1,4 +1,8 @@
<?php # $Id$
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
@ -16,9 +20,9 @@ class serendipity_plugin_comments extends serendipity_plugin
$propbag->add('description', PLUGIN_COMMENTS_BLAHBLAH);
$propbag->add('stackable', true);
$propbag->add('author', 'Garvin Hicking, Tadashi Jokagi, Judebert, G. Brockhaus');
$propbag->add('version', '1.14');
$propbag->add('version', '1.15');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'serendipity' => '1.6',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
@ -37,6 +41,7 @@ class serendipity_plugin_comments extends serendipity_plugin
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'authorid':
$authors = array('all' => ALL_AUTHORS, 'login' => CURRENT_AUTHOR);
/*
@ -118,7 +123,7 @@ class serendipity_plugin_comments extends serendipity_plugin
break;
default:
return false;
return false;
}
return true;
}
@ -154,14 +159,13 @@ class serendipity_plugin_comments extends serendipity_plugin
} elseif ($this->get_config('viewmode') == 'trackbacks') {
$viewtype .= ' AND (co.type = \'TRACKBACK\' OR co.type = \'PINGBACK\')';
}
$cond = array();
$cond['and'] = ' AND e.isdraft = \'false\' ';
if ($this->get_config('authorid') == 'login') {
serendipity_ACL_SQL($cond, true);
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries'));
}
$q = 'SELECT co.body AS comment,
co.timestamp AS stamp,
@ -186,7 +190,7 @@ class serendipity_plugin_comments extends serendipity_plugin
LIMIT ' . $max_entries;
$sql = serendipity_db_query($q);
// echo $q;
if ($sql && is_array($sql)) {
foreach($sql AS $key => $row) {
if (function_exists('mb_strimwidth')) {
@ -199,20 +203,20 @@ class serendipity_plugin_comments extends serendipity_plugin
$comment .= ' [...]';
}
}
$showurls = $this->get_config('showurls','trackbacks');
$isTrackBack = $row['comment_type'] == 'TRACKBACK' || $row['comment_type'] == 'PINGBACK';
if ($row['comment_url'] != '' && ( ($isTrackBack && ($showurls =='trackbacks' || $showurls =='all') || !$isTrackBack && ($showurls =='comments' || $showurls =='all')))) {
/* Fix invalid cases in protocoll part */
$row['comment_url'] = preg_replace('@^http://@i','http://', $row['comment_url']);
$row['comment_url'] = preg_replace('@^https://@i','https://', $row['comment_url']);
if (substr($row['comment_url'], 0, 7) != 'http://' &&
if (substr($row['comment_url'], 0, 7) != 'http://' &&
substr($row['comment_url'], 0, 8) != 'https://') {
$row['comment_url'] = 'http://' . $row['comment_url'];
}
$row['comment_url'] = 'http://' . $row['comment_url'];
}
$user = '<a class="highlight" href="' . serendipity_specialchars(strip_tags($row['comment_url'])) . '" title="' . serendipity_specialchars(strip_tags($row['comment_title'])) . '">' . serendipity_specialchars(strip_tags($row['user'])) . '</a>';
} else {
$user = serendipity_specialchars(strip_tags($row['user']));
@ -265,6 +269,8 @@ class serendipity_plugin_comments extends serendipity_plugin
}
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>