mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
add a few comments
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
* Text processing and parsing functions
|
* Text processing and parsing functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
||||||
* $Revision: 1.78 $
|
* $Revision: 1.79 $
|
||||||
* $Date: 2009-10-30 23:38:14 $
|
* $Date: 2009-11-12 21:41:34 $
|
||||||
* $Author: e107steved $
|
* $Author: marj_nl_fr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('e107_INIT')) { exit(); }
|
if (!defined('e107_INIT')) { exit(); }
|
||||||
@@ -461,6 +461,7 @@ class e_parse
|
|||||||
* @param boolean $mod [optional] The 'no_html' and 'no_php' modifiers blanket prevent HTML and PHP posting regardless of posting permissions. (used in logging)
|
* @param boolean $mod [optional] The 'no_html' and 'no_php' modifiers blanket prevent HTML and PHP posting regardless of posting permissions. (used in logging)
|
||||||
* @param boolean $original_author [optional]
|
* @param boolean $original_author [optional]
|
||||||
* @return string
|
* @return string
|
||||||
|
* @todo complete the documentation of this essential method
|
||||||
*/
|
*/
|
||||||
public function toDB($data, $nostrip = FALSE, $no_encode = FALSE, $mod = FALSE, $original_author = FALSE)
|
public function toDB($data, $nostrip = FALSE, $no_encode = FALSE, $mod = FALSE, $original_author = FALSE)
|
||||||
{
|
{
|
||||||
@@ -768,8 +769,8 @@ class e_parse
|
|||||||
* Truncate a HTML string to a maximum length $len append the string $more if it was truncated
|
* Truncate a HTML string to a maximum length $len append the string $more if it was truncated
|
||||||
*
|
*
|
||||||
* @param string $text String to process
|
* @param string $text String to process
|
||||||
* @param integer $len Length of characters to be truncated
|
* @param integer $len [optional] Length of characters to be truncated - default 200
|
||||||
* @param string $more String which will be added if truncation
|
* @param string $more [optional] String which will be added if truncation - default ' ... '
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function html_truncate ($text, $len = 200, $more = ' ... ')
|
public function html_truncate ($text, $len = 200, $more = ' ... ')
|
||||||
@@ -862,7 +863,9 @@ class e_parse
|
|||||||
{
|
{
|
||||||
// Always valid
|
// Always valid
|
||||||
if(strlen($text) <= $len)
|
if(strlen($text) <= $len)
|
||||||
|
{
|
||||||
return $text;
|
return $text;
|
||||||
|
}
|
||||||
/* shouldn't be needed
|
/* shouldn't be needed
|
||||||
if (strtolower(CHARSET) !== 'utf-8')
|
if (strtolower(CHARSET) !== 'utf-8')
|
||||||
{
|
{
|
||||||
@@ -878,7 +881,9 @@ class e_parse
|
|||||||
$text, $matches);
|
$text, $matches);
|
||||||
// return if utf-8 length is less than max as well
|
// return if utf-8 length is less than max as well
|
||||||
if (empty($matches[2]))
|
if (empty($matches[2]))
|
||||||
|
{
|
||||||
return $text;
|
return $text;
|
||||||
|
}
|
||||||
$ret = $matches[1];
|
$ret = $matches[1];
|
||||||
}
|
}
|
||||||
// search for possible broken html entities
|
// search for possible broken html entities
|
||||||
@@ -886,7 +891,9 @@ class e_parse
|
|||||||
// it should work for any characters encoding
|
// it should work for any characters encoding
|
||||||
$leftAmp = strrpos(substr($ret, -8), '&');
|
$leftAmp = strrpos(substr($ret, -8), '&');
|
||||||
if($leftAmp)
|
if($leftAmp)
|
||||||
|
{
|
||||||
$ret = substr($ret, 0, strlen($ret) - 8 + $leftAmp);
|
$ret = substr($ret, 0, strlen($ret) - 8 + $leftAmp);
|
||||||
|
}
|
||||||
|
|
||||||
return $ret.$more;
|
return $ret.$more;
|
||||||
}
|
}
|
||||||
@@ -941,11 +948,14 @@ class e_parse
|
|||||||
* @param mixed $postID [optional]
|
* @param mixed $postID [optional]
|
||||||
* @param boolean $wrap [optional]
|
* @param boolean $wrap [optional]
|
||||||
* @return string
|
* @return string
|
||||||
|
* @todo complete the documentation of this essential method
|
||||||
*/
|
*/
|
||||||
public function toHTML($text, $parseBB = FALSE, $modifiers = "", $postID = "", $wrap = FALSE)
|
public function toHTML($text, $parseBB = FALSE, $modifiers = '', $postID = "", $wrap = FALSE)
|
||||||
{
|
{
|
||||||
if($text == '')
|
if($text == '')
|
||||||
|
{
|
||||||
return $text;
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
global $pref, $fromadmin;
|
global $pref, $fromadmin;
|
||||||
|
|
||||||
@@ -989,17 +999,24 @@ class e_parse
|
|||||||
|
|
||||||
// Turn off a few things if not enabled in options
|
// Turn off a few things if not enabled in options
|
||||||
if(!varsettrue($pref['smiley_activate']))
|
if(!varsettrue($pref['smiley_activate']))
|
||||||
|
{
|
||||||
$opts['emotes'] = FALSE;
|
$opts['emotes'] = FALSE;
|
||||||
|
}
|
||||||
if(!varsettrue($pref['make_clickable']))
|
if(!varsettrue($pref['make_clickable']))
|
||||||
|
{
|
||||||
$opts['link_click'] = FALSE;
|
$opts['link_click'] = FALSE;
|
||||||
|
}
|
||||||
if(!varsettrue($pref['link_replace']))
|
if(!varsettrue($pref['link_replace']))
|
||||||
|
{
|
||||||
$opts['link_replace'] = FALSE;
|
$opts['link_replace'] = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$fromadmin = $opts['fromadmin'];
|
$fromadmin = $opts['fromadmin'];
|
||||||
|
|
||||||
// Convert 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)
|
||||||
// The check for '::' is a workaround for a bug in the Zend Optimiser 3.3.0 and PHP 5.2.4 combination
|
// The check for '::' is a workaround for a bug in the Zend Optimiser 3.3.0 and PHP 5.2.4 combination
|
||||||
// - causes crashes if '::' in site name
|
// - causes crashes if '::' in site name
|
||||||
|
//TODO - marj - find a way to use language method here XOR remove the limit of 24 characters.
|
||||||
if($opts['defs'] && (strlen($text) < 25) && ((strpos($text, '::') === FALSE) && defined(trim($text))))
|
if($opts['defs'] && (strlen($text) < 25) && ((strpos($text, '::') === FALSE) && defined(trim($text))))
|
||||||
{
|
{
|
||||||
return constant(trim($text));
|
return constant(trim($text));
|
||||||
@@ -1076,7 +1093,10 @@ class e_parse
|
|||||||
switch ($matches[2])
|
switch ($matches[2])
|
||||||
{
|
{
|
||||||
case 'php' :
|
case 'php' :
|
||||||
if (DB_INF_SHOW) echo "PHP decode: ".htmlentities($matches[4])."<br /><br />";
|
if (DB_INF_SHOW)
|
||||||
|
{
|
||||||
|
echo "PHP decode: ".htmlentities($matches[4])."<br /><br />";
|
||||||
|
}
|
||||||
|
|
||||||
// Probably run the output through the normal processing functions - but put here so the PHP code can disable if desired
|
// Probably run the output through the normal processing functions - but put here so the PHP code can disable if desired
|
||||||
$proc_funcs = TRUE;
|
$proc_funcs = TRUE;
|
||||||
@@ -1089,20 +1109,28 @@ class e_parse
|
|||||||
// if (!$matches[3]) $bbcode = str_replace($search, $replace, $matches[4]);
|
// if (!$matches[3]) $bbcode = str_replace($search, $replace, $matches[4]);
|
||||||
// Because we're bypassing most of the initial parser processing, we should be able to just reverse the effects of toDB() and execute the code
|
// Because we're bypassing most of the initial parser processing, we should be able to just reverse the effects of toDB() and execute the code
|
||||||
if (!$matches[3])
|
if (!$matches[3])
|
||||||
|
{
|
||||||
$bbcode = html_entity_decode($matches[4], ENT_QUOTES, 'UTF-8');
|
$bbcode = html_entity_decode($matches[4], ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
if (DB_INF_SHOW)
|
if (DB_INF_SHOW)
|
||||||
|
{
|
||||||
echo "PHP after decode: ".htmlentities($bbcode)."<br /><br />";
|
echo "PHP after decode: ".htmlentities($bbcode)."<br /><br />";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'html' :
|
case 'html' :
|
||||||
$proc_funcs = TRUE;
|
$proc_funcs = TRUE;
|
||||||
$convertNL = FALSE;
|
$convertNL = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'hide' :
|
case 'hide' :
|
||||||
$proc_funcs = TRUE;
|
$proc_funcs = TRUE;
|
||||||
|
|
||||||
default : // Most bbcodes will just execute their normal file
|
default : // Most bbcodes will just execute their normal file
|
||||||
// Just read in the code file and execute it
|
// Just read in the code file and execute it
|
||||||
$bbcode = file_get_contents($bbFile);
|
$bbcode = file_get_contents($bbFile);
|
||||||
} // end - switch ($matches[2])
|
} // end - switch ($matches[2])
|
||||||
|
|
||||||
if ($bbcode)
|
if ($bbcode)
|
||||||
{ // Execute the file
|
{ // Execute the file
|
||||||
ob_start();
|
ob_start();
|
||||||
@@ -1143,7 +1171,9 @@ class e_parse
|
|||||||
{
|
{
|
||||||
// Its a style block - just pass it through unaltered - except, do we need the line break stuff? - QUERY XXX-01
|
// Its a style block - just pass it through unaltered - except, do we need the line break stuff? - QUERY XXX-01
|
||||||
if(DB_INF_SHOW)
|
if(DB_INF_SHOW)
|
||||||
|
{
|
||||||
echo "Processing stylesheet: {$sub_blk}<br />";
|
echo "Processing stylesheet: {$sub_blk}<br />";
|
||||||
|
}
|
||||||
$ret_parser .= $sub_blk;
|
$ret_parser .= $sub_blk;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user