From f7a14d29ae83e9fc3a60a77ce999d24a85acd921 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 2 Feb 2017 11:48:13 -0800 Subject: [PATCH] Plugin/Theme update check moved to admin_shortcodes --- e107_admin/admin.php | 18 +- e107_admin/boot.php | 2 +- .../shortcodes/batch/admin_shortcodes.php | 118 ++++++++++- e107_handlers/theme_handler.php | 19 +- e107_themes/bootstrap3/admin_dark.css | 2 +- e107_themes/bootstrap3/admin_style.css | 3 + e107_themes/bootstrap3/admin_template.php | 197 +----------------- e107_themes/bootstrap3/admin_theme.php | 15 +- 8 files changed, 170 insertions(+), 204 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index 0ad7fede6..ed176071e 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -110,7 +110,7 @@ class admin_start function __construct() { - if(!getperms('0') || varset($_GET['mode']) === 'customize') // don't display this tuff to regular admins only main admin. + if(e_AJAX_REQUEST || !getperms('0') || varset($_GET['mode']) === 'customize') // don't display this tuff to regular admins only main admin. { return null; } @@ -189,12 +189,12 @@ class admin_start e107::getDb()->db_Mark_Time('Check New Install'); $this->checkNewInstall(); - e107::getDb()->db_Mark_Time('Check Plugin Update'); + /* e107::getDb()->db_Mark_Time('Check Plugin Update'); $this->checkPluginUpdate(); e107::getDb()->db_Mark_Time('Check Theme Update'); $this->checkThemeUpdate(); - + */ e107::getDb()->db_Mark_Time('Check Password Encryption'); $this->checkPasswordEncryption(); @@ -287,7 +287,8 @@ class admin_start } - +/* + * // Moved to admin_shortcodes.php private function checkPluginUpdate() { require_once(e_HANDLER.'e_marketplace.php'); @@ -322,14 +323,15 @@ class admin_start e107::getMessage()->addInfo($message); - e107::getMessage()->addDebug("Local version: ".$version." Remote version: ".$versions[$folder]['version']); + } } - } - + }*/ +/* + * Moved to admin_shortcodes.php private function checkThemeUpdate() { require_once(e_HANDLER.'e_marketplace.php'); @@ -376,7 +378,7 @@ class admin_start - } + }*/ /** * diff --git a/e107_admin/boot.php b/e107_admin/boot.php index 900be40ce..e760bd231 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -77,7 +77,7 @@ if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'core' && ($_GET['type'] -if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'addons' ) +if(ADMIN && (e_AJAX_REQUEST || e_DEBUG_FEEDS===true) && varset($_GET['mode']) == 'addons' ) { $type = ($_GET['type'] == 'plugin') ? 'plugin' : 'theme'; $tag = 'Infopanel_'.$type; diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 7dd8fdd42..1ef13e578 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1319,7 +1319,123 @@ Inverse 10 10 } - + function sc_admin_addon_updates() + { + if(!getperms('0')) + { + return null; + } + + $themes = $this->getUpdateable('theme'); + $plugins = $this->getUpdateable('plugin'); + + $text = $this->renderAddonUpdate($plugins); + $text .= $this->renderAddonUpdate($themes); + + if(empty($text)) + { + return null; + } + + $tp = e107::getParser(); + + return e107::getRender()->tablerender($tp->toGlyph('fa-arrow-circle-o-down').'Updates Available',$text,'default',true); + + + } + + + private function getUpdateable($type) + { + + if(empty($type)) + { + return false; + } + + require_once(e_HANDLER.'e_marketplace.php'); + $mp = new e_marketplace(); // autodetect the best method + + switch($type) + { + case "theme": + $versions = $mp->getVersionList('theme'); + $list = e107::getTheme()->getThemeList('version'); + break; + + case "plugin": + $versions = $mp->getVersionList('plugin'); + $list = e107::getPref('plug_installed'); + break; + } + + $ret = array(); + + foreach($list as $folder=>$version) + { + + if(!empty($versions[$folder]['version']) && version_compare( $version, $versions[$folder]['version'], '<')) + { + $versions[$folder]['modalDownload'] = $mp->getDownloadModal('theme', $versions[$folder]); + $ret[] = $versions[$folder]; + e107::getMessage()->addDebug("Local version: ".$version." Remote version: ".$versions[$folder]['version']); + } + + } + + return $ret; + + } + + + + private function renderAddonUpdate($list) + { + + if(empty($list)) + { + return null; + } + + + $tp = e107::getParser(); + $text = '"; + + + return $text; + } + function sc_admin_update() { diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 282820c8d..5e38e7d37 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -106,14 +106,20 @@ class e_theme $tloop = 1; - $array = scandir(e_THEME); + $cacheTag = self::CACHETAG; + if(!empty($mode)) + { + $cacheTag = self::CACHETAG.'_'.$mode; + } - if($force === false && $tmp = e107::getCache()->retrieve(self::CACHETAG, self::CACHETIME, true, true)) + if($force === false && $tmp = e107::getCache()->retrieve($cacheTag, self::CACHETIME, true, true)) { return e107::unserialize($tmp); } + $array = scandir(e_THEME); + foreach($array as $file) { @@ -124,10 +130,15 @@ class e_theme if($file != "." && $file != ".." && $file != "CVS" && $file != "templates" && is_dir(e_THEME.$file) && is_readable(e_THEME.$file."/theme.php")) { - if($mode == "id") + if($mode === "id") { $themeArray[$tloop] = $file; } + elseif($mode === 'version') + { + $data = self::getThemeInfo($file); + $themeArray[$file] = $data['version']; + } else { $themeArray[$file] = self::getThemeInfo($file); @@ -140,7 +151,7 @@ class e_theme $cacheSet = e107::serialize($themeArray,'json'); - e107::getCache()->set(self::CACHETAG,$cacheSet,true,true,true); + e107::getCache()->set($cacheTag,$cacheSet,true,true,true); return $themeArray; } diff --git a/e107_themes/bootstrap3/admin_dark.css b/e107_themes/bootstrap3/admin_dark.css index 6bb6ad8da..a47292c38 100644 --- a/e107_themes/bootstrap3/admin_dark.css +++ b/e107_themes/bootstrap3/admin_dark.css @@ -38,7 +38,7 @@ tr.highlight-even, .table-striped > tbody > tr.highlight-even { background-colo color: black; } - +tr.first a, th a { color: rgb(102, 102, 102); } .bootstrap-select.btn-group .dropdown-menu .optgroup-div { diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index ac3d1d59c..e784cda9e 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -142,7 +142,10 @@ table label.checkbox { margin-left: 20px } #admin-ui-media-manager-search { margin-bottom: 20px } + +/* .panel-default:hover { transition: color .50s ease-in-out; -moz-transition: color .50s ease-in-out; -webkit-transition: color .50s ease-in-out; color: #fff } +*/ #admin-ui-edit { } #admin-ui-edit-db-language { margin-bottom: -30px; padding-bottom:5px; padding-right:5px } diff --git a/e107_themes/bootstrap3/admin_template.php b/e107_themes/bootstrap3/admin_template.php index e5ad85c37..4e7e4b234 100644 --- a/e107_themes/bootstrap3/admin_template.php +++ b/e107_themes/bootstrap3/admin_template.php @@ -157,54 +157,7 @@ $E_ADMIN_NAVIGATION['end'] = ''; $inverse = (e107::getPref('admincss') == "admin_light.css") ? "navbar-inverse" : ""; - - /* -$ADMIN_HEADER = ''; -*/ - -/* -$ADMIN_MODAL = '';*/ - - -// TODO - LANs $ADMIN_MODAL = '