class Parse (View source)

The Parse class holds all parsing methods.

Methods

static array
allowedFileTypes()

Return an array with the allowed file types.

static string
caption(string $file)

Read a file's caption file and parse contained markdown syntax.

static array
csv(string $str)

Split and trim comma separated string.

static array
fileDeclaration(string $str, object $Page, boolean $stripBaseDir = false)

Parse a file declaration string where multiple glob patterns can be separated by a comma and return an array with the resolved file paths.

static boolean
fileIsImage(string $file)

Parse a filename to check whether a file is an image or not.

static array
jsonOptions(string $str)

Parse a (dirty) JSON string and return an associative, filtered array

static array
textFile(string $file)

Loads and parses a text file.

Details

static array allowedFileTypes()

Return an array with the allowed file types.

Return Value

array An array of file types

static string caption(string $file)

Read a file's caption file and parse contained markdown syntax.

The caption filename is build out of the actual filename with the appended ".caption" extension, like "image.jpg.caption".

Parameters

string $file

Return Value

string The caption string

static array csv(string $str)

Split and trim comma separated string.

Parameters

string $str

Return Value

array The array of separate and trimmed strings

static array fileDeclaration(string $str, object $Page, boolean $stripBaseDir = false)

Parse a file declaration string where multiple glob patterns can be separated by a comma and return an array with the resolved file paths.

If $stripBaseDir is true, the base directory will be stripped from the path and each path gets resolved to be relative to the Automad installation directory.

Parameters

string $str
object $Page (current page)
boolean $stripBaseDir

Return Value

array An array with resolved file paths

static boolean fileIsImage(string $file)

Parse a filename to check whether a file is an image or not.

Parameters

string $file

Return Value

boolean True if $file is an image file

static array jsonOptions(string $str)

Parse a (dirty) JSON string and return an associative, filtered array

Parameters

string $str

Return Value

array $options - associative array

static array textFile(string $file)

Loads and parses a text file.

First it separates the different blocks into simple key/value pairs. Then it creates an array of vars by splitting the pairs.

Parameters

string $file

Return Value

array $vars