Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_history
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv869/plugins/serendipity_plugin_history
Added Files:
serendipity_plugin_history.php
Log Message:
Added a history plugin that displays things you wrote one year
ago (or a week ago, whatever...). Check it out and tell me if
there's something wrong with it :)
--- NEW FILE: serendipity_plugin_history.php ---
<?php # $Id: serendipity_plugin_history.php,v 1.1 2004/06/24 20:00:52 jhermanns Exp $
switch ($serendipity['lang']) {
case 'de':
@define('PLUGIN_HISTORY_NAME', 'Geschichte');
@define('PLUGIN_HISTORY_DESC', 'Zeigt Einträge eines einstellbaren '.
'Alters an.');
@define('PLUGIN_HISTORY_MIN_AGE', 'Mindestalter');
@define('PLUGIN_HISTORY_MIN_AGE_DESC', 'Mindestalter der Einträge (in Tagen).');
@define('PLUGIN_HISTORY_MAX_AGE', 'Höchstalter');
@define('PLUGIN_HISTORY_MAX_AGE_DESC','Höchstalter der Einträge (in Tagen).');
@define('PLUGIN_HISTORY_MAX_ENTRIES', 'Anzahl');
@define('PLUGIN_HISTORY_MAX_ENTRIES_DESC', 'Wieviele Einträge sollen maximal angezeigt werden?');
@define('PLUGIN_HISTORY_SHOWFULL', 'Ganze Einträge');
@define('PLUGIN_HISTORY_SHOWFULL_DESC', 'Nicht nur Überschriften, sondern ganze Einträge anzeigen.');
@define('PLUGIN_HISTORY_INTRO', 'Intro');
@define('PLUGIN_HISTORY_INTRO_DESC', 'Text, der vor den Einträgen angezeigt werden soll');
@define('PLUGIN_HISTORY_DISPLAYDATE', 'Datum anzeigen');
@define('PLUGIN_HISTORY_DISPLAYDATE_DESC', 'Vor jedem Eintrag das Datum anzeigen?');
break;
default:
@define('PLUGIN_HISTORY_NAME', 'History');
@define('PLUGIN_HISTORY_DESC', 'Displays ancient entries of an '.
'adjustable age.');
@define('PLUGIN_HISTORY_MIN_AGE', 'Min age');
@define('PLUGIN_HISTORY_MIN_AGE_DESC', 'Minimum age of entries (in days).');
@define('PLUGIN_HISTORY_MAX_AGE', 'Max age');
@define('PLUGIN_HISTORY_MAX_AGE_DESC','Maximum age of entries (in days).');
@define('PLUGIN_HISTORY_MAX_ENTRIES', 'Maximum entries');
@define('PLUGIN_HISTORY_MAX_ENTRIES_DESC', 'Number of entries to display');
@define('PLUGIN_HISTORY_SHOWFULL', 'Full entries');
@define('PLUGIN_HISTORY_SHOWFULL_DESC', 'Display full entries instead of '.
'linked headlines.');
@define('PLUGIN_HISTORY_INTRO', 'Intro');
@define('PLUGIN_HISTORY_INTRO_DESC', 'A short intro like \'One year ago I said:\'.');
@define('PLUGIN_HISTORY_DISPLAYDATE', 'Display date');
@define('PLUGIN_HISTORY_DISPLAYDATE_DESC', 'Display the date of each entry?');
break;
}
class serendipity_plugin_history extends serendipity_plugin
{
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_HISTORY_NAME);
$propbag->add('description', PLUGIN_HISTORY_DESC);
$propbag->add('configuration', array('title',
'intro',
'min_age',
'max_age',
'max_entries',
'full',
'amount',
'displaydate',
'dateformat'));
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', '');
$propbag->add('default', PLUGIN_HISTORY_NAME);
break;
case 'intro':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_HISTORY_INTRO);
$propbag->add('description', PLUGIN_HISTORY_INTRO_DESC);
$propbag->add('default', '');
break;
case 'min_age':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_HISTORY_MIN_AGE);
$propbag->add('description', PLUGIN_HISTORY_MIN_AGE_DESC);
$propbag->add('default', 365);
break;
case 'max_age':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_HISTORY_MAX_AGE);
$propbag->add('description', PLUGIN_HISTORY_MAX_AGE_DESC);
$propbag->add('default', 365);
break;
case 'max_entries':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_HISTORY_MAX_ENTRIES);
$propbag->add('description', PLUGIN_HISTORY_MAX_ENTRIES_DESC);
$propbag->add('default', 5);
break;
case 'full':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_HISTORY_SHOWFULL);
$propbag->add('description', PLUGIN_HISTORY_SHOWFULL_DESC);
$propbag->add('select_values', array('false','true'));
$propbag->add('default', 'false');
break;
case 'displaydate':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_HISTORY_DISPLAYDATE);
$propbag->add('description', PLUGIN_HISTORY_DISPLAYDATE_DESC);
$propbag->add('select_values', array('false','true'));
$propbag->add('default', 'true');
break;
case 'dateformat':
$propbag->add('type', 'string');
$propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
$propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%a, %d.%m.%Y %H:%M'));
$propbag->add('default', '%a, %d.%m.%Y %H:%M');
break;
default:
return false;
}
return true;
}
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title');
$intro = $this->get_config('intro');
$min_age = $this->get_config('min_age');
$max_age = $this->get_config('min_age');
$displaydate = $this->get_config('displaydate');
$dateformat = $this->get_config('dateformat');
$full = ($this->get_config('full')=='0') ? false : true;
if (!$min_age || !is_numeric($min_age) || $min_age < 1) {
$min_age = 365;
}
if (!$max_age || !is_numeric($max_age) || $max_age < 1) {
$max_age = 365;
}
if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) {
$max_entries = 5;
}
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%a, %d.%m.%Y %H:%M';
}
$mints = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$maxts = mktime(23, 59, 59, date('m'), date('d'), date('Y'));
$e = serendipity_fetchEntries(array(($mints-$min_age*86400),
($maxts-$max_age*86400)), $full, 15);
print ("$intro<br />");
for($x=0; $x<@count($e); $x++) {
$url = serendipity_archiveURL($e[$x]['id'],
$e[$x]['title'],
'serendipityHTTPPath');
$date = ($displaydate=='0') ? '' : strftime($dateformat);
print ("$date<a href='$url'>{$e[$x][title]}</a> ".
strip_tags($e[$x][body])."<br />");
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|