refactor smilie code to allow for extensions and generation of a table of the entire list
This commit is contained in:
parent
cbabf9d7ef
commit
134fdda75f
1 changed files with 58 additions and 13 deletions
|
@ -678,21 +678,56 @@ function linkify($s) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(! function_exists('smilies')) {
|
if(! function_exists('smilies')) {
|
||||||
function smilies($s) {
|
function smilies($s, $sample = false) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$s = str_replace(
|
$texts = array(
|
||||||
array( '<3', '</3', '<\\3', ':-)', ':)', ';-)', ';)', ':-(', ':(', ':-P', ':P', ':-"', ':-"', ':-x', ':-X', ':-D', ':D', '8-|', '8-O', ':-O', '\\o/', 'o.O', 'O.o', '\\.../', '\\ooo/', ":'(", ":-!", ":-/", ":-[", "8-)",
|
'<3',
|
||||||
':beer', ':homebrew', ':coffee',
|
'</3',
|
||||||
'~friendika', '~friendica', 'Diaspora*' ),
|
'<\\3',
|
||||||
array(
|
':-)',
|
||||||
|
':)',
|
||||||
|
';-)',
|
||||||
|
';)',
|
||||||
|
':-(',
|
||||||
|
':(',
|
||||||
|
':-P',
|
||||||
|
':P',
|
||||||
|
':-"',
|
||||||
|
':-"',
|
||||||
|
':-x',
|
||||||
|
':-X',
|
||||||
|
':-D',
|
||||||
|
':D',
|
||||||
|
'8-|',
|
||||||
|
'8-O',
|
||||||
|
':-O',
|
||||||
|
'\\o/',
|
||||||
|
'o.O',
|
||||||
|
'O.o',
|
||||||
|
'\\.../',
|
||||||
|
'\\ooo/',
|
||||||
|
":'(",
|
||||||
|
":-!",
|
||||||
|
":-/",
|
||||||
|
":-[",
|
||||||
|
"8-)",
|
||||||
|
':beer',
|
||||||
|
':homebrew',
|
||||||
|
':coffee',
|
||||||
|
'~friendika',
|
||||||
|
'~friendica',
|
||||||
|
'Diaspora*'
|
||||||
|
);
|
||||||
|
|
||||||
|
$icons = array(
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";)"/>',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";)"/>',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />',
|
||||||
|
@ -702,7 +737,7 @@ function smilies($s) {
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":D"/>',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":D"/>',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" />',
|
||||||
|
@ -715,19 +750,29 @@ function smilies($s) {
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/smiley-cool.gif" alt="8-)" />',
|
'<img src="' . $a->get_baseurl() . '/images/smiley-cool.gif" alt="8-)" />',
|
||||||
|
|
||||||
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":beer" />',
|
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":beer" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />',
|
'<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />',
|
||||||
'<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
|
'<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
|
||||||
|
|
||||||
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
|
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
|
||||||
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendica" /></a>',
|
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendica" /></a>',
|
||||||
'<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
|
'<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
|
||||||
|
|
||||||
), $s);
|
);
|
||||||
|
|
||||||
call_hooks('smilie', $s);
|
$params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
|
||||||
|
call_hooks('smilie', $params);
|
||||||
|
|
||||||
|
if($sample) {
|
||||||
|
$s = '<div class="smiley-sample">';
|
||||||
|
for($x = 0; $x < count($params['texts']); $x ++) {
|
||||||
|
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$s = str_replace($params['texts'],$params['icons'],$params['string']);
|
||||||
|
}
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue