fix fallback for custom template emoticons

adds an example file to extend this to custom emoticons
Add description of this in plugins config.
This commit is contained in:
Ian 2015-02-05 15:46:53 +01:00
parent 45233a2948
commit e5d1a8da3a
6 changed files with 125 additions and 18 deletions

View File

@ -0,0 +1,24 @@
1.8:
-----
* Fix fetching custom theme based emoticons
for 2.0 backend views
* Extends the plugins example description
* Add custom copy emoticons.inc.php file example
UPGRADE NOTES:
Due to a changed fallback behaviour in Serendipity 2.0+
for frontend and backend templates you need to this:
If you already have you own emoticons.inc.php file, living
in /templates/yourTemplate/*, you need to change all occurrences
of
serendipity_getTemplateFile('img/emoticons/yoursmiley.png')
to
serendipity_getTemplateFile('img/emoticons/yoursmiley.png', 'serendipityHTTPPath', true)
The distinction of Backend and Frontend themes in Serendipity 2.0 will try
to search for a file in the backend-directory of a theme,
or use the default template (which currently is 2k11),
because backend screens live normally in a themes /admin directory,
not in other frontends.

View File

@ -1,7 +1,10 @@
<?php #
<?php
@define('PLUGIN_EVENT_EMOTICATE_NAME', 'Textformatierung: Smilies');
@define('PLUGIN_EVENT_EMOTICATE_DESC', 'Standard Text-Smilies in Grafiken konvertieren');
@define('PLUGIN_EVENT_EMOTICATE_TRANSFORM', 'Standard-Text Smilies wie :-) und ;-) werden zu Bildern konvertiert.');
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION', 'Dateinamenerweiterung');
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION_BLAHBLAH', 'Die Dateinamenerweiterung der Emoticons. Groß-/Kleinschreibung beachten.');
@define('PLUGIN_EVENT_EMOTICATE_EXAMPLE_EXTEND_DESC', 'Dieses Plugin ist erweiterbar, in dem man dem eigenen Template eigene emoticon Vorlagen in "/templates/yourTemplate/img/emoticons/*" und eine Konfigurations Datei "emoticons.inc.php" dem eigenen Template Basisordner hinzufügt. Eine kopierbare Beispiel-Datei ist diesem Plugin Ordner zugefügt. Das zusätzliche serendipity_event_emoticonchooser Plugin erweitert die möglichen Stellen der Benutzung um die definierte Liste aller Emoticons als klickbare Emoticons.');

View File

@ -0,0 +1,71 @@
<?php
/** Custom emoticons.inc.php file example.
Rewrite to your own needs and place this file in your own template directory base.
This needs to correspond with the emoticon images placed in "/templates/yourTemplate/img/emoticons/*.*".
Keep in mind that some smileys you can find in the internet are restricted in license!
Add Notes of what is what for your own custom_emoticons_regexp ;-)
:anger: = anger - 8-) = cool - :'( = cry
:-O = eek - :grmpf: = grmpf - :grrr: = grrr
:haha: = haha - :) = happy - :hero: = hero
:ko: = ko - :-D = laugh - :mo: = mo
:-| = normal - :-( = sad - :safe: = safe
:$ = shame - :-) = smile - :still: = still
:-P = tongue - :( = unhappy - :o: = whistle - ;-) = wink
. . . etc
*/
$serendipity['custom_emoticons_regexp'] = true;
$serendipity['custom_emoticons'] = array(
"\:'\(" => serendipity_getTemplateFile('img/emoticons/cry.png', 'serendipityHTTPPath', true),
'\:\-?\)' => serendipity_getTemplateFile('img/emoticons/smile.png', 'serendipityHTTPPath', true),
'\:\-?\|' => serendipity_getTemplateFile('img/emoticons/normal.png', 'serendipityHTTPPath', true),
'\:\-?O' => serendipity_getTemplateFile('img/emoticons/eek.png', 'serendipityHTTPPath', true),
'\:\-?\(' => serendipity_getTemplateFile('img/emoticons/sad.png', 'serendipityHTTPPath', true),
'8\-?\)' => serendipity_getTemplateFile('img/emoticons/cool.png', 'serendipityHTTPPath', true),
'\:\-?D' => serendipity_getTemplateFile('img/emoticons/laugh.png', 'serendipityHTTPPath', true),
'\:\-?P' => serendipity_getTemplateFile('img/emoticons/tongue.png', 'serendipityHTTPPath', true),
';\-?\)' => serendipity_getTemplateFile('img/emoticons/wink.png', 'serendipityHTTPPath', true),
'\:anger\:' => serendipity_getTemplateFile('img/emoticons/anger.png', 'serendipityHTTPPath', true),
'\:\$' => serendipity_getTemplateFile('img/emoticons/shame.png', 'serendipityHTTPPath', true),
'\:grmpf\:' => serendipity_getTemplateFile('img/emoticons/grmpf.png', 'serendipityHTTPPath', true),
'\:grrr\:' => serendipity_getTemplateFile('img/emoticons/grrr.png', 'serendipityHTTPPath', true),
'\:haha\:' => serendipity_getTemplateFile('img/emoticons/haha.png', 'serendipityHTTPPath', true),
'\:\)' => serendipity_getTemplateFile('img/emoticons/happy.png', 'serendipityHTTPPath', true),
'\:hero\:' => serendipity_getTemplateFile('img/emoticons/hero.png', 'serendipityHTTPPath', true),
'\:ko\:' => serendipity_getTemplateFile('img/emoticons/ko.png', 'serendipityHTTPPath', true),
'\:safe\:' => serendipity_getTemplateFile('img/emoticons/safe.png', 'serendipityHTTPPath', true),
'\:still\:' => serendipity_getTemplateFile('img/emoticons/still.png', 'serendipityHTTPPath', true),
'\:\(' => serendipity_getTemplateFile('img/emoticons/unhappy.png', 'serendipityHTTPPath', true),
'\:o\:' => serendipity_getTemplateFile('img/emoticons/whistle.png', 'serendipityHTTPPath', true),
);
?>

View File

@ -1,7 +1,10 @@
<?php #
<?php
@define('PLUGIN_EVENT_EMOTICATE_NAME', 'Textformatierung: Smilies');
@define('PLUGIN_EVENT_EMOTICATE_DESC', 'Standard Text-Smilies in Grafiken konvertieren');
@define('PLUGIN_EVENT_EMOTICATE_TRANSFORM', 'Standard-Text Smilies wie :-) und ;-) werden zu Bildern konvertiert.');
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION', 'Dateinamenerweiterung');
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION_BLAHBLAH', 'Die Dateinamenerweiterung der Emoticons. Groß-/Kleinschreibung beachten.');
@define('PLUGIN_EVENT_EMOTICATE_EXAMPLE_EXTEND_DESC', 'Dieses Plugin ist erweiterbar, in dem man dem eigenen Template eigene emoticon Vorlagen in "/templates/yourTemplate/img/emoticons/*" und eine Konfigurations Datei "emoticons.inc.php" dem eigenen Template Basisordner hinzufügt. Eine kopierbare Beispiel-Datei ist diesem Plugin Ordner zugefügt. Das zusätzliche serendipity_event_emoticonchooser Plugin erweitert die möglichen Stellen der Benutzung um die definierte Liste aller Emoticons als klickbare Emoticons.');

View File

@ -1,4 +1,4 @@
<?php #
<?php
/**
* @version
@ -12,3 +12,5 @@
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION', 'File extension');
@define('PLUGIN_EVENT_EMOTICATE_EXTENSION_BLAHBLAH', 'The file extension of your emoticons. This is case sensitive.');
@define('PLUGIN_EVENT_EMOTICATE_EXAMPLE_EXTEND_DESC', 'You may extend this by your own added emoticon images in "/templates/yourTemplate/img/emoticons/*" and a configuration file "emoticons.inc.php" added to your templates root. A copy example of this file is added in this plugin directory here. The additional serendipity_event_emoticonchooser plugin extends this to get a clickable list of alle defined emoticons where possible.');

View File

@ -1,4 +1,4 @@
<?php #
<?php
@serendipity_plugin_api::load_language(dirname(__FILE__));
@ -14,15 +14,18 @@ class serendipity_event_emoticate extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_EMOTICATE_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.7');
$propbag->add('version', '1.8');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '5.2.0'
));
$propbag->add('groups', array('MARKUP'));
$propbag->add('cachable_events', array('frontend_display' => true));
$propbag->add('event_hooks', array('frontend_display' => true, 'frontend_comment' => true, 'css_backend' => true, 'css' => true));
$propbag->add('cachable_events', array( 'frontend_display' => true) );
$propbag->add('event_hooks', array( 'frontend_display' => true,
'frontend_comment' => true,
'css_backend' => true,
'css' => true));
$this->markup_elements = array(
array(
@ -70,7 +73,7 @@ class serendipity_event_emoticate extends serendipity_event
}
/* Hijack global variable $serendipity['custom_emoticons'] if it exists */
$hijack_file = serendipity_getTemplateFile('emoticons.inc.php', 'serendipityPath');
$hijack_file = serendipity_getTemplateFile('emoticons.inc.php', 'serendipityPath', true);
if (@file_exists($hijack_file)) {
@include $hijack_file; // This file contains $serendipity['custom_emoticons'] and maybe $serendipity['custom_emoticons_regexp']
if (isset($serendipity['custom_emoticons']) && is_array($serendipity['custom_emoticons'])) {
@ -87,23 +90,23 @@ class serendipity_event_emoticate extends serendipity_event
if (!isset($this->smilies)) {
$ext = $this->get_config('extension', 'png');
$this->smilies = array(
"\:'\(" => serendipity_getTemplateFile('img/emoticons/cry.'.$ext),
"\:'\(" => serendipity_getTemplateFile('img/emoticons/cry.'.$ext, 'serendipityHTTPPath', true),
'\:\-?\)' => serendipity_getTemplateFile('img/emoticons/smile.'.$ext),
'\:\-?\)' => serendipity_getTemplateFile('img/emoticons/smile.'.$ext, 'serendipityHTTPPath', true),
'\:\-?\|' => serendipity_getTemplateFile('img/emoticons/normal.'.$ext),
'\:\-?\|' => serendipity_getTemplateFile('img/emoticons/normal.'.$ext, 'serendipityHTTPPath', true),
'\:\-?O' => serendipity_getTemplateFile('img/emoticons/eek.'.$ext),
'\:\-?O' => serendipity_getTemplateFile('img/emoticons/eek.'.$ext, 'serendipityHTTPPath', true),
'\:\-?\(' => serendipity_getTemplateFile('img/emoticons/sad.'.$ext),
'\:\-?\(' => serendipity_getTemplateFile('img/emoticons/sad.'.$ext, 'serendipityHTTPPath', true),
'8\-?\)' => serendipity_getTemplateFile('img/emoticons/cool.'.$ext),
'8\-?\)' => serendipity_getTemplateFile('img/emoticons/cool.'.$ext, 'serendipityHTTPPath', true),
'\:\-?D' => serendipity_getTemplateFile('img/emoticons/laugh.'.$ext),
'\:\-?D' => serendipity_getTemplateFile('img/emoticons/laugh.'.$ext, 'serendipityHTTPPath', true),
'\:\-?P' => serendipity_getTemplateFile('img/emoticons/tongue.'.$ext),
'\:\-?P' => serendipity_getTemplateFile('img/emoticons/tongue.'.$ext, 'serendipityHTTPPath', true),
';\-?\)' => serendipity_getTemplateFile('img/emoticons/wink.'.$ext),
';\-?\)' => serendipity_getTemplateFile('img/emoticons/wink.'.$ext, 'serendipityHTTPPath', true),
);
}
@ -119,7 +122,8 @@ class serendipity_event_emoticate extends serendipity_event
}
function example() {
$s = '<table cellspacing="5" class="example_emos">';
$s = PLUGIN_EVENT_EMOTICATE_EXAMPLE_EXTEND_DESC;
$s .= '<table cellspacing="5" class="example_emos">';
$s .= '<tr>';
$i = 1;
foreach($this->getEmoticons() as $key => $value) {