ContentReplace
in package
No description yet.
Table of Contents
Properties
- $preloaded_widgets : mixed
Methods
- dbFields() : string
- Replace database fields with database values
- documentLinks() : string
- Use Sprout::specialFileLinks instead, it's got better unit tests etc.
- emailWidgets() : string
- Replace embed code with the actual widget. This is a tweaked version of embedWidgets, designed for email
- embedWidget() : string
- Embeds a widget into some text
- embedWidgets() : string
- Replace embed code with the actual widgets.
- emptyTables() : string
- Remove tables that don't contain any content
- executeChain() : string
- Execute a content replace chain
- expandolink() : string
- Replaces an expando with a link to the specified URL
- fileDownload() : string
- Replace file URLs that refer to IDs with URLs which refer to filenames
- html() : string
- Do all the replacements normally required for HTML content Internal links, inline addons, the local anchor fix, etc.
- intlinks() : string
- Replace links to internal pages in the format page/view_by_id/... with the page's friendly url
- localAnchor() : string
- Replace anchors without a URL (e.g. href="#top") to include the page URL to fix issues with BASE HREF
- lookupWidgets() : array<string|int, mixed>
- preloadWidgets() : void
- Add some preloaded widgets, e.g. generated by a preview
- removeWidgets() : string
- Remove widget embed code from the specified HTML Embed code is in the format ((WIDGET code))
- _intlinks() : mixed
Properties
$preloaded_widgets
public
static mixed
$preloaded_widgets
= array()
Methods
dbFields()
Replace database fields with database values
public
static dbFields(string $text, array<string|int, mixed> $data) : string
Replacement code is in the format ((REPLACE field_name))
Parameters
- $text : string
-
The text to process
- $data : array<string|int, mixed>
-
An array of field data
Return values
stringdocumentLinks()
Use Sprout::specialFileLinks instead, it's got better unit tests etc.
public
static documentLinks(string $html) : string
Parameters
- $html : string
Return values
stringemailWidgets()
Replace embed code with the actual widget. This is a tweaked version of embedWidgets, designed for email
public
static emailWidgets(mixed $text, string $widget_table, int $widget_record, string|null $pre_html, string|null $post_html) : string
Embed code is in the format ((WIDGET code))
Parameters
- $text : mixed
- $widget_table : string
-
The host table of the widgets, e.g. 'page'
- $widget_record : int
-
The record id
- $pre_html : string|null
- $post_html : string|null
Return values
stringembedWidget()
Embeds a widget into some text
public
static embedWidget(string $text, string $pattern, array<string|int, mixed> $widget) : string
Parameters
- $text : string
-
The text containing the widget embed
- $pattern : string
-
The widget embed to replace
- $widget : array<string|int, mixed>
-
as per , has keys and values matching the DB fields: 'type' (string), 'settings' (array), and 'embed_key' (string)
Return values
string —The text with the rendered widget
embedWidgets()
Replace embed code with the actual widgets.
public
static embedWidgets(string $text, string $widget_table, int $widget_record) : string
Embed code is in the format ((WIDGET code))
Parameters
- $text : string
-
The text which contains the widget embed codes
- $widget_table : string
-
The host table of the widgets, e.g. 'page'
- $widget_record : int
-
The record id
Return values
string —$text
emptyTables()
Remove tables that don't contain any content
public
static emptyTables(string $text) : string
Parameters
- $text : string
Return values
stringexecuteChain()
Execute a content replace chain
public
static executeChain(string $chain, string $html) : string
Parameters
- $chain : string
-
The name of the chain to execute
- $html : string
-
The incoming HTML
Tags
Return values
stringexpandolink()
Replaces an expando with a link to the specified URL
public
static expandolink(string $html[, string $url = null ]) : string
This method might not preserve whitespace in the input html. The link is only appended if the content actually contained expandos. The lunk url is optional. If not provided, no link gets appended.
Parameters
- $html : string
-
The HTML which contains expandos.
- $url : string = null
-
A url for the link which gets appended to the end.
Return values
stringfileDownload()
Replace file URLs that refer to IDs with URLs which refer to filenames
public
static fileDownload(string $html) : string
Parameters
- $html : string
Return values
stringhtml()
Do all the replacements normally required for HTML content Internal links, inline addons, the local anchor fix, etc.
public
static html(string $html) : string
Parameters
- $html : string
Return values
string —HTML
intlinks()
Replace links to internal pages in the format page/view_by_id/... with the page's friendly url
public
static intlinks(string $text) : string
Parameters
- $text : string
Return values
stringlocalAnchor()
Replace anchors without a URL (e.g. href="#top") to include the page URL to fix issues with BASE HREF
public
static localAnchor(string $text) : string
Parameters
- $text : string
Return values
stringlookupWidgets()
public
static lookupWidgets(string $widget_table, int $widget_record, array<string|int, mixed> $embed_keys) : array<string|int, mixed>
Parameters
- $widget_table : string
-
The host table of the widgets, e.g. 'page'
- $widget_record : int
-
The record id
- $embed_keys : array<string|int, mixed>
-
The embed keys
Return values
array<string|int, mixed> —Keys are the widget reference codes, values are arrays with keys and values matching the DB fields: 'type' (string), 'settings' (array), and 'embed_key' (string)
preloadWidgets()
Add some preloaded widgets, e.g. generated by a preview
public
static preloadWidgets(array<string|int, mixed> $widgets, array<string|int, mixed> $settings) : void
Parameters
- $widgets : array<string|int, mixed>
-
Format to match $_POST['widgets'] on admin/edit/page/{id}
- $settings : array<string|int, mixed>
-
Format to match $_POST['widget_settings'] on admin/edit/page/{id}
removeWidgets()
Remove widget embed code from the specified HTML Embed code is in the format ((WIDGET code))
public
static removeWidgets(string $text) : string
Parameters
- $text : string
Return values
string_intlinks()
private
static _intlinks(mixed $matches) : mixed
Parameters
- $matches : mixed