Skip to content

Commit a6c4243

Browse files
API Deprecate API that will be removed in CMS 6 (#11630)
1 parent ca75158 commit a6c4243

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

src/Forms/HTMLEditor/HTMLEditorField.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class HTMLEditorField extends TextareaField
5454
* Extra height per row
5555
*
5656
* @var int
57+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorConfig.fixed_row_height
5758
*/
5859
private static $fixed_row_height = 20;
5960

src/Forms/HTMLEditor/HTMLEditorSanitiser.php

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SilverStripe\Core\Config\Configurable;
88
use SilverStripe\Core\Injector\Injectable;
99
use SilverStripe\Core\XssSanitiser;
10+
use SilverStripe\Dev\Deprecation;
1011
use SilverStripe\View\Parsers\HTMLValue;
1112
use stdClass;
1213

@@ -34,12 +35,22 @@ class HTMLEditorSanitiser
3435
*/
3536
private static $link_rel_value = 'noopener noreferrer';
3637

37-
/** @var stdClass - $element => $rule hash for whitelist element rules where the element name isn't a pattern */
38+
/**
39+
* @var stdClass - $element => $rule hash for whitelist element rules where the element name isn't a pattern
40+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet
41+
*/
3842
protected $elements = [];
39-
/** @var stdClass - Sequential list of whitelist element rules where the element name is a pattern */
43+
44+
/**
45+
* @var stdClass - Sequential list of whitelist element rules where the element name is a pattern
46+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet
47+
*/
4048
protected $elementPatterns = [];
4149

42-
/** @var stdClass - The list of attributes that apply to all further whitelisted elements added */
50+
/**
51+
* @var stdClass - The list of attributes that apply to all further whitelisted elements added
52+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet
53+
*/
4354
protected $globalAttributes = [];
4455

4556
/**
@@ -68,9 +79,14 @@ public function __construct(HTMLEditorConfig $config)
6879
*
6980
* @param $str - The TinyMCE pattern
7081
* @return string - The equivalent regex
82+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::patternToRegex()
7183
*/
7284
protected function patternToRegex($str)
7385
{
86+
Deprecation::noticeWithNoReplacment(
87+
'5.4.0',
88+
'Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::patternToRegex()'
89+
);
7490
return '/^' . preg_replace('/([?+*])/', '.$1', $str ?? '') . '$/';
7591
}
7692

@@ -81,9 +97,14 @@ protected function patternToRegex($str)
8197
* Logic based heavily on javascript version from tiny_mce_src.js
8298
*
8399
* @param string $validElements - The valid_elements or extended_valid_elements string to add to the whitelist
100+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet
84101
*/
85102
protected function addValidElements($validElements)
86103
{
104+
Deprecation::noticeWithNoReplacment(
105+
'5.4.0',
106+
'Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet'
107+
);
87108
$elementRuleRegExp = '/^([#+\-])?([^\[\/]+)(?:\/([^\[]+))?(?:\[([^\]]+)\])?$/';
88109
$attrRuleRegExp = '/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/';
89110
$hasPatternsRegExp = '/[*?+]/';
@@ -186,9 +207,14 @@ protected function addValidElements($validElements)
186207
* Given an element tag, return the rule structure for that element
187208
* @param string $tag The element tag
188209
* @return stdClass The element rule
210+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::getRuleForElement()
189211
*/
190212
protected function getRuleForElement($tag)
191213
{
214+
Deprecation::noticeWithNoReplacment(
215+
'5.4.0',
216+
'Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::getRuleForElement()'
217+
);
192218
if (isset($this->elements[$tag])) {
193219
return $this->elements[$tag];
194220
}
@@ -206,9 +232,14 @@ protected function getRuleForElement($tag)
206232
* @param object $elementRule
207233
* @param string $name The attribute name
208234
* @return stdClass The attribute rule
235+
* @deprecated 5.4.0 Will be replaced with logic in SilverStripe\Forms\HTMLEditor\HTMLEditorElementRule
209236
*/
210237
protected function getRuleForAttribute($elementRule, $name)
211238
{
239+
Deprecation::noticeWithNoReplacment(
240+
'5.4.0',
241+
'Will be replaced with logic in SilverStripe\Forms\HTMLEditor\HTMLEditorElementRule'
242+
);
212243
if (isset($elementRule->attributes[$name])) {
213244
return $elementRule->attributes[$name];
214245
}
@@ -225,9 +256,14 @@ protected function getRuleForAttribute($elementRule, $name)
225256
* @param DOMElement $element The element to check
226257
* @param stdClass $rule The rule to check against
227258
* @return bool True if the element passes (and so can be kept), false if it fails (and so needs stripping)
259+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::isElementAllowed()
228260
*/
229261
protected function elementMatchesRule($element, $rule = null)
230262
{
263+
Deprecation::noticeWithNoReplacment(
264+
'5.4.0',
265+
'Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorRuleSet::isElementAllowed()'
266+
);
231267
// If the rule doesn't exist at all, the element isn't allowed
232268
if (!$rule) {
233269
return false;
@@ -263,9 +299,14 @@ protected function elementMatchesRule($element, $rule = null)
263299
* @param DOMAttr $attr - the attribute to check
264300
* @param stdClass $rule - the rule to check against
265301
* @return bool - true if the attribute passes (and so can be kept), false if it fails (and so needs stripping)
302+
* @deprecated 5.4.0 Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorElementRule::isAttributeAllowed()
266303
*/
267304
protected function attributeMatchesRule($attr, $rule = null)
268305
{
306+
Deprecation::noticeWithNoReplacment(
307+
'5.4.0',
308+
'Will be replaced with SilverStripe\Forms\HTMLEditor\HTMLEditorElementRule::isAttributeAllowed()'
309+
);
269310
// If the rule doesn't exist at all, the attribute isn't allowed
270311
if (!$rule) {
271312
return false;

src/Forms/HTMLEditor/TinyMCECombinedGenerator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
use SilverStripe\Core\Flushable;
1010
use SilverStripe\Core\Injector\Injectable;
1111
use SilverStripe\Core\Manifest\ModuleResource;
12+
use SilverStripe\Dev\Deprecation;
1213

1314
/**
1415
* Generates tinymce config using a combined file generated via a standard
1516
* SilverStripe {@link GeneratedAssetHandler}
17+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TinyMCE\TinyMCECombinedGenerator
1618
*/
1719
class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable
1820
{
@@ -31,6 +33,15 @@ class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable
3133
*/
3234
protected $assetHandler = null;
3335

36+
public function __construct()
37+
{
38+
Deprecation::noticeWithNoReplacment(
39+
'5.4.0',
40+
'Will be replaced with SilverStripe\TinyMCE\TinyMCECombinedGenerator',
41+
Deprecation::SCOPE_CLASS
42+
);
43+
}
44+
3445
/**
3546
* Assign backend store for generated assets
3647
*

src/Forms/HTMLEditor/TinyMCEConfig.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use SilverStripe\Core\Injector\Injector;
1010
use SilverStripe\Core\Manifest\ModuleResource;
1111
use SilverStripe\Core\Manifest\ModuleResourceLoader;
12+
use SilverStripe\Dev\Deprecation;
1213
use SilverStripe\i18n\i18n;
1314
use SilverStripe\i18n\i18nEntityProvider;
1415
use SilverStripe\View\Requirements;
@@ -17,6 +18,7 @@
1718

1819
/**
1920
* Default configuration for HtmlEditor specific to tinymce
21+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TinyMCE\TinyMCEConfig
2022
*/
2123
class TinyMCEConfig extends HTMLEditorConfig implements i18nEntityProvider
2224
{
@@ -354,6 +356,11 @@ class TinyMCEConfig extends HTMLEditorConfig implements i18nEntityProvider
354356

355357
public function __construct()
356358
{
359+
Deprecation::noticeWithNoReplacment(
360+
'5.4.0',
361+
'Will be replaced with SilverStripe\TinyMCE\TinyMCEConfig',
362+
Deprecation::SCOPE_CLASS
363+
);
357364
$this->settings = static::config()->get('default_options');
358365
}
359366

src/Forms/HTMLEditor/TinyMCEScriptGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/**
66
* Declares a service which can generate a script URL for a given HTMLEditor config
7+
* @deprecated 5.4.0 Will be replaced with SilverStripe\TinyMCE\TinyMCEScriptGenerator
78
*/
89
interface TinyMCEScriptGenerator
910
{

0 commit comments

Comments
 (0)