Summary
- abstract
- File
- Package hierarchy Formatting\parser
- Class hierarchy \AbstractParser \ContentFormattingParser
This class is abstract. It contains tools that are usefull for implement a content parser.
This class is abstract. It contains tools that are usefull for implement a content parser.
__construct()
Buils a ContentFormattingParser object.
None found |
get_content() : string
Returns the content of the parser. If you called a method which parses the content, this content will be parsed.
The content of the parser.
None found |
set_content(string $content)
Sets the content of the parser. When you will call a parse method, it will deal with this content.
string | $content | Content |
None found |
set_path_to_root(string $path)
Sets the reference path for relative URL
string | $path | Path |
None found |
get_path_to_root() : string
Returns the path to root attribute.
The path
None found |
set_page_path(string $page_path)
Sets the page path
string | $page_path | Page path |
None found |
get_page_path() : string
Returns the page path
path
None found |
add_module_special_tag( $pattern, $replacement)
{@inheritdoc}
$pattern | ||
$replacement |
None found |
get_module_special_tags()
{@inheritdoc}
None found |
parse() : void
Parses the content of the parser
None found |
set_forbidden_tags(array<mixed,string> $forbidden_tags)
Sets the tags which mustn't be parsed.
array<mixed,string> | $forbidden_tags | list of the name of the tags which mustn't be parsed. |
None found |
get_forbidden_tags() : array<mixed,string>
Gets the forbidden tags.
List of the forbidden tags
None found |
set_html_auth(array<mixed,mixed> $array_auth)
Sets the required authorizations that are necessary to post some HTML code which will be displayed by the web browser.
array<mixed,mixed> | $array_auth | authorization array |
None found |
get_html_auth() : array<mixed,mixed>
Returns the HTML tag auth
None found |
_parse_imbricated(string $match, string $regex, string $replace)
Parses a nested tag
string | $match | The regular expression which matches the tag to replace |
string | $regex | The regular expression which matches the replacement |
string | $replace | The replacement syntax. |
None found |
parse_tag_args(string $matches, string $allowed_args = array())
Parses tag args to get allowed ones
string | $matches | The regular expression which matches the tag args |
string | $allowed_args | The args that are allowed to be present |
None found |
split_imbricated_tag(string $content, string $tag, string $attributes)
Splits a string accorting to a tag name.
Works also with nested tags.
string | $content | Content to split, will be converted in a string[] variable containing the following pattern:
|
string | $tag | Tag name |
string | $attributes | Regular expression of the attribute form |
None found |
preg_split_safe_recurse( $content, $tag, $attributes) : array<mixed,string>
Splits a string according to a regular expression. The matched pattern can be nested and must follow the BBCode syntax, i.e matching [tag=args]content of the tag[/tag].
It returns an array For example, il you have this: $my_str = '[tag=1]test1[/tag]test2[tag=2]test3[tag=3]test4[/tag]test5[/tag]?est6'; You call it like that: ContentFormattingParser::preg_split_safe_recurse($my_str, 'tag', '[0-9]'); It will return you array('', '1', 'test1', 'test2', '2', array('test3', '3', 'test4', 'test5'), 'test6').
$content | string Content into which you want to search the pattern |
|
$tag | string BBCode tage name |
|
$attributes | string The regular expression (PCRE syntax) corresponding to the arguments which you want to match. There mustn't be any matching parenthesis into that regular expression |
the split string
None found |
pick_up_tag( $tag, $arguments = '')
Removes the content of the tag $tag and replaces them by an identifying code. They will be reinserted in the content by the reimplant_tags method.
It enables you to treat the whole string enough affecting the interior of some tags. Example: $my_parser contains this content: 'test1[tag=1]test2[/tag]test3' $my_parser->pick_up_tag('tag', '[0-9]'); will replace the content of the parser by 'test1[CODE_TAG_1]test3'
$tag | string The tag to isolate |
|
$arguments | string The regular expression matching the arguments syntax. |
None found |
reimplant_tag( $tag) : boolean
reimplants the code which has been picked up by the _pick_up method.
$tag | string tag to reimplant. |
True if the reimplantation succed, otherwise false.
None found |
parse_module_special_tags()
desc |
Parses module special tags if any. The special tags are [link] for module pages or wiki for example. |
parse_feed_tag()
None found |
parse_fa_tag(array<mixed,string> $matches) : string
array<mixed,string> | $matches | Content matched by a regular expression |
The string in which the fa tag are parsed
desc |
Callback which parses the font awasome icons tag |
parse_wikipedia_tag(array<mixed,string> $matches) : string
array<mixed,string> | $matches | Content matched by a regular expression |
The string in which the wikipedia tag are parsed
desc |
Callback which parses the wikipedia tag |
index_tags( $content, $tag, $attributes) : array<mixed,integer>
$content | string Content into which index the positions. |
|
$tag | string tag name |
|
$attributes | The regular expression matching the parameters of the tag (see the preg_split_safe_recurse method). |
The positions of the opening tags.
static |
Indexes the position of all the tags in the document. Returns the list of the positions of each tag. |
$content : string
None found |
$array_tags : array<mixed,string>
None found |
$path_to_root : string
None found |
$page_path : string
None found |
$module_special_tags : array<mixed,string>
None found |
$html_auth : array<mixed,string>
None found |
$forbidden_tags : array<mixed,string>
None found |
PICK_UP = true
None found |
REIMPLANT = false
None found |