2015-08-28 16:28:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pico dummy plugin - a template for plugins
|
|
|
|
*
|
|
|
|
* You're a plugin developer? This template may be helpful :-)
|
|
|
|
* Simply remove the events you don't need and add your own logic.
|
|
|
|
*
|
|
|
|
* @author Daniel Rudolf
|
|
|
|
* @link http://picocms.org
|
2016-05-23 13:13:56 +00:00
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License
|
2016-12-12 14:31:06 +00:00
|
|
|
* @version 2.0
|
2015-08-28 16:28:25 +00:00
|
|
|
*/
|
2017-05-07 12:15:24 +00:00
|
|
|
class DummyPlugin extends AbstractPicoPlugin
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
2017-05-10 15:00:48 +00:00
|
|
|
/**
|
|
|
|
* API version used by this plugin
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
const API_VERSION = 2;
|
|
|
|
|
2015-08-28 16:28:25 +00:00
|
|
|
/**
|
2017-05-07 12:15:24 +00:00
|
|
|
* This plugin is disabled by default
|
|
|
|
*
|
|
|
|
* If you want to enable your plugin by default, simply remove this class
|
|
|
|
* property.
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see AbstractPicoPlugin::$enabled
|
2015-10-29 01:55:30 +00:00
|
|
|
* @var boolean
|
2015-08-28 16:28:25 +00:00
|
|
|
*/
|
|
|
|
protected $enabled = false;
|
|
|
|
|
|
|
|
/**
|
2015-10-29 01:55:30 +00:00
|
|
|
* This plugin depends on ...
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2017-05-07 12:15:24 +00:00
|
|
|
* If your plugin doesn't depend on any other plugin, remove this class
|
|
|
|
* property.
|
|
|
|
*
|
2015-08-28 16:28:25 +00:00
|
|
|
* @see AbstractPicoPlugin::$dependsOn
|
2015-10-29 01:55:30 +00:00
|
|
|
* @var string[]
|
2015-08-28 16:28:25 +00:00
|
|
|
*/
|
|
|
|
protected $dependsOn = array();
|
|
|
|
|
|
|
|
/**
|
2015-10-09 18:51:07 +00:00
|
|
|
* Triggered after Pico has loaded all available plugins
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* This event is triggered nevertheless the plugin is enabled or not.
|
|
|
|
* It is NOT guaranteed that plugin dependencies are fulfilled!
|
|
|
|
*
|
|
|
|
* @see Pico::getPlugin()
|
|
|
|
* @see Pico::getPlugins()
|
2017-05-13 16:17:19 +00:00
|
|
|
* @param object[] $plugins loaded plugin instances
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-05-13 16:17:19 +00:00
|
|
|
public function onPluginsLoaded(array $plugins)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when Pico manually loads a plugin
|
|
|
|
*
|
|
|
|
* @see Pico::getPlugin()
|
|
|
|
* @see Pico::getPlugins()
|
|
|
|
* @param object $plugin loaded plugin instance
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onPluginManuallyLoaded($plugin)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has read its configuration
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getConfig()
|
2016-01-25 18:31:53 +00:00
|
|
|
* @param array &$config array of config variables
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-25 03:07:46 +00:00
|
|
|
public function onConfigLoaded(array &$config)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has evaluated the request URL
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getRequestUrl()
|
2015-10-27 00:39:28 +00:00
|
|
|
* @param string &$url part of the URL describing the requested contents
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onRequestUrl(&$url)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has discovered the content file to serve
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see Pico::getBaseUrl()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @see Pico::getRequestFile()
|
2015-10-27 00:39:28 +00:00
|
|
|
* @param string &$file absolute path to the content file to serve
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onRequestFile(&$file)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered before Pico reads the contents of the file to serve
|
|
|
|
*
|
|
|
|
* @see Pico::loadFileContent()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::onContentLoaded()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @param string &$file path to the file which contents will be read
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onContentLoading(&$file)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has read the contents of the file to serve
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getRawContent()
|
|
|
|
* @param string &$rawContent raw file contents
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onContentLoaded(&$rawContent)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-29 01:55:30 +00:00
|
|
|
* Triggered before Pico reads the contents of a 404 file
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::load404Content()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::on404ContentLoaded()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @param string &$file path to the file which contents were requested
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function on404ContentLoading(&$file)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has read the contents of the 404 file
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getRawContent()
|
|
|
|
* @param string &$rawContent raw file contents
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function on404ContentLoaded(&$rawContent)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 18:51:07 +00:00
|
|
|
* Triggered when Pico reads its known meta header fields
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getMetaHeaders()
|
2015-10-27 00:48:58 +00:00
|
|
|
* @param string[] &$headers list of known meta header
|
2015-10-27 00:39:28 +00:00
|
|
|
* fields; the array value specifies the YAML key to search for, the
|
|
|
|
* array key is later used to access the found value
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-25 03:07:46 +00:00
|
|
|
public function onMetaHeaders(array &$headers)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered before Pico parses the meta header
|
|
|
|
*
|
|
|
|
* @see Pico::parseFileMeta()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::onMetaParsed()
|
2015-10-27 00:48:58 +00:00
|
|
|
* @param string &$rawContent raw file contents
|
|
|
|
* @param string[] &$headers known meta header fields
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-25 03:07:46 +00:00
|
|
|
public function onMetaParsing(&$rawContent, array &$headers)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has parsed the meta header
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getFileMeta()
|
2015-10-27 00:48:58 +00:00
|
|
|
* @param string[] &$meta parsed meta data
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-25 03:07:46 +00:00
|
|
|
public function onMetaParsed(array &$meta)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered before Pico parses the pages content
|
|
|
|
*
|
|
|
|
* @see Pico::prepareFileContent()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::prepareFileContent()
|
|
|
|
* @see DummyPlugin::onContentParsed()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @param string &$rawContent raw file contents
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onContentParsing(&$rawContent)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has prepared the raw file contents for parsing
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::parseFileContent()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::onContentParsed()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @param string &$content prepared file contents for parsing
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-06 00:08:31 +00:00
|
|
|
public function onContentPrepared(&$content)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 15:35:15 +00:00
|
|
|
* Triggered after Pico has parsed the contents of the file to serve
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
|
|
|
* @see Pico::getFileContent()
|
2015-09-13 18:46:09 +00:00
|
|
|
* @param string &$content parsed contents
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onContentParsed(&$content)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
2015-10-29 01:55:30 +00:00
|
|
|
/**
|
|
|
|
* Triggered before Pico reads all known pages
|
|
|
|
*
|
|
|
|
* @see Pico::readPages()
|
2017-05-07 12:15:24 +00:00
|
|
|
* @see DummyPlugin::onSinglePageLoading()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::onSinglePageLoaded()
|
2017-05-13 16:08:54 +00:00
|
|
|
* @see DummyPlugin::onPagesDiscovered()
|
2015-10-29 01:55:30 +00:00
|
|
|
* @see DummyPlugin::onPagesLoaded()
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onPagesLoading()
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
2015-08-28 16:28:25 +00:00
|
|
|
/**
|
2017-05-07 12:15:24 +00:00
|
|
|
* Triggered before Pico loads a single page
|
|
|
|
*
|
2017-05-13 16:08:54 +00:00
|
|
|
* Set `$id` to `null` to remove this page from the pages array.
|
|
|
|
*
|
2017-05-07 12:15:24 +00:00
|
|
|
* @see DummyPlugin::onSinglePageLoaded()
|
2017-05-13 16:08:54 +00:00
|
|
|
* @see DummyPlugin::onPagesDiscovered()
|
2017-05-07 12:15:24 +00:00
|
|
|
* @see DummyPlugin::onPagesLoaded()
|
|
|
|
* @param string &$id relative path to the content file
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onSinglePageLoading(&$id)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when Pico loads a single page
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2015-10-29 17:13:35 +00:00
|
|
|
* The `$pageData` parameter consists of the following values:
|
2015-12-07 14:17:39 +00:00
|
|
|
*
|
2015-10-29 17:13:35 +00:00
|
|
|
* | Array key | Type | Description |
|
2015-12-07 14:17:39 +00:00
|
|
|
* | -------------- | ------ | ---------------------------------------- |
|
2015-10-29 17:13:35 +00:00
|
|
|
* | 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 |
|
2015-10-27 00:39:28 +00:00
|
|
|
*
|
2017-05-07 12:15:24 +00:00
|
|
|
* Set `$pageData` to `null` to remove this page from the pages array.
|
|
|
|
*
|
2017-05-13 16:08:54 +00:00
|
|
|
* @see DummyPlugin::onPagesDiscovered()
|
2015-10-29 17:07:45 +00:00
|
|
|
* @see DummyPlugin::onPagesLoaded()
|
|
|
|
* @param array &$pageData data of the loaded page
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-11-25 03:07:46 +00:00
|
|
|
public function onSinglePageLoaded(array &$pageData)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-13 16:08:54 +00:00
|
|
|
* Triggered after Pico has discovered all known pages
|
|
|
|
*
|
|
|
|
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the
|
|
|
|
* structure of the page data. Please note that the pages array isn't
|
|
|
|
* sorted yet.
|
|
|
|
*
|
|
|
|
* @see Pico::sortPages()
|
|
|
|
* @see DummyPlugin::onPagesLoaded()
|
|
|
|
* @param array[] &$pages data of all known pages
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onPagesDiscovered(array &$pages)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered after Pico has sorted the pages array
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2015-10-27 00:39:28 +00:00
|
|
|
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the
|
|
|
|
* structure of the page data.
|
|
|
|
*
|
2015-08-28 16:28:25 +00:00
|
|
|
* @see Pico::getPages()
|
2017-05-13 16:08:54 +00:00
|
|
|
* @param array[] &$pages data of all known pages
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onPagesLoaded(array &$pages)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when Pico discovered the current, previous and next pages
|
|
|
|
*
|
|
|
|
* See {@link DummyPlugin::onSinglePageLoaded()} for details about the
|
|
|
|
* structure of the page data.
|
|
|
|
*
|
|
|
|
* @see Pico::discoverPageSiblings()
|
|
|
|
* @see Pico::discoverCurrentPage()
|
2015-08-28 16:28:25 +00:00
|
|
|
* @see Pico::getCurrentPage()
|
|
|
|
* @see Pico::getPreviousPage()
|
|
|
|
* @see Pico::getNextPage()
|
2015-11-25 03:07:46 +00:00
|
|
|
* @param array|null &$currentPage data of the page being served
|
|
|
|
* @param array|null &$previousPage data of the previous page
|
|
|
|
* @param array|null &$nextPage data of the next page
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-05-13 16:08:54 +00:00
|
|
|
public function onCurrentPageDiscovered(
|
2015-11-27 18:31:22 +00:00
|
|
|
array &$currentPage = null,
|
|
|
|
array &$previousPage = null,
|
|
|
|
array &$nextPage = null
|
|
|
|
) {
|
2015-08-28 16:28:25 +00:00
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-13 16:08:54 +00:00
|
|
|
* Triggered before Pico renders the page
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2017-05-13 16:08:54 +00:00
|
|
|
* @see Pico::getTwigTemplate()
|
|
|
|
* @see Pico::getTwigVariables()
|
|
|
|
* @see DummyPlugin::onPageRendered()
|
|
|
|
* @param string &$templateName file name of the template
|
|
|
|
* @param array &$twigVariables template variables
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-05-13 16:08:54 +00:00
|
|
|
public function onPageRendering(&$templateName, array &$twigVariables)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-13 16:08:54 +00:00
|
|
|
* Triggered after Pico has rendered the page
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2017-05-13 16:08:54 +00:00
|
|
|
* @param string &$output contents which will be sent to the user
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-05-13 16:08:54 +00:00
|
|
|
public function onPageRendered(&$output)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-13 16:08:54 +00:00
|
|
|
* Triggered when Pico registers the YAML parser
|
2015-08-28 16:28:25 +00:00
|
|
|
*
|
2017-05-13 16:08:54 +00:00
|
|
|
* @see Pico::getYamlParser()
|
|
|
|
* @param \Symfony\Component\Yaml\Parser &$yamlParser YAML parser instance
|
2015-08-28 16:28:25 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-05-13 16:08:54 +00:00
|
|
|
public function onYamlParserRegistered(\Symfony\Component\Yaml\Parser &$yamlParser)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when Pico registers the Parsedown parser
|
|
|
|
*
|
|
|
|
* @see Pico::getParsedown()
|
|
|
|
* @param Parsedown &$parsedown Parsedown instance
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onParsedownRegistered(Parsedown &$parsedown)
|
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when Pico registers the twig template engine
|
|
|
|
*
|
|
|
|
* @see Pico::getTwig()
|
|
|
|
* @param Twig_Environment &$twig Twig instance
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function onTwigRegistered(Twig_Environment &$twig)
|
2015-08-28 16:28:25 +00:00
|
|
|
{
|
|
|
|
// your code
|
|
|
|
}
|
|
|
|
}
|