-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nswdpc/ss410
Update minimum required versions
- Loading branch information
Showing
7 changed files
with
91 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
/tests export-ignore | ||
/docs export-ignore | ||
/client/src export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php_cs.dist | ||
/.phpcs.xml.dist | ||
/.phpunit.xml.dist | ||
/.waratah export-ignore | ||
/README.md export-ignore | ||
/tests export-ignore | ||
/docs export-ignore | ||
/client/src export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.waratah export-ignore | ||
/code-of-conduct.md export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/README.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/client/node_modules | ||
/vendor/ | ||
.DS_Store | ||
/.php-cs-cache | ||
/.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,29 +15,52 @@ | |
use SilverStripe\Security\Permission; | ||
use SilverStripe\View\Requirements; | ||
use SilverStripe\View\ViewableData; | ||
|
||
/** | ||
* ElementIframe class | ||
* Iframe content block | ||
* | ||
* @author Mark Taylor <[email protected]> | ||
* @author James Ellis <[email protected]> | ||
* @author Mark Taylor | ||
* @author James Ellis | ||
*/ | ||
class ElementIframe extends BaseElement implements PermissionProvider { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'ElementIframe'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $icon = 'font-icon-code'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $singular_name = 'Iframe'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $plural_name = 'Iframes'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $default_allow_attributes = [ | ||
'fullscreen' | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_one = [ | ||
'URL' => Link::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'IsLazy' => 'Boolean', | ||
'IsFullWidth' => 'Boolean', | ||
|
@@ -48,6 +71,9 @@ class ElementIframe extends BaseElement implements PermissionProvider { | |
'AlternateContent' => 'Text' | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $defaults = [ | ||
'IsLazy' => 1, | ||
'IsFullWidth' => 1, | ||
|
@@ -56,23 +82,42 @@ class ElementIframe extends BaseElement implements PermissionProvider { | |
'Height' => '400', | ||
]; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $title = 'Iframe'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $description = 'Display content in an HTML iframe tag'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $responsive_options = [ | ||
'16x9' => '16x9', | ||
'4x3' => '4x3' | ||
]; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $default_height = '400'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $load_polyfill = true; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private static $resizer_log = false; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getType() | ||
{ | ||
return _t(__CLASS__ . '.BlockType', 'Iframe'); | ||
|
@@ -180,25 +225,40 @@ public function providePermissions() | |
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function canEdit($member = null) | ||
{ | ||
return Permission::checkMember($member, 'ELEMENT_IFRAME_EDIT'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function canDelete($member = null) | ||
{ | ||
return Permission::checkMember($member, 'ELEMENT_IFRAME_DELETE'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function canCreate($member = null, $context = []) | ||
{ | ||
return Permission::checkMember($member, 'ELEMENT_IFRAME_EDIT'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getResponsiveOptions() { | ||
return $this->config()->get('responsive_options') ?: []; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function onBeforeWrite() | ||
{ | ||
parent::onBeforeWrite(); | ||
|
@@ -275,15 +335,18 @@ public function getIframeHeight() { | |
/** | ||
* Return the width or 100% if not set | ||
*/ | ||
public function getIframeWidth() { | ||
public function getIframeWidth() : string { | ||
$width = $this->getField('Width'); | ||
if(!$width || $this->IsFullWidth || $this->IsResponsive) { | ||
$width = "100%"; | ||
} | ||
return $width; | ||
} | ||
|
||
protected function getDefaultHeight() { | ||
/** | ||
* Return the default height or a set height of 400 if not set | ||
*/ | ||
protected function getDefaultHeight() : string { | ||
$height = $this->config()->get('default_height'); | ||
if(!$height) { | ||
$height = '400'; | ||
|
@@ -309,6 +372,9 @@ public function getURLAsString() : string { | |
return $url; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getCMSFields() { | ||
$fields = parent::getCMSFields(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters