diff --git a/docs/en/04_Changelogs/beta/3.6.0-beta2.md b/docs/en/04_Changelogs/beta/3.6.0-beta2.md new file mode 100644 index 000000000..86ee3050b --- /dev/null +++ b/docs/en/04_Changelogs/beta/3.6.0-beta2.md @@ -0,0 +1,10 @@ +# 3.6.0-beta2 + + + +## 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) diff --git a/forms/gridfield/GridFieldFilterHeader.php b/forms/gridfield/GridFieldFilterHeader.php index f55157e4b..39d17aa0b 100755 --- a/forms/gridfield/GridFieldFilterHeader.php +++ b/forms/gridfield/GridFieldFilterHeader.php @@ -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) ); } diff --git a/model/Image.php b/model/Image.php index 57c6cca8b..cd7b87056 100644 --- a/model/Image.php +++ b/model/Image.php @@ -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); } /** diff --git a/tests/forms/gridfield/GridFieldFilterHeaderTest.php b/tests/forms/gridfield/GridFieldFilterHeaderTest.php new file mode 100644 index 000000000..fb47d1fe4 --- /dev/null +++ b/tests/forms/gridfield/GridFieldFilterHeaderTest.php @@ -0,0 +1,32 @@ +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', + ); + +}