Mark Twig variables rewrite_url and is_front_page as deprecated
This commit is contained in:
parent
ec3f7fb626
commit
9a2dd4f078
@ -183,7 +183,6 @@ to use in your theme. Please note that paths (e.g. `{{ base_dir }}`) and URLs
|
|||||||
is enabled or not
|
is enabled or not
|
||||||
* `{{ theme_dir }}` - The path to the currently active theme
|
* `{{ theme_dir }}` - The path to the currently active theme
|
||||||
* `{{ theme_url }}` - The URL to the currently active theme
|
* `{{ theme_url }}` - The URL to the currently active theme
|
||||||
* `{{ rewrite_url }}` - A boolean flag indicating enabled/disabled URL rewriting
|
|
||||||
* `{{ site_title }}` - Shortcut to the site title (see `config/config.php`)
|
* `{{ site_title }}` - Shortcut to the site title (see `config/config.php`)
|
||||||
* `{{ meta }}` - Contains the meta values from the current page
|
* `{{ meta }}` - Contains the meta values from the current page
|
||||||
* `{{ meta.title }}`
|
* `{{ meta.title }}`
|
||||||
@ -213,7 +212,6 @@ to use in your theme. Please note that paths (e.g. `{{ base_dir }}`) and URLs
|
|||||||
* `{{ prev_page }}` - The data of the previous page (relative to `current_page`)
|
* `{{ prev_page }}` - The data of the previous page (relative to `current_page`)
|
||||||
* `{{ current_page }}` - The data of the current page
|
* `{{ current_page }}` - The data of the current page
|
||||||
* `{{ next_page }}` - The data of the next page (relative to `current_page`)
|
* `{{ next_page }}` - The data of the next page (relative to `current_page`)
|
||||||
* `{{ is_front_page }}` - A boolean flag for the front page
|
|
||||||
|
|
||||||
Pages can be used like the following:
|
Pages can be used like the following:
|
||||||
|
|
||||||
|
@ -1518,14 +1518,12 @@ class Pico
|
|||||||
return $this->twigVariables;
|
return $this->twigVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
$frontPage = $this->getConfig('content_dir') . 'index' . $this->getConfig('content_ext');
|
|
||||||
return array(
|
return array(
|
||||||
'config' => $this->getConfig(),
|
'config' => $this->getConfig(),
|
||||||
'base_dir' => rtrim($this->getRootDir(), '/'),
|
'base_dir' => rtrim($this->getRootDir(), '/'),
|
||||||
'base_url' => rtrim($this->getBaseUrl(), '/'),
|
'base_url' => rtrim($this->getBaseUrl(), '/'),
|
||||||
'theme_dir' => $this->getThemesDir() . $this->getConfig('theme'),
|
'theme_dir' => $this->getThemesDir() . $this->getConfig('theme'),
|
||||||
'theme_url' => $this->getBaseThemeUrl() . $this->getConfig('theme'),
|
'theme_url' => $this->getBaseThemeUrl() . $this->getConfig('theme'),
|
||||||
'rewrite_url' => $this->isUrlRewritingEnabled(),
|
|
||||||
'site_title' => $this->getConfig('site_title'),
|
'site_title' => $this->getConfig('site_title'),
|
||||||
'meta' => $this->meta,
|
'meta' => $this->meta,
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
@ -1533,7 +1531,6 @@ class Pico
|
|||||||
'prev_page' => $this->previousPage,
|
'prev_page' => $this->previousPage,
|
||||||
'current_page' => $this->currentPage,
|
'current_page' => $this->currentPage,
|
||||||
'next_page' => $this->nextPage,
|
'next_page' => $this->nextPage,
|
||||||
'is_front_page' => ($this->requestFile === $frontPage),
|
|
||||||
'version' => static::VERSION
|
'version' => static::VERSION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,8 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the deprecated event before_render($twigVariables, $twig, $templateName)
|
* Adds the deprecated variables rewrite_url and is_front_page, triggers
|
||||||
|
* the deprecated event before_render($twigVariables, $twig, $templateName)
|
||||||
*
|
*
|
||||||
* Please note that the `before_render()` event gets `$templateName` passed
|
* Please note that the `before_render()` event gets `$templateName` passed
|
||||||
* without its file extension. The file extension is later added again.
|
* without its file extension. The file extension is later added again.
|
||||||
@ -401,6 +402,16 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
*/
|
*/
|
||||||
public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
|
public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
|
||||||
{
|
{
|
||||||
|
// rewrite_url and is_front_page are deprecated since Pico 1.1
|
||||||
|
if (!isset($twigVariables['rewrite_url'])) {
|
||||||
|
$twigVariables['rewrite_url'] = $this->isUrlRewritingEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($twigVariables['is_front_page'])) {
|
||||||
|
$frontPage = $this->getConfig('content_dir') . 'index' . $this->getConfig('content_ext');
|
||||||
|
$twigVariables['is_front_page'] = ($this->getRequestFile() === $frontPage);
|
||||||
|
}
|
||||||
|
|
||||||
// template name contains file extension since Pico 1.0
|
// template name contains file extension since Pico 1.0
|
||||||
$fileExtension = '';
|
$fileExtension = '';
|
||||||
if (($fileExtensionPos = strrpos($templateName, '.')) !== false) {
|
if (($fileExtensionPos = strrpos($templateName, '.')) !== false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user