From 21f8fdcbf6e1b8cb64c839c47a9caed130aa504c Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 21 Mar 2021 20:15:03 -0700 Subject: [PATCH] Fixes #2392 - Theme-Manager > Tools > Create (ie. theme-copy tool) updated to work with libraries, layouts, prefs etc. --- e107_admin/theme.php | 122 +++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 39 deletions(-) diff --git a/e107_admin/theme.php b/e107_admin/theme.php index 79a8d95bd..82dc1ba70 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -818,7 +818,7 @@ class theme_admin_ui extends e_admin_ui public function ChoosePage() { - e107::getTheme()->clearCache(); + e107::getTheme('front', true); // clear cache and reload from disk. return $this->GridPage(); } @@ -1267,7 +1267,6 @@ class theme_builder extends e_admin_ui if(vartrue($_GET['step']) == 3) { return $this->step3(); - } if(vartrue($_GET['step']) == 2) @@ -1360,8 +1359,6 @@ class theme_builder extends e_admin_ui $frm = e107::getForm(); - - $data = array( 'main' => array('name','lang','version','date', 'compatibility'), 'author' => array('name','url'), @@ -1372,7 +1369,10 @@ class theme_builder extends e_admin_ui 'category' => array('category'), 'livedemo' => array('livedemo'), 'copyright' => array('copyright'), - 'stylesheets' => array('stylesheets') + // 'libraries' => array('libraries'), + // 'layouts' => array('layouts'), + // 'stylesheets' => array('stylesheets'), + // 'adminLinks' => array('url','description','icon','iconSmall','primary'), // 'sitelinks' => array('url','description','icon','iconSmall') ); @@ -1531,6 +1531,55 @@ class theme_builder extends e_admin_ui $mes = e107::getMessage(); $tp = e107::getParser(); + $newArray = array( + 'LIBRARIES' => '', + 'PREFS' => '', + 'STYLESHEETS' => '' + ); + + $LAYOUTS = ''; + + $source = e107::getTheme($this->themeSrc)->get(); + + if(!empty($source['library'])) + { + $newArray['LIBRARIES'] = ''; + + foreach($source['library'] as $val) + { + $newArray['LIBRARIES'] .= "\n\t\t".''; + } + + $newArray['LIBRARIES'] .= "\n\t"; + } + + if(!empty($source['preferences'])) + { + $newArray['PREFS'] = "\n\t"; + + foreach($source['preferences'] as $key=>$val) + { + $newArray['PREFS'] .= "\n\t\t".''.$val.''; + } + + $newArray['PREFS'] .= "\n\t"; + } + + if(!empty($source['css'])) + { + $newArray['STYLESHEETS'] = "\n\t"; + + foreach($source['css'] as $val) + { + $newArray['STYLESHEETS'] .= "\n\t\t".'$val) { $key = strtoupper(str_replace("-","_",$key)); @@ -1544,41 +1593,26 @@ class theme_builder extends e_admin_ui $LAYOUTS .= " {CUSTOMPAGES}\n"; $LAYOUTS .= " "; } - else + elseif(!empty($source['layouts'])) { - $LAYOUTS = ""; - } - - if(!empty($newArray['STYLESHEETS_STYLESHEETS'])) - { - $STYLESHEETS = ''; - foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val) + foreach($source['layouts'] as $name=>$val) { - if(empty($val['file'])) - { - continue; - } - - $STYLESHEETS .= "\t\t\n"; + $LAYOUTS .= "\n\t\t\n"; + $LAYOUTS .= "\t\t"; } - - if(!empty($STYLESHEETS)) - { - $STYLESHEETS = "\n\t\n".$STYLESHEETS."\t"; - } - - unset($newArray['STYLESHEETS_STYLESHEETS']); } else { - $STYLESHEETS = ""; + $LAYOUTS = ""; } - $newArray['STYLESHEETS'] = $STYLESHEETS; + $newArray['MAIN_DATE'] = date('Y-m-d', $newArray['MAIN_DATE']); // print_a($newArray); - $template = <<