diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 395e16060..f560d5b7d 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -1498,12 +1498,18 @@ class themeHandler $mes = e107::getMessage(); $frm = e107::getForm(); + $pref = e107::getConfig()->getPref(); $mes->addDebug("Rendering Theme Config"); $this->loadThemeConfig(); $value = e107::getThemeConfig($this->id)->getPref(); + if(empty($value) && !empty($pref['sitetheme_pref'])) + { + $value = $pref['sitetheme_pref']; + } + if($this->themeConfigObj) { $var = call_user_func(array(&$this->themeConfigObj, 'config')); @@ -1523,7 +1529,8 @@ class themeHandler $value[$field] = varset($value[$field][e_LANGUAGE],''); } - $text .= "".$val['title'].":".$frm->renderElement($field, $value[$field], $val)."
".$val['help']."
+ $tdClass = !empty($val['writeParms']['post']) ? 'form-inline' : ''; + $text .= "".$val['title'].":".$frm->renderElement($field, $value[$field], $val)."
".$val['help']."
"; } } @@ -1566,9 +1573,24 @@ class themeHandler $theme_pref[$field] = $_POST[$field]; } - return $pref->setPref($theme_pref)->save(true,true,false); + if($pref->setPref($theme_pref)->save(true,true,false)) + { + $siteThemePref = e107::getConfig()->get('sitetheme_pref'); + if(!empty($siteThemePref)) + { + e107::getConfig()->set('sitetheme_pref',null)->save(false,true,false); // remove old theme pref + } + } + + if($pref->dataHasChanged()) + { + e107::getCache()->clearAll('system'); // Need to clear cache in order to refresh library information. + } + + return true; } + e107::getCache()->clearAll('system'); return call_user_func(array(&$this->themeConfigObj, 'process')); //pre v2.1.4 } } diff --git a/e107_themes/bootstrap3/theme_config.php b/e107_themes/bootstrap3/theme_config.php index 8a0d8573b..60a833289 100644 --- a/e107_themes/bootstrap3/theme_config.php +++ b/e107_themes/bootstrap3/theme_config.php @@ -2,53 +2,17 @@ if (!defined('e107_INIT')) { exit; } -e107::lan('theme', 'admin',true); // e_PLUGIN.'tinymce4/languages/'.e_LANGUAGE.'_admin.php' +e107::lan('theme', 'admin',true); -// Dummy Theme Configuration File. -class theme_bootstrap3 implements e_theme_config +// Theme Configuration File. +class theme_config implements e_theme_config { - function process() // Save posted values from config() fields. - { - $pref = e107::getConfig(); - - $theme_pref = array(); - $theme_pref['nav_alignment'] = $_POST['nav_alignment']; - $theme_pref['usernav_placement'] = $_POST['usernav_placement']; - $theme_pref['branding'] = $_POST['branding']; - $theme_pref['bootswatch'] = $_POST['bootswatch']; - $theme_pref['cdn'] = $_POST['cdn']; - - $pref->set('sitetheme_pref', $theme_pref); - $changed = $pref->dataHasChanged(); - - if($changed) - { - // Need to clear cache in order to refresh library information. - e107::getCache()->clearAll('system'); - } - - return $changed; - } function config($type='front') { - $frm = e107::getForm(); $brandingOpts = array('sitename'=>LAN_THEMEPREF_04, 'logo' => LAN_THEMEPREF_05, 'sitenamelogo'=>LAN_THEMEPREF_06); - $var[0]['caption'] = LAN_THEMEPREF_00; - $var[0]['html'] = $frm->select('branding', $brandingOpts, e107::pref('theme', 'branding', 'sitename')); - $var[0]['help'] = ""; - - $var[1]['caption'] = LAN_THEMEPREF_01; - $var[1]['html'] = $frm->select('nav_alignment', array('left'=>LAN_THEMEPREF_07,'right'=> LAN_THEMEPREF_08), e107::pref('theme', 'nav_alignment', 'left')); - $var[1]['help'] = ""; - - $var[2]['caption'] = LAN_THEMEPREF_02; - $var[2]['html'] = $frm->select('usernav_placement', array('top'=>LAN_THEMEPREF_09, 'bottom'=>LAN_THEMEPREF_10), e107::pref('theme', 'usernav_placement', 'top')); - $var[2]['help'] = ""; - - $bootswatch = array( // '' => LAN_DEFAULT, "cerulean"=> 'Cerulean', @@ -69,33 +33,18 @@ class theme_bootstrap3 implements e_theme_config "yeti"=> 'Yeti', ); - $cdnFront = array( - 'cdnjs' => "CDNJS (Cloudflare)", - 'jsdelivr' => "jsDelivr" - // google ? No fontawesome support? - - ); - $previewLink = " ".LAN_PREVIEW.""; - $var[3]['caption'] = LAN_THEMEPREF_03; - $var[3]['html'] = "
".$frm->select('bootswatch', $bootswatch, e107::pref('theme', 'bootswatch', ''),null,LAN_DEFAULT ).$previewLink."
"; - $var[3]['help'] = ""; + $fields = array( + 'branding' => array('title'=>LAN_THEMEPREF_00, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> $brandingOpts)), + 'nav_alignment' => array('title'=>LAN_THEMEPREF_01, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> array('left'=> LAN_THEMEPREF_07,'right'=> LAN_THEMEPREF_08))), + 'usernav_placement' => array('title'=>LAN_THEMEPREF_02, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> array('top'=> LAN_THEMEPREF_09, 'bottom'=> LAN_THEMEPREF_10))), + 'bootswatch' => array('title'=>LAN_THEMEPREF_03, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> $bootswatch, 'post'=>$previewLink)), + ); - $var[4]['caption'] = "CDN"; - $var[4]['html'] = $frm->select('cdn', $cdnFront, e107::pref('theme', 'cdn', '') ); - $var[4]['help'] = ""; + return $fields; - - - - - - // $var[1]['caption'] = "Sample configuration field 2"; - // $var[1]['html'] = $frm->text('_blank_example2', e107::pref('theme', 'example2', 'default')); - - return $var; }