mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.6' into 4
This commit is contained in:
commit
8287fad24d
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
|
||||
@ -104,4 +105,14 @@ class GroupedDropdownField extends DropdownField
|
||||
);
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SingleLookupField
|
||||
*/
|
||||
public function performReadonlyTransformation()
|
||||
{
|
||||
$field = parent::performReadonlyTransformation();
|
||||
$field->setSource(ArrayLib::flatten($this->getSource()));
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +160,17 @@ class EmbedShortcodeProvider implements ShortcodeHandler
|
||||
$arguments['style'] = 'width: ' . intval($arguments['width']) . 'px;';
|
||||
}
|
||||
|
||||
// override iframe dimension attributes provided by webservice with ones specified in shortcode arguments
|
||||
foreach (['width', 'height'] as $attr) {
|
||||
if (!($value = $arguments[$attr] ?? false)) {
|
||||
continue;
|
||||
}
|
||||
foreach (['"', "'"] as $quote) {
|
||||
$rx = "/(<iframe .*?)$attr=$quote([0-9]+)$quote([^>]+>)/";
|
||||
$content = preg_replace($rx, "$1{$attr}={$quote}{$value}{$quote}$3", $content);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'Arguments' => $arguments,
|
||||
'Attributes' => static::buildAttributeListFromArguments($arguments, ['width', 'height', 'url', 'caption']),
|
||||
|
@ -129,4 +129,39 @@ class GroupedDropdownFieldTest extends SapphireTest
|
||||
preg_replace('/\s+/', ' ', (string)$field->Field())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that readonly version of GroupedDropdownField displays all values
|
||||
*/
|
||||
public function testReadonlyValue()
|
||||
{
|
||||
$field = GroupedDropdownField::create(
|
||||
'Test',
|
||||
'Testing',
|
||||
[
|
||||
"1" => "One",
|
||||
"Group One" => [
|
||||
"2" => "Two",
|
||||
"3" => "Three"
|
||||
],
|
||||
"Group Two" => [
|
||||
"4" => "Four"
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
// value on first level
|
||||
$field->setValue("1");
|
||||
$this->assertRegExp(
|
||||
'/<span class="readonly" id="Test">One<\/span><input type="hidden" name="Test" value="1" \/>/',
|
||||
(string)$field->performReadonlyTransformation()->Field()
|
||||
);
|
||||
|
||||
// value on first level
|
||||
$field->setValue("2");
|
||||
$this->assertRegExp(
|
||||
'/<span class="readonly" id="Test">Two<\/span><input type="hidden" name="Test" value="2" \/>/',
|
||||
(string)$field->performReadonlyTransformation()->Field()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class EmbedShortcodeProviderTest extends SapphireTest
|
||||
[
|
||||
'url' => static::$test_youtube,
|
||||
'caption' => 'A nice video',
|
||||
'width' => 480,
|
||||
'height' => 360,
|
||||
'width' => 777,
|
||||
'height' => 437,
|
||||
],
|
||||
[
|
||||
'version' => '1.0',
|
||||
@ -58,7 +58,7 @@ class EmbedShortcodeProviderTest extends SapphireTest
|
||||
);
|
||||
$this->assertEqualIgnoringWhitespace(
|
||||
<<<EOS
|
||||
<div style="width: 480px;"><iframe width="480" height="270" src="https://www.youtube.com/embed/dM15HfUYwF0?feature=oembed" frameborder="0" allowfullscreen></iframe>
|
||||
<div style="width: 777px;"><iframe width="777" height="437" src="https://www.youtube.com/embed/dM15HfUYwF0?feature=oembed" frameborder="0" allowfullscreen></iframe>
|
||||
<p class="caption">A nice video</p></div>
|
||||
EOS
|
||||
,
|
||||
|
Loading…
Reference in New Issue
Block a user