Skip to content

Commit

Permalink
NEW Adding a paragraph to display the version of SilverStripe CMS and…
Browse files Browse the repository at this point in the history
… Framework on the installed module report
  • Loading branch information
ScopeyNZ committed May 22, 2018
1 parent ac4f254 commit 033abfd
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/Reports/SiteSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@ public function description()
);
}

public function sourceRecords($params)
public function getCMSFields()
{
$fields = parent::getCMSFields();

$this->beforeExtending('updateCMSFields', function (FieldList $fields) {
$fields->insertAfter('ReportDescription', new LiteralField(
'Version',
'<p><strong>' . _t(__CLASS__ . '.VERSION', 'Version: ') . $this->resolveCmsVersion() . '</strong></p>'
));
});

return $fields;
}

public function sourceRecords()
{
return Package::get()->filter('Type:StartsWith', 'silverstripe');
}
Expand All @@ -49,4 +63,34 @@ public function getReportField()
]);
return $grid;
}

/**
* @return string
*/
protected function resolveCmsVersion()
{

$versionModules = [
'silverstripe/framework' => 'Framework',
'silverstripe/cms' => 'CMS',
];
$this->extend('updateVersionModules', $versionModules);

$records = $this->sourceRecords()->filter('name', array_keys($versionModules));
$versionParts = [];

foreach ($versionModules as $name => $label) {
$record = $records->find('Name', $name);
if (!$record) {
$version = _t(__CLASS__.'.VersionUnknown', 'Unknown');
}
else {
$version = $record->Version;
}

$versionParts[] = "$label $version";
}

return implode(', ', $versionParts);
}
}

0 comments on commit 033abfd

Please sign in to comment.