Page 1 of 1

History plugin improvement

Posted: Fri Jan 02, 2009 9:49 am
by gimmel
The new version of the history plugin (v1.5, shipped with s9y 1.4) has a little „bug“. If author and date are suppressed, the (X)HTML output contains empty spans although.

I changed this

Code: Select all

$date   = ($displaydate=='0') ? '' : serendipity_strftime($dateformat,$e[$x]['timestamp']);
$author = ($displayauthor) ? $e[$x]['author'] . ': ' : '';
$t = ($maxlength==0 || strlen($e[$x]['title'])<=$maxlength) ?
    $e[$x]['title'] :
    (trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength-3)).' [...]');
echo '<div class="serendipity_history_info"><span class="serendipity_history_author">' . $author . '</span> <span class="serendipity_history_date">'. $date . "</span> <a href='$url' title='".str_replace("'", '`', htmlspecialchars($e[$x]['title']))."'>". htmlspecialchars($t) . '</a></div>' . '<div class="serendipity_history_body">' .
    strip_tags($e[$x]['body']) . '</div>';
to that

Code: Select all

echo '<div class="serendipity_history_info">';
if ($displayauthor)
    { echo '<span class="serendipity_history_author">' . $e[$x]['author'] . ': </span>'; }
if ($displaydate)
    { echo '<span class="serendipity_history_date">'. serendipity_strftime($dateformat,$e[$x]['timestamp']) . ' </span>'; }
$t = ($maxlength==0 || strlen($e[$x]['title'])<=$maxlength) ?
    $e[$x]['title'] :
    (trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength-3)).' [...]');
echo "<a href=" . $url . " title='".str_replace("'", "`", htmlspecialchars($e[$x]['title']))."'>". htmlspecialchars($t) . "</a></div>";
echo '<div class="serendipity_history_body">' . strip_tags($e[$x]['body']) . '</div>';
to correct that problem.

Yes, I am the other one who uses this plugin, yellowled… ;-)

Re: History plugin improvement

Posted: Fri Jan 02, 2009 10:23 am
by yellowled
gimmel wrote:Yes, I am the other one who uses this plugin, yellowled… ;-)
Sweet $DEITY, I'm not alone out there :wink:

I'll submit those to svn asap. Thanks!

YL

Wrong year in history plugin

Posted: Tue Jan 06, 2009 8:28 pm
by gimmel
Another little bug: „One year ago“ calculates one day to late.

Code: Select all

if (!is_numeric($min_age) || $min_age < 0 || $specialage == 'year') {
    $min_age = 365 + date('L', serendipity_serverOffsetHour());
}
A year has 365 days, that's right. But if you start e.g. on 1.1.2008 the 365th day is 31.12.2008. To get the 1.1.2009 you need an offset of 366.

Anyway, the date should not be generated by offset, because of leap years. Why not calculating the date by DD.MM.YYYY-1 ?

Re: History plugin improvement

Posted: Mon Feb 02, 2009 12:09 pm
by yellowled
Another little bug here. This:

Code: Select all

echo "<a href=" . $url . " title='".str_replace("'", "`", htmlspecialchars($e[$x]['title']))."'>". htmlspecialchars($t) . "</a></div>";
emits invalid HTML since the URL is not included in " - probably due to incorrectly masked instances of those. I'm not sure I understand the PHP code here fully, so someone please help me out.

Also, we should probably add a check whether this:

Code: Select all

echo '<div class="serendipity_history_body">' . strip_tags($e[$x]['body']) . '</div>';
is actually supposed to be emitted (there's a config option for that now, right?).

YL

Re: History plugin improvement

Posted: Mon Feb 02, 2009 12:55 pm
by yellowled
Resolved. (Both of them.) :)

YL

Re: History plugin improvement

Posted: Mon Feb 02, 2009 1:09 pm
by gimmel
Thanks a lot!
Do you still use an offset (366) or a search for the date?

Re: History plugin improvement

Posted: Mon Feb 02, 2009 1:25 pm
by yellowled
gimmel wrote:Do you still use an offset (366) or a search for the date?
I have not interfered with the actual functionality of the plugin at all, so it's still using whatever it was using before :)

YL