Array and string offset access syntax with curly braces is deprecated as of PHP 7.4 - replaced with square brackets.
Also: Code formatting.
This commit is contained in:
parent
b6f32d1f4f
commit
97fae60a29
@ -30,7 +30,6 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/stringparser.class.php';
|
||||
|
||||
define('BBCODE_CLOSETAG_FORBIDDEN', -1);
|
||||
@ -53,6 +52,7 @@ define ('BBCODE_PARAGRAPH_BLOCK_ELEMENT', 2);
|
||||
* @package stringparser
|
||||
*/
|
||||
class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* String parser mode
|
||||
*
|
||||
@ -124,6 +124,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Paragraph handling parameters
|
||||
*
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
@ -134,7 +135,9 @@ class StringParser_BBCode extends StringParser {
|
||||
);
|
||||
|
||||
/**
|
||||
* Allow mixed attribute types (e.g. [code=bla attr=blub])
|
||||
* Allow mixed attribute types (e.g.
|
||||
* [code=bla attr=blub])
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
@ -142,6 +145,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Whether to call validation function again (with $action == 'validate_auto') when closetag comes
|
||||
*
|
||||
* @access protected
|
||||
* @var bool
|
||||
*/
|
||||
@ -151,13 +155,20 @@ class StringParser_BBCode extends StringParser {
|
||||
* Add a code
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the code
|
||||
* @param string $callback_type See documentation
|
||||
* @param string $callback_func The callback function to call
|
||||
* @param array $callback_params The callback parameters
|
||||
* @param string $content_type See documentation
|
||||
* @param array $allowed_within See documentation
|
||||
* @param array $not_allowed_within See documentation
|
||||
* @param string $name
|
||||
* The name of the code
|
||||
* @param string $callback_type
|
||||
* See documentation
|
||||
* @param string $callback_func
|
||||
* The callback function to call
|
||||
* @param array $callback_params
|
||||
* The callback parameters
|
||||
* @param string $content_type
|
||||
* See documentation
|
||||
* @param array $allowed_within
|
||||
* See documentation
|
||||
* @param array $not_allowed_within
|
||||
* See documentation
|
||||
* @return bool
|
||||
*/
|
||||
function addCode($name, $callback_type, $callback_func, $callback_params, $content_type, $allowed_within, $not_allowed_within) {
|
||||
@ -184,7 +195,8 @@ class StringParser_BBCode extends StringParser {
|
||||
* Remove a code
|
||||
*
|
||||
* @access public
|
||||
* @param $name The code to remove
|
||||
* @param string $name
|
||||
* The code to remove
|
||||
* @return bool
|
||||
*/
|
||||
function removeCode($name) {
|
||||
@ -208,9 +220,12 @@ class StringParser_BBCode extends StringParser {
|
||||
* Set a code flag
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the code
|
||||
* @param string $flag The name of the flag to set
|
||||
* @param mixed $value The value of the flag to set
|
||||
* @param string $name
|
||||
* The name of the code
|
||||
* @param string $flag
|
||||
* The name of the flag to set
|
||||
* @param mixed $value
|
||||
* The value of the flag to set
|
||||
* @return bool
|
||||
*/
|
||||
function setCodeFlag($name, $flag, $value) {
|
||||
@ -231,8 +246,10 @@ class StringParser_BBCode extends StringParser {
|
||||
* times in the hole text.
|
||||
*
|
||||
* @access public
|
||||
* @param string $code The name of the code
|
||||
* @param string $type The name of the occurrence type to set
|
||||
* @param string $code
|
||||
* The name of the code
|
||||
* @param string $type
|
||||
* The name of the occurrence type to set
|
||||
* @return bool
|
||||
*/
|
||||
function setOccurrenceType($code, $type) {
|
||||
@ -243,8 +260,10 @@ class StringParser_BBCode extends StringParser {
|
||||
* Set maximum number of occurrences
|
||||
*
|
||||
* @access public
|
||||
* @param string $type The name of the occurrence type
|
||||
* @param int $count The maximum number of occurrences
|
||||
* @param string $type
|
||||
* The name of the occurrence type
|
||||
* @param int $count
|
||||
* The maximum number of occurrences
|
||||
* @return bool
|
||||
*/
|
||||
function setMaxOccurrences($type, $count) {
|
||||
@ -260,8 +279,10 @@ class StringParser_BBCode extends StringParser {
|
||||
* Add a parser
|
||||
*
|
||||
* @access public
|
||||
* @param string $type The content type for which the parser is to add
|
||||
* @param mixed $parser The function to call
|
||||
* @param string $type
|
||||
* The content type for which the parser is to add
|
||||
* @param mixed $parser
|
||||
* The function to call
|
||||
* @return bool
|
||||
*/
|
||||
function addParser($type, $parser) {
|
||||
@ -282,7 +303,8 @@ class StringParser_BBCode extends StringParser {
|
||||
* Set root content type
|
||||
*
|
||||
* @access public
|
||||
* @param string $content_type The new root content type
|
||||
* @param string $content_type
|
||||
* The new root content type
|
||||
*/
|
||||
function setRootContentType($content_type) {
|
||||
$this->_rootContentType = $content_type;
|
||||
@ -292,7 +314,8 @@ class StringParser_BBCode extends StringParser {
|
||||
* Set paragraph handling on root element
|
||||
*
|
||||
* @access public
|
||||
* @param bool $enabled The new status of paragraph handling on root element
|
||||
* @param bool $enabled
|
||||
* The new status of paragraph handling on root element
|
||||
*/
|
||||
function setRootParagraphHandling($enabled) {
|
||||
$this->_rootParagraphHandling = (bool) $enabled;
|
||||
@ -302,9 +325,12 @@ class StringParser_BBCode extends StringParser {
|
||||
* Set paragraph handling parameters
|
||||
*
|
||||
* @access public
|
||||
* @param string $detect_string The string to detect
|
||||
* @param string $start_tag The replacement for the start tag (e.g. <p>)
|
||||
* @param string $end_tag The replacement for the start tag (e.g. </p>)
|
||||
* @param string $detect_string
|
||||
* The string to detect
|
||||
* @param string $start_tag
|
||||
* The replacement for the start tag (e.g. <p>)
|
||||
* @param string $end_tag
|
||||
* The replacement for the start tag (e.g. </p>)
|
||||
*/
|
||||
function setParagraphHandlingParameters($detect_string, $start_tag, $end_tag) {
|
||||
$this->_paragraphHandling = array(
|
||||
@ -391,10 +417,14 @@ class StringParser_BBCode extends StringParser {
|
||||
* Get a code flag
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the code
|
||||
* @param string $flag The name of the flag to get
|
||||
* @param string $type The type of the return value
|
||||
* @param mixed $default The default return value
|
||||
* @param string $name
|
||||
* The name of the code
|
||||
* @param string $flag
|
||||
* The name of the flag to get
|
||||
* @param string $type
|
||||
* The type of the return value
|
||||
* @param mixed $default
|
||||
* The default return value
|
||||
* @return bool
|
||||
*/
|
||||
function getCodeFlag($name, $flag, $type = 'mixed', $default = null) {
|
||||
@ -413,57 +443,107 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Set a specific status
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _setStatus($status) {
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$this->_charactersSearch = array ('[/', '[');
|
||||
$this->_charactersSearch = array(
|
||||
'[/',
|
||||
'['
|
||||
);
|
||||
$this->_status = $status;
|
||||
break;
|
||||
case 1:
|
||||
$this->_charactersSearch = array (']', ' = "', '="', ' = \'', '=\'', ' = ', '=', ': ', ':', ' ');
|
||||
$this->_charactersSearch = array(
|
||||
']',
|
||||
' = "',
|
||||
'="',
|
||||
' = \'',
|
||||
'=\'',
|
||||
' = ',
|
||||
'=',
|
||||
': ',
|
||||
':',
|
||||
' '
|
||||
);
|
||||
$this->_status = $status;
|
||||
break;
|
||||
case 2:
|
||||
$this->_charactersSearch = array (']');
|
||||
$this->_charactersSearch = array(
|
||||
']'
|
||||
);
|
||||
$this->_status = $status;
|
||||
$this->_savedName = '';
|
||||
break;
|
||||
case 3:
|
||||
if ($this->_quoting !== null) {
|
||||
if ($this->_mixedAttributeTypes) {
|
||||
$this->_charactersSearch = array ('\\\\', '\\'.$this->_quoting, $this->_quoting.' ', $this->_quoting.']', $this->_quoting);
|
||||
$this->_charactersSearch = array(
|
||||
'\\\\',
|
||||
'\\' . $this->_quoting,
|
||||
$this->_quoting . ' ',
|
||||
$this->_quoting . ']',
|
||||
$this->_quoting
|
||||
);
|
||||
} else {
|
||||
$this->_charactersSearch = array ('\\\\', '\\'.$this->_quoting, $this->_quoting.']', $this->_quoting);
|
||||
$this->_charactersSearch = array(
|
||||
'\\\\',
|
||||
'\\' . $this->_quoting,
|
||||
$this->_quoting . ']',
|
||||
$this->_quoting
|
||||
);
|
||||
}
|
||||
$this->_status = $status;
|
||||
break;
|
||||
}
|
||||
if ($this->_mixedAttributeTypes) {
|
||||
$this->_charactersSearch = array (' ', ']');
|
||||
$this->_charactersSearch = array(
|
||||
' ',
|
||||
']'
|
||||
);
|
||||
} else {
|
||||
$this->_charactersSearch = array (']');
|
||||
$this->_charactersSearch = array(
|
||||
']'
|
||||
);
|
||||
}
|
||||
$this->_status = $status;
|
||||
break;
|
||||
case 4:
|
||||
$this->_charactersSearch = array (' ', ']', '="', '=\'', '=');
|
||||
$this->_charactersSearch = array(
|
||||
' ',
|
||||
']',
|
||||
'="',
|
||||
'=\'',
|
||||
'='
|
||||
);
|
||||
$this->_status = $status;
|
||||
$this->_savedName = '';
|
||||
$this->_savedValue = '';
|
||||
break;
|
||||
case 5:
|
||||
if ($this->_quoting !== null) {
|
||||
$this->_charactersSearch = array ('\\\\', '\\'.$this->_quoting, $this->_quoting.' ', $this->_quoting.']', $this->_quoting);
|
||||
$this->_charactersSearch = array(
|
||||
'\\\\',
|
||||
'\\' . $this->_quoting,
|
||||
$this->_quoting . ' ',
|
||||
$this->_quoting . ']',
|
||||
$this->_quoting
|
||||
);
|
||||
} else {
|
||||
$this->_charactersSearch = array (' ', ']');
|
||||
$this->_charactersSearch = array(
|
||||
' ',
|
||||
']'
|
||||
);
|
||||
}
|
||||
$this->_status = $status;
|
||||
$this->_savedValue = '';
|
||||
break;
|
||||
case 7:
|
||||
$this->_charactersSearch = array ('[/'.$this->_topNode ('name').']');
|
||||
$this->_charactersSearch = array(
|
||||
'[/' . $this->_topNode('name') . ']'
|
||||
);
|
||||
if (!$this->_topNode('getFlag', 'case_sensitive', 'boolean', true) || !$this->_caseSensitive) {
|
||||
$this->_charactersSearch [] = '[/';
|
||||
}
|
||||
@ -477,8 +557,10 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Abstract method Append text depending on current status
|
||||
*
|
||||
* @access protected
|
||||
* @param string $text The text to append
|
||||
* @param string $text
|
||||
* The text to append
|
||||
* @return bool On success, the function returns true, else false
|
||||
*/
|
||||
function _appendText($text) {
|
||||
@ -551,9 +633,12 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Handle status
|
||||
*
|
||||
* @access protected
|
||||
* @param int $status The current status
|
||||
* @param string $needle The needle that was found
|
||||
* @param int $status
|
||||
* The current status
|
||||
* @param string $needle
|
||||
* The needle that was found
|
||||
* @return bool
|
||||
*/
|
||||
function _handleStatus($status, $needle) {
|
||||
@ -920,7 +1005,10 @@ class StringParser_BBCode extends StringParser {
|
||||
*/
|
||||
function _isOpenableWithClose($name, &$closecount) {
|
||||
$tnname = $this->_getCanonicalName($this->_topNode('name'));
|
||||
if (!in_array ($this->getCodeFlag ($tnname, 'closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array (BBCODE_CLOSETAG_FORBIDDEN, BBCODE_CLOSETAG_OPTIONAL))) {
|
||||
if (!in_array($this->getCodeFlag($tnname, 'closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array(
|
||||
BBCODE_CLOSETAG_FORBIDDEN,
|
||||
BBCODE_CLOSETAG_OPTIONAL
|
||||
))) {
|
||||
return false;
|
||||
}
|
||||
$node = $this->_findNamedNode($name, true);
|
||||
@ -936,7 +1024,10 @@ class StringParser_BBCode extends StringParser {
|
||||
if ($this->_stack [$i]->equals($node)) {
|
||||
return true;
|
||||
}
|
||||
if (in_array ($this->_stack[$i]->getFlag ('closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array (BBCODE_CLOSETAG_IMPLICIT_ON_CLOSE_ONLY, BBCODE_CLOSETAG_MUSTEXIST))) {
|
||||
if (in_array($this->_stack [$i]->getFlag('closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array(
|
||||
BBCODE_CLOSETAG_IMPLICIT_ON_CLOSE_ONLY,
|
||||
BBCODE_CLOSETAG_MUSTEXIST
|
||||
))) {
|
||||
return false;
|
||||
}
|
||||
if ($this->_validateAgain) {
|
||||
@ -951,6 +1042,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Abstract method: Close remaining blocks
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _closeRemainingBlocks() {
|
||||
@ -1006,6 +1098,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Abstract method: Output tree
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
@ -1025,6 +1118,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Output a node
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
@ -1053,12 +1147,12 @@ class StringParser_BBCode extends StringParser {
|
||||
$ol = strlen($output);
|
||||
switch ($node->getFlag('newlinemode.begin', 'integer', BBCODE_NEWLINE_PARSE)) {
|
||||
case BBCODE_NEWLINE_IGNORE:
|
||||
if ($ol && $output{0} == "\n") {
|
||||
if ($ol && $output [0] == "\n") {
|
||||
$before = "\n";
|
||||
}
|
||||
// don't break!
|
||||
case BBCODE_NEWLINE_DROP:
|
||||
if ($ol && $output{0} == "\n") {
|
||||
if ($ol && $output [0] == "\n") {
|
||||
$output = substr($output, 1);
|
||||
$ol--;
|
||||
}
|
||||
@ -1066,12 +1160,12 @@ class StringParser_BBCode extends StringParser {
|
||||
}
|
||||
switch ($node->getFlag('newlinemode.end', 'integer', BBCODE_NEWLINE_PARSE)) {
|
||||
case BBCODE_NEWLINE_IGNORE:
|
||||
if ($ol && $output{$ol-1} == "\n") {
|
||||
if ($ol && $output [$ol - 1] == "\n") {
|
||||
$after = "\n";
|
||||
}
|
||||
// don't break!
|
||||
case BBCODE_NEWLINE_DROP:
|
||||
if ($ol && $output{$ol-1} == "\n") {
|
||||
if ($ol && $output [$ol - 1] == "\n") {
|
||||
$output = substr($output, 0, -1);
|
||||
$ol--;
|
||||
}
|
||||
@ -1103,6 +1197,7 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Abstract method: Manipulate the tree
|
||||
*
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
@ -1169,7 +1264,8 @@ class StringParser_BBCode extends StringParser {
|
||||
$nodes = $this->_root->getNodesByCriterium('empty', true);
|
||||
$nodes_count = count($nodes);
|
||||
if (isset($parent)) {
|
||||
unset ($parent); $parent = null;
|
||||
unset($parent);
|
||||
$parent = null;
|
||||
}
|
||||
for($i = 0; $i < $nodes_count; $i++) {
|
||||
if ($nodes [$i]->_type != STRINGPARSER_BBCODE_NODE_PARAGRAPH) {
|
||||
@ -1185,8 +1281,10 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Handle paragraphs
|
||||
*
|
||||
* @access protected
|
||||
* @param object $node The node to handle
|
||||
* @param object $node
|
||||
* The node to handle
|
||||
* @return bool
|
||||
*/
|
||||
function _handleParagraphs(&$node) {
|
||||
@ -1233,8 +1331,10 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Search for a paragraph node in tree in upward direction
|
||||
*
|
||||
* @access protected
|
||||
* @param object $node The node to analyze
|
||||
* @param object $node
|
||||
* The node to analyze
|
||||
* @return bool
|
||||
*/
|
||||
function _hasParagraphAncestor(&$node) {
|
||||
@ -1250,8 +1350,10 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Break up nodes
|
||||
*
|
||||
* @access protected
|
||||
* @param object $node The node to break up
|
||||
* @param object $node
|
||||
* The node to break up
|
||||
* @return array
|
||||
*/
|
||||
function &_breakupNodeByParagraphs(&$node) {
|
||||
@ -1325,9 +1427,12 @@ class StringParser_BBCode extends StringParser {
|
||||
|
||||
/**
|
||||
* Is this node a usecontent node
|
||||
*
|
||||
* @access protected
|
||||
* @param object $node The node to check
|
||||
* @param bool $check_attrs Also check whether 'usecontent?'-attributes exist
|
||||
* @param object $node
|
||||
* The node to check
|
||||
* @param bool $check_attrs
|
||||
* Also check whether 'usecontent?'-attributes exist
|
||||
* @return bool
|
||||
*/
|
||||
function _isUseContent(&$node, $check_attrs = false) {
|
||||
@ -1389,27 +1494,30 @@ class StringParser_BBCode extends StringParser {
|
||||
}
|
||||
return $rname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Node type: BBCode Element node
|
||||
*
|
||||
* @see StringParser_BBCode_Node_Element::_type
|
||||
*/
|
||||
define('STRINGPARSER_BBCODE_NODE_ELEMENT', 32);
|
||||
|
||||
/**
|
||||
* Node type: BBCode Paragraph node
|
||||
*
|
||||
* @see StringParser_BBCode_Node_Paragraph::_type
|
||||
*/
|
||||
define('STRINGPARSER_BBCODE_NODE_PARAGRAPH', 33);
|
||||
|
||||
|
||||
/**
|
||||
* BBCode String parser paragraph node class
|
||||
*
|
||||
* @package stringparser
|
||||
*/
|
||||
class StringParser_BBCode_Node_Paragraph extends StringParser_Node {
|
||||
|
||||
/**
|
||||
* The type of this node.
|
||||
*
|
||||
@ -1425,8 +1533,10 @@ class StringParser_BBCode_Node_Paragraph extends StringParser_Node {
|
||||
* Determines whether a criterium matches this node
|
||||
*
|
||||
* @access public
|
||||
* @param string $criterium The criterium that is to be checked
|
||||
* @param mixed $value The value that is to be compared
|
||||
* @param string $criterium
|
||||
* The criterium that is to be checked
|
||||
* @param mixed $value
|
||||
* The value that is to be compared
|
||||
* @return bool True if this node matches that criterium
|
||||
*/
|
||||
function matchesCriterium($criterium, $value) {
|
||||
@ -1449,10 +1559,10 @@ class StringParser_BBCode_Node_Paragraph extends StringParser_Node {
|
||||
$f_begin = $this->_children [0]->getFlag('newlinemode.begin', 'integer', BBCODE_NEWLINE_PARSE);
|
||||
$f_end = $this->_children [0]->getFlag('newlinemode.end', 'integer', BBCODE_NEWLINE_PARSE);
|
||||
$content = $this->_children [0]->content;
|
||||
if ($f_begin != BBCODE_NEWLINE_PARSE && $content{0} == "\n") {
|
||||
if ($f_begin != BBCODE_NEWLINE_PARSE && $content [0] == "\n") {
|
||||
$content = substr($content, 1);
|
||||
}
|
||||
if ($f_end != BBCODE_NEWLINE_PARSE && $content{strlen($content)-1} == "\n") {
|
||||
if ($f_end != BBCODE_NEWLINE_PARSE && $content [strlen($content) - 1] == "\n") {
|
||||
$content = substr($content, 0, -1);
|
||||
}
|
||||
if (!strlen($content)) {
|
||||
@ -1461,6 +1571,7 @@ class StringParser_BBCode_Node_Paragraph extends StringParser_Node {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1469,6 +1580,7 @@ class StringParser_BBCode_Node_Paragraph extends StringParser_Node {
|
||||
* @package stringparser
|
||||
*/
|
||||
class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
|
||||
/**
|
||||
* The type of this node.
|
||||
*
|
||||
@ -1556,7 +1668,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Set name of this element
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The new name of the element
|
||||
* @param string $name
|
||||
* The new name of the element
|
||||
*/
|
||||
function setName($name) {
|
||||
$this->_name = $name;
|
||||
@ -1567,7 +1680,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Append to name of this element
|
||||
*
|
||||
* @access public
|
||||
* @param string $chars The chars to append to the name of the element
|
||||
* @param string $chars
|
||||
* The chars to append to the name of the element
|
||||
*/
|
||||
function appendToName($chars) {
|
||||
$this->_name .= $chars;
|
||||
@ -1578,8 +1692,10 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Append to attribute of this element
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the attribute
|
||||
* @param string $chars The chars to append to the attribute of the element
|
||||
* @param string $name
|
||||
* The name of the attribute
|
||||
* @param string $chars
|
||||
* The chars to append to the attribute of the element
|
||||
*/
|
||||
function appendToAttribute($name, $chars) {
|
||||
if (!isset($this->_attributes [$name])) {
|
||||
@ -1594,8 +1710,10 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Set attribute
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the attribute
|
||||
* @param string $value The new value of the attribute
|
||||
* @param string $name
|
||||
* The name of the attribute
|
||||
* @param string $value
|
||||
* The new value of the attribute
|
||||
*/
|
||||
function setAttribute($name, $value) {
|
||||
$this->_attributes [$name] = $value;
|
||||
@ -1606,7 +1724,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Set code info
|
||||
*
|
||||
* @access public
|
||||
* @param array $info The code info array
|
||||
* @param array $info
|
||||
* The code info array
|
||||
*/
|
||||
function setCodeInfo($info) {
|
||||
$this->_codeInfo = $info;
|
||||
@ -1618,7 +1737,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Get attribute value
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the attribute
|
||||
* @param string $name
|
||||
* The name of the attribute
|
||||
*/
|
||||
function attribute($name) {
|
||||
if (!isset($this->_attributes [$name])) {
|
||||
@ -1669,8 +1789,10 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Determines whether a criterium matches this node
|
||||
*
|
||||
* @access public
|
||||
* @param string $criterium The criterium that is to be checked
|
||||
* @param mixed $value The value that is to be compared
|
||||
* @param string $criterium
|
||||
* The criterium that is to be checked
|
||||
* @param mixed $value
|
||||
* The value that is to be compared
|
||||
* @return bool True if this node matches that criterium
|
||||
*/
|
||||
function matchesCriterium($criterium, $value) {
|
||||
@ -1846,9 +1968,12 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Get Flag
|
||||
*
|
||||
* @access public
|
||||
* @param string $flag The requested flag
|
||||
* @param string $type The requested type of the return value
|
||||
* @param mixed $default The default return value
|
||||
* @param string $flag
|
||||
* The requested flag
|
||||
* @param string $type
|
||||
* The requested type of the return value
|
||||
* @param mixed $default
|
||||
* The default return value
|
||||
* @return mixed
|
||||
*/
|
||||
function getFlag($flag, $type = 'mixed', $default = null) {
|
||||
@ -1866,8 +1991,10 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Set a flag
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the flag
|
||||
* @param mixed $value The value of the flag
|
||||
* @param string $name
|
||||
* The name of the flag
|
||||
* @param mixed $value
|
||||
* The value of the flag
|
||||
*/
|
||||
function setFlag($name, $value) {
|
||||
$this->_flags [$name] = $value;
|
||||
@ -1878,7 +2005,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Validate code
|
||||
*
|
||||
* @access public
|
||||
* @param string $action The action which is to be called ('validate'
|
||||
* @param string $action
|
||||
* The action which is to be called ('validate'
|
||||
* for first validation, 'validate_again' for
|
||||
* second validation (optional))
|
||||
* @return bool
|
||||
@ -1895,7 +2023,12 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
if (($this->_codeInfo ['callback_type'] == 'usecontent' || $this->_codeInfo ['callback_type'] == 'usecontent?' || $this->_codeInfo ['callback_type'] == 'callback_replace?') && count($this->_children) == 1 && $this->_children [0]->_type == STRINGPARSER_NODE_TEXT) {
|
||||
// we have to make sure the object gets passed on as a reference
|
||||
// if we do call_user_func(..., &$this) this will clash with PHP5
|
||||
$callArray = array ($action, $this->_attributes, $this->_children[0]->content, $this->_codeInfo['callback_params']);
|
||||
$callArray = array(
|
||||
$action,
|
||||
$this->_attributes,
|
||||
$this->_children [0]->content,
|
||||
$this->_codeInfo ['callback_params']
|
||||
);
|
||||
$callArray [] = $this;
|
||||
$res = call_user_func_array($this->_codeInfo ['callback_func'], $callArray);
|
||||
if ($res) {
|
||||
@ -1914,7 +2047,12 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
|
||||
// we have to make sure the object gets passed on as a reference
|
||||
// if we do call_user_func(..., &$this) this will clash with PHP5
|
||||
$callArray = array ($action, $this->_attributes, null, $this->_codeInfo['callback_params']);
|
||||
$callArray = array(
|
||||
$action,
|
||||
$this->_attributes,
|
||||
null,
|
||||
$this->_codeInfo ['callback_params']
|
||||
);
|
||||
$callArray [] = $this;
|
||||
return call_user_func_array($this->_codeInfo ['callback_func'], $callArray);
|
||||
}
|
||||
@ -1925,7 +2063,8 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
* Get replacement for this code
|
||||
*
|
||||
* @access public
|
||||
* @param string $subcontent The content of all sub-nodes
|
||||
* @param string $subcontent
|
||||
* The content of all sub-nodes
|
||||
* @return string
|
||||
*/
|
||||
function getReplacement($subcontent) {
|
||||
@ -1943,7 +2082,12 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
|
||||
// we have to make sure the object gets passed on as a reference
|
||||
// if we do call_user_func(..., &$this) this will clash with PHP5
|
||||
$callArray = array ('output', $this->_attributes, $subcontent, $this->_codeInfo['callback_params']);
|
||||
$callArray = array(
|
||||
'output',
|
||||
$this->_attributes,
|
||||
$subcontent,
|
||||
$this->_codeInfo ['callback_params']
|
||||
);
|
||||
$callArray [] = $this;
|
||||
return call_user_func_array($this->_codeInfo ['callback_func'], $callArray);
|
||||
}
|
||||
@ -1974,6 +2118,7 @@ class StringParser_BBCode_Node_Element extends StringParser_Node {
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user