-
-
Notifications
You must be signed in to change notification settings - Fork 616
/
DummyPlugin.php
504 lines (471 loc) · 13.7 KB
/
DummyPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
<?php
/**
* This file is part of Pico. It's copyrighted by the contributors recorded
* in the version control history of the file, available from the following
* original location:
*
* <https://github.com/picocms/Pico/blob/master/plugins/DummyPlugin.php>
*
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/
/**
* 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
* @license http://opensource.org/licenses/MIT The MIT License
* @version 2.1
*/
class DummyPlugin extends AbstractPicoPlugin
{
/**
* API version used by this plugin
*
* @var int
*/
const API_VERSION = 3;
/**
* This plugin is disabled by default
*
* Usually you should remove this class property (or set it to NULL) to
* leave the decision whether this plugin should be enabled or disabled by
* default up to Pico. If all the plugin's dependenies are fulfilled (see
* {@see DummyPlugin::$dependsOn}), Pico enables the plugin by default.
* Otherwise the plugin is silently disabled.
*
* If this plugin should never be disabled *silently* (e.g. when dealing
* with security-relevant stuff like access control, or similar), set this
* to TRUE. If Pico can't fulfill all the plugin's dependencies, it will
* throw an RuntimeException.
*
* If this plugin rather does some "crazy stuff" a user should really be
* aware of before using it, you can set this to FALSE. The user will then
* have to enable the plugin manually. However, if another plugin depends
* on this plugin, it might get enabled silently nevertheless.
*
* No matter what, the user can always explicitly enable or disable this
* plugin in Pico's config.
*
* @see AbstractPicoPlugin::$enabled
* @var bool|null
*/
protected $enabled = false;
/**
* This plugin depends on ...
*
* If your plugin doesn't depend on any other plugin, remove this class
* property.
*
* @see AbstractPicoPlugin::$dependsOn
* @var string[]
*/
protected $dependsOn = array();
/**
* Triggered after Pico has loaded all available plugins
*
* This event is triggered nevertheless the plugin is enabled or not.
* It is NOT guaranteed that plugin dependencies are fulfilled!
*
* @see Pico::loadPlugin()
* @see Pico::getPlugin()
* @see Pico::getPlugins()
*
* @param object[] $plugins loaded plugin instances
*/
public function onPluginsLoaded(array $plugins)
{
// your code
}
/**
* Triggered when Pico manually loads a plugin
*
* @see Pico::loadPlugin()
* @see Pico::getPlugin()
* @see Pico::getPlugins()
*
* @param object $plugin loaded plugin instance
*/
public function onPluginManuallyLoaded($plugin)
{
// your code
}
/**
* Triggered after Pico has read its configuration
*
* @see Pico::getConfig()
* @see Pico::getBaseUrl()
* @see Pico::isUrlRewritingEnabled()
*
* @param array &$config array of config variables
*/
public function onConfigLoaded(array &$config)
{
// your code
}
/**
* Triggered before Pico loads its theme
*
* @see Pico::loadTheme()
* @see DummyPlugin::onThemeLoaded()
*
* @param string &$theme name of current theme
*/
public function onThemeLoading(&$theme)
{
// your code
}
/**
* Triggered after Pico loaded its theme
*
* @see DummyPlugin::onThemeLoading()
* @see Pico::getTheme()
* @see Pico::getThemeApiVersion()
*
* @param string $theme name of current theme
* @param int $themeApiVersion API version of the theme
* @param array &$themeConfig config array of the theme
*/
public function onThemeLoaded($theme, $themeApiVersion, array &$themeConfig)
{
// your code
}
/**
* Triggered after Pico has evaluated the request URL
*
* @see Pico::getRequestUrl()
*
* @param string &$url part of the URL describing the requested contents
*/
public function onRequestUrl(&$url)
{
// your code
}
/**
* Triggered after Pico has discovered the content file to serve
*
* @see Pico::resolveFilePath()
* @see Pico::getRequestFile()
*
* @param string &$file absolute path to the content file to serve
*/
public function onRequestFile(&$file)
{
// your code
}
/**
* Triggered before Pico reads the contents of the file to serve
*
* @see Pico::loadFileContent()
* @see DummyPlugin::onContentLoaded()
*/
public function onContentLoading()
{
// your code
}
/**
* Triggered before Pico reads the contents of a 404 file
*
* @see Pico::load404Content()
* @see DummyPlugin::on404ContentLoaded()
*/
public function on404ContentLoading()
{
// your code
}
/**
* Triggered after Pico has read the contents of the 404 file
*
* @see DummyPlugin::on404ContentLoading()
* @see Pico::getRawContent()
* @see Pico::is404Content()
*
* @param string &$rawContent raw file contents
*/
public function on404ContentLoaded(&$rawContent)
{
// your code
}
/**
* Triggered after Pico has read the contents of the file to serve
*
* If Pico serves a 404 file, this event is triggered with the raw contents
* of said 404 file. Use {@see Pico::is404Content()} to check for this
* case when necessary.
*
* @see DummyPlugin::onContentLoading()
* @see Pico::getRawContent()
* @see Pico::is404Content()
*
* @param string &$rawContent raw file contents
*/
public function onContentLoaded(&$rawContent)
{
// your code
}
/**
* Triggered before Pico parses the meta header
*
* @see Pico::parseFileMeta()
* @see DummyPlugin::onMetaParsed()
*/
public function onMetaParsing()
{
// your code
}
/**
* Triggered after Pico has parsed the meta header
*
* @see DummyPlugin::onMetaParsing()
* @see Pico::getFileMeta()
*
* @param string[] &$meta parsed meta data
*/
public function onMetaParsed(array &$meta)
{
// your code
}
/**
* Triggered before Pico parses the pages content
*
* @see Pico::prepareFileContent()
* @see Pico::substituteFileContent()
* @see DummyPlugin::onContentPrepared()
* @see DummyPlugin::onContentParsed()
*/
public function onContentParsing()
{
// your code
}
/**
* Triggered after Pico has prepared the raw file contents for parsing
*
* @see DummyPlugin::onContentParsing()
* @see Pico::parseFileContent()
* @see DummyPlugin::onContentParsed()
*
* @param string &$markdown Markdown contents of the requested page
*/
public function onContentPrepared(&$markdown)
{
// your code
}
/**
* Triggered after Pico has parsed the contents of the file to serve
*
* @see DummyPlugin::onContentParsing()
* @see DummyPlugin::onContentPrepared()
* @see Pico::getFileContent()
*
* @param string &$content parsed contents (HTML) of the requested page
*/
public function onContentParsed(&$content)
{
// your code
}
/**
* Triggered before Pico reads all known pages
*
* @see DummyPlugin::onPagesDiscovered()
* @see DummyPlugin::onPagesLoaded()
*/
public function onPagesLoading()
{
// your code
}
/**
* Triggered before Pico loads a single page
*
* Set the `$skipFile` parameter to TRUE to remove this page from the pages
* array. Pico usually passes NULL by default, unless it is a conflicting
* page (i.e. `content/sub.md`, but there's also a `content/sub/index.md`),
* then it passes TRUE. Don't change this value incautiously if it isn't
* NULL! Someone likely set it to TRUE or FALSE on purpose...
*
* @see DummyPlugin::onSinglePageContent()
* @see DummyPlugin::onSinglePageLoaded()
*
* @param string $id relative path to the content file
* @param bool|null $skipPage set this to TRUE to remove this page from the
* pages array, otherwise leave it unchanged
*/
public function onSinglePageLoading($id, &$skipPage)
{
// your code
}
/**
* Triggered when Pico loads the raw contents of a single page
*
* Please note that this event isn't triggered when the currently processed
* page is the requested page. The reason for this exception is that the
* raw contents of this page were loaded already.
*
* @see DummyPlugin::onSinglePageLoading()
* @see DummyPlugin::onSinglePageLoaded()
*
* @param string $id relative path to the content file
* @param string &$rawContent raw file contents
*/
public function onSinglePageContent($id, &$rawContent)
{
// your code
}
/**
* Triggered when Pico loads a single page
*
* Please refer to {@see Pico::readPages()} for information about the
* structure of a single page's data.
*
* @see DummyPlugin::onSinglePageLoading()
* @see DummyPlugin::onSinglePageContent()
*
* @param array &$pageData data of the loaded page
*/
public function onSinglePageLoaded(array &$pageData)
{
// your code
}
/**
* Triggered after Pico has discovered all known pages
*
* Pico's pages array isn't sorted until the `onPagesLoaded` event is
* triggered. Please refer to {@see Pico::readPages()} for information
* about the structure of Pico's pages array and the structure of a single
* page's data.
*
* @see DummyPlugin::onPagesLoading()
* @see DummyPlugin::onPagesLoaded()
*
* @param array[] &$pages list of all known pages
*/
public function onPagesDiscovered(array &$pages)
{
// your code
}
/**
* Triggered after Pico has sorted the pages array
*
* Please refer to {@see Pico::readPages()} for information about the
* structure of Pico's pages array and the structure of a single page's
* data.
*
* @see DummyPlugin::onPagesLoading()
* @see DummyPlugin::onPagesDiscovered()
* @see Pico::getPages()
*
* @param array[] &$pages sorted list of all known pages
*/
public function onPagesLoaded(array &$pages)
{
// your code
}
/**
* Triggered when Pico discovered the current, previous and next pages
*
* If Pico isn't serving a regular page, but a plugin's virtual page, there
* will neither be a current, nor previous or next pages. Please refer to
* {@see Pico::readPages()} for information about the structure of a single
* page's data.
*
* @see Pico::getCurrentPage()
* @see Pico::getPreviousPage()
* @see Pico::getNextPage()
*
* @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
*/
public function onCurrentPageDiscovered(
array &$currentPage = null,
array &$previousPage = null,
array &$nextPage = null
) {
// your code
}
/**
* Triggered after Pico built the page tree
*
* Please refer to {@see Pico::buildPageTree()} for information about
* the structure of Pico's page tree array.
*
* @see Pico::getPageTree()
*
* @param array &$pageTree page tree
*/
public function onPageTreeBuilt(array &$pageTree)
{
// your code
}
/**
* Triggered before Pico renders the page
*
* @see DummyPlugin::onPageRendered()
*
* @param string &$templateName file name of the template
* @param array &$twigVariables template variables
*/
public function onPageRendering(&$templateName, array &$twigVariables)
{
// your code
}
/**
* Triggered after Pico has rendered the page
*
* @see DummyPlugin::onPageRendering()
*
* @param string &$output contents which will be sent to the user
*/
public function onPageRendered(&$output)
{
// your code
}
/**
* Triggered when Pico reads its known meta header fields
*
* @see Pico::getMetaHeaders()
*
* @param string[] &$headers list of known meta header fields; the array
* key specifies the YAML key to search for, the array value is later
* used to access the found value
*/
public function onMetaHeaders(array &$headers)
{
// your code
}
/**
* Triggered when Pico registers the YAML parser
*
* @see Pico::getYamlParser()
*
* @param \Symfony\Component\Yaml\Parser &$yamlParser YAML parser instance
*/
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
*/
public function onParsedownRegistered(Parsedown &$parsedown)
{
// your code
}
/**
* Triggered when Pico registers the twig template engine
*
* @see Pico::getTwig()
*
* @param Twig_Environment &$twig Twig instance
*/
public function onTwigRegistered(Twig_Environment &$twig)
{
// your code
}
}