Property | Type | Description | |
---|---|---|---|
$config | array | null | Current configuration of this Pico instance | |
$configDir | string | Config directory of this Pico instance | |
$content | string | null | Parsed content being served | |
$currentPage | array | null | Data of the page being served | |
$locked | boolean | Boolean indicating whether Pico started processing yet | |
$meta | array | null | Meta data of the page to serve | |
$nextPage | array | null | Data of the next page relative to the page being served | |
$pages | array[] | null | List of known pages | |
$parsedown | ParsedownExtra | null | Parsedown Extra instance used for markdown parsing | |
$plugins | object[] | null | List of loaded plugins | |
$pluginsDir | string | Plugins directory of this Pico instance | |
$previousPage | array | null | Data of the previous page relative to the page being served | |
$rawContent | string | null | Raw, not yet parsed contents to serve | |
$requestFile | string | null | Absolute path to the content file being served | |
$requestUrl | string | null | Part of the URL describing the requested contents | |
$rootDir | string | Root directory of this Pico instance | |
$themesDir | string | Themes directory of this Pico instance | |
$twig | Twig_Environment | null | Twig instance used for template parsing | |
$twigVariables | array | null | Variables passed to the twig template |
Method | Description | |
---|---|---|
__construct ( string $rootDir, string $configDir, string $pluginsDir, string $themesDir ) | Constructs a new Pico instance | |
getAbsolutePath ( string $path ) : string | Makes a relative path absolute to Pico's root dir | |
getBaseUrl ( ) : string | Returns the base URL of this Pico instance | |
getConfig ( string $configName = null ) : mixed | Returns either the value of the specified config variable or the config array | |
getConfigDir ( ) : string | Returns the config directory of this Pico instance | |
getCurrentPage ( ) : array | null | Returns the data of the requested page | |
getFileContent ( ) : string | null | Returns the cached contents of the requested page | |
getFileMeta ( ) : array | null | Returns the parsed meta data of the requested page | |
getMetaHeaders ( ) : string[] | Returns known meta headers and triggers the onMetaHeaders event | |
getNextPage ( ) : array | null | Returns the data of the next page relative to the page being served | |
getPageUrl ( string $page, array | string $queryData = null ) : string | Returns the URL to a given page | |
getPages ( ) : array[] | null | Returns the list of known pages | |
getParsedown ( ) : ParsedownExtra | null | Returns the Parsedown Extra markdown parser | |
getPlugin ( string $pluginName ) : object | Returns the instance of a named plugin | |
getPlugins ( ) : object[] | null | Returns all loaded plugins | |
getPluginsDir ( ) : string | Returns the plugins directory of this Pico instance | |
getPreviousPage ( ) : array | null | Returns the data of the previous page relative to the page being served | |
getRawContent ( ) : string | null | Returns the raw contents, either of the requested or the 404 file | |
getRequestFile ( ) : string | null | Returns the absolute path to the content file to serve | |
getRequestUrl ( ) : string | null | Returns the URL where a user requested the page | |
getRootDir ( ) : string | Returns the root directory of this Pico instance | |
getThemesDir ( ) : string | Returns the themes directory of this Pico instance | |
getTwig ( ) : Twig_Environment | null | Returns the twig template engine | |
isUrlRewritingEnabled ( ) : boolean | Returns true if URL rewriting is enabled | |
load404Content ( string $file ) : string | Returns the raw contents of the first found 404 file when traversing up from the directory the requested file is in | |
loadFileContent ( string $file ) : string | Returns the raw contents of a file | |
parseFileContent ( string $content ) : string | Parses the contents of a page using ParsedownExtra | |
parseFileMeta ( string $rawContent, array $headers ) : array | Parses the file meta from raw file contents | |
prepareFileContent ( string $rawContent, array $meta ) : string | Applies some static preparations to the raw contents of a page, e.g. removing the meta header and replacing %base_url% | |
run ( ) : string | Runs this Pico instance | |
setConfig ( array $config ) : void | Sets Pico's config before calling Pico::run() |
Method | Description | |
---|---|---|
discoverCurrentPage ( ) : void | Walks through the list of known pages and discovers the requested page as well as the previous and next page relative to it | |
discoverRequestFile ( ) : void | Uses the request URL to discover the content file to serve | |
evaluateRequestUrl ( ) : void | Evaluates the requested URL | |
getFiles ( string $directory, string $fileExtension = '', integer $order = self::SORT_ASC ) : array | Recursively walks through a directory and returns all containing files matching the specified file extension | |
getTwigVariables ( ) : array | Returns the variables passed to the template | |
loadConfig ( ) : void | Loads the config.php from Pico::$configDir | |
loadPlugins ( ) : void | Loads plugins from Pico::$pluginsDir in alphabetical order | |
readPages ( ) : void | Reads the data of all pages known to Pico | |
registerParsedown ( ) : void | Registers the Parsedown Extra markdown parser | |
registerTwig ( ) : void | Registers the twig template engine | |
sortPages ( ) : void | Sorts all pages known to Pico | |
triggerEvent ( string $eventName, array $params = [] ) : void | Triggers events on plugins which implement PicoPluginInterface |
public __construct ( string $rootDir, string $configDir, string $pluginsDir, string $themesDir ) | ||
$rootDir | string | root directory of this Pico instance |
$configDir | string | config directory of this Pico instance |
$pluginsDir | string | plugins directory of this Pico instance |
$themesDir | string | themes directory of this Pico instance |
protected discoverCurrentPage ( ) : void | ||
return | void |
protected discoverRequestFile ( ) : void | ||
return | void |
protected evaluateRequestUrl ( ) : void | ||
return | void |
public getAbsolutePath ( string $path ) : string | ||
$path | string | relative or absolute path |
return | string | absolute path |
public getBaseUrl ( ) : string | ||
return | string | the base url |
public getConfigDir ( ) : string | ||
return | string | config directory path |
public getCurrentPage ( ) : array | null | ||
return | array | null | page data |
public getFileContent ( ) : string | null | ||
return | string | null | parsed contents |
public getFileMeta ( ) : array | null | ||
return | array | null | parsed meta data |
protected getFiles ( string $directory, string $fileExtension = '', integer $order = self::SORT_ASC ) : array | ||
$directory | string | start directory |
$fileExtension | string | return files with the given file extension only (optional) |
$order | integer | specify whether and how files should be sorted; use Pico::SORT_ASC for a alphabetical ascending order (this is the default behaviour), Pico::SORT_DESC for a descending order or Pico::SORT_NONE to leave the result unsorted |
return | array | list of found files |
public getMetaHeaders ( ) : string[] | ||
return | string[] | known meta headers; the array value specifies the YAML key to search for, the array key is later used to access the found value |
public getNextPage ( ) : array | null | ||
return | array | null | page data |
public getParsedown ( ) : ParsedownExtra | null | ||
return | ParsedownExtra | null | Parsedown Extra markdown parser |
public getPlugins ( ) : object[] | null | ||
return | object[] | null |
public getPluginsDir ( ) : string | ||
return | string | plugins directory path |
public getPreviousPage ( ) : array | null | ||
return | array | null | page data |
public getRawContent ( ) : string | null | ||
return | string | null | raw contents |
public getRequestFile ( ) : string | null | ||
return | string | null | file path |
public getRequestUrl ( ) : string | null | ||
return | string | null | request URL |
public getRootDir ( ) : string | ||
return | string | root directory path |
public getThemesDir ( ) : string | ||
return | string | themes directory path |
protected getTwigVariables ( ) : array | ||
return | array | template variables |
public isUrlRewritingEnabled ( ) : boolean | ||
return | boolean | true if URL rewriting is enabled, false otherwise |
public load404Content ( string $file ) : string | ||
$file | string | path to requested (but not existing) file |
return | string | raw contents of the 404 file |
protected loadConfig ( ) : void | ||
return | void |
public loadFileContent ( string $file ) : string | ||
$file | string | file path |
return | string | raw contents of the file |
protected loadPlugins ( ) : void | ||
return | void |
public parseFileContent ( string $content ) : string | ||
$content | string | raw contents of a page (Markdown) |
return | string | parsed contents (HTML) |
protected registerParsedown ( ) : void | ||
return | void |
protected registerTwig ( ) : void | ||
return | void |
protected string $configDir | ||
return | string |
protected bool $locked | ||
return | boolean |
protected array[]|null $pages | ||
return | array[] | null |
protected ParsedownExtra|null $parsedown | ||
return | ParsedownExtra | null |
protected object[]|null $plugins | ||
return | object[] | null |
protected string $pluginsDir | ||
return | string |
protected string $rootDir | ||
return | string |
protected string $themesDir | ||
return | string |
protected Twig_Environment|null $twig | ||
return | Twig_Environment | null |