2014-09-07 07:09:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2016-12-04 20:53:53 +01:00
|
|
|
* @package docsviewer
|
2014-09-07 07:09:28 +02:00
|
|
|
*/
|
2015-11-21 07:25:41 +01:00
|
|
|
class DocumentationViewerVersionWarning extends Extension
|
|
|
|
{
|
2016-12-04 20:53:53 +01:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2015-11-21 07:25:41 +01:00
|
|
|
public function VersionWarning()
|
|
|
|
{
|
|
|
|
$page = $this->owner->getPage();
|
|
|
|
|
|
|
|
if (!$page) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-04 20:53:53 +01:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
$entity = $page->getEntity();
|
|
|
|
|
|
|
|
if (!$entity) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$versions = $this->owner->getManifest()->getAllVersionsOfEntity($entity);
|
|
|
|
|
|
|
|
if ($entity->getIsStable()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$stable = $this->owner->getManifest()->getStableVersion($entity);
|
|
|
|
$compare = $entity->compare($stable);
|
|
|
|
|
2016-12-04 20:53:53 +01:00
|
|
|
if ($entity->getVersion() == 'master' || $compare > 0) {
|
2016-12-02 03:31:18 +01:00
|
|
|
return $this->owner->customise(
|
|
|
|
new ArrayData(
|
|
|
|
array(
|
2016-12-04 20:53:53 +01:00
|
|
|
'FutureRelease' => true,
|
|
|
|
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
|
2016-12-02 03:31:18 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
} else {
|
2016-12-02 03:31:18 +01:00
|
|
|
return $this->owner->customise(
|
|
|
|
new ArrayData(
|
|
|
|
array(
|
2016-12-04 20:53:53 +01:00
|
|
|
'OutdatedRelease' => true,
|
|
|
|
'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion())
|
2016-12-02 03:31:18 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2016-12-04 20:53:53 +01:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|