mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 05:07:27 +02:00
Emoticons now have their own css class. Improved emoticon code detection.
This commit is contained in:
@@ -4615,12 +4615,13 @@ return $html;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class e_emotefilter {
|
class e_emotefilter
|
||||||
var $search;
|
{
|
||||||
var $replace;
|
private $search;
|
||||||
var $emotes;
|
private $replace;
|
||||||
|
private $emotes;
|
||||||
|
|
||||||
function __construct() /* constructor */
|
function __construct()
|
||||||
{
|
{
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
|
|
||||||
@@ -4633,28 +4634,46 @@ class e_emotefilter {
|
|||||||
|
|
||||||
$this->emotes = e107::getConfig("emote")->getPref();
|
$this->emotes = e107::getConfig("emote")->getPref();
|
||||||
|
|
||||||
if(!vartrue($this->emotes))
|
if(empty($this->emotes))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->emotes as $key => $value)
|
foreach($this->emotes as $key => $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
if ($value)
|
if ($value)
|
||||||
{ // Only 'activate' emote if there's a substitution string set
|
{ // Only 'activate' emote if there's a substitution string set
|
||||||
|
|
||||||
|
|
||||||
$key = preg_replace("#!(\w{3,}?)$#si", ".\\1", $key);
|
$key = preg_replace("#!(\w{3,}?)$#si", ".\\1", $key);
|
||||||
// Next two probably to sort out legacy issues - may not be required any more
|
// Next two probably to sort out legacy issues - may not be required any more
|
||||||
$key = preg_replace("#_(\w{3})$#", ".\\1", $key);
|
// $key = preg_replace("#_(\w{3})$#", ".\\1", $key);
|
||||||
$key = str_replace("!", "_", $key);
|
|
||||||
|
$key = str_replace("!", "_", $key);
|
||||||
|
|
||||||
$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key;
|
$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key;
|
||||||
|
|
||||||
$fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;
|
$fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;
|
||||||
|
|
||||||
|
$alt = str_replace(array('.png','.gif', '.jpg'),'', $key);
|
||||||
|
|
||||||
if(file_exists($filename))
|
if(file_exists($filename))
|
||||||
{
|
{
|
||||||
|
$tmp = explode(" ", $value);
|
||||||
|
foreach($tmp as $code)
|
||||||
|
{
|
||||||
|
$img = "<img class='e-emoticon' src='".$fileloc."' alt=\"".$alt."\" />";
|
||||||
|
$this->regSearch[] = "/(^|[\s>])(".quotemeta($code).")($|[\s<])/";
|
||||||
|
$this->regReplace[] ="$1".$img."$3";
|
||||||
|
$this->search[] = $code;
|
||||||
|
$this->replace[] = $img;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if(strstr($value, " "))
|
if(strstr($value, " "))
|
||||||
{
|
{
|
||||||
$tmp = explode(" ", $value);
|
$tmp = explode(" ", $value);
|
||||||
@@ -4662,9 +4681,9 @@ class e_emotefilter {
|
|||||||
{
|
{
|
||||||
$this->search[] = " ".$code;
|
$this->search[] = " ".$code;
|
||||||
$this->search[] = "\n".$code;
|
$this->search[] = "\n".$code;
|
||||||
//TODO CSS class?
|
|
||||||
$this->replace[] = " <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
$this->replace[] = " <img class='e-emoticon' src='".$fileloc."' alt=\"".$alt."\" /> ";
|
||||||
$this->replace[] = "\n <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
$this->replace[] = "\n <img class='e-emoticon' src='".$fileloc."'alt=\"".$alt."\" /> ";
|
||||||
}
|
}
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
@@ -4674,32 +4693,36 @@ class e_emotefilter {
|
|||||||
{
|
{
|
||||||
$this->search[] = " ".$value;
|
$this->search[] = " ".$value;
|
||||||
$this->search[] = "\n".$value;
|
$this->search[] = "\n".$value;
|
||||||
//TODO CSS class?
|
|
||||||
$this->replace[] = " <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
$this->replace[] = " <img class='e-emoticon' src='".$fileloc."' alt=\"".$alt."\" /> ";
|
||||||
$this->replace[] = "\n <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
$this->replace[] = "\n <img class='e-emoticon' src='".$fileloc."' alt=\"".$alt."\" /> ";
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unset($this->emotes[$key]);
|
unset($this->emotes[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function filterEmotes($text)
|
function filterEmotes($text)
|
||||||
{
|
{
|
||||||
$text = str_replace($this->search, $this->replace, $text);
|
return preg_replace($this->regSearch,$this->regReplace,$text);
|
||||||
return $text;
|
//$text = str_replace($this->search, $this->replace, $text);
|
||||||
|
//return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function filterEmotesRev($text)
|
function filterEmotesRev($text)
|
||||||
{
|
{
|
||||||
$text = str_replace($this->replace, $this->search, $text);
|
return str_replace($this->replace, $this->search, $text);
|
||||||
return $text;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -321,4 +321,7 @@ optgroup.level-5 { padding-left:4em }
|
|||||||
.online-menu-extended li, .online-menu li ul li { min-height: 40px; padding-top:8px}
|
.online-menu-extended li, .online-menu li ul li { min-height: 40px; padding-top:8px}
|
||||||
.online-menu-extended ul { padding-bottom:20px}
|
.online-menu-extended ul { padding-bottom:20px}
|
||||||
.online-menu-extended span.online-menu-user { display:block; font-size:1.1em;margin-top:4px; line-height:1}
|
.online-menu-extended span.online-menu-user { display:block; font-size:1.1em;margin-top:4px; line-height:1}
|
||||||
.online-menu-extended-label { font-size:1.2em; }
|
.online-menu-extended-label { font-size:1.2em; }
|
||||||
|
|
||||||
|
/* Emoticons */
|
||||||
|
img.e-emoticon { vertical-align:middle; border:0; width:24px }
|
Reference in New Issue
Block a user