Ajout du FR

Ajout du FR + correction du "functions.php"
This commit is contained in:
Gauvain Boiché
2020-03-30 14:52:34 +02:00
commit 5e4c5f9418
4541 changed files with 608941 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<?php
/*
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2019 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter;
abstract class Bundle
{
public static function getCachedParser()
{
if (!isset(static::$parser))
static::$parser = static::getParser();
return static::$parser;
}
public static function getCachedRenderer()
{
if (!isset(static::$renderer))
static::$renderer = static::getRenderer();
return static::$renderer;
}
public static function parse($text)
{
if (isset(static::$beforeParse))
$text = \call_user_func(static::$beforeParse, $text);
$xml = static::getCachedParser()->parse($text);
if (isset(static::$afterParse))
$xml = \call_user_func(static::$afterParse, $xml);
return $xml;
}
public static function render($xml, array $params = [])
{
$renderer = static::getCachedRenderer();
if (!empty($params))
$renderer->setParameters($params);
if (isset(static::$beforeRender))
$xml = \call_user_func(static::$beforeRender, $xml);
$output = $renderer->render($xml);
if (isset(static::$afterRender))
$output = \call_user_func(static::$afterRender, $output);
return $output;
}
public static function reset()
{
static::$parser = \null;
static::$renderer = \null;
}
public static function unparse($xml)
{
if (isset(static::$beforeUnparse))
$xml = \call_user_func(static::$beforeUnparse, $xml);
$text = Unparser::unparse($xml);
if (isset(static::$afterUnparse))
$text = \call_user_func(static::$afterUnparse, $text);
return $text;
}
}