Remove various event params that are a bit out of place
This commit is contained in:
parent
a231abc4c1
commit
151908fbad
27
lib/Pico.php
27
lib/Pico.php
@ -395,13 +395,13 @@ class Pico
|
|||||||
$this->triggerEvent('onRequestFile', array(&$this->requestFile));
|
$this->triggerEvent('onRequestFile', array(&$this->requestFile));
|
||||||
|
|
||||||
// load raw file content
|
// load raw file content
|
||||||
$this->triggerEvent('onContentLoading', array(&$this->requestFile));
|
$this->triggerEvent('onContentLoading');
|
||||||
|
|
||||||
$hiddenFileRegex = '/(?:^|\/)(?:_|404' . preg_quote($this->getConfig('content_ext'), '/') . '$)/';
|
$hiddenFileRegex = '/(?:^|\/)(?:_|404' . preg_quote($this->getConfig('content_ext'), '/') . '$)/';
|
||||||
if (file_exists($this->requestFile) && !preg_match($hiddenFileRegex, $this->requestFile)) {
|
if (file_exists($this->requestFile) && !preg_match($hiddenFileRegex, $this->requestFile)) {
|
||||||
$this->rawContent = $this->loadFileContent($this->requestFile);
|
$this->rawContent = $this->loadFileContent($this->requestFile);
|
||||||
} else {
|
} else {
|
||||||
$this->triggerEvent('on404ContentLoading', array(&$this->requestFile));
|
$this->triggerEvent('on404ContentLoading');
|
||||||
|
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||||
$this->rawContent = $this->load404Content($this->requestFile);
|
$this->rawContent = $this->load404Content($this->requestFile);
|
||||||
@ -413,17 +413,17 @@ class Pico
|
|||||||
$this->triggerEvent('onContentLoaded', array(&$this->rawContent));
|
$this->triggerEvent('onContentLoaded', array(&$this->rawContent));
|
||||||
|
|
||||||
// parse file meta
|
// parse file meta
|
||||||
$this->triggerEvent('onMetaParsing', array(&$this->rawContent));
|
$this->triggerEvent('onMetaParsing');
|
||||||
$this->meta = $this->parseFileMeta($this->rawContent, $this->getMetaHeaders());
|
$this->meta = $this->parseFileMeta($this->rawContent, $this->getMetaHeaders());
|
||||||
$this->triggerEvent('onMetaParsed', array(&$this->meta));
|
$this->triggerEvent('onMetaParsed', array(&$this->meta));
|
||||||
|
|
||||||
// parse file content
|
// parse file content
|
||||||
$this->triggerEvent('onContentParsing', array(&$this->rawContent));
|
$this->triggerEvent('onContentParsing');
|
||||||
|
|
||||||
$this->content = $this->prepareFileContent($this->rawContent, $this->meta);
|
$markdown = $this->prepareFileContent($this->rawContent, $this->meta);
|
||||||
$this->triggerEvent('onContentPrepared', array(&$this->content));
|
$this->triggerEvent('onContentPrepared', array(&$markdown));
|
||||||
|
|
||||||
$this->content = $this->parseFileContent($this->content);
|
$this->content = $this->parseFileContent($markdown);
|
||||||
$this->triggerEvent('onContentParsed', array(&$this->content));
|
$this->triggerEvent('onContentParsed', array(&$this->content));
|
||||||
|
|
||||||
// read pages
|
// read pages
|
||||||
@ -1490,15 +1490,12 @@ class Pico
|
|||||||
$id = substr($file, $contentDirLength, -$contentExtLength);
|
$id = substr($file, $contentDirLength, -$contentExtLength);
|
||||||
|
|
||||||
// trigger onSinglePageLoading event
|
// trigger onSinglePageLoading event
|
||||||
$this->triggerEvent('onSinglePageLoading', array(&$id));
|
// skip inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists) by default
|
||||||
|
|
||||||
if ($id === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists)
|
|
||||||
$conflictFile = $contentDir . $id . '/index' . $contentExt;
|
$conflictFile = $contentDir . $id . '/index' . $contentExt;
|
||||||
if (in_array($conflictFile, $files, true)) {
|
$skipFile = in_array($conflictFile, $files, true) ?: null;
|
||||||
|
$this->triggerEvent('onSinglePageLoading', array($id, &$skipFile));
|
||||||
|
|
||||||
|
if ($skipFile) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,10 +113,9 @@ class DummyPlugin extends AbstractPicoPlugin
|
|||||||
*
|
*
|
||||||
* @see Pico::loadFileContent()
|
* @see Pico::loadFileContent()
|
||||||
* @see DummyPlugin::onContentLoaded()
|
* @see DummyPlugin::onContentLoaded()
|
||||||
* @param string &$file path to the file which contents will be read
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onContentLoading(&$file)
|
public function onContentLoading()
|
||||||
{
|
{
|
||||||
// your code
|
// your code
|
||||||
}
|
}
|
||||||
@ -126,10 +125,9 @@ class DummyPlugin extends AbstractPicoPlugin
|
|||||||
*
|
*
|
||||||
* @see Pico::load404Content()
|
* @see Pico::load404Content()
|
||||||
* @see DummyPlugin::on404ContentLoaded()
|
* @see DummyPlugin::on404ContentLoaded()
|
||||||
* @param string &$file path to the file which contents were requested
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function on404ContentLoading(&$file)
|
public function on404ContentLoading()
|
||||||
{
|
{
|
||||||
// your code
|
// your code
|
||||||
}
|
}
|
||||||
@ -167,11 +165,9 @@ class DummyPlugin extends AbstractPicoPlugin
|
|||||||
*
|
*
|
||||||
* @see Pico::parseFileMeta()
|
* @see Pico::parseFileMeta()
|
||||||
* @see DummyPlugin::onMetaParsed()
|
* @see DummyPlugin::onMetaParsed()
|
||||||
* @param string &$rawContent raw file contents
|
|
||||||
* @param string[] &$headers known meta header fields
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onMetaParsing(&$rawContent, array &$headers)
|
public function onMetaParsing()
|
||||||
{
|
{
|
||||||
// your code
|
// your code
|
||||||
}
|
}
|
||||||
@ -194,10 +190,9 @@ class DummyPlugin extends AbstractPicoPlugin
|
|||||||
* @see Pico::prepareFileContent()
|
* @see Pico::prepareFileContent()
|
||||||
* @see DummyPlugin::prepareFileContent()
|
* @see DummyPlugin::prepareFileContent()
|
||||||
* @see DummyPlugin::onContentParsed()
|
* @see DummyPlugin::onContentParsed()
|
||||||
* @param string &$rawContent raw file contents of the requested page
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onContentParsing(&$rawContent)
|
public function onContentParsing()
|
||||||
{
|
{
|
||||||
// your code
|
// your code
|
||||||
}
|
}
|
||||||
@ -246,16 +241,22 @@ class DummyPlugin extends AbstractPicoPlugin
|
|||||||
/**
|
/**
|
||||||
* Triggered before Pico loads a single page
|
* Triggered before Pico loads a single page
|
||||||
*
|
*
|
||||||
* Set `$id` to `null` to remove this page from the pages array.
|
* 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::onSinglePageContent()
|
||||||
* @see DummyPlugin::onSinglePageLoaded()
|
* @see DummyPlugin::onSinglePageLoaded()
|
||||||
* @see DummyPlugin::onPagesDiscovered()
|
* @see DummyPlugin::onPagesDiscovered()
|
||||||
* @see DummyPlugin::onPagesLoaded()
|
* @see DummyPlugin::onPagesLoaded()
|
||||||
* @param string &$id relative path to the content file
|
* @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
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onSinglePageLoading(&$id)
|
public function onSinglePageLoading($id, &$skipPage)
|
||||||
{
|
{
|
||||||
// your code
|
// your code
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user