Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • ArrayLib
  • BBCodeParser
  • Convert
  • Cookie
  • DataDifferencer
  • Geoip
  • HTMLCleaner
  • HTTP
  • i18n
  • Profiler
  • ShortcodeParser
  • SSHTMLBBCodeParser
  • SSHTMLBBCodeParser_Filter
  • SSHTMLBBCodeParser_Filter_Basic
  • SSHTMLBBCodeParser_Filter_EmailLinks
  • SSHTMLBBCodeParser_Filter_Extended
  • SSHTMLBBCodeParser_Filter_Images
  • SSHTMLBBCodeParser_Filter_Links
  • SSHTMLBBCodeParser_Filter_Lists
  • TextParser
  • Translatable_Transformation
  • XML

Class ShortcodeParser

A simple parser that allows you to map BBCode-like "shortcodes" to an arbitrary callback.

Shortcodes can take the form:

[shortcode]
[shortcode attributes="example" /]
[shortcode]enclosed content[/shortcode]
Package: sapphire\misc
Located at sapphire/parsers/ShortcodeParser.php

Methods summary

public static ShortcodeParser
# get( string $identifier = 'default' )

Get the ShortcodeParser instance that is attached to a particular identifier.

Get the ShortcodeParser instance that is attached to a particular identifier.

Parameters

$identifier
string $identifier Defaults to "default".

Returns

ShortcodeParser
ShortcodeParser
public static ShortcodeParser
# get_active( )

Get the currently active/default ShortcodeParser instance.

Get the currently active/default ShortcodeParser instance.

Returns

ShortcodeParser
ShortcodeParser
public static
# set_active( string $identifier )

Set the identifier to use for the current active/default ShortcodeParser instance.

Set the identifier to use for the current active/default ShortcodeParser instance.

Parameters

$identifier
string $identifier
public
# register( string $shortcode, callable $callback )

Register a shortcode, and attach it to a PHP callback.

Register a shortcode, and attach it to a PHP callback.

The callback for a shortcode will have the following arguments passed to it: - Any parameters attached to the shortcode as an associative array (keys are lower-case). - Any content enclosed within the shortcode (if it is an enclosing shortcode). Note that any content within this will not have been parsed, and can optionally be fed back into the parser. - The ShortcodeParser instance used to parse the content. - The shortcode tag name that was matched within the parsed content.

Parameters

$shortcode
string $shortcode The shortcode tag to map to the callback - normally in lowercase_underscore format.
$callback
callback $callback The callback to replace the shortcode with.
public boolean
# registered( string $shortcode )

Check if a shortcode has been registered.

Check if a shortcode has been registered.

Parameters

$shortcode
string $shortcode

Returns

boolean
bool
public
# unregister( string $shortcode )

Remove a specific registered shortcode.

Remove a specific registered shortcode.

Parameters

$shortcode
string $shortcode
public
# clear( )

Remove all registered shortcodes.

Remove all registered shortcodes.

public string
# parse( string $content )

Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.

Parse a string, and replace any registered shortcodes within it with the result of the mapped callback.

Parameters

$content
string $content

Returns

string
string

Magic methods summary

Properties summary

protected array $shortcodes
#
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0