From adc74ac02e00eaba0af921a63ec99d1fcc2ff0b0 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Fri, 29 Mar 2019 00:21:51 +1100 Subject: [PATCH] Add changelog link to updates screen - Fixes #4101 --- modules/system/classes/UpdateManager.php | 33 +++++++++++++ modules/system/controllers/Updates.php | 27 +++++++++++ .../controllers/updates/_changelog_list.htm | 47 +++++++++++++++++++ modules/system/controllers/updates/index.htm | 8 ++++ modules/system/lang/en/lang.php | 3 ++ 5 files changed, 118 insertions(+) create mode 100644 modules/system/controllers/updates/_changelog_list.htm diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 4be195a33..006aadcfd 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -748,6 +748,39 @@ class UpdateManager $this->productCache[$type][$code] = $data; } + // + // Changelog + // + + /** + * Returns the latest changelog information. + */ + public function requestChangelog() + { + $result = Http::get('https://octobercms.com/changelog?json'); + + if ($result->code == 404) { + throw new ApplicationException(Lang::get('system::lang.server.response_empty')); + } + + if ($result->code != 200) { + throw new ApplicationException( + strlen($result->body) + ? $result->body + : Lang::get('system::lang.server.response_empty') + ); + } + + try { + $resultData = json_decode($result->body, true); + } + catch (Exception $ex) { + throw new ApplicationException(Lang::get('system::lang.server.response_invalid')); + } + + return $resultData; + } + // // Notes // diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index 9e32b990b..3cc7985b7 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -699,6 +699,33 @@ class Updates extends Controller return Backend::redirect('system/updates'); } + // + // View Changelog + // + + /** + * Displays changelog information + */ + public function onLoadChangelog() + { + try { + $fetchedContent = UpdateManager::instance()->requestChangelog(); + + $changelog = array_get($fetchedContent, 'history'); + + if (!$changelog || !is_array($changelog)) { + throw new ApplicationException(Lang::get('system::lang.server.response_empty')); + } + + $this->vars['changelog'] = $changelog; + } + catch (Exception $ex) { + $this->handleError($ex); + } + + return $this->makePartial('changelog_list'); + } + // // Plugin management // diff --git a/modules/system/controllers/updates/_changelog_list.htm b/modules/system/controllers/updates/_changelog_list.htm new file mode 100644 index 000000000..8c396df82 --- /dev/null +++ b/modules/system/controllers/updates/_changelog_list.htm @@ -0,0 +1,47 @@ + + + + diff --git a/modules/system/controllers/updates/index.htm b/modules/system/controllers/updates/index.htm index 6d98cd48c..39c997d39 100644 --- a/modules/system/controllers/updates/index.htm +++ b/modules/system/controllers/updates/index.htm @@ -35,6 +35,14 @@

+

+ + + +

diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index 161b7ff2d..5890babd7 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -317,11 +317,14 @@ return [ 'plugin_author' => 'Author', 'plugin_not_found' => 'Plugin not found', 'core_current_build' => 'Current build', + 'core_view_changelog' => 'View Changelog', 'core_build' => 'Build :build', 'core_build_help' => 'Latest build is available.', 'core_downloading' => 'Downloading application files', 'core_extracting' => 'Unpacking application files', 'core_set_build' => 'Setting build number', + 'changelog' => 'Changelog', + 'changelog_view_details' => 'View details', 'plugins' => 'Plugins', 'themes' => 'Themes', 'disabled' => 'Disabled',