Merge branch 'add-template-overrides' into 'dev'
Add template overrides See merge request hubzilla/core!1256
This commit is contained in:
commit
b78c9a2251
@ -64,17 +64,20 @@ class SmartyTemplate implements TemplateEngine {
|
||||
public function get_intltext_template($file, $root='') {
|
||||
|
||||
$lang = \App::$language;
|
||||
|
||||
if(file_exists("view/$lang/$file"))
|
||||
$template_file = "view/$lang/$file";
|
||||
elseif(file_exists("view/en/$file"))
|
||||
$template_file = "view/en/$file";
|
||||
else
|
||||
$template_file = theme_include($file,$root);
|
||||
if ($root != '' && substr($root,-1) != '/' ) {
|
||||
$root .= '/';
|
||||
}
|
||||
foreach (Array(
|
||||
$root."view/$lang/$file",
|
||||
$root."view/en/$file",
|
||||
''
|
||||
) as $template_file) {
|
||||
if (is_file($template_file)) { break; }
|
||||
}
|
||||
if ($template_file=='') {$template_file = theme_include($file,$root);}
|
||||
if($template_file) {
|
||||
$template = new SmartyInterface();
|
||||
$template->filename = $template_file;
|
||||
|
||||
return $template;
|
||||
}
|
||||
return "";
|
||||
|
3
boot.php
3
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;
|
||||
|
@ -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 = '') {
|
||||
$testroot = ($root=='') ? $testroot = "ROOT" : $root;
|
||||
$t = App::template_engine();
|
||||
|
||||
$t = App::template_engine();
|
||||
|
||||
$template = $t->get_intltext_template($s, $root);
|
||||
return $template;
|
||||
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 = '') {
|
||||
$testroot = ($root=='') ? $testroot = "ROOT" : $root;
|
||||
|
||||
$t = App::template_engine();
|
||||
$template = $t->get_markup_template($s, $root);
|
||||
return $template;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user