Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_history
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4052/plugins/serendipity_plugin_history
Modified Files:
serendipity_plugin_history.php
Log Message:
Added maxlength configure-option. Maybe this "cut a string to a certain
length" logic should be serendipity_something()? To make it behave nicely
and not cut words in half, etc.?
Index: serendipity_plugin_history.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_history/serendipity_plugin_history.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_plugin_history.php 3 Aug 2004 20:55:09 -0000 1.9
+++ serendipity_plugin_history.php 4 Aug 2004 17:39:59 -0000 1.10
@@ -19,6 +19,8 @@
@define('PLUGIN_HISTORY_OUTRO_DESC', 'Text, der hinter den Einträgen angezeigt werden soll');
@define('PLUGIN_HISTORY_DISPLAYDATE', 'Datum anzeigen');
@define('PLUGIN_HISTORY_DISPLAYDATE_DESC', 'Vor jedem Eintrag das Datum anzeigen?');
+ @define('PLUGIN_HISTORY_MAXLENGTH', 'Überschriftenlänge');
+ @define('PLUGIN_HISTORY_MAXLENGTH_DESC', 'Nach wievielen Zeichen sollen die Überschriften abgeschnitten werden (0 für garnicht)?');
@define('PLUGIN_HISTORY_SPECIALAGE', 'Vorgefertigter Zeitrahmen');
@define('PLUGIN_HISTORY_SPECIALAGE_DESC', 'Wenn Sie statt einem vorgefertigten lieber einen eigenen Zeitraum einstellen möchten, wählen Sie \'Anderer\' aus und füllen die unteren beiden Felder.');
@define('PLUGIN_HISTORY_SPECIALAGE_YEAR', 'Zeigt Einträge vom selben Datum des letzten Jahres an.');
@@ -45,6 +47,8 @@
@define('PLUGIN_HISTORY_OUTRO_DESC', 'A short Outro like \'Nice, eh?\'.');
@define('PLUGIN_HISTORY_DISPLAYDATE', 'Display date');
@define('PLUGIN_HISTORY_DISPLAYDATE_DESC', 'Display the date of each entry?');
+ @define('PLUGIN_HISTORY_MAXLENGTH', 'Title-Length');
+ @define('PLUGIN_HISTORY_MAXLENGTH_DESC', 'After how many characters to cut the titles (0 for full titles)?');
@define('PLUGIN_HISTORY_SPECIALAGE', 'Ready-made age?');
@define('PLUGIN_HISTORY_SPECIALAGE_DESC', 'If you want to define your own timerange instead of a ready-made, select \'I\'ll define one\' here and adjust the two settings below.');
@define('PLUGIN_HISTORY_SPECIALAGE_YEAR', 'Display items of exactly one year ago');
@@ -66,6 +70,7 @@
$propbag->add('configuration', array('title',
'intro',
'outro',
+ 'maxlength',
'specialage',
'min_age',
'max_age',
@@ -97,6 +102,12 @@
$propbag->add('description', PLUGIN_HISTORY_OUTRO_DESC);
$propbag->add('default', '');
break;
+ case 'maxlength':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_HISTORY_MAXLENGTH);
+ $propbag->add('description', PLUGIN_HISTORY_MAXLENGTH_DESC);
+ $propbag->add('default', 30);
+ break;
case 'specialage':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_HISTORY_SPECIALAGE);
@@ -154,6 +165,7 @@
$title = $this->get_config('title', PLUGIN_HISTORY_NAME);
$intro = $this->get_config('intro');
$outro = $this->get_config('outro');
+ $maxlength = $this->get_config('maxlength');
$max_entries = $this->get_config('max_entries');
$min_age = $this->get_config('min_age');
$max_age = $this->get_config('max_age');
@@ -174,6 +186,9 @@
$max_entries = 5;
}
+ if (!$maxlength ||!is_numeric($maxlength) ||$maxlength <0)
+ $maxlength = 30;
+
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%a, %d.%m.%Y %H:%M';
}
@@ -194,7 +209,10 @@
false
);
$date = ($displaydate=='0') ? '' : strftime($dateformat,$e[$x]['timestamp']);
- echo $date . "<a href='$url'>{$e[$x]['title']}</a> " .
+ $t = ($maxlength==0 || strlen($e[$x]['title'])<=$maxlength) ?
+ $e[$x]['title'] :
+ (trim(substr($e[$x]['title'], 0, $maxlength-3)).' [...]');
+ echo $date . "<a href='$url' title='".str_replace("'", '`', $e[$x][title])."'>".$t."</a> " .
strip_tags($e[$x]['body']) . '<br />';
}
echo $outro;
|