PHP 클래스 Pico

Pico is a stupidly simple, blazing fast, flat file CMS. - Stupidly Simple: Pico makes creating and maintaining a website as simple as editing text files. - Blazing Fast: Pico is seriously lightweight and doesn't use a database, making it super fast. - No Database: Pico is a "flat file" CMS, meaning no database woes, no MySQL queries, nothing. - Markdown Formatting: Edit your website in your favourite text editor using simple Markdown formatting. - Twig Templates: Pico uses the Twig templating engine, for powerful and flexible themes. - Open Source: Pico is completely free and open source, released under the MIT license. See for more info.
저자: Gilbert Pellegrom
저자: Daniel Rudolf
파일 보기 프로젝트 열기: gilbitron/pico 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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

공개 메소드들

메소드 설명
__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()

보호된 메소드들

메소드 설명
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

메소드 상세

__construct() 공개 메소드

To carry out all the processing in Pico, call {@link Pico::run()}.
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

discoverCurrentPage() 보호된 메소드

Walks through the list of known pages and discovers the requested page as well as the previous and next page relative to it
또한 보기: Pico::getCurrentPage()
또한 보기: Pico::getPreviousPage()
또한 보기: Pico::getNextPage()
protected discoverCurrentPage ( ) : void
리턴 void

discoverRequestFile() 보호된 메소드

Uses the request URL to discover the content file to serve
또한 보기: Pico::getRequestFile()
protected discoverRequestFile ( ) : void
리턴 void

evaluateRequestUrl() 보호된 메소드

Pico 1.0 uses the QUERY_STRING routing method (e.g. /pico/?sub/page) to support SEO-like URLs out-of-the-box with any webserver. You can still setup URL rewriting (e.g. using mod_rewrite on Apache) to basically remove the ? from URLs, but your rewritten URLs must follow the new QUERY_STRING principles. URL rewriting requires some special configuration on your webserver, but this should be "basic work" for any webmaster... Pico 0.9 and older required Apache with mod_rewrite enabled, thus old plugins, templates and contents may require you to enable URL rewriting to work. If you're upgrading from Pico 0.9, you will probably have to update your rewriting rules. We recommend you to use the link filter in templates to create internal links, e.g. {{ "sub/page"|link }} is equivalent to {{ base_url }}/sub/page and {{ base_url }}?sub/page, depending on enabled URL rewriting. In content files you can use the %base_url% variable; e.g. %base_url%?sub/page will be replaced accordingly.
또한 보기: Pico::getRequestUrl()
protected evaluateRequestUrl ( ) : void
리턴 void

getAbsolutePath() 공개 메소드

This method also guarantees a trailing slash.
public getAbsolutePath ( string $path ) : string
$path string relative or absolute path
리턴 string absolute path

getBaseUrl() 공개 메소드

Security Notice: You MUST configure Pico's base URL explicitly when using the base URL in contexts that are potentially vulnerable to HTTP Host Header Injection attacks (e.g. when generating emails).
public getBaseUrl ( ) : string
리턴 string the base url

getConfig() 공개 메소드

Returns either the value of the specified config variable or the config array
또한 보기: Pico::setConfig()
또한 보기: Pico::loadConfig()
public getConfig ( string $configName = null ) : mixed
$configName string optional name of a config variable
리턴 mixed returns either the value of the named config variable, null if the config variable doesn't exist or the config array if no config name was supplied

getConfigDir() 공개 메소드

Returns the config directory of this Pico instance
public getConfigDir ( ) : string
리턴 string config directory path

getCurrentPage() 공개 메소드

Returns the data of the requested page
또한 보기: Pico::discoverCurrentPage()
public getCurrentPage ( ) : array | null
리턴 array | null page data

getFileContent() 공개 메소드

Returns the cached contents of the requested page
또한 보기: Pico::prepareFileContent()
또한 보기: Pico::parseFileContent()
public getFileContent ( ) : string | null
리턴 string | null parsed contents

getFileMeta() 공개 메소드

Returns the parsed meta data of the requested page
또한 보기: Pico::parseFileMeta()
public getFileMeta ( ) : array | null
리턴 array | null parsed meta data

getFiles() 보호된 메소드

Recursively walks through a directory and returns all containing files matching the specified file extension
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
리턴 array list of found files

getMetaHeaders() 공개 메소드

Heads up! Calling this method triggers the onMetaHeaders event. Keep this in mind to prevent a infinite loop!
public getMetaHeaders ( ) : string[]
리턴 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

getNextPage() 공개 메소드

Returns the data of the next page relative to the page being served
또한 보기: Pico::discoverCurrentPage()
public getNextPage ( ) : array | null
리턴 array | null page data

getPageUrl() 공개 메소드

Returns the URL to a given page
public getPageUrl ( string $page, array | string $queryData = null ) : string
$page string identifier of the page to link to
$queryData array | string either an array containing properties to create a URL-encoded query string from, or a already encoded string
리턴 string URL

getPages() 공개 메소드

Returns the list of known pages
또한 보기: Pico::readPages()
또한 보기: Pico::sortPages()
public getPages ( ) : array[] | null
리턴 array[] | null the data of all pages

getParsedown() 공개 메소드

Returns the Parsedown Extra markdown parser
또한 보기: Pico::registerParsedown()
public getParsedown ( ) : ParsedownExtra | null
리턴 ParsedownExtra | null Parsedown Extra markdown parser

getPlugin() 공개 메소드

Plugins SHOULD implement {@link PicoPluginInterface}, but you MUST NOT rely on it. For more information see {@link PicoPluginInterface}.
또한 보기: Pico::loadPlugins()
또한 보기: Pico::getPlugins()
public getPlugin ( string $pluginName ) : object
$pluginName string name of the plugin
리턴 object instance of the plugin

getPlugins() 공개 메소드

Returns all loaded plugins
또한 보기: Pico::loadPlugins()
또한 보기: Pico::getPlugin()
public getPlugins ( ) : object[] | null
리턴 object[] | null

getPluginsDir() 공개 메소드

Returns the plugins directory of this Pico instance
public getPluginsDir ( ) : string
리턴 string plugins directory path

getPreviousPage() 공개 메소드

Returns the data of the previous page relative to the page being served
또한 보기: Pico::discoverCurrentPage()
public getPreviousPage ( ) : array | null
리턴 array | null page data

getRawContent() 공개 메소드

Returns the raw contents, either of the requested or the 404 file
또한 보기: Pico::loadFileContent()
또한 보기: Pico::load404Content()
public getRawContent ( ) : string | null
리턴 string | null raw contents

getRequestFile() 공개 메소드

Returns the absolute path to the content file to serve
또한 보기: Pico::discoverRequestFile()
public getRequestFile ( ) : string | null
리턴 string | null file path

getRequestUrl() 공개 메소드

Returns the URL where a user requested the page
또한 보기: Pico::evaluateRequestUrl()
public getRequestUrl ( ) : string | null
리턴 string | null request URL

getRootDir() 공개 메소드

Returns the root directory of this Pico instance
public getRootDir ( ) : string
리턴 string root directory path

getThemesDir() 공개 메소드

Returns the themes directory of this Pico instance
public getThemesDir ( ) : string
리턴 string themes directory path

getTwig() 공개 메소드

Returns the twig template engine
또한 보기: Pico::registerTwig()
public getTwig ( ) : Twig_Environment | null
리턴 Twig_Environment | null Twig template engine

getTwigVariables() 보호된 메소드

URLs and paths (namely base_dir, base_url, theme_dir and theme_url) don't add a trailing slash for historic reasons.
protected getTwigVariables ( ) : array
리턴 array template variables

isUrlRewritingEnabled() 공개 메소드

Returns true if URL rewriting is enabled
public isUrlRewritingEnabled ( ) : boolean
리턴 boolean true if URL rewriting is enabled, false otherwise

load404Content() 공개 메소드

Returns the raw contents of the first found 404 file when traversing up from the directory the requested file is in
또한 보기: Pico::getRawContent()
public load404Content ( string $file ) : string
$file string path to requested (but not existing) file
리턴 string raw contents of the 404 file

loadConfig() 보호된 메소드

Loads the config.php from Pico::$configDir
또한 보기: Pico::setConfig()
또한 보기: Pico::getConfig()
protected loadConfig ( ) : void
리턴 void

loadFileContent() 공개 메소드

Returns the raw contents of a file
또한 보기: Pico::getRawContent()
public loadFileContent ( string $file ) : string
$file string file path
리턴 string raw contents of the file

loadPlugins() 보호된 메소드

Plugin files MAY be prefixed by a number (e.g. 00-PicoDeprecated.php) to indicate their processing order. Plugins without a prefix will be loaded last. If you want to use a prefix, you MUST consider the following directives: - 00 to 19: Reserved - 20 to 39: Low level code helper plugins - 40 to 59: Plugins manipulating routing or the pages array - 60 to 79: Plugins hooking into template or markdown parsing - 80 to 99: Plugins using the onPageRendered event
또한 보기: Pico::getPlugin()
또한 보기: Pico::getPlugins()
protected loadPlugins ( ) : void
리턴 void

parseFileContent() 공개 메소드

Parses the contents of a page using ParsedownExtra
또한 보기: Pico::prepareFileContent()
또한 보기: Pico::getFileContent()
public parseFileContent ( string $content ) : string
$content string raw contents of a page (Markdown)
리턴 string parsed contents (HTML)

parseFileMeta() 공개 메소드

Meta data MUST start on the first line of the file, either opened and closed by --- or C-style block comments (deprecated). The headers are parsed by the YAML component of the Symfony project, keys are lowered. If you're a plugin developer, you MUST register new headers during the onMetaHeaders event first. The implicit availability of headers is for users and pure (!) theme developers ONLY.
또한 보기: Pico::getFileMeta()
또한 보기: http://symfony.com/doc/current/components/yaml/introduction.html
public parseFileMeta ( string $rawContent, array $headers ) : array
$rawContent string the raw file contents
$headers array known meta headers
리턴 array parsed meta data

prepareFileContent() 공개 메소드

Applies some static preparations to the raw contents of a page, e.g. removing the meta header and replacing %base_url%
또한 보기: Pico::parseFileContent()
또한 보기: Pico::getFileContent()
public prepareFileContent ( string $rawContent, array $meta ) : string
$rawContent string raw contents of a page
$meta array meta data to use for %meta.*% replacement
리턴 string contents prepared for parsing

readPages() 보호된 메소드

The page data will be an array containing the following values: | Array key | Type | Description | | -------------- | ------ | ---------------------------------------- | | id | string | relative path to the content file | | url | string | URL to the page | | title | string | title of the page (YAML header) | | description | string | description of the page (YAML header) | | author | string | author of the page (YAML header) | | time | string | timestamp derived from the Date header | | date | string | date of the page (YAML header) | | date_formatted | string | formatted date of the page | | raw_content | string | raw, not yet parsed contents of the page | | meta | string | parsed meta data of the page |
또한 보기: Pico::sortPages()
또한 보기: Pico::getPages()
protected readPages ( ) : void
리턴 void

registerParsedown() 보호된 메소드

Registers the Parsedown Extra markdown parser
또한 보기: Pico::getParsedown()
protected registerParsedown ( ) : void
리턴 void

registerTwig() 보호된 메소드

This method also registers Pico's core Twig filters link and content as well as Pico's {@link PicoTwigExtension} Twig extension.
또한 보기: Pico::getTwig()
protected registerTwig ( ) : void
리턴 void

run() 공개 메소드

Loads plugins, evaluates the config file, does URL routing, parses meta headers, processes Markdown, does Twig processing and returns the rendered contents.
public run ( ) : string
리턴 string rendered Pico contents

setConfig() 공개 메소드

This method allows you to modify Pico's config without creating a {@path "config/config.php"} or changing some of its variables before Pico starts processing. You can call this method between {@link Pico::__construct()} and {@link Pico::run()} only. Options set with this method cannot be overwritten by {@path "config/config.php"}.
또한 보기: Pico::loadConfig()
또한 보기: Pico::getConfig()
public setConfig ( array $config ) : void
$config array array with config variables
리턴 void

sortPages() 보호된 메소드

Sorts all pages known to Pico
또한 보기: Pico::readPages()
또한 보기: Pico::getPages()
protected sortPages ( ) : void
리턴 void

triggerEvent() 보호된 메소드

Deprecated events (as used by plugins not implementing {@link PicoPluginInterface}) are triggered by {@link PicoDeprecated}.
또한 보기: PicoPluginInterface
또한 보기: AbstractPicoPlugin
또한 보기: DummyPlugin
protected triggerEvent ( string $eventName, array $params = [] ) : void
$eventName string name of the event to trigger
$params array optional parameters to pass
리턴 void

프로퍼티 상세

$config 보호되어 있는 프로퍼티

Current configuration of this Pico instance
또한 보기: Pico::getConfig()
protected array|null $config
리턴 array | null

$configDir 보호되어 있는 프로퍼티

Config directory of this Pico instance
또한 보기: Pico::getConfigDir()
protected string $configDir
리턴 string

$content 보호되어 있는 프로퍼티

Parsed content being served
또한 보기: Pico::getFileContent()
protected string|null $content
리턴 string | null

$currentPage 보호되어 있는 프로퍼티

Data of the page being served
또한 보기: Pico::getCurrentPage()
protected array|null $currentPage
리턴 array | null

$locked 보호되어 있는 프로퍼티

Boolean indicating whether Pico started processing yet
protected bool $locked
리턴 boolean

$meta 보호되어 있는 프로퍼티

Meta data of the page to serve
또한 보기: Pico::getFileMeta()
protected array|null $meta
리턴 array | null

$nextPage 보호되어 있는 프로퍼티

Data of the next page relative to the page being served
또한 보기: Pico::getNextPage()
protected array|null $nextPage
리턴 array | null

$pages 보호되어 있는 프로퍼티

List of known pages
또한 보기: Pico::getPages()
protected array[]|null $pages
리턴 array[] | null

$parsedown 보호되어 있는 프로퍼티

Parsedown Extra instance used for markdown parsing
또한 보기: Pico::getParsedown()
protected ParsedownExtra|null $parsedown
리턴 ParsedownExtra | null

$plugins 보호되어 있는 프로퍼티

List of loaded plugins
또한 보기: Pico::getPlugins()
protected object[]|null $plugins
리턴 object[] | null

$pluginsDir 보호되어 있는 프로퍼티

Plugins directory of this Pico instance
또한 보기: Pico::getPluginsDir()
protected string $pluginsDir
리턴 string

$previousPage 보호되어 있는 프로퍼티

Data of the previous page relative to the page being served
또한 보기: Pico::getPreviousPage()
protected array|null $previousPage
리턴 array | null

$rawContent 보호되어 있는 프로퍼티

Raw, not yet parsed contents to serve
또한 보기: Pico::getRawContent()
protected string|null $rawContent
리턴 string | null

$requestFile 보호되어 있는 프로퍼티

Absolute path to the content file being served
또한 보기: Pico::getRequestFile()
protected string|null $requestFile
리턴 string | null

$requestUrl 보호되어 있는 프로퍼티

Part of the URL describing the requested contents
또한 보기: Pico::getRequestUrl()
protected string|null $requestUrl
리턴 string | null

$rootDir 보호되어 있는 프로퍼티

Root directory of this Pico instance
또한 보기: Pico::getRootDir()
protected string $rootDir
리턴 string

$themesDir 보호되어 있는 프로퍼티

Themes directory of this Pico instance
또한 보기: Pico::getThemesDir()
protected string $themesDir
리턴 string

$twig 보호되어 있는 프로퍼티

Twig instance used for template parsing
또한 보기: Pico::getTwig()
protected Twig_Environment|null $twig
리턴 Twig_Environment | null

$twigVariables 보호되어 있는 프로퍼티

Variables passed to the twig template
또한 보기: Pico::getTwigVariables
protected array|null $twigVariables
리턴 array | null