DummyPlugin.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <?php
  2. /**
  3. * Pico dummy plugin - a template for plugins
  4. *
  5. * You're a plugin developer? This template may be helpful :-)
  6. * Simply remove the events you don't need and add your own logic.
  7. *
  8. * @author Daniel Rudolf
  9. * @link http://picocms.org
  10. * @license http://opensource.org/licenses/MIT The MIT License
  11. * @version 1.0
  12. */
  13. final class DummyPlugin extends AbstractPicoPlugin
  14. {
  15. /**
  16. * This plugin is enabled by default?
  17. *
  18. * @see AbstractPicoPlugin::$enabled
  19. * @var boolean
  20. */
  21. protected $enabled = false;
  22. /**
  23. * This plugin depends on ...
  24. *
  25. * @see AbstractPicoPlugin::$dependsOn
  26. * @var string[]
  27. */
  28. protected $dependsOn = array();
  29. /**
  30. * Triggered after Pico has loaded all available plugins
  31. *
  32. * This event is triggered nevertheless the plugin is enabled or not.
  33. * It is NOT guaranteed that plugin dependencies are fulfilled!
  34. *
  35. * @see Pico::getPlugin()
  36. * @see Pico::getPlugins()
  37. * @param object[] &$plugins loaded plugin instances
  38. * @return void
  39. */
  40. public function onPluginsLoaded(array &$plugins)
  41. {
  42. // your code
  43. }
  44. /**
  45. * Triggered after Pico has read its configuration
  46. *
  47. * @see Pico::getConfig()
  48. * @param array &$config array of config variables
  49. * @return void
  50. */
  51. public function onConfigLoaded(array &$config)
  52. {
  53. // your code
  54. }
  55. /**
  56. * Triggered after Pico has evaluated the request URL
  57. *
  58. * @see Pico::getRequestUrl()
  59. * @param string &$url part of the URL describing the requested contents
  60. * @return void
  61. */
  62. public function onRequestUrl(&$url)
  63. {
  64. // your code
  65. }
  66. /**
  67. * Triggered after Pico has discovered the content file to serve
  68. *
  69. * @see Pico::getBaseUrl()
  70. * @see Pico::getRequestFile()
  71. * @param string &$file absolute path to the content file to serve
  72. * @return void
  73. */
  74. public function onRequestFile(&$file)
  75. {
  76. // your code
  77. }
  78. /**
  79. * Triggered before Pico reads the contents of the file to serve
  80. *
  81. * @see Pico::loadFileContent()
  82. * @see DummyPlugin::onContentLoaded()
  83. * @param string &$file path to the file which contents will be read
  84. * @return void
  85. */
  86. public function onContentLoading(&$file)
  87. {
  88. // your code
  89. }
  90. /**
  91. * Triggered after Pico has read the contents of the file to serve
  92. *
  93. * @see Pico::getRawContent()
  94. * @param string &$rawContent raw file contents
  95. * @return void
  96. */
  97. public function onContentLoaded(&$rawContent)
  98. {
  99. // your code
  100. }
  101. /**
  102. * Triggered before Pico reads the contents of a 404 file
  103. *
  104. * @see Pico::load404Content()
  105. * @see DummyPlugin::on404ContentLoaded()
  106. * @param string &$file path to the file which contents were requested
  107. * @return void
  108. */
  109. public function on404ContentLoading(&$file)
  110. {
  111. // your code
  112. }
  113. /**
  114. * Triggered after Pico has read the contents of the 404 file
  115. *
  116. * @see Pico::getRawContent()
  117. * @param string &$rawContent raw file contents
  118. * @return void
  119. */
  120. public function on404ContentLoaded(&$rawContent)
  121. {
  122. // your code
  123. }
  124. /**
  125. * Triggered when Pico reads its known meta header fields
  126. *
  127. * @see Pico::getMetaHeaders()
  128. * @param string[] &$headers list of known meta header
  129. * fields; the array value specifies the YAML key to search for, the
  130. * array key is later used to access the found value
  131. * @return void
  132. */
  133. public function onMetaHeaders(array &$headers)
  134. {
  135. // your code
  136. }
  137. /**
  138. * Triggered before Pico parses the meta header
  139. *
  140. * @see Pico::parseFileMeta()
  141. * @see DummyPlugin::onMetaParsed()
  142. * @param string &$rawContent raw file contents
  143. * @param string[] &$headers known meta header fields
  144. * @return void
  145. */
  146. public function onMetaParsing(&$rawContent, array &$headers)
  147. {
  148. // your code
  149. }
  150. /**
  151. * Triggered after Pico has parsed the meta header
  152. *
  153. * @see Pico::getFileMeta()
  154. * @param string[] &$meta parsed meta data
  155. * @return void
  156. */
  157. public function onMetaParsed(array &$meta)
  158. {
  159. // your code
  160. }
  161. /**
  162. * Triggered before Pico parses the pages content
  163. *
  164. * @see Pico::prepareFileContent()
  165. * @see DummyPlugin::prepareFileContent()
  166. * @see DummyPlugin::onContentParsed()
  167. * @param string &$rawContent raw file contents
  168. * @return void
  169. */
  170. public function onContentParsing(&$rawContent)
  171. {
  172. // your code
  173. }
  174. /**
  175. * Triggered after Pico has prepared the raw file contents for parsing
  176. *
  177. * @see Pico::parseFileContent()
  178. * @see DummyPlugin::onContentParsed()
  179. * @param string &$content prepared file contents for parsing
  180. * @return void
  181. */
  182. public function onContentPrepared(&$content)
  183. {
  184. // your code
  185. }
  186. /**
  187. * Triggered after Pico has parsed the contents of the file to serve
  188. *
  189. * @see Pico::getFileContent()
  190. * @param string &$content parsed contents
  191. * @return void
  192. */
  193. public function onContentParsed(&$content)
  194. {
  195. // your code
  196. }
  197. /**
  198. * Triggered before Pico reads all known pages
  199. *
  200. * @see Pico::readPages()
  201. * @see DummyPlugin::onSinglePageLoaded()
  202. * @see DummyPlugin::onPagesLoaded()
  203. * @return void
  204. */
  205. public function onPagesLoading()
  206. {
  207. // your code
  208. }
  209. /**
  210. * Triggered when Pico reads a single page from the list of all known pages
  211. *
  212. * The `$pageData` parameter consists of the following values:
  213. *
  214. * | Array key | Type | Description |
  215. * | -------------- | ------ | ---------------------------------------- |
  216. * | id | string | relative path to the content file |
  217. * | url | string | URL to the page |
  218. * | title | string | title of the page (YAML header) |
  219. * | description | string | description of the page (YAML header) |
  220. * | author | string | author of the page (YAML header) |
  221. * | time | string | timestamp derived from the Date header |
  222. * | date | string | date of the page (YAML header) |
  223. * | date_formatted | string | formatted date of the page |
  224. * | raw_content | string | raw, not yet parsed contents of the page |
  225. * | meta | string | parsed meta data of the page |
  226. *
  227. * @see DummyPlugin::onPagesLoaded()
  228. * @param array &$pageData data of the loaded page
  229. * @return void
  230. */
  231. public function onSinglePageLoaded(array &$pageData)
  232. {
  233. // your code
  234. }
  235. /**
  236. * Triggered after Pico has read all known pages
  237. *
  238. * See {@link DummyPlugin::onSinglePageLoaded()} for details about the
  239. * structure of the page data.
  240. *
  241. * @see Pico::getPages()
  242. * @see Pico::getCurrentPage()
  243. * @see Pico::getPreviousPage()
  244. * @see Pico::getNextPage()
  245. * @param array[] &$pages data of all known pages
  246. * @param array|null &$currentPage data of the page being served
  247. * @param array|null &$previousPage data of the previous page
  248. * @param array|null &$nextPage data of the next page
  249. * @return void
  250. */
  251. public function onPagesLoaded(
  252. array &$pages,
  253. array &$currentPage = null,
  254. array &$previousPage = null,
  255. array &$nextPage = null
  256. ) {
  257. // your code
  258. }
  259. /**
  260. * Triggered before Pico registers the twig template engine
  261. *
  262. * @return void
  263. */
  264. public function onTwigRegistration()
  265. {
  266. // your code
  267. }
  268. /**
  269. * Triggered before Pico renders the page
  270. *
  271. * @see Pico::getTwig()
  272. * @see DummyPlugin::onPageRendered()
  273. * @param Twig_Environment &$twig twig template engine
  274. * @param array &$twigVariables template variables
  275. * @param string &$templateName file name of the template
  276. * @return void
  277. */
  278. public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
  279. {
  280. // your code
  281. }
  282. /**
  283. * Triggered after Pico has rendered the page
  284. *
  285. * @param string &$output contents which will be sent to the user
  286. * @return void
  287. */
  288. public function onPageRendered(&$output)
  289. {
  290. // your code
  291. }
  292. }