Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_recententries
In directory sc8-pr-cvs1:/tmp/cvs-serv14079/serendipity_plugin_recententries
Added Files:
serendipity_plugin_recententries.php
Log Message:
Recent Entries external plugin, contributed by Christian Machmeier
<cm...@re...>. Modified a bit for configuration options. :)
--- NEW FILE: serendipity_plugin_recententries.php ---
<?php # $Id: serendipity_plugin_recententries.php,v 1.1 2004/01/20 09:11:52 garvinhicking Exp $
// Contributed by Christian Machmeier <cm...@re...>
class serendipity_plugin_recententries extends serendipity_plugin {
function introspect(&$propbag) {
$propbag->add('name', RECENTENTRIES_PLUGIN_TITLE);
$propbag->add('description', RECENTENTRIES_PLUGIN_BLAHBLAH);
$propbag->add('configuration', array('number', 'language', 'dateformat'));
}
function introspect_config_item($name, &$propbag) {
switch($name) {
case 'number':
$propbag->add('type', 'string');
$propbag->add('name', RECENTENTRIES_PLUGIN_NUMBER);
$propbag->add('description', RECENTENTRIES_PLUGIN_NUMBER_BLAHBLAH);
break;
case 'language':
$propbag->add('type', 'string');
$propbag->add('name', GENERAL_PLUGIN_LANGUAGE);
$propbag->add('description', GENERAL_PLUGIN_LANGUAGE_BLAHBLAH);
break;
case 'dateformat':
$propbag->add('type', 'string');
$propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
$propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e %Y'));
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
global $serendipity;
$number = $this->get_config('number');
$lang = strtolower($this->get_config('language'));
$dateformat = $this->get_config('dateformat');
if (!$number || !is_numeric($number) || $number < 1) {
$number = 10;
}
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%A, %B %e %Y';
}
if ($lang != 'de' && $lang != 'en') {
$lang = 'en';
}
switch($lang) {
case 'de':
$loc = setlocale(LC_ALL, 'de_DE');
if (!$loc) $loc = setlocale(LC_ALL, 'de');
break;
case 'en':
$loc = setlocale(LC_ALL, 'en_US');
if (!$loc) $loc = setlocale(LC_ALL, 'en');
break;
}
$title = RECENTENTRIES_PLUGIN_TITLE;
$entries = serendipity_db_query("SELECT id,
title,
timestamp
FROM {$serendipity['dbPrefix']}entries
WHERE isdraft = 'false'
ORDER BY timestamp DESC
LIMIT $number");
foreach ($entries as $k => $entry) {
$entryLink = serendipity_archiveURL(
$entry['id'],
$entry['title'],
'serendipityHTTPPath'
);
echo '<a href="' . $entryLink . '" title="' . htmlentities($entry['title']) . '">' . $entry['title'] . '</a><br />'
. '<div class="serendipitySideBarDate">'
. htmlentities(strftime($dateformat, $entry['timestamp']))
. '</div><br />';
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|