1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

remove incompatible hook= code; replace w/ new support for "SuperModifiers" as designed

by team
This commit is contained in:
mrpete
2007-01-20 16:19:43 +00:00
parent d631950d19
commit 091e68526f
8 changed files with 188 additions and 67 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/download_shortcodes.php,v $
| $Revision: 1.7 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.8 $
| $Date: 2007-01-20 16:09:53 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
@@ -155,7 +155,7 @@ SC_END
SC_BEGIN DOWNLOAD_CATEGORY_DESCRIPTION
global $tp,$dl;
$text = $tp -> toHTML($dl['download_category_description'], TRUE,'hook=description');
$text = $tp -> toHTML($dl['download_category_description'], TRUE,'description');
if($parm){
return substr($text,0,$parm);
}else{
@@ -204,7 +204,7 @@ SC_END
SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION
global $tp, $dl;
$maxlen = ($parm ? intval($parm) : 0);
$text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE, 'hook=description') : "");
$text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE, 'description') : "");
if($maxlen){
return substr($text, 0, $maxlen);
}else{

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/news_shortcodes.php,v $
| $Revision: 1.3 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.4 $
| $Date: 2007-01-20 16:09:53 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
@@ -24,16 +24,16 @@ SC_BEGIN NEWSTITLE
global $tp;
$news_item = getcachedvars('current_news_item');
$param = getcachedvars('current_news_param');
return $tp -> toHTML($news_item['news_title'], TRUE, 'parse_sc,no_hook,emotes_off, no_make_clickable,hook=title');
return $tp -> toHTML($news_item['news_title'], TRUE, 'TITLE');
SC_END
SC_BEGIN NEWSBODY
global $tp;
$news_item = getcachedvars('current_news_item');
$param = getcachedvars('current_news_param');
$news_body = $tp -> toHTML($news_item['news_body'], TRUE, 'parse_sc, fromadmin,hook=content', $news_item['news_author']);
$news_body = $tp -> toHTML($news_item['news_body'], TRUE, 'BODY, fromadmin', $news_item['news_author']);
if($news_item['news_extended'] && (isset($_POST['preview']) || strpos(e_QUERY, 'extend') !== FALSE)) {
$news_extended = $tp -> toHTML($news_item['news_extended'], TRUE, 'parse_sc, fromadmin,hook=content', $news_item['news_author']);
$news_extended = $tp -> toHTML($news_item['news_extended'], TRUE, 'BODY, fromadmin', $news_item['news_author']);
$news_body .= "<br /><br />".$news_extended;
}
return $news_body;

View File

@@ -1,4 +1,4 @@
// $Id: wmessage.sc,v 1.3 2007-01-17 21:29:28 e107steved Exp $
// $Id: wmessage.sc,v 1.4 2007-01-20 16:10:32 mrpete Exp $
$prefwmsc = isset($pref['wmessage_sc']) && $pref['wmessage_sc'];
if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) ){
return;
@@ -59,9 +59,9 @@ if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) ){
{
while ($row = $sql->db_Fetch())
{
$wmessage .= $tp->toHTML($row['gen_chardata'], TRUE, 'parse_sc, defs, hook=content', 'admin')."<br />";
$wmessage .= $tp->toHTML($row['gen_chardata'], TRUE, 'BODY, defs', 'admin')."<br />";
if(!$wmcaption){
$wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'defs, hook=title');
$wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE');
}
}
}

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
| $Revision: 1.4 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.5 $
| $Date: 2007-01-20 16:12:51 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
@@ -28,8 +28,86 @@ class e_parse
var $e_hook;
var $search = array('&#39;', '&#039;', '&quot;', 'onerror', '&gt;', '&amp;#039;', '&amp;quot;');
var $replace = array("'", "'", '"', 'one<i></i>rror', '>', "'", '"');
var $e_highlighting;
var $e_query;
var $e_highlighting; // Set to TRUE or FALSE once it has been calculated
var $e_query; // Highlight query
// toHTML Action defaults. For now these match existing convention.
// Let's reverse the logic on the first set ASAP; too confusing!
var $e_modSet = array();
var $e_optDefault = array(
'context' => 'olddefault', // default context: all "opt-out" conversions :(
'fromadmin' => FALSE,
// Enabled by Default
'value' => FALSE, // Restore entity form of quotes and such to single characters - TRUE disables
'nobreak' => FALSE, // Line break compression - TRUE removes multiple line breaks
'retain_nl' => FALSE, // Retain newlines - wraps to \n instead of <br /> if TRUE
'no_make_clickable' => FALSE, // URLs etc are clickable - TRUE disables
'no_replace' => FALSE, // Replace clickable links - TRUE disables (only if no_make_clickable not set)
'emotes_off' => FALSE, // Convert emoticons to graphical icons - TRUE disables conversion
'emotes_on' => FALSE, // FORCE conversion to emotes, even if syspref is disabled
'no_hook' => FALSE, // Hooked parsers (TRUE disables completely)
// Disabled by Default
'defs' => FALSE, // Convert defines(constants) within text.
'constants' => FALSE, // replace all {e_XXX} constants with their e107 value
'parse_sc' => FALSE // Parse shortcodes - TRUE enables parsing
);
// Super modifiers adjust default option values
// First line of adjustments change default-ON options
// Second line changes default-OFF options
var $e_SuperMods = array(
'title' => //text is part of a title (e.g. news title)
array(
'nobreak'=>TRUE, 'retain_nl'=>TRUE, 'no_make_clickable'=>TRUE,'emotes_off'=>TRUE,'no_hook'=>TRUE,
'defs'=>TRUE,'parse_sc'=>TRUE),
'summary' => // text is part of the summary of a longer item (e.g. content summary)
array(
// no changes to default-on items
'defs'=>TRUE, 'constants'=>TRUE, 'parse_sc'=>TRUE),
'description' => // text is the description of an item (e.g. download, link)
array(
// no changes to default-on items
'defs'=>TRUE, 'constants'=>TRUE, 'parse_sc'=>TRUE),
'body' => // text is 'body' or 'bulk' text (e.g. custom page body, content body)
array(
// no changes to default-on items
'defs'=>TRUE, 'constants'=>TRUE, 'parse_sc'=>TRUE),
'linktext' => // text is the 'content' of a link (A tag, etc)
array(
'nobreak'=>TRUE, 'retain_nl'=>TRUE, 'no_make_clickable'=>TRUE,'emotes_off'=>TRUE,'no_hook'=>TRUE,
'defs'=>TRUE,'parse_sc'=>TRUE),
'rawtext' => // text is used (for admin edit) without fancy conversions
array(
'nobreak'=>TRUE, 'retain_nl'=>TRUE, 'no_make_clickable'=>TRUE,'emotes_off'=>TRUE,'no_hook'=>TRUE,
// leave opt-in options off
)
);
function e_parse()
{
// Preprocess the supermods to be useful default arrays with all values
foreach ($this->e_SuperMods as $key=>$val)
{
$this->e_SuperMods[$key] = array_merge($this->e_optDefault,$this->e_SuperMods[$key]); // precalculate super defaults
$this->e_SuperMods[$key]['context']=$key;
}
foreach ($this->e_optDefault as $key=>$val)
{
$this->e_modSet[$key] = TRUE;
}
}
function toDB($data, $nostrip = false, $no_encode = false, $original_author = false, $mod = false)
{
@@ -301,38 +379,73 @@ class e_parse
}
global $pref, $fromadmin;
// Set defaults for options
$opts = array(
'fromadmin' => FALSE,
'defs' => FALSE, // support for converting defines(constants) within text.
'constants' => FALSE, // replace all {e_XXX} constants with their e107 value
'nobreak' => FALSE, // Line break compression - TRUE removes multiple line breaks
'retain_nl' => FALSE, // Retain newlines - wraps to \n instead of <br /> if TRUE
'no_make_clickable' => FALSE, // URLs etc are clickable - TRUE disables
'no_replace' => FALSE, // Replace clickable links - TRUE disables (only if no_make_clickable not set)
'do_hook' => FALSE, // Tentative option to force hooking when TRUE (area is null string)
'no_hook' => FALSE, // Deprecated - TRUE disables hooked parsers
'hook' => '', // Generic 'set text area for hooked parser' option
'emotes_off' => FALSE, // Convert emoticons to graphical icons - TRUE disables conversion
'emotes_on' => FALSE, // Force conversion to emotes if TRUE (overridden by 'emotes_off')
'value' => FALSE, // Restore entity form of quotes and such to single characters - TRUE disables
'parse_sc' => FALSE // Parse shortcodes - TRUE enables parsing
//
// SET MODIFIERS
//
// Get modifier strings for toHTML
// "super" modifiers set a baseline. Recommend entering in UPPER CASE to highlight
// other modifiers override
// modifiers SHOULD be delimited with commas (eventually this will be 'MUST')
// modifiers MAY have spaces in between as desired
$opts = $this->e_optDefault;
if (strlen($modifiers))
{
//
// Yes, the following code is strangely-written. It is one of the MOST used bits in
// all of e107. We "inlined" the assignments to optimize speed through
// some careful testing (19 Jan 2007).
//
// Some alternatives that do NOT speed things up (they make it slower)
// - use of array_intersect, array_walk, preg_replace, intermediate variables, etc etc etc.
//
if (1) // php 4 code
{
$opts = $this->e_optDefault;
$aMods = explode( ',',
// convert blanks to comma, then comma-comma (from blank-comma) to single comma
str_replace(array(' ', ',,'), array(',', ',' ),
// work with all lower case
strtolower($modifiers)
)
);
// Now decode options from any modifiers set
foreach (explode(',',$modifiers) as $t)
foreach ($aMods as $mod)
{
$t = trim($t); // Allow for spaces after commas in the list
$tval = TRUE;
if (strpos($t,'=') !== FALSE) list($t,$tval) = explode('=',$t,2);
if (array_key_exists($t,$opts)) $opts[$t] = $tval;
if (isset($this->e_SuperMods[$mod]))
{
$opts = $this->e_SuperMods[$mod];
}
}
// Find any regular mods
foreach ($aMods as $mod)
{
$opts[$mod] = TRUE; // Change mods as spec'd
}
}
if (0) // php 5 code - not tested, and may not be faster anyway
{
$aMods = array_flip(
explode( ',',
// convert blanks to comma, then comma-comma (from blank-comma) to single comma
str_replace(array(' ', ',,'), array(',', ',' ),
// work with all lower case
strtolower($modifiers)
)
)
);
$opts = array_merge($opts, array_intersect_key($this->e_SuperMods,$aMods)); // merge in any supermods found
$opts = array_merge($opts, array_intersect_key($this->modSet, $aMods)); // merge in any other mods found
}
}
// $fromadmin = strpos($modifiers, "fromadmin");
$fromadmin = $opts['fromadmin'];
// support for converting defines(constants) within text. eg. Lan_XXXX - must be the entire text string (i.e. not embedded)
// Convert defines(constants) within text. eg. Lan_XXXX - must be the entire text string (i.e. not embedded)
// if(strpos($modifiers,"defs") !== FALSE && strlen($text) < 25 && defined(trim($text)))
if ($opts['defs'] && (strlen($text) < 25) && defined(trim($text)))
{
@@ -459,7 +572,7 @@ class e_parse
//Run any hooked in parsers
if ((($opts['hook'] != '') || $opts['do_hook']) && !$opts['no_hook'] && isset($pref['tohtml_hook']) && $pref['tohtml_hook'])
if (!$opts['no_hook'] && varset($pref['tohtml_hook']))
{
foreach(explode(",",$pref['tohtml_hook']) as $hook)
{
@@ -469,7 +582,7 @@ class e_parse
$hook_class = "e_".$hook;
$this->e_hook[$hook] = new $hook_class;
}
$text = $this->e_hook[$hook]->$hook($text,$opts['hook']);
$text = $this->e_hook[$hook]->$hook($text,$opts['context']);
}
}
@@ -568,7 +681,10 @@ class e_parse
// "full" = produce absolute URL path, e.g. http://sitename.com/e107_plugins/etc
// TRUE = produce truncated URL path, e.g. e107plugins/etc
// "" (default) = URL's get relative path e.g. ../e107_plugins/etc
// AND all other e107 constants are replaced
//
// $all - if TRUE, then
// when $nonrelative is "full" or TRUE, USERID is also replaced...
// when $nonrelative is "" (default), ALL other e107 constants are replaced
//
// only an ADMIN user can convert {e_ADMIN}
//
@@ -585,6 +701,11 @@ class e_parse
$replace_absolute[] = SITEURL.$ADMIN_DIRECTORY;
$search[] = "{e_ADMIN}";
}
if ($all) {
$replace_relative[] = USERID;
$replace_absolute[] = USERID;
$search[] = "{USERID}";
}
$replace = ((string)$nonrelative == "full" ) ? $replace_absolute : $replace_relative;
return str_replace($search,$replace,$text);
}
@@ -635,7 +756,7 @@ class e_parse
$len = strlen($val);
if(substr($url,0,$len) == $val)
{
return str_replace($val,$key,$url);
return substr_replace($url,$key,0,$len); // replace the first instance only
}
}

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chat.php,v $
| $Revision: 1.2 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2007-01-20 16:16:42 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
require_once("../../class2.php");
@@ -111,7 +111,7 @@ foreach ($chatList as $row)
{
$CHAT_TABLE_DATESTAMP = $obj2->convert_date($row['cb_datestamp'], "long");
$CHAT_TABLE_NICK = preg_replace("/[0-9]+\./", "", $row['cb_nick']);
$cb_message = $tp->toHTML($row['cb_message'], TRUE,'hook=content');
$cb_message = $tp->toHTML($row['cb_message'], TRUE,'BODY');
if($row['cb_blocked'])
{
$cb_message .= "<br />".CHATBOX_L25;

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chatbox_menu.php,v $
| $Revision: 1.4 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.5 $
| $Date: 2007-01-20 16:16:42 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
@@ -196,7 +196,7 @@ if(!$text = $e107cache->retrieve("nq_chatbox"))
$datestamp = $obj2->convert_date($cb['cb_datestamp'], "short");
if(!$pref['cb_wordwrap']) { $pref['cb_wordwrap'] = 30; }
$emotes_active = $pref['cb_emote'] ? 'emotes_on, hook=content' : 'emotes_off, hook=content';
$emotes_active = $pref['cb_emote'] ? 'BODY, emotes_on' : 'BODY, emotes_off';
$cb_message = $tp -> toHTML($cb['cb_message'], FALSE, $emotes_active, $cb_uid, $pref['menu_wordwrap']);

View File

@@ -12,9 +12,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $
| $Revision: 1.5 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.6 $
| $Date: 2007-01-20 16:19:22 $
| $Author: mrpete $
+---------------------------------------------------------------+
*/
@@ -1282,7 +1282,7 @@ function show_content_item(){
}
if($idp==1){
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "hook=summary") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "SUMMARY") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY);
}else{
$CONTENT_CONTENT_TABLE_SUMMARY = "";
@@ -1307,13 +1307,13 @@ function show_content_item(){
}
}else{
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "hook=summary") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "SUMMARY") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY);
$lastpage = TRUE;
}
$CONTENT_CONTENT_TABLE_TEXT = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_TEXT);
$CONTENT_CONTENT_TABLE_TEXT = $tp -> toHTML($CONTENT_CONTENT_TABLE_TEXT, TRUE, "hook=content");
$CONTENT_CONTENT_TABLE_TEXT = $tp -> toHTML($CONTENT_CONTENT_TABLE_TEXT, TRUE, "BODY");
$custom = $eArrayStorage->ReadArray($row['content_pref']);

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox.php,v $
| $Revision: 1.2 $
| $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2007-01-20 16:19:43 $
| $Author: mrpete $
+----------------------------------------------------------------------------+
*/
@@ -50,8 +50,8 @@ else
}
$fbcc = $fb_title;
$fb_title = $tp -> toHTML($fb_title, TRUE,'hook=title');
$fb_text = $tp -> toHTML($fb_text, TRUE,'hook=content');
$fb_title = $tp -> toHTML($fb_title, TRUE,'title');
$fb_text = $tp -> toHTML($fb_text, TRUE,'body');
if(!$fb_rendertype)
{
$ns -> tablerender($fb_title, $fb_text, 'featurebox');