1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Consolidate parsing classes into single file.

This commit is contained in:
Cameron
2013-05-20 17:10:38 -07:00
parent e55b3cbbd9
commit 4581b9986c
13 changed files with 234 additions and 53 deletions

View File

@@ -4,16 +4,12 @@
| e107 website system | e107 website system
| |
| Copyright (C) 2001-2002 Steve Dunstan (jalist@e107.org) | Copyright (C) 2001-2002 Steve Dunstan (jalist@e107.org)
| Copyright (C) 2008-2010 e107 Inc (e107.org) | Copyright (C) 2008-2013 e107 Inc (e107.org)
| |
| |
| Released under the terms and conditions of the | Released under the terms and conditions of the
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.7/e107_handlers/emote.php $
| $Revision: 11678 $
| $Id: emote.php 11678 2010-08-22 00:43:45Z e107coders $
| $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */

View File

@@ -3,13 +3,15 @@ $class = e107::getBB()->getClass('code');
global $pref, $e107cache, $tp; global $pref, $e107cache;
$tp = e107::getParser();
if($pref['smiley_activate']) if($pref['smiley_activate'])
{ {
if (!is_object($tp->e_emote)) if (!is_object($tp->e_emote))
{ {
require_once(e_HANDLER.'emote_filter.php'); // require_once(e_HANDLER.'emote_filter.php');
$tp->e_emote = new e_emoteFilter; $tp->e_emote = new e_emoteFilter;
} }
$code_text = $tp->e_emote->filterEmotesRev($code_text); $code_text = $tp->e_emote->filterEmotesRev($code_text);

View File

@@ -1,5 +1,5 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Copyright (C) 2008-2009 e107 Inc (e107.org)
@@ -7,11 +7,7 @@
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* Administration UI handlers, admin helper functions * Administration UI handlers, admin helper functions
* * @DEPRECATED FILE
* $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $
* $Revision$
* $Date$
* $Author$
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }

View File

@@ -1,5 +1,5 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Copyright (C) 2008-2009 e107 Inc (e107.org)
@@ -9,19 +9,23 @@
* *
* $URL$ * $URL$
* $Id$ * $Id$
* @DEPRECATED FILE
*/ */
if (!defined('e107_INIT')) if (!defined('e107_INIT'))
{ {
exit; exit;
} }
/**
* @DEPRECATED
* Use e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true); instead.
*/
function avatar($avatar) function avatar($avatar)
{ {
return e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true); return e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true);
/*
global $tp; global $tp;
if (stristr($avatar, '-upload-') !== false) if (stristr($avatar, '-upload-') !== false)
{ {
@@ -43,6 +47,7 @@ function avatar($avatar)
{ {
return $avatar; return $avatar;
} }
*/
} }
?> ?>

View File

@@ -260,6 +260,44 @@ if (!function_exists('asortbyindex'))
} }
} }
if (!function_exists('r_emote'))
{
/**
* @DEPRECATED
*/
function r_emote()
{
global $sysprefs, $pref;
$tp = e107::getParser();
if (!is_object($tp->e_emote))
{
// require_once(e_HANDLER.'emote_filter.php');
$tp->e_emote = new e_emoteFilter;
}
$str = '';
foreach($tp->e_emote->emotes as $key => $value) // filename => text code
{
$key = str_replace("!", ".", $key); // Usually '.' was replaced by '!' when saving
$key = preg_replace("#_(\w{3})$#", ".\\1", $key); // '_' followed by exactly 3 chars is file extension
$key = e_IMAGE."emotes/" . $pref['emotepack'] . "/" .$key; // Add in the file path
$value2 = substr($value, 0, strpos($value, " "));
$value = ($value2 ? $value2 : $value);
$value = ($value == '&|') ? ':((' : $value;
$value = " ".$value." ";
//TODO CSS class
$str .= "\n<a href=\"javascript:addtext('$value',true)\"><img src='$key' alt='' /></a> ";
}
return "<div class='spacer'>".$str."</div>";
}
}
if (!function_exists('multiarray_sort')) if (!function_exists('multiarray_sort'))
{ {

View File

@@ -1273,7 +1273,9 @@ class e_parse extends e_parser
return $text; return $text;
} }
global $pref, $fromadmin; $pref = e107::getPref();
global $fromadmin;
// Set default modifiers to start // Set default modifiers to start
$opts = $this->e_optDefault; $opts = $this->e_optDefault;
@@ -1570,7 +1572,7 @@ class e_parse extends e_parser
{ {
if (!is_object($this->e_emote)) if (!is_object($this->e_emote))
{ {
require_once(e_HANDLER.'emote_filter.php'); // require_once(e_HANDLER.'emote_filter.php');
$this->e_emote = new e_emoteFilter; $this->e_emote = new e_emoteFilter;
} }
$sub_blk = $this->e_emote->filterEmotes($sub_blk); $sub_blk = $this->e_emote->filterEmotes($sub_blk);
@@ -1655,7 +1657,7 @@ class e_parse extends e_parser
{ {
if (!is_object($this->e_pf)) if (!is_object($this->e_pf))
{ {
require_once(e_HANDLER."profanity_filter.php"); // require_once(e_HANDLER."profanity_filter.php");
$this->e_pf = new e_profanityFilter; $this->e_pf = new e_profanityFilter;
} }
$sub_blk = $this->e_pf->filterProfanities($sub_blk); $sub_blk = $this->e_pf->filterProfanities($sub_blk);
@@ -2901,3 +2903,151 @@ return $html;
} }
class e_emotefilter {
var $search;
var $replace;
var $emotes;
function e_emotefilter() /* constructor */
{
$pref = e107::getPref();
if(!$pref['emotepack'])
{
$pref['emotepack'] = "default";
save_prefs();
}
$this->emotes = e107::getConfig("emote")->getPref();
if(!vartrue($this->emotes))
{
return;
}
foreach($this->emotes as $key => $value)
{
$value = trim($value);
if ($value)
{ // Only 'activate' emote if there's a substitution string set
$key = preg_replace("#!(\w{3,}?)$#si", ".\\1", $key);
// Next two probably to sort out legacy issues - may not be required any more
$key = preg_replace("#_(\w{3})$#", ".\\1", $key);
$key = str_replace("!", "_", $key);
$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key;
$fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;
if(file_exists($filename))
{
if(strstr($value, " "))
{
$tmp = explode(" ", $value);
foreach($tmp as $code)
{
$this->search[] = " ".$code;
$this->search[] = "\n".$code;
//TODO CSS class?
$this->replace[] = " <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
$this->replace[] = "\n <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
}
unset($tmp);
}
else
{
if($value)
{
$this->search[] = " ".$value;
$this->search[] = "\n".$value;
//TODO CSS class?
$this->replace[] = " <img src='".$filename."' alt='' style='vertical-align:middle; border:0' /> ";
$this->replace[] = "\n <img src='".$filename."' alt='' style='vertical-align:middle; border:0' /> ";
}
}
}
}
else
{
unset($this->emotes[$key]);
}
}
}
function filterEmotes($text)
{
$text = str_replace($this->search, $this->replace, $text);
return $text;
}
function filterEmotesRev($text)
{
$text = str_replace($this->replace, $this->search, $text);
return $text;
}
}
class e_profanityFilter
{
var $profanityList;
function e_profanityFilter()
{
global $pref;
$words = explode(",", $pref['profanity_words']);
$word_array = array();
foreach($words as $word)
{
$word = trim($word);
if($word != "")
{
$word_array[] = $word;
if (strpos($word, '&#036;') !== FALSE)
{
$word_array[] = str_replace('&#036;', '\$', $word); // Special case - '$' may be 'in clear' or as entity
}
}
}
if(count($word_array))
{
$this->profanityList = str_replace('#','\#',implode("\b|\b", $word_array)); // We can get entities in the string - confuse the regex delimiters
}
unset($words);
return TRUE;
}
function filterProfanities($text)
{
global $pref;
if (!$this->profanityList)
{
return $text;
}
if ($pref['profanity_replace'])
{
return preg_replace("#\b".$this->profanityList."\b#is", $pref['profanity_replace'], $text);
}
else
{
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);
}
}
function replaceProfanities($matches)
{
/*!
@function replaceProfanities callback
@abstract replaces vowels in profanity words with stars
@param text string - text string to be filtered
@result filtered text
*/
return preg_replace("#a|e|i|o|u#i", "*" , $matches[0]);
}
}

View File

@@ -1,21 +1,16 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* * @DEPRECATED FILE
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/emote.php,v $
* $Revision$
* $Date$
* $Author$
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
/*
function r_emote() function r_emote()
{ {
global $sysprefs, $pref, $tp; global $sysprefs, $pref, $tp;
@@ -43,5 +38,5 @@ function r_emote()
return "<div class='spacer'>".$str."</div>"; return "<div class='spacer'>".$str."</div>";
} }
*/
?> ?>

View File

@@ -1,27 +1,23 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2009 e107 Inc (e107.org) * Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* * @DEPRECATED FILE
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/emote_filter.php,v $
* $Revision$
* $Date$
* $Author$
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
/*
class e_emotefilter { class e_emotefilter {
var $search; var $search;
var $replace; var $replace;
var $emotes; var $emotes;
function e_emotefilter() /* constructor */ function e_emotefilter()
{ {
$pref = e107::getPref(); $pref = e107::getPref();
@@ -101,6 +97,9 @@ class e_emotefilter {
} }
} }
*/

View File

@@ -1,20 +1,17 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2011 e107 Inc (e107.org) * Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* * @DEPRECATED FILE
*
* $URL$
* $Revision$
* $Id$
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
/*
class e_profanityFilter class e_profanityFilter
{ {
var $profanityList; var $profanityList;
@@ -61,18 +58,21 @@ class e_profanityFilter
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text); return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);
} }
} }
*
function replaceProfanities($matches) *
{ // @function replaceProfanities callback
/*!
@function replaceProfanities callback
@abstract replaces vowels in profanity words with stars @abstract replaces vowels in profanity words with stars
@param text string - text string to be filtered @param text string - text string to be filtered
@result filtered text @result filtered text
*/
function replaceProfanities($matches)
{
return preg_replace("#a|e|i|o|u#i", "*" , $matches[0]); return preg_replace("#a|e|i|o|u#i", "*" , $matches[0]);
} }
} }
*/
?> ?>

View File

@@ -314,7 +314,7 @@ function PreFile_Select($formid='prefile_selector')
} }
function Emoticon_Select($formid='emoticon_selector') { function Emoticon_Select($formid='emoticon_selector') {
require_once(e_HANDLER."emote.php"); // require_once(e_HANDLER."emote.php");
$text ="<!-- Start of Emoticon selector --> $text ="<!-- Start of Emoticon selector -->
<div style='margin-left:0px;margin-right:0px; position:relative;z-index:1000;float:right;display:none' id='{$formid}' onclick=\"this.style.display='none'\" > <div style='margin-left:0px;margin-right:0px; position:relative;z-index:1000;float:right;display:none' id='{$formid}' onclick=\"this.style.display='none'\" >
<div style='position:absolute; bottom:30px; right:75px; width:221px; height:133px; overflow:auto;'> <div style='position:absolute; bottom:30px; right:75px; width:221px; height:133px; overflow:auto;'>

View File

@@ -54,7 +54,7 @@ if(($pref['cb_layer']==2) || isset($_POST['chatbox_ajax']))
*/ */
// if(!defined('e_HANDLER')){ exit; } // if(!defined('e_HANDLER')){ exit; }
require_once(e_HANDLER.'emote.php'); // require_once(e_HANDLER.'emote.php');
$emessage=''; $emessage='';

View File

@@ -571,7 +571,7 @@ class listclass
$tp = e107::getParser(); $tp = e107::getParser();
if (!is_object($parser->e_pf)) if (!is_object($parser->e_pf))
{ {
require_once(e_HANDLER.'profanity_filter.php'); // require_once(e_HANDLER.'profanity_filter.php');
$parser->e_pf = new e_profanityFilter; $parser->e_pf = new e_profanityFilter;
} }
foreach ($listArray as $k => $v) foreach ($listArray as $k => $v)

View File

@@ -174,7 +174,7 @@ class pm_shortcodes extends e_shortcode
public function sc_pm_emotes() public function sc_pm_emotes()
{ {
require_once(e_HANDLER.'emote.php'); // require_once(e_HANDLER.'emote.php');
return r_emote(); return r_emote();
} }