Automad
 All Classes Functions Variables Pages
Automad\Core\Parse Class Reference

Static Public Member Functions

static allowedFileTypes ()
 
static extractTags ($data)
 
static fileDeclaration ($str, $Page, $stripBaseDir=false)
 
static isFileName ($str)
 
static jsonEscape ($str)
 
static jsonOptions ($str)
 
static markdownFile ($file)
 
static queryArray ()
 
static queryKey ($key)
 
static request ()
 
static sanitize ($str, $removeDots=false)
 
static siteData ()
 
static textFile ($file)
 

Detailed Description

The Parse class holds all parsing methods.

Author
Marc Anton Dahmen hello.nosp@m.@mar.nosp@m.cdahm.nosp@m.en.d.nosp@m.e
License
MIT license - http://automad.org/license

Definition at line 52 of file parse.php.

Member Function Documentation

static Automad\Core\Parse::allowedFileTypes ( )
static

Return an array with the allowed file types.

Returns
Array of file types

Definition at line 61 of file parse.php.

static Automad\Core\Parse::extractTags (   $data)
static

Extracts the tags string out of a given array and returns an array with these tags.

Parameters
array$data
Returns
array $tags

Definition at line 82 of file parse.php.

Referenced by Automad\Core\Automad\collectPages().

static Automad\Core\Parse::fileDeclaration (   $str,
  $Page,
  $stripBaseDir = false 
)
static

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
Returns
Array with resolved file paths

Definition at line 116 of file parse.php.

References Automad\Core\Resolve\filePath().

Referenced by Extensions\Carousel\Carousel(), Automad\Core\Filelist\config(), Extensions\Gallery\Gallery(), Automad\Core\Html\generatePagelist(), and Automad\Core\Toolbox\imgSet().

static Automad\Core\Parse::isFileName (   $str)
static

Tests if a string is a file name (with an allowed file extension).

Basically a possibly existing file extension is checked against the array of allowed file extensions.

"/url/file.jpg" will return true, "/url/file" or "/url/file.something" will return false.

Parameters
string$str
Returns
boolean

Definition at line 154 of file parse.php.

Referenced by Automad\Core\Resolve\url().

static Automad\Core\Parse::jsonEscape (   $str)
static

Escape a string to be used within a JSON string.

Parameters
string$str
Returns
Escaped, JSON-safe string

Definition at line 181 of file parse.php.

Referenced by Automad\Core\Template\processContent().

static Automad\Core\Parse::jsonOptions (   $str)
static

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

Parameters
string$str
Returns
$options - associative array

Definition at line 198 of file parse.php.

References Automad\Core\Debug\log().

Referenced by Automad\Core\Template\processMarkup().

static Automad\Core\Parse::markdownFile (   $file)
static

Parses a text file including markdown syntax.

If a variable in that file has a multiline string as its value, that string will be then parsed as markdown. If the variable string is just a single line, markdown parsing is skipped. If the variable is a multiline string, but starts and ends with a <head> element, markdown parsing will be skipped as well.

Parameters
string$file
Returns
Array of variables

Definition at line 241 of file parse.php.

Referenced by Automad\GUI\GUI\__construct(), and Automad\Core\Automad\collectPages().

static Automad\Core\Parse::queryArray ( )
static

Get the query string, if existing.

Returns
$query

Definition at line 270 of file parse.php.

Referenced by Automad\Core\Pagelist\config(), Automad\Core\Html\generateFilterMenu(), and Automad\Core\Html\generateSortMenu().

static Automad\Core\Parse::queryKey (   $key)
static

Return value of a query string parameter or any empty string, if that parameter doesn't exist. Note: Since this method always returns a string, it should not be used to test whether a parameter exists in the query string, because a non-existing parameter and an empty string as a parameter's value will return the same.

Parameters
string$key
Returns
$queryKey

Definition at line 294 of file parse.php.

Referenced by Automad\GUI\GUI\__construct(), Automad\Core\Html\generateFilterMenu(), Automad\Core\Automad\getPageByUrl(), and Automad\GUI\GUI\siteTree().

static Automad\Core\Parse::request ( )
static

Return the URL of the currently requested page.

Returns
The requested URL

Definition at line 313 of file parse.php.

References Automad\Core\Debug\log().

static Automad\Core\Parse::sanitize (   $str,
  $removeDots = false 
)
static

Cleans up a string to be used as URL, directory or file name. The returned string constists of the following characters: a-z, A-Z, - and optional dots (.) That means, this method is safe to be used with filenames as well, since it keeps by default the dots as suffix separators.

Note: To produce fully safe prefixes and directory names, possible dots should be removed by setting $removeDots = true.

Parameters
string$str
boolean$removeDots
Returns
the sanitized string

Definition at line 413 of file parse.php.

Referenced by Automad\Core\Html\addImage(), Automad\Core\Cache\getPageCacheFilePath(), Automad\Core\Automad\makeUrl(), and Automad\GUI\GUI\movePage().

static Automad\Core\Parse::siteData ( )
static

Parse Site Data to replace defaults.

Get all sitewide settings (like site name, the theme etc.) from the main settings file in the root of the /shared directory.

Returns
Array with the site's settings

Definition at line 447 of file parse.php.

Referenced by Automad\GUI\GUI\__construct(), and Automad\Core\Automad\__construct().

static Automad\Core\Parse::textFile (   $file)
static

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
Returns
array $vars

Definition at line 473 of file parse.php.


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