XOOPS RMCommon Utilities
 All Classes Namespaces Files Functions Variables
RMCustomCode Class Reference

Public Member Functions

 add ($tag, $func)
 atts ($pairs, $atts)
 doCode ($content)
 doTag ($m)
 getRegex ()
 parseAtts ($text)
 remove ($tag)
 removeAll ()
 strip ($content)
 stripTag ($m)

Static Public Member Functions

static get ()

Private Attributes

 $custom_codes = array()

Detailed Description

This code is a modified fragment toaken from Wordpress. The idea is to provide the functionallity of shortcodes directly on XOOPS using rmcommon

Definition at line 8 of file customcode.php.

Member Function Documentation

RMCustomCode::add (   $tag,

Add hook for customcode tag.

There can only be one hook for each customcode. Which means that if another plugin has a similar customcode, it will override yours or yours will override theirs depending on which order the plugins are included and/or ran.

Simplest example of a customcode tag using the API:

// [footag foo="bar"] function footag_func($atts) { return "foo = {$atts[foo]}"; } add_customcode('footag', 'footag_func');

Example with nice attribute defaults:

// [bartag foo="bar"] function bartag_func($atts) { extract(customcode_atts(array( 'foo' => 'no foo', 'baz' => 'default baz', ), $atts));

return "foo = {$foo}"; } add_customcode('bartag', 'bartag_func');

Example with enclosed content:

// [baztag]content[/baztag] function baztag_func($atts, $content='') { return "content = $content"; } add_customcode('baztag', 'baztag_func');

2.5 $customcode_tags
string$tagcustomcode tag to be searched in post content.
callable$funcHook to run when customcode is found.

Definition at line 73 of file customcode.php.

RMCustomCode::atts (   $pairs,

Combine user attributes with known attributes and fill in defaults when needed.

The pairs should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $pairs list.

If the $atts list has unsupported attributes, then they will be ignored and removed from the final returned list.

array$pairsEntire list of supported attributes and their defaults.
array$attsUser defined attributes in customcode tag.
array Combined and filtered attribute list.

Definition at line 271 of file customcode.php.

RMCustomCode::doCode (   $content)

Search content for customcodes and filter customcodes through their hooks.

If there are no customcode tags defined, then the content will be returned without any filtering. This might cause issues when plugins are disabled but the customcode will still show up in the post or content.

2.5 $customcode_tags get_customcode_regex() Gets the search pattern for searching customcodes.
string$contentContent to search for customcodes
string Content with customcodes filtered out.

Definition at line 123 of file customcode.php.

References $content, and getRegex().

Here is the call graph for this function:

RMCustomCode::doTag (   $m)

Regular Expression callable for do_customcode() for calling customcode hook.

See Also
get_customcode_regex for details of the match array contents.
2.5 private $customcode_tags
array$mRegular expression match array
mixed False on failure.

Definition at line 201 of file customcode.php.

References parseAtts().

Here is the call graph for this function:

static RMCustomCode::get ( )

Definition at line 15 of file customcode.php.

RMCustomCode::getRegex ( )

Retrieve the customcode regular expression for searching.

The regular expression combines the customcode tags in the regular expression in a regex class.

The regular expression contains 6 different sub matches to help with parsing.

1 - An extra [ to allow for escaping customcodes with double [[]] 2 - The customcode name 3 - The customcode argument list 4 - The self closing / 5 - The content of a customcode when it wraps some content. 6 - An extra ] to allow for escaping customcodes with double [[]]

2.5 $customcode_tags
string The customcode search regular expression

Definition at line 152 of file customcode.php.

Referenced by doCode(), and strip().

Here is the caller graph for this function:

RMCustomCode::parseAtts (   $text)

Retrieve all attributes from the customcodes tag.

The attributes list has the attribute name as the key and the value of the attribute as the value in the key/value pair. This allows for easier retrieval of the attributes, since all attributes have to be known.

array List of attributes and their value.

Definition at line 232 of file customcode.php.

References elseif().

Referenced by doTag().

Here is the call graph for this function:

Here is the caller graph for this function:

RMCustomCode::remove (   $tag)

Removes hook for customcode.

2.5 $customcode_tags
string$tagcustomcode tag to remove hook for.

Definition at line 88 of file customcode.php.

RMCustomCode::removeAll ( )

Clear all customcodes.

This function is simple, it clears all of the customcode tags by replacing the customcodes global by a empty array. This is actually a very efficient method for removing all customcodes.

2.5 $customcode_tags

Definition at line 103 of file customcode.php.

RMCustomCode::strip (   $content)

Remove all customcode tags from the given content.

2.5 $customcode_tags
string$contentContent to remove customcode tags.
string Content without customcode tags.

Definition at line 292 of file customcode.php.

References $content, and getRegex().

Here is the call graph for this function:

RMCustomCode::stripTag (   $m)

Definition at line 302 of file customcode.php.

Member Data Documentation

RMCustomCode::$custom_codes = array()

Contains all custom codes registered

Definition at line 13 of file customcode.php.

The documentation for this class was generated from the following file: