Emoticons toolbar
- allows the integration of emoticons as UTFT-8 HTML entity via a toolbar - the toolbar is available when creating/editing entries, static pages and in the comment function
This commit is contained in:
parent
c288ac3ac1
commit
bad919b1cd
@ -37,6 +37,7 @@
|
||||
{if function_exists('plugin_bbcode_init')}
|
||||
{include file="plugin:bbcode/toolbar"}
|
||||
{/if}
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<p>
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
|
@ -35,6 +35,7 @@
|
||||
{if function_exists('plugin_bbcode_init')}
|
||||
{include file="plugin:bbcode/toolbar"}
|
||||
{/if}
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<p>
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
|
@ -1,21 +1,21 @@
|
||||
{if !$entry_commslock}
|
||||
<h4 id="addcomment">{$lang.comments.head}</h4>
|
||||
<p>{$lang.comments.descr}</p>
|
||||
|
||||
|
||||
|
||||
<form id="commentform" method="post"
|
||||
action="{$flatpress.params.entry|link:comments_link}#commentform"
|
||||
enctype="multipart/form-data">
|
||||
|
||||
|
||||
|
||||
{include file='shared:errorlist.tpl'}
|
||||
|
||||
|
||||
|
||||
|
||||
{if not $flatpress.loggedin}
|
||||
|
||||
|
||||
{*<fieldset id="comment-userdata">*}
|
||||
<div id="comment-userdata">
|
||||
|
||||
|
||||
<p>
|
||||
{if isset($error) && isset($error.name) && !empty($error.name)}
|
||||
{assign var=class value="field-error"}
|
||||
@ -30,7 +30,7 @@
|
||||
<input type="text" class="{$class}" name="name" id="name" value="{$namevalue|wp_specialchars:1|default:$cookie.name}" />
|
||||
<label class="textlabel" for="name">{$lang.comments.name}</label>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
{if isset($error) && isset($error.email) && !empty($error.email)}
|
||||
{assign var=class value="field-error"}
|
||||
@ -45,7 +45,7 @@
|
||||
<input type="text" class="{$class}" name="email" id="email" value="{$emailvalue|wp_specialchars:1|default:$cookie.email}" />
|
||||
<label class="textlabel" for="email">{$lang.comments.email}</label>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
{if isset($error) && isset($error.url) && !empty($error.url)}
|
||||
{assign var=class value="field-error"}
|
||||
@ -60,15 +60,15 @@
|
||||
<input type="text" class="{$class}" name="url" id="url" value="{$urlvalue|wp_specialchars:1|default:$cookie.url}" />
|
||||
<label class="textlabel" for="url">{$lang.comments.www}</label>
|
||||
</p>
|
||||
|
||||
|
||||
{* do action *}
|
||||
{comment_form}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
<!-- BOF Custom toolbar -->{action hook=simple_toolbar_form}<!-- EOF Custom toolbar -->
|
||||
<div class="comment-content">
|
||||
{if isset($error) && isset($error.content) && !empty($error.content)}
|
||||
{assign var=class value="field-error"}
|
||||
@ -84,7 +84,7 @@
|
||||
id="content" rows="10" cols="74">{$contentvalue|wp_specialchars:1}</textarea></p>
|
||||
{*here will go a plugin hook*}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="buttonbar">
|
||||
<input type="submit" name="submit" id="submit" value="{$lang.comments.submit}" />
|
||||
</div>
|
||||
|
84
fp-plugins/emoticons/plugin.emoticons.php
Normal file
84
fp-plugins/emoticons/plugin.emoticons.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*
|
||||
* Plugin Name: Emoticons
|
||||
* Version: 1.1.0
|
||||
* Plugin URI: https://flatpress.org
|
||||
* Description: Allows use of emoticons. Part of the standard distribution.
|
||||
* Author: FlatPress
|
||||
* Author URI: https://flatpress.org
|
||||
*/
|
||||
// assigns markdown to HTML Entity
|
||||
global $plugin_emoticons;
|
||||
$plugin_emoticons = array(
|
||||
':smile:' => '😄',
|
||||
':smiley:' => '😃',
|
||||
':wink:' => '😉',
|
||||
':blush:' => '😊',
|
||||
':grin:' => '😁',
|
||||
':smirk:' => '😏',
|
||||
':heart_eyes:' => '😍',
|
||||
':sunglasses:' => '😎',
|
||||
':laughing:' => '😆',
|
||||
':neutral_face:' => '😐',
|
||||
':flushed:' => '😳',
|
||||
':dizzy_face:' => '😵',
|
||||
':cry:' => '😢',
|
||||
':persevere:' => '😣',
|
||||
':worried:' => '😟',
|
||||
':hushed:' => '😮',
|
||||
':mag:' => '🔍',
|
||||
':hot_beverage:' => '☕',
|
||||
':exclamation:' => '❗',
|
||||
':question:' => '❓'
|
||||
);
|
||||
|
||||
// outputs the editor toolbar
|
||||
function plugin_emoticons() {
|
||||
global $plugin_emoticons;
|
||||
if (!count($plugin_emoticons))
|
||||
return true;
|
||||
echo '<script src="' . plugin_geturl('emoticons') . 'res/emoticons.js"></script>';
|
||||
echo '<div class="emoticons">';
|
||||
foreach ($plugin_emoticons as $text => $emoticon) {
|
||||
echo '<a href="#content" title="' . htmlentities($text) . '" onclick="emoticons(unescape(\'' . urlencode($text) . '\')); return false;">';
|
||||
echo $emoticon;
|
||||
echo '</a> ';
|
||||
}
|
||||
echo '</div>';
|
||||
return true;
|
||||
}
|
||||
|
||||
// replaces the text with an utf-8 emoticon
|
||||
function plugin_emoticons_filter ($emostring) {
|
||||
global $plugin_emoticons;
|
||||
|
||||
foreach ($plugin_emoticons as $text => $emoticon) {
|
||||
$emostring = str_replace(
|
||||
["$text"],
|
||||
"{$emoticon}",
|
||||
$emostring
|
||||
);
|
||||
}
|
||||
return $emostring;
|
||||
}
|
||||
|
||||
// css file
|
||||
function plugin_emoticons_css() {
|
||||
$pdir = plugin_geturl('emoticons');
|
||||
echo '
|
||||
<!-- BOF Emoticons css file -->
|
||||
<link rel="stylesheet" type="text/css" href="' . $pdir . 'res/emoticons.css">
|
||||
<!-- EOF Emoticons css file -->';
|
||||
}
|
||||
|
||||
// register css file
|
||||
add_action('wp_head', 'plugin_emoticons_css', 0);
|
||||
// register editor toolbar
|
||||
add_filter('simple_toolbar_form', 'plugin_emoticons',);
|
||||
// register to the hook
|
||||
add_filter('the_content','plugin_emoticons_filter');
|
||||
// register for emoticon in comment
|
||||
add_filter('comment_text','plugin_emoticons_filter');
|
||||
// register for the excerpt of a post
|
||||
add_filter('the_excerpt', 'plugin_emoticons_filter');
|
||||
?>
|
13
fp-plugins/emoticons/res/emoticons.css
Normal file
13
fp-plugins/emoticons/res/emoticons.css
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Name: Emoticons CSS
|
||||
* Author: Fraenkiman
|
||||
* Version: 1.0.0
|
||||
* Module: emoticons.css
|
||||
* Description: This file defines the style of the emoticons
|
||||
*/
|
||||
|
||||
.emoticons a, .emoticons a:hover {
|
||||
text-decoration: none !IMPORTANT;
|
||||
text-shadow: none !IMPORTANT;
|
||||
font-weight: normal !IMPORTANT
|
||||
}
|
21
fp-plugins/emoticons/res/emoticons.js
Normal file
21
fp-plugins/emoticons/res/emoticons.js
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Emoticons Plugin
|
||||
*/
|
||||
function insertAtCursor(myField, myValue) {
|
||||
if(document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
}
|
||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
|
||||
} else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
function emoticons(value) {
|
||||
return insertAtCursor(document.getElementById('content'), value);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user