diff --git a/classes/plugin/Admin.php b/classes/plugin/Admin.php index e2284360..546511fd 100644 --- a/classes/plugin/Admin.php +++ b/classes/plugin/Admin.php @@ -2136,10 +2136,41 @@ class Admin return $_SERVER['HTTP_REFERER'] ?? null; } + + /** + * Get Grav system log files + * + * @return array + */ public function getLogFiles() { $logs = new GravData(['grav.log' => 'Grav System Log', 'email.log' => 'Email Log']); Grav::instance()->fireEvent('onAdminLogFiles', new Event(['logs' => &$logs])); return $logs->toArray(); } + + /** + * Get changelog for a given GPM package based on slug + * + * @param null $slug + * @return array + */ + public function getChangelog($slug = null) + { + $gpm = $this->gpm(); + $changelog = []; + + if (!empty($slug)) { + $package = $gpm->findPackage($slug); + } else { + $package = $gpm->grav; + } + + + if ($package) { + $changelog = $package->getChangelog(); + } + + return $changelog; + } } diff --git a/themes/grav/templates/changelog.html.twig b/themes/grav/templates/changelog.html.twig index 8ec45400..c9114ff9 100644 --- a/themes/grav/templates/changelog.html.twig +++ b/themes/grav/templates/changelog.html.twig @@ -1,13 +1,6 @@ {% set slug = uri.param('slug') %} -{% if slug %} - {% set package = admin.gpm.findPackage(slug) %} - {% set changelog = package.changelog %} - {% set title = package.name %} -{% else %} - {% set changelog = admin.gpm.grav.changelog %} - {% set title = "Grav" %} -{% endif %} +{% set changelog = admin.getChangelog(slug) %}