mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2247 from open-sausages/pulls/4.2/2227-show-link-tracking
API: Add `show_link_tracking` config to `SiteTreeLinkTracking` extension
This commit is contained in:
commit
aa3760ed66
@ -4,3 +4,8 @@ Name: cmslinktracking
|
|||||||
SilverStripe\ORM\DataObject:
|
SilverStripe\ORM\DataObject:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\CMS\Model\SiteTreeLinkTracking
|
- SilverStripe\CMS\Model\SiteTreeLinkTracking
|
||||||
|
---
|
||||||
|
Name: cmslinktrackingvisibility
|
||||||
|
---
|
||||||
|
SilverStripe\Security\Member:
|
||||||
|
show_sitetree_link_tracking: true
|
||||||
|
@ -4,6 +4,8 @@ namespace SilverStripe\CMS\Model;
|
|||||||
|
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use SilverStripe\Assets\Shortcodes\FileLinkTracking;
|
use SilverStripe\Assets\Shortcodes\FileLinkTracking;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
|
use SilverStripe\Forms\FormScaffolder;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
@ -52,6 +54,15 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls visibility of the Link Tracking tab
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
* @see linktracking.yml
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private static $show_sitetree_link_tracking = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser for link tracking
|
* Parser for link tracking
|
||||||
*
|
*
|
||||||
@ -194,4 +205,13 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
$domReference->removeAttribute('class');
|
$domReference->removeAttribute('class');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateCMSFields(FieldList $fields)
|
||||||
|
{
|
||||||
|
if (!$this->owner->config()->get('show_sitetree_link_tracking')) {
|
||||||
|
$fields->removeByName('LinkTracking');
|
||||||
|
} elseif ($this->owner->ID && !$this->owner->getField('LinkTracking')) {
|
||||||
|
FormScaffolder::addManyManyRelationshipFields($fields, 'LinkTracking', null, true, $this->owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user