add appendHTML, prependHTML, addRegexReplace
This commit is contained in:
parent
98b6c95c89
commit
031e6fb073
1 changed files with 26 additions and 1 deletions
|
|
@ -4,6 +4,9 @@ class html_process
|
||||||
protected $latecss = [];
|
protected $latecss = [];
|
||||||
protected $css = [];
|
protected $css = [];
|
||||||
protected $js = [];
|
protected $js = [];
|
||||||
|
protected $beforeBuffer = "";
|
||||||
|
protected $afterBuffer = "";
|
||||||
|
protected $replacer = [];
|
||||||
|
|
||||||
private function updateLoginTable()
|
private function updateLoginTable()
|
||||||
{
|
{
|
||||||
|
|
@ -188,9 +191,24 @@ class html_process
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function appendHtml($html)
|
||||||
|
{
|
||||||
|
$this->afterBuffer .= $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prependHtml($html)
|
||||||
|
{
|
||||||
|
$this->beforeBuffer .= $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRegexReplace($pattern, $replace)
|
||||||
|
{
|
||||||
|
$this->replacer[] = [$pattern, $replace];
|
||||||
|
}
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
global $config, $g5, $member;
|
global $config;
|
||||||
|
|
||||||
$this->updateLoginTable();
|
$this->updateLoginTable();
|
||||||
$this->cleanOldLoginRecords($config['cf_login_minutes']);
|
$this->cleanOldLoginRecords($config['cf_login_minutes']);
|
||||||
|
|
@ -203,6 +221,13 @@ class html_process
|
||||||
$buffer = $this->injectStyles($buffer, $stylesheet, $latestylesheet);
|
$buffer = $this->injectStyles($buffer, $stylesheet, $latestylesheet);
|
||||||
$buffer = $this->injectJavascript($buffer, $javascript);
|
$buffer = $this->injectJavascript($buffer, $javascript);
|
||||||
|
|
||||||
|
foreach($this->replacer as $v) {
|
||||||
|
$buffer = preg_replace($v[0], $v[1], $buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
$buffer = preg_replace('#(</head>[^<]*<body[^>]*>)#', "$1{$this->beforeBuffer}", $buffer);
|
||||||
|
$buffer = preg_replace('#</(?:\s+)?body>#', "</body>" . $this->afterBuffer, $buffer);
|
||||||
|
|
||||||
if (class_exists("EventHandler")) {
|
if (class_exists("EventHandler")) {
|
||||||
EventHandler::triggerEvent("amber.renderhtml_before_print", $buffer);
|
EventHandler::triggerEvent("amber.renderhtml_before_print", $buffer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue