\Anax\TextFilterTTextUtilities

Utilities when working with text.

Summary

Methods
Properties
Constants
getUntilStop()
getUntilMore()
wrapElementWithStartEnd()
wrapElementContentWithStartEnd()
createToc()
createAnchor4Header()
addBaseurlToRelativeLinks()
addBaseurlToImageSource()
addRevisionHistory()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getUntilStop()

getUntilStop(string  $text) : string

Get text until <!--stop--> or all text.

Parameters

string $text

with content

Returns

string —

with text

getUntilMore()

getUntilMore(string  $text) : array

Get text until <!--more--> or all text.

Parameters

string $text

with content

Returns

array —

with text and boolean if more was detected.

wrapElementWithStartEnd()

wrapElementWithStartEnd(string  $text, string  $tag, string  $start, string  $end, \Anax\TextFilter\number  $count) : array

Wrap HTML element with with start and end.

Parameters

string $text

with content

string $tag

HTML tag to search for

string $start

wrap start part

string $end

wrap end part

\Anax\TextFilter\number $count

hits to search for

Returns

array —

with text and boolean if more was detected.

wrapElementContentWithStartEnd()

wrapElementContentWithStartEnd(string  $text, string  $tag, string  $start, string  $end, \Anax\TextFilter\number  $count) : array

Wrap content of a HTML element with start and end.

Parameters

string $text

with content

string $tag

HTML tag to search for

string $start

wrap start part

string $end

wrap end part

\Anax\TextFilter\number $count

hits to search for

Returns

array —

with text and boolean if more was detected.

createToc()

createToc(string  $text, integer  $start = 2, integer  $stop = 4) : array

Create a TOC of HTML headings from and to a certain level.

Parameters

string $text

with content

integer $start

level of headings to use for toc.

integer $stop

level of headings to use for toc.

Returns

array —

with entries to generate a TOC.

createAnchor4Header()

createAnchor4Header(string  $text, integer  $start = 1, integer  $stop = 4) : string

Create a anchor for each header having an id.

Parameters

string $text

with content

integer $start

level of headings to use.

integer $stop

level of headings to use.

Returns

string —

with modified text.

addBaseurlToRelativeLinks()

addBaseurlToRelativeLinks(string  $text, string  $baseurl, callable  $callback) : string

Add baseurl to all relative links.

Parameters

string $text

with content.

string $baseurl

as string to prepend relative link.

callable $callback

Use to create url from route.

Returns

string —

with modified text.

addBaseurlToImageSource()

addBaseurlToImageSource(string  $text, string  $baseurl, callable  $callback) : string

Add baseurl to all relative links in image source.

Parameters

string $text

with content.

string $baseurl

as string to prepend relative link.

callable $callback

Use to create url from route.

Returns

string —

with modified text.

addRevisionHistory()

addRevisionHistory(string  $text, array  $revision, string  $start, string  $end, string  $class, string  $source = null) : string

Generate revision history and add to the end of content.

Parameters

string $text

with content.

array $revision

with all revisions.

string $start

start wrap with this.

string $end

end wrap with this.

string $class

to add to ul element.

string $source

optional url to document source.

Returns

string —

with text and optionally added revision history.