mirror of
https://github.com/silverstripe/silverstripe-versionfeed
synced 2024-10-22 09:05:31 +00:00
ENH Add generic types (#94)
This commit is contained in:
parent
5071f0e449
commit
b7b4ff8fbd
@ -13,10 +13,13 @@ use SilverStripe\ORM\FieldType\DBField;
|
|||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
use SilverStripe\View\Parsers\HtmlDiff;
|
use SilverStripe\View\Parsers\HtmlDiff;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\Versioned\Versioned_Version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Extension<SiteTree&static>
|
||||||
|
*/
|
||||||
class VersionFeed extends SiteTreeExtension
|
class VersionFeed extends SiteTreeExtension
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'PublicHistory' => 'Boolean(true)'
|
'PublicHistory' => 'Boolean(true)'
|
||||||
);
|
);
|
||||||
@ -68,7 +71,7 @@ class VersionFeed extends SiteTreeExtension
|
|||||||
* @param int $highestVersion Top version number to consider.
|
* @param int $highestVersion Top version number to consider.
|
||||||
* @param int $limit Limit to the amount of items returned.
|
* @param int $limit Limit to the amount of items returned.
|
||||||
*
|
*
|
||||||
* @returns ArrayList List of cleaned records.
|
* @return ArrayList<Versioned_Version> List of cleaned records.
|
||||||
*/
|
*/
|
||||||
public function getDiffList($highestVersion = null, $limit = 100)
|
public function getDiffList($highestVersion = null, $limit = 100)
|
||||||
{
|
{
|
||||||
@ -156,7 +159,7 @@ class VersionFeed extends SiteTreeExtension
|
|||||||
* Return a single diff representing this version.
|
* Return a single diff representing this version.
|
||||||
* Returns the initial version if there is nothing to compare to.
|
* Returns the initial version if there is nothing to compare to.
|
||||||
*
|
*
|
||||||
* @return DataObject|null Object with relevant fields diffed.
|
* @return Versioned_Version|null Object with relevant fields diffed.
|
||||||
*/
|
*/
|
||||||
public function getDiff()
|
public function getDiff()
|
||||||
{
|
{
|
||||||
@ -173,7 +176,7 @@ class VersionFeed extends SiteTreeExtension
|
|||||||
if (!$this->owner->config()->get('changes_enabled')) {
|
if (!$this->owner->config()->get('changes_enabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add public history field.
|
// Add public history field.
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Settings',
|
'Root.Settings',
|
||||||
|
@ -11,25 +11,29 @@ use SilverStripe\ORM\DB;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
use SilverStripe\Core\Extension;
|
use SilverStripe\Core\Extension;
|
||||||
use SilverStripe\VersionFeed\Filters\ContentFilter;
|
use SilverStripe\VersionFeed\Filters\ContentFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Extension<Controller&static>
|
||||||
|
*/
|
||||||
class VersionFeedController extends Extension
|
class VersionFeedController extends Extension
|
||||||
{
|
{
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'changes',
|
'changes',
|
||||||
'allchanges'
|
'allchanges'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content handler
|
* Content handler
|
||||||
*
|
*
|
||||||
* @var ContentFilter
|
* @var ContentFilter
|
||||||
*/
|
*/
|
||||||
protected $contentFilter;
|
protected $contentFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the content filter
|
* Sets the content filter
|
||||||
*
|
*
|
||||||
@ -39,7 +43,7 @@ class VersionFeedController extends Extension
|
|||||||
{
|
{
|
||||||
$this->contentFilter = $contentFilter;
|
$this->contentFilter = $contentFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates the result of the given callback
|
* Evaluates the result of the given callback
|
||||||
*
|
*
|
||||||
@ -163,7 +167,7 @@ class VersionFeedController extends Extension
|
|||||||
$rss->setTemplate('Page_allchanges_rss');
|
$rss->setTemplate('Page_allchanges_rss');
|
||||||
return $rss->outputToBrowser();
|
return $rss->outputToBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and embeds the RSS header link for the page-specific version rss feed
|
* Generates and embeds the RSS header link for the page-specific version rss feed
|
||||||
*/
|
*/
|
||||||
@ -172,7 +176,7 @@ class VersionFeedController extends Extension
|
|||||||
if (!Config::inst()->get(VersionFeed::class, 'changes_enabled') || !$this->owner->PublicHistory) {
|
if (!Config::inst()->get(VersionFeed::class, 'changes_enabled') || !$this->owner->PublicHistory) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RSSFeed::linkToFeed(
|
RSSFeed::linkToFeed(
|
||||||
$this->owner->Link('changes'),
|
$this->owner->Link('changes'),
|
||||||
_t(
|
_t(
|
||||||
@ -193,7 +197,7 @@ class VersionFeedController extends Extension
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RSS feed to all-site changes.
|
// RSS feed to all-site changes.
|
||||||
$title = Convert::raw2xml($this->linkToAllSitesRSSFeedTitle());
|
$title = Convert::raw2xml($this->linkToAllSitesRSSFeedTitle());
|
||||||
$url = $this->owner->getSiteRSSLink();
|
$url = $this->owner->getSiteRSSLink();
|
||||||
|
@ -7,13 +7,15 @@ use SilverStripe\Forms\CheckboxField;
|
|||||||
use SilverStripe\Forms\FieldGroup;
|
use SilverStripe\Forms\FieldGroup;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows global configuration of all changes
|
* Allows global configuration of all changes
|
||||||
|
*
|
||||||
|
* @extends DataExtension<SiteConfig>
|
||||||
*/
|
*/
|
||||||
class VersionFeedSiteConfig extends DataExtension
|
class VersionFeedSiteConfig extends DataExtension
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'AllChangesEnabled' => 'Boolean(true)'
|
'AllChangesEnabled' => 'Boolean(true)'
|
||||||
);
|
);
|
||||||
@ -26,7 +28,7 @@ class VersionFeedSiteConfig extends DataExtension
|
|||||||
{
|
{
|
||||||
$labels['AllChangesEnabled'] = _t(__CLASS__ . '.ALLCHANGESLABEL', 'Make global changes feed public');
|
$labels['AllChangesEnabled'] = _t(__CLASS__ . '.ALLCHANGESLABEL', 'Make global changes feed public');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields)
|
public function updateCMSFields(FieldList $fields)
|
||||||
{
|
{
|
||||||
if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) {
|
if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user