Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_shoutbox
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12018/plugins/serendipity_plugin_shoutbox
Modified Files:
serendipity_plugin_shoutbox.php
Log Message:
Matthias sent an updated shoutbox plugin that added "delete comment"
functionality. Because Matthias codebase diverges from the codebase within
the, his file needed gentle prodding to integrate his changes into the
'official' version.
Here is the diff.
CVS
Index: serendipity_plugin_shoutbox.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_shoutbox/serendipity_plugin_shoutbox.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- serendipity_plugin_shoutbox.php 16 Mar 2004 09:06:55 -0000 1.2
+++ serendipity_plugin_shoutbox.php 21 Mar 2004 08:59:43 -0000 1.3
@@ -6,8 +6,10 @@
case 'de':
@define('PLUGIN_SHOUTBOX_NAME', 'Shoutbox');
@define('PLUGIN_SHOUTBOX_BLAHBLAH', 'Zeigt eine Shoutbox für beliebige Kommentare');
+ @define('PLUGIN_SHOUTBOX_DELETE', 'Löschen');
+ @define('PLUGIN_SHOUTBOX_SUBMIT', 'Abschicken');
@define('PLUGIN_SHOUTBOX_WORDWRAP', 'Zeilenumbruch');
- @define('PLUGIN_SHOUTBOX_WORDWRAP_BLAHBLAH', 'Nach wievielen Wörtern soll ein Zeilenumbruch eingefügt werden? (Standard: 30)');
+ @define('PLUGIN_SHOUTBOX_WORDWRAP_BLAHBLAH', 'Nach wievielen Zeichen soll ein Zeilenumbruch eingefügt werden?');
@define('PLUGIN_SHOUTBOX_MAXCHARS', 'Zeichen pro Kommentar');
@define('PLUGIN_SHOUTBOX_MAXCHARS_BLAHBLAH', 'Wieviele Zeichen sollen pro Kommentar gezeigt werden? (Standard: 120)');
@define('PLUGIN_SHOUTBOX_MAXENTRIES', 'Anzahl an Kommentaren');
@@ -18,9 +20,11 @@
case 'es':
default:
@define('PLUGIN_SHOUTBOX_NAME', 'Shoutbox');
+ @define('PLUGIN_SHOUTBOX_DELETE', 'Delete');
+ @define('PLUGIN_SHOUTBOX_SUBMIT', 'Shout it out');
@define('PLUGIN_SHOUTBOX_BLAHBLAH', 'Displays a shoutbox for unrelated comments');
@define('PLUGIN_SHOUTBOX_WORDWRAP', 'Wordwrap');
- @define('PLUGIN_SHOUTBOX_WORDWRAP_BLAHBLAH', 'How many words until a wordwrap will occur? (Default: 30)');
+ @define('PLUGIN_SHOUTBOX_WORDWRAP_BLAHBLAH', 'How many chars until a wordwrap will occur? (Default: 30)');
@define('PLUGIN_SHOUTBOX_MAXCHARS', 'Maximum chars per comment');
@define('PLUGIN_SHOUTBOX_MAXCHARS_BLAHBLAH', 'How many chars will be displayed for each comment? (Default: 120)');
@define('PLUGIN_SHOUTBOX_MAXENTRIES', 'Maximum number of comments');
@@ -101,11 +105,11 @@
// Create table, if not yet existant
if ($this->get_config('version') != '1.0') {
- $q = "CREATE TABLE {$serendipity['dbPrefix']}shoutbox (
- id {AUTOINCREMENT} {PRIMARY},
- timestamp int(10) {UNSIGNED} NULL,
- ip varchar(15) default NULL,
- body text
+ $q = "CREATE TABLE {$serendipity['dbPrefix']}shoutbox (
+ id {AUTOINCREMENT} {PRIMARY},
+ timestamp int(10) {UNSIGNED} NULL,
+ ip varchar(15) default NULL,
+ body text
)";
$sql = serendipity_db_schema_import($q);
$this->set_config('version', '1.0');
@@ -128,6 +132,15 @@
serendipity_db_escape_string($_REQUEST['serendipity']['shouttext']));
serendipity_db_query($sql);
}
+ if ( $serendipity['GET']['action'] == 'shoutboxdelete'
+ && $_SESSION['serendipityAuthedUser'] === true) {
+ $sql = sprintf("DELETE from %sshoutbox
+ WHERE id = %d
+ LIMIT 1",
+ $serendipity['dbPrefix'],
+ $serendipity['GET']['shout_id']);
+ serendipity_db_query($sql);
+ }
if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) {
$max_entries = 15;
@@ -153,11 +166,13 @@
case 'de':
$loc = setlocale(LC_ALL, 'de_DE');
if (!$loc) $loc = setlocale(LC_ALL, 'de');
+ $out = '%s zu%s';
break;
case 'en':
$loc = setlocale(LC_ALL, 'en_US');
if (!$loc) $loc = setlocale(LC_ALL, 'en');
+ $out = '%s about%s';
break;
}
?>
@@ -165,7 +180,7 @@
<div>
<input type="hidden" name="action" value="fillshoutbox" />
<textarea name="serendipity[shouttext]" rows="4" style="width: 90%"></textarea>
- <input name='submit' type='submit' value='Abschicken' />
+ <input name='submit' type='submit' value='<?php echo PLUGIN_SHOUTBOX_SUBMIT; ?>' />
</div>
</form><br />
<?php
@@ -184,13 +199,25 @@
$comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments);
$comment = $aComment[0];
+ if (count($aComment) > 1) {
+ $comment .= ' [...]';
+ }
- $entry = array('comment' => wordwrap($comment, $wordwrap, "\n"));
+ $deleteLink = "";
+ if ($_SESSION['serendipityAuthedUser'] === true) {
+ $deleteLink = ' | <a href="' . $serendipity['baseURL']
+ . '?serendipity[action]=shoutboxdelete&serendipity[comment_id]='
+ . $row['shout_id'] . '">' . PLUGIN_SHOUTBOX_DELETE . '</a>';
+ }
+ $entry = array('comment' => wordwrap($comment, $wordwrap, "\n",1));
serendipity_plugin_api::hook_event('frontend_display', $entry);
- echo "<b>" . htmlentities(strftime($dateformat, $row['stamp'])) . "</b><br />\n"
- . $entry['comment']
- . "<br /><br /><br />\n\n";
+ printf(
+ "<b>" . htmlentities(strftime($dateformat, $row['stamp'])) . '</b> <br />' . "\n"
+ . $entry['comment']
+ . $deleteLink
+ . '<br /><br /><br />' . "\n\n"
+ );
}
}
?>
|