Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Set theme base href when loading a revision

givanz081c7c761562
diff --git a/admin/controller/editor/revisions.php b/admin/controller/editor/revisions.php
index 4f15583..77fb3d6 100644
--- a/admin/controller/editor/revisions.php
+++ b/admin/controller/editor/revisions.php
@@ -70,14 +70,24 @@ class Revisions extends Base {
}
function load() {
- $file = $this->request->post['file'] ?? false;
+ $file = $this->request->post['file'] ?? false;
+ $theme = $this->getThemeFolder();
if ($file) {
$file = $this->backupFolder() . $this->sanitizeBackupFileName($file) . '.html';
if (file_exists($file)) {
$this->response->setType('text');
- $this->response->output(file_get_contents($file));
+ $html = file_get_contents($file);
+ $base = "/themes/$theme/";
+
+ if (strpos($html, '<base') !== false) {
+ $html = preg_replace('/<base(.*)href=["\'](.*?)["\'](.*?)>/', '<base$1href="' . $base . '"$3>', $html);
+ } else {
+ $html = str_replace('<head>', "<head>\n<base href=\"$base\">\n", $html);
+ }
+
+ $this->response->output($html);
}
} else {
die(__('Invalid request!'));