Merge branch '3.6' into 3

This commit is contained in:
Daniel Hensby 2017-05-18 13:55:07 +01:00
commit 283e3279be
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
4 changed files with 82 additions and 9 deletions

View File

@ -0,0 +1,10 @@
# 3.6.0-beta2
<!--- Changes below this line will be automatically regenerated -->
## Change Log
### Bugfixes
* 2017-04-26 [000a5f7](https://github.com/silverstripe/silverstripe-cms/commit/000a5f7209065aceae14801244a08d3ed186e752) Fix page history / settings forms (Damian Mooyman)
* 2017-04-21 [7e77753](https://github.com/silverstripe/silverstripe-cms/commit/7e77753274421c79bac85c5b0c9a35728ce3e3aa) intl test (Daniel Hensby)

View File

@ -102,6 +102,29 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
return $dataListClone;
}
/**
* @param string $class
* @param string $column
* @return string
*/
protected function columnToFilterField($class, $column)
{
if (strpos($column, '.') === false) {
return $column;
}
/** @var DataObject $model */
$model = singleton($class);
$columnParts = explode('.', $column);
if ($model->getRelationClass($columnParts[0])) {
return $column;
}
return $columnParts[0];
}
/**
* @param GridField $gridField
* @return array
*/
public function getHTMLFragments($gridField) {
if(!$this->checkDataType($gridField->getList())) return;
@ -110,18 +133,21 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
$columns = $gridField->getColumns();
$filterArguments = $gridField->State->GridFieldFilterHeader->Columns->toArray();
$currentColumn = 0;
foreach($columns as $columnField) {
$currentColumn++;
++$currentColumn;
$metadata = $gridField->getColumnMetadata($columnField);
$title = $metadata['title'];
$fields = new FieldGroup();
if($title && $gridField->getList()->canFilterBy($columnField)) {
$filterField = $this->columnToFilterField($gridField->getModelClass(), $columnField);
if($title && $gridField->getList()->canFilterBy($filterField)) {
$value = '';
if(isset($filterArguments[$columnField])) {
$value = $filterArguments[$columnField];
if(isset($filterArguments[$filterField])) {
$value = $filterArguments[$filterField];
}
$field = new TextField('filter[' . $gridField->getName() . '][' . $columnField . ']', '', $value);
$field = new TextField('filter[' . $gridField->getName() . '][' . $filterField . ']', '', $value);
$field->addExtraClass('ss-gridfield-sort');
$field->addExtraClass('no-change-track');
@ -133,7 +159,7 @@ class GridFieldFilterHeader implements GridField_HTMLProvider, GridField_DataMan
GridField_FormAction::create($gridField, 'reset', false, 'reset', null)
->addExtraClass('ss-gridfield-button-reset')
->setAttribute('title', _t('GridField.ResetFilter', "Reset"))
->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)
->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $filterField)
);
}

View File

@ -339,10 +339,11 @@ class Image extends File implements Flushable {
*
* @param integer $width The width to size to
* @param integer $height The height to size to
* @param string $backgroundColor The background colour to use on padded sides (default white)
* @param integer $transparencyPercent Level of transparency
* @return Image|null
*/
public function Pad($width, $height, $backgroundColor='FFFFFF', $transparencyPercent = 0) {
public function Pad($width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent = 0) {
return $this->isSize($width, $height) && !Config::inst()->get('Image', 'force_resample')
? $this
: $this->getFormattedImage('Pad', $width, $height, $backgroundColor, $transparencyPercent);
@ -354,12 +355,16 @@ class Image extends File implements Flushable {
* @param Image_Backend $backend
* @param integer $width The width to size to
* @param integer $height The height to size to
* @param string $backgroundColor The background colour to use on padded sides (default white)
* @param integer $transparencyPercent Level of transparency
* @return Image_Backend
* @deprecated 4.0 Generate methods are no longer applicable
*/
public function generatePad(Image_Backend $backend, $width, $height, $backgroundColor='FFFFFF') {
public function generatePad(Image_Backend $backend, $width, $height, $backgroundColor = 'FFFFFF',
$transparencyPercent = 0
) {
Deprecation::notice('4.0', 'Generate methods are no longer applicable');
return $backend->paddedResize($width, $height, $backgroundColor);
return $backend->paddedResize($width, $height, $backgroundColor, $transparencyPercent);
}
/**

View File

@ -0,0 +1,32 @@
<?php
class GridFieldFilterHeaderTest extends SapphireTest {
protected $extraDataObjects = array(
'GridFieldFilterHeaderTest_DataObject',
);
public function testColumnToFilterField() {
$class = 'GridFieldFilterHeaderTest_DataObject';
$header = new GridFieldFilterHeader();
$method = new ReflectionMethod($header, 'columnToFilterField');
$method->setAccessible(true);
$this->assertEquals('Title', $method->invoke($header, $class,'Title.ATT'));
$this->assertEquals('isTest', $method->invoke($header, $class, 'isTest.Nice'));
$this->assertEquals('Self.isTest.Nice', $method->invoke($header, $class, 'Self.isTest.Nice'));
}
}
class GridFieldFilterHeaderTest_DataObject extends DataObject implements TestOnly {
private static $db = array(
'Title' => 'Varchar',
'isTest' => 'Boolean',
);
private static $has_one = array(
'Self' => 'GridFieldFilterHeaderTest_DataObject',
);
}