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