From 8c507c964dd75e2f0aaa16deefffb43f93945f06 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 29 Jan 2017 15:10:32 -0800 Subject: [PATCH] updated themes to use e107::library(). e107::getCache()->clearAll() now accepts 'library' as an option. --- e107_handlers/cache_handler.php | 21 ++++-- e107_handlers/theme_handler.php | 63 +++++++++++------ e107_themes/bootstrap3/theme.xml | 5 ++ e107_themes/bootstrap3/theme_config.php | 3 +- e107_themes/bootstrap3/theme_library.php | 2 +- e107_themes/landingzero/theme.php | 15 ++-- e107_themes/landingzero/theme.xml | 3 + e107_themes/landingzero/theme_config.php | 5 +- e107_themes/landingzero/theme_shortcodes.php | 73 ++++++++++---------- e107_themes/voux/theme.php | 9 ++- 10 files changed, 123 insertions(+), 76 deletions(-) diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php index 635dd8b2d..4c2ad3482 100644 --- a/e107_handlers/cache_handler.php +++ b/e107_handlers/cache_handler.php @@ -309,7 +309,7 @@ class ecache { /** * Clear Full Cache - * @param string $type: content | system| browser | db | image + * @param string $type: content | system| browser | db | image | js | css | library * @example clearAll('db'); */ @@ -323,42 +323,48 @@ class ecache { return; } - if($type == 'system') + if($type === 'system') { $this->clear_sys(); return; } - if($type == 'browser') + if($type === 'browser') { e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); return; } - if($type == 'db') + if($type === 'db') { $path = e_CACHE_DB; $mask = ($mask == null) ? '.*\.php' : $mask; } - if($type == 'image') + if($type === 'image') { $path = e_CACHE_IMAGE; $mask = ($mask == null) ? '.*\.cache\.bin' : $mask; } - if($type == 'js') + if($type === 'js') { $path = e_WEB."cache/"; $mask = ($mask == null) ? '.*\.js' : $mask; } - if($type == 'css') + if($type === 'css') { $path = e_WEB."cache/"; $mask = ($mask == null) ? '.*\.css' : $mask; } + if($type === 'library') + { + $path = e_CACHE_CONTENT; + $mask = ($mask == null) ? 'S_Library_.*\.cache\.php' : $mask; + } + if((null == $path) || (null == $mask)) { return; @@ -367,6 +373,7 @@ class ecache { $fl = e107::getFile(false); $fl->mode = 'fname'; $files = $fl->get_files($path, $mask); + if($files) { foreach ($files as $file) diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index f560d5b7d..b251fd9c2 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -1582,15 +1582,16 @@ class themeHandler } } - if($pref->dataHasChanged()) + // if($pref->dataHasChanged()) { - e107::getCache()->clearAll('system'); // Need to clear cache in order to refresh library information. + + e107::getCache()->clearAll('library'); // Need to clear cache in order to refresh library information. } return true; } - e107::getCache()->clearAll('system'); + e107::getCache()->clearAll('library'); return call_user_func(array(&$this->themeConfigObj, 'process')); //pre v2.1.4 } } @@ -2352,13 +2353,40 @@ class themeHandler if(!empty($this->themeArray[$name]['preferences'])) { - $core->set('sitetheme_pref', $this->themeArray[$name]['preferences']); + $themePrefs = $this->themeArray[$name]['preferences']; + + e107::getMessage()->addDebug("ThemePrefs found in theme.xml"); + + $this->id = $name; + $this->loadThemeConfig(); + $name = get_class($this->themeConfigObj); + + if($name === 'theme_config') // new way. 2.1.4 + { + $themeConfig = e107::getThemeConfig($name); + + e107::getMessage()->addDebug("Saving theme prefs to their own row. "); + + foreach($themePrefs as $key=>$val) + { + + $themeConfig->add($key,$val); + } + + $themeConfig->save(false,true,false); + + + } + else // old way. + { + e107::getMessage()->addDebug("Saving theme prefs to sitetheme_ref"); + $core->set('sitetheme_pref', $this->themeArray[$name]['preferences']); + } + + + } - - - // $core->set('sitetheme_releaseUrl', $this->themeArray[$name]['releaseUrl']); - - + if($contentCheck === true) { $sql->delete("menus", "menu_layout !='' "); @@ -2367,6 +2395,7 @@ class themeHandler e107::getCache()->clear(); e107::getCache()->clearAll('js'); e107::getCache()->clearAll('css'); + e107::getCache()->clearAll('library'); if($core->save()) { @@ -2375,27 +2404,21 @@ class themeHandler $med = e107::getMedia(); $med->import('_common_image', e_THEME.$name, "^.*?logo.*?(\.png|\.jpeg|\.jpg|\.JPG|\.GIF|\.PNG)$"); - $med->import('_common_image', e_THEME.$name, '', 'min-size=20000'); - - + $med->import('_common_image', e_THEME.$name, '', 'min-size=20000'); if($contentCheck === true) { $this->installContentCheck($name); } - - + $this->theme_adminlog('01', $name.', style.css'); - - - - - return TRUE; + + return true; } else { // $mes->add(TPVLAN_3." '".$name."'", E_MESSAGE_ERROR); - return FALSE; + return true; } } diff --git a/e107_themes/bootstrap3/theme.xml b/e107_themes/bootstrap3/theme.xml index bf46b5841..8191d3f68 100644 --- a/e107_themes/bootstrap3/theme.xml +++ b/e107_themes/bootstrap3/theme.xml @@ -43,4 +43,9 @@ + + sitename + right + top + \ No newline at end of file diff --git a/e107_themes/bootstrap3/theme_config.php b/e107_themes/bootstrap3/theme_config.php index 60a833289..381bb47e5 100644 --- a/e107_themes/bootstrap3/theme_config.php +++ b/e107_themes/bootstrap3/theme_config.php @@ -14,7 +14,6 @@ class theme_config implements e_theme_config $brandingOpts = array('sitename'=>LAN_THEMEPREF_04, 'logo' => LAN_THEMEPREF_05, 'sitenamelogo'=>LAN_THEMEPREF_06); $bootswatch = array( - // '' => LAN_DEFAULT, "cerulean"=> 'Cerulean', "cosmo"=> 'Cosmo', "cyborg"=> 'Cyborg', @@ -40,7 +39,7 @@ class theme_config implements e_theme_config '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)), + 'bootswatch' => array('title'=>LAN_THEMEPREF_03, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> $bootswatch, 'post'=>$previewLink, 'default'=>LAN_DEFAULT)), ); return $fields; diff --git a/e107_themes/bootstrap3/theme_library.php b/e107_themes/bootstrap3/theme_library.php index ecadad16b..86ab63dea 100644 --- a/e107_themes/bootstrap3/theme_library.php +++ b/e107_themes/bootstrap3/theme_library.php @@ -34,7 +34,7 @@ class theme_library { $bootswatch = e107::pref('theme', 'bootswatch', false); - if($bootswatch) + if(!empty($bootswatch)) { // Disable Bootstrap CSS. unset($libraries['cdn.bootstrap']['files']['css']); diff --git a/e107_themes/landingzero/theme.php b/e107_themes/landingzero/theme.php index 18de9d3a5..19c592c23 100644 --- a/e107_themes/landingzero/theme.php +++ b/e107_themes/landingzero/theme.php @@ -15,13 +15,16 @@ define('VIEWPORT', "width=device-width, initial-scale=1.0"); e107::lan('theme'); $cndPref = e107::pref('theme', 'cdn','cdnjs'); + +e107::library('load', 'bootstrap'); +e107::library('load', 'fontawesome'); switch($cndPref) { case "jsdelivr": - e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css'); - e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css'); - e107::js("footer", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery'); + // e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css'); + // e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css'); + // e107::js("footer", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery'); e107::js("footer", "https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js", 'jquery'); @@ -32,9 +35,9 @@ switch($cndPref) break; */ case "cdnjs": default: - e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'); - e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'); - e107::js("footer", "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js", 'jquery', 2); + // e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'); + // e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'); + // e107::js("footer", "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js", 'jquery', 2); e107::js("footer", "https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js", 'jquery', 2); diff --git a/e107_themes/landingzero/theme.xml b/e107_themes/landingzero/theme.xml index ac096cc18..ffc3ee840 100644 --- a/e107_themes/landingzero/theme.xml +++ b/e107_themes/landingzero/theme.xml @@ -46,4 +46,7 @@ + + top + \ No newline at end of file diff --git a/e107_themes/landingzero/theme_config.php b/e107_themes/landingzero/theme_config.php index ceb563d97..92447f4a3 100644 --- a/e107_themes/landingzero/theme_config.php +++ b/e107_themes/landingzero/theme_config.php @@ -4,7 +4,6 @@ if (!defined('e107_INIT')) { exit; } e107::lan('theme', 'admin',true); -// Dummy Theme Configuration File. class theme_config implements e_theme_config { @@ -23,8 +22,8 @@ class theme_config implements e_theme_config 'videomobilebackground' => array('title' => LAN_LZ_THEMEPREF_01, 'type'=>'image', 'help'=>''), 'videoposter' => array('title' => LAN_LZ_THEMEPREF_02, 'type'=>'image', 'help'=>''), 'videourl' => array('title' => LAN_LZ_THEMEPREF_03, 'type'=>'text', 'writeParms'=>array('size'=>'xxlarge'),'help'=>''), - 'usernav_placement' => array('title' => LAN_LZ_THEMEPREF_04, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>array(LAN_LZ_THEMEPREF_05, LAN_LZ_THEMEPREF_06), 'useValues'=>1)), - 'cdn' => array('title' => 'CDN', 'type'=>'dropdown', 'writeParms'=>array('optArray'=>array( 'cdnjs' => 'CDNJS (Cloudflare)', 'jsdelivr' => 'jsDelivr'))) + 'usernav_placement' => array('title' => LAN_LZ_THEMEPREF_04, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>array('top'=>LAN_LZ_THEMEPREF_05, 'bottom'=>LAN_LZ_THEMEPREF_06))), + // 'cdn' => array('title' => 'CDN', 'type'=>'dropdown', 'writeParms'=>array('optArray'=>array( 'cdnjs' => 'CDNJS (Cloudflare)', 'jsdelivr' => 'jsDelivr'))) ); return $fields; diff --git a/e107_themes/landingzero/theme_shortcodes.php b/e107_themes/landingzero/theme_shortcodes.php index 124b0740d..178ee2055 100644 --- a/e107_themes/landingzero/theme_shortcodes.php +++ b/e107_themes/landingzero/theme_shortcodes.php @@ -113,42 +113,45 @@ class theme_shortcodes extends e_shortcode $text .= ' '.$sitedisclaimer; return e107::getParser()->toHtml($text, true, 'SUMMARY'); - } - - function sc_xurl_icons() { - $social = array( - 'rss' => array('href'=> (e107::isInstalled('rss_menu') ? e107::url('rss_menu', 'index', array('rss_url'=>'news')) : ''), 'title'=>'RSS/Atom Feed'), - 'facebook' => array('href'=> deftrue('XURL_FACEBOOK'), 'title'=>'Facebook'), - 'twitter' => array('href'=> deftrue('XURL_TWITTER'), 'title'=>'Twitter'), - 'google' => array('href'=> deftrue('XURL_GOOGLE'), 'title'=>'Google Plus'), - 'linkedin' => array('href'=> deftrue('XURL_LINKEDIN'), 'title'=>'LinkedIn'), - 'github' => array('href'=> deftrue('XURL_GITHUB'), 'title'=>'Github'), - 'pinterest' => array('href'=> deftrue('XURL_PINTEREST'), 'title'=>'Pinterest'), - 'flickr' => array('href'=> deftrue('XURL_FLICKR'), 'title'=>'Flickr'), - 'instagram' => array('href'=> deftrue('XURL_INSTAGRAM'), 'title'=>'Instagram'), - 'youtube' => array('href'=> deftrue('XURL_YOUTUBE'), 'title'=>'YouTube'), - 'question-circle' => array('href'=> deftrue('XURL_VIMEO'), 'title'=>'e107 HELP') - ); - - //Fixme - GooglePlus not working. + } - $text = ''; - $textstart =''; - foreach($social as $id => $data) - { - if($data['href'] != '') - { - $text .= ' -
  •  
  • '; - $text .= "\n"; - } - } - if($text !='') - { - return $textstart.$text.$textend; - } - } + + //@todo Replace with social template. + function sc_xurl_icons() + { + $social = array( + 'rss' => array('href' => (e107::isInstalled('rss_menu') ? e107::url('rss_menu', 'index', array('rss_url' => 'news')) : ''), 'title' => 'RSS/Atom Feed'), + 'facebook' => array('href' => deftrue('XURL_FACEBOOK'), 'title' => 'Facebook'), + 'twitter' => array('href' => deftrue('XURL_TWITTER'), 'title' => 'Twitter'), + 'google' => array('href' => deftrue('XURL_GOOGLE'), 'title' => 'Google Plus'), + 'linkedin' => array('href' => deftrue('XURL_LINKEDIN'), 'title' => 'LinkedIn'), + 'github' => array('href' => deftrue('XURL_GITHUB'), 'title' => 'Github'), + 'pinterest' => array('href' => deftrue('XURL_PINTEREST'), 'title' => 'Pinterest'), + 'flickr' => array('href' => deftrue('XURL_FLICKR'), 'title' => 'Flickr'), + 'instagram' => array('href' => deftrue('XURL_INSTAGRAM'), 'title' => 'Instagram'), + 'youtube' => array('href' => deftrue('XURL_YOUTUBE'), 'title' => 'YouTube'), + 'question-circle' => array('href' => deftrue('XURL_VIMEO'), 'title' => 'e107 HELP') + ); + + //Fixme - GooglePlus not working. + + $text = ''; + $textstart = ''; + foreach($social as $id => $data) + { + if($data['href'] != '') + { + $text .= ' +
  •  
  • '; + $text .= "\n"; + } + } + if($text != '') + { + return $textstart . $text . $textend; + } + } function sc_lz_subscribe() diff --git a/e107_themes/voux/theme.php b/e107_themes/voux/theme.php index e0ce72430..1407ffb8d 100644 --- a/e107_themes/voux/theme.php +++ b/e107_themes/voux/theme.php @@ -20,9 +20,14 @@ define('VIEWPORT', "width=device-width, initial-scale=1.0"); // Warning: Some bootstrap CDNs are not compiled with popup.js // use https if e107 is using https. -e107::js("url", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery', 2); +/*e107::js("url", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery', 2); e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css'); -e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.5.0/css/font-awesome.min.css'); +e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.5.0/css/font-awesome.min.css');*/ + +e107::library('load', 'bootstrap'); +e107::library('load', 'fontawesome'); + + e107::css('url', 'http://fonts.googleapis.com/css?family=Bad+Script|Raleway:400,500,600,700,300|Lora:400'); // e107::css('theme','voux.css'); e107::css('url', 'http://fonts.googleapis.com/css?family=Montserrat:400,700&ver=4.2.4');