mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 19:36:08 +01:00
Switched to new Grav Yaml class
This commit is contained in:
@@ -13,7 +13,7 @@ docs: https://github.com/getgrav/grav-plugin-admin/blob/develop/README.md
|
|||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- { name: grav, version: '>=1.4.5' }
|
- { name: grav, version: '>=1.5.1' }
|
||||||
- { name: form, version: '>=2.14.0' }
|
- { name: form, version: '>=2.14.0' }
|
||||||
- { name: login, version: '>=2.7.0' }
|
- { name: login, version: '>=2.7.0' }
|
||||||
- { name: email, version: '>=2.7.0' }
|
- { name: email, version: '>=2.7.0' }
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
namespace Grav\Plugin\Admin\Twig;
|
namespace Grav\Plugin\Admin\Twig;
|
||||||
|
|
||||||
use Grav\Common\Grav;
|
use Grav\Common\Grav;
|
||||||
|
use Grav\Common\Yaml;
|
||||||
use Grav\Common\Language\Language;
|
use Grav\Common\Language\Language;
|
||||||
use Grav\Common\Page\Page;
|
use Grav\Common\Page\Page;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
|
||||||
use Symfony\Component\Yaml\Parser;
|
|
||||||
|
|
||||||
class AdminTwigExtension extends \Twig_Extension
|
class AdminTwigExtension extends \Twig_Extension
|
||||||
{
|
{
|
||||||
@@ -81,7 +80,7 @@ class AdminTwigExtension extends \Twig_Extension
|
|||||||
return $this->grav['admin']->translate($args, $lang);
|
return $this->grav['admin']->translate($args, $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toYamlFilter($value, $inline = true)
|
public function toYamlFilter($value, $inline = null)
|
||||||
{
|
{
|
||||||
return Yaml::dump($value, $inline);
|
return Yaml::dump($value, $inline);
|
||||||
|
|
||||||
@@ -89,8 +88,7 @@ class AdminTwigExtension extends \Twig_Extension
|
|||||||
|
|
||||||
public function fromYamlFilter($value)
|
public function fromYamlFilter($value)
|
||||||
{
|
{
|
||||||
$yaml = new Parser();
|
return Yaml::parse($value);
|
||||||
return $yaml->parse($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adminNicetimeFilter($date, $long_strings = true)
|
public function adminNicetimeFilter($date, $long_strings = true)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceIterator;
|
|||||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||||
use RocketTheme\Toolbox\Session\Message;
|
use RocketTheme\Toolbox\Session\Message;
|
||||||
use RocketTheme\Toolbox\Session\Session;
|
use RocketTheme\Toolbox\Session\Session;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Grav\Common\Yaml;
|
||||||
use Composer\Semver\Semver;
|
use Composer\Semver\Semver;
|
||||||
use PicoFeed\Reader\Reader;
|
use PicoFeed\Reader\Reader;
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ use Grav\Common\Utils;
|
|||||||
use Grav\Common\Backup\ZipBackup;
|
use Grav\Common\Backup\ZipBackup;
|
||||||
use Grav\Plugin\Admin\Twig\AdminTwigExtension;
|
use Grav\Plugin\Admin\Twig\AdminTwigExtension;
|
||||||
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
|
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
|
||||||
|
use Grav\Common\Yaml;
|
||||||
use RocketTheme\Toolbox\Event\Event;
|
use RocketTheme\Toolbox\Event\Event;
|
||||||
use RocketTheme\Toolbox\File\File;
|
use RocketTheme\Toolbox\File\File;
|
||||||
use RocketTheme\Toolbox\File\JsonFile;
|
use RocketTheme\Toolbox\File\JsonFile;
|
||||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||||
use Symfony\Component\Yaml\Exception\ParseException;
|
|
||||||
use Symfony\Component\Yaml\Yaml;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AdminController
|
* Class AdminController
|
||||||
@@ -760,16 +760,8 @@ class AdminController extends AdminBaseController
|
|||||||
public function checkValidFrontmatter($frontmatter)
|
public function checkValidFrontmatter($frontmatter)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Try native PECL YAML PHP extension first if available.
|
Yaml::parse($frontmatter);
|
||||||
if (function_exists('yaml_parse')) {
|
} catch (\RuntimeException $e) {
|
||||||
$saved = @ini_get('yaml.decode_php');
|
|
||||||
@ini_set('yaml.decode_php', 0);
|
|
||||||
@yaml_parse("---\n" . $frontmatter . "\n...");
|
|
||||||
@ini_set('yaml.decode_php', $saved);
|
|
||||||
} else {
|
|
||||||
Yaml::parse($frontmatter);
|
|
||||||
}
|
|
||||||
} catch (ParseException $e) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user