[Php-blog-plugin-cvs] additional_plugins/serendipity_event_emoticonchooser serendipity_event_emotico
A reliable, secure & extensible PHP blog | Not mainstream since 2002
Brought to you by:
garvinhicking,
jhermanns
From: Garvin H. <gar...@us...> - 2004-12-17 10:31:26
|
Update of /cvsroot/php-blog/additional_plugins/serendipity_event_emoticonchooser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1387 Added Files: serendipity_event_emoticonchooser.php Log Message: display emoticons to choose from --- NEW FILE: serendipity_event_emoticonchooser.php --- <?php # $Id: serendipity_event_emoticonchooser.php,v 1.1 2004/12/17 10:31:17 garvinhicking Exp $ switch ($serendipity['lang']) { case 'de': @define('PLUGIN_EVENT_EMOTICONCHOOSER_TITLE', 'Smilie-Auswahlleiste'); @define('PLUGIN_EVENT_EMOTICONCHOOSER_DESC', 'Zeigt eine Auswahlleiste bei der Erstellung eines Eintrags um Smilies einzufügen.'); break; case 'en': case 'es': default: @define('PLUGIN_EVENT_EMOTICONCHOOSER_TITLE', 'Show Emoticon toolbar'); @define('PLUGIN_EVENT_EMOTICONCHOOSER_DESC', 'Shows a toolbar to select emoticons to insert into your entry'); break; } class serendipity_event_emoticonchooser extends serendipity_event { var $title = PLUGIN_EVENT_EMOTICONCHOOSER_TITLE; function introspect(&$propbag) { global $serendipity; $propbag->add('name', PLUGIN_EVENT_EMOTICONCHOOSER_TITLE); $propbag->add('description', PLUGIN_EVENT_EMOTICONCHOOSER_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); $propbag->add('version', '1.0'); $propbag->add('event_hooks', array( 'backend_entry_toolbar_extended' => true, 'backend_entry_toolbar_body' => true, )); } function generate_content(&$title) { $title = PLUGIN_EVENT_EMOTICONCHOOSER_TITLE; } function event_hook($event, &$bag, &$eventData) { global $serendipity; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'backend_entry_toolbar_extended': $txtarea = 'extended'; case 'backend_entry_toolbar_body': if (!isset($txtarea)) { $txtarea = 'body'; } $i = 1; $emoticons = serendipity_event_emoticate::getEmoticons(); $unique = array(); foreach($emoticons as $key => $value) { $unique[$value] = $key; } ?> <script type="text/javascript"> function use_emoticon_<?php echo $txtarea; ?>(img) { txtarea = document.getElementById('serendipity[<?php echo $txtarea; ?>]'); if (txtarea.createTextRange && txtarea.caretPos) { caretPos = txtarea.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + ' ' + img + ' ' : caretPos.text + ' ' + img + ' '; txtarea.focus(); } else { txtarea.value += ' ' + img + ' '; txtarea.focus(); } } </script> <?php echo '<div style="text-align: right; margin-top: 5px">'; foreach($unique as $value => $key) { echo '<a href="javascript:use_emoticon_' . $txtarea . '(\'' . addslashes($key) . '\')" title="' . $key . '"><img src="'. $value .'" style="border: 0px" /></a> '; if ($i++ % 10 == 0) { echo '<br />'; } } echo '</div>'; return true; break; default: return false; break; } } else { return false; } } } /* vim: set sts=4 ts=4 expandtab : */ ?> |