aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM.Dent <dentm42@dm42.net>2018-08-12 19:47:10 -0400
committerM.Dent <dentm42@dm42.net>2018-08-12 19:47:10 -0400
commitb436c4a94c86a7b346872b4c92f3c803b1582ed0 (patch)
treef7593f8d892020d40373adb4c5c6bd8ddbe9045a
parent9402f537b62e80939d09ad602f96460e8ab66b1c (diff)
downloadvolse-hubzilla-b436c4a94c86a7b346872b4c92f3c803b1582ed0.tar.gz
volse-hubzilla-b436c4a94c86a7b346872b4c92f3c803b1582ed0.tar.bz2
volse-hubzilla-b436c4a94c86a7b346872b4c92f3c803b1582ed0.zip
Add support for overriding the default template location and individual templates via .htconfig.php
-rwxr-xr-xboot.php3
-rwxr-xr-xinclude/plugin.php55
2 files changed, 45 insertions, 13 deletions
diff --git a/boot.php b/boot.php
index fca184555..6816187cb 100755
--- a/boot.php
+++ b/boot.php
@@ -728,6 +728,9 @@ class App {
private static $perms = null; // observer permissions
private static $widgets = array(); // widgets for this page
public static $config = array(); // config cache
+ public static $override_intltext_templates = array();
+ public static $override_markup_templates = array();
+ public static $override_templateroot = null;
public static $session = null;
public static $groups;
diff --git a/include/plugin.php b/include/plugin.php
index 13652c620..23cb2b5f6 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -959,9 +959,8 @@ function format_js_if_exists($source) {
function theme_include($file, $root = '') {
// Make sure $root ends with a slash / if it's not blank
- if($root !== '' && $root[strlen($root)-1] !== '/')
+ if($root !== '' && substr($root,-1) !== '/')
$root = $root . '/';
-
$theme_info = App::$theme_info;
if(array_key_exists('extends',$theme_info))
@@ -992,21 +991,51 @@ function theme_include($file, $root = '') {
return '';
}
-
function get_intltext_template($s, $root = '') {
-
- $t = App::template_engine();
-
- $template = $t->get_intltext_template($s, $root);
- return $template;
+ $testroot = ($root=='') ? $testroot = "ROOT" : $root;
+ $t = App::template_engine();
+
+ if (isset(\App::$override_intltext_templates[$testroot][$s]["content"])) {
+ return \App::$override_intltext_templates[$testroot][$s]["content"];
+ } else {
+ if (isset(\App::$override_intltext_templates[$testroot][$s]["root"]) &&
+ isset(\App::$override_intltext_templates[$testroot][$s]["file"])) {
+ $s = \App::$override_intltext_templates[$testroot][$s]["file"];
+ $root = \App::$override_intltext_templates[$testroot][$s]["root"];
+ } elseif (\App::$override_templateroot) {
+ $newroot = \App::$override_templateroot.$root;
+ if ($newroot != '' && substr($newroot,-1) != '/' ) {
+ $newroot .= '/';
+ }
+ $template = $t->get_intltext_template($s, $newroot);
+ }
+ $template = $t->get_intltext_template($s, $root);
+ return $template;
+ }
}
-
function get_markup_template($s, $root = '') {
-
- $t = App::template_engine();
- $template = $t->get_markup_template($s, $root);
- return $template;
+ $testroot = ($root=='') ? $testroot = "ROOT" : $root;
+
+ $t = App::template_engine();
+
+ if (isset(\App::$override_markup_templates[$testroot][$s]["content"])) {
+ return \App::$override_markup_templates[$testroot][$s]["content"];
+ } else {
+ if (isset(\App::$override_markup_templates[$testroot][$s]["root"]) &&
+ isset(\App::$override_markup_templates[$testroot][$s]["file"])) {
+ $s = \App::$override_markup_templates[$testroot][$s]["file"];
+ $root = \App::$override_markup_templates[$testroot][$s]["root"];
+ } elseif (\App::$override_templateroot) {
+ $newroot = \App::$override_templateroot.$root;
+ if ($newroot != '' && substr($newroot,-1) != '/' ) {
+ $newroot .= '/';
+ }
+ $template = $t->get_markup_template($s, $newroot);
+ }
+ $template = $t->get_markup_template($s, $root);
+ return $template;
+ }
}
/**