silverstripe-docsviewer/code/extensions/DocumentationViewerVersionWarning.php
Will Rossiter 0b91b91e33 Kill DocumentationService in favour of config API.
This continues on the migration to the Manifest. Instead of using calls to a `Service` now all file related lookups are done through the `DocumentationManifest`
2014-09-07 17:09:28 +12:00

42 lines
998 B
PHP

<?php
/**
* Check to see if the currently accessed version is out of date or
* perhaps a future version rather than the stable edition
*
* @return false|ArrayData
*/
class DocumentationViewerVersionWarning extends Extension {
public function VersionWarning() {
$page = $this->owner->getPage();
$version = $this->owner->getVersion();
$versions = $this->owner->getVersions();
if($page && $verions->count() > 0) {
$stable = $this->owner->getStableVersion();
$compare = $version->compare($stable);
// same
if($version == $stable) {
return false;
}
if($version == "master" || $compare > 0) {
return $this->customise(new ArrayData(array(
'FutureRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable)
)));
}
else {
return $this->customise(new ArrayData(array(
'OutdatedRelease' => true,
'StableVersion' => DBField::create_field('HTMLText', $stable)
)));
}
}
return false;
}
}