From 73301881dde99f630250c977a038321cb2af6b57 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 2 Nov 2017 14:30:19 -0700 Subject: [PATCH] Allow theme config page to use custom methods. (see bootstrap3 for example) --- e107_handlers/theme_handler.php | 18 ++++++++++++------ e107_themes/bootstrap3/theme_config.php | 14 +++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index c6d159e4a..5c1a62926 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -814,6 +814,7 @@ class themeHandler var $frm; var $fl; var $themeConfigObj = null; + var $themeConfigFormObj= null; var $noLog = FALSE; private $curTheme = null; @@ -1816,6 +1817,11 @@ class themeHandler if(class_exists('theme_config')) // new v2.1.4 theme_config is the class name. { $this->themeConfigObj = new theme_config(); + + if(class_exists('theme_config_form')) // new v2.1.7 + { + $this->themeConfigFormObj = new theme_config_form(); + } } elseif(class_exists($className)) // old way. { @@ -1834,7 +1840,9 @@ class themeHandler { $mes = e107::getMessage(); - $frm = e107::getForm(); + + $frm = ($this->themeConfigFormObj !== null) ? $this->themeConfigFormObj : e107::getForm(); + $pref = e107::getConfig()->getPref(); e107::getDebug()->log("Rendering Theme Config"); @@ -1851,13 +1859,12 @@ class themeHandler { $var = call_user_func(array(&$this->themeConfigObj, 'config')); $text = ''; // avoid notice - + foreach ($var as $field=>$val) { if(is_numeric($field)) { - $text .= "".$val['caption'].":".$val['html']."
".$val['help']."
-"; + $text .= "".$val['caption'].":".$val['html']."
".$val['help']."
"; } else { @@ -1867,8 +1874,7 @@ class themeHandler } $tdClass = !empty($val['writeParms']['post']) ? 'form-inline' : ''; - $text .= "".$val['title'].":".$frm->renderElement($field, $value[$field], $val)."
".$val['help']."
-"; + $text .= "".$val['title'].":".$frm->renderElement($field, $value[$field], $val)."
".$val['help']."
"; } } diff --git a/e107_themes/bootstrap3/theme_config.php b/e107_themes/bootstrap3/theme_config.php index 381bb47e5..556ffcd2f 100644 --- a/e107_themes/bootstrap3/theme_config.php +++ b/e107_themes/bootstrap3/theme_config.php @@ -53,5 +53,17 @@ class theme_config implements e_theme_config } } +/* +// Custom Methods +class theme_config_form extends e_form +{ -?> \ No newline at end of file + function custom_method($value,$mode,$parms) // named the same as $fields key.(eg. 'branding') Used when type = 'method' + { + + return $this->text('custom_method', $value); + + } + +} +*/ \ No newline at end of file