DummyPlugin.php.txt 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
  11. * @version 1.0
  12. */
  13. 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(&$plugins)
  41. {
  42. // your code
  43. }
  44. /**
  45. * Triggered after Pico has read its configuration
  46. *
  47. * @see Pico::getConfig()
  48. * @param mixed[] &$config array of config variables
  49. * @return void
  50. */
  51. public function onConfigLoaded(&$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(&$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, &$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(&$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 prepareFileContent(&$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. * <pre>
  214. * +----------------+--------+------------------------------------------+
  215. * | Array key | Type | Description |
  216. * +----------------+--------+------------------------------------------+
  217. * | id | string | relative path to the content file |
  218. * | url | string | URL to the page |
  219. * | title | string | title of the page (YAML header) |
  220. * | description | string | description of the page (YAML header) |
  221. * | author | string | author of the page (YAML header) |
  222. * | time | string | timestamp derived from the Date header |
  223. * | date | string | date of the page (YAML header) |
  224. * | date_formatted | string | formatted date of the page |
  225. * | raw_content | string | raw, not yet parsed contents of the page |
  226. * | meta | string | parsed meta data of the page |
  227. * +----------------+--------+------------------------------------------+
  228. * </pre>
  229. *
  230. * @see DummyPlugin::onPagesLoaded()
  231. * @param array &$pageData data of the loaded page
  232. * @return void
  233. */
  234. public function onSinglePageLoaded(&$pageData)
  235. {
  236. // your code
  237. }
  238. /**
  239. * Triggered after Pico has read all known pages
  240. *
  241. * See {@link DummyPlugin::onSinglePageLoaded()} for details about the
  242. * structure of the page data.
  243. *
  244. * @see Pico::getPages()
  245. * @see Pico::getCurrentPage()
  246. * @see Pico::getPreviousPage()
  247. * @see Pico::getNextPage()
  248. * @param array &$pages data of all known pages
  249. * @param array &$currentPage data of the page being served
  250. * @param array &$previousPage data of the previous page
  251. * @param array &$nextPage data of the next page
  252. * @return void
  253. */
  254. public function onPagesLoaded(&$pages, &$currentPage, &$previousPage, &$nextPage)
  255. {
  256. // your code
  257. }
  258. /**
  259. * Triggered before Pico registers the twig template engine
  260. *
  261. * @return void
  262. */
  263. public function onTwigRegistration()
  264. {
  265. // your code
  266. }
  267. /**
  268. * Triggered before Pico renders the page
  269. *
  270. * @see Pico::getTwig()
  271. * @see DummyPlugin::onPageRendered()
  272. * @param Twig_Environment &$twig twig template engine
  273. * @param mixed[] &$twigVariables template variables
  274. * @param string &$templateName file name of the template
  275. * @return void
  276. */
  277. public function onPageRendering(&$twig, &$twigVariables, &$templateName)
  278. {
  279. // your code
  280. }
  281. /**
  282. * Triggered after Pico has rendered the page
  283. *
  284. * @param string &$output contents which will be sent to the user
  285. * @return void
  286. */
  287. public function onPageRendered(&$output)
  288. {
  289. // your code
  290. }
  291. }