Skip to content

Commit

Permalink
Merge branch 'master' into 1.0
Browse files Browse the repository at this point in the history
* master:
  revert rendering of Block back to using Block DataObject. Fixes #66
  Remove trailing spaces in the source code
  Adding default Scrutinizer config for CI
  Fixing composer.json
  Adding default Travis config for testing
  Block Type Filter
  • Loading branch information
sheadawson committed Feb 28, 2016
2 parents 817e1a7 + ac94d53 commit c14e98d
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
inherit: true

checks:
php:
code_rating: true
duplication: true

filter:
paths: [code/*, tests/*]
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details

sudo: false

language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0

env:
- DB=MYSQL CORE_RELEASE=3.2

matrix:
include:
- php: 5.6
env: DB=MYSQL CORE_RELEASE=3
- php: 5.6
env: DB=MYSQL CORE_RELEASE=3.1
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3.2
allow_failures:
- php: 7.0

before_script:
- composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
- composer install

script:
- vendor/bin/phpunit silverstripe-blocks/tests
14 changes: 14 additions & 0 deletions code/controllers/BlockAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,18 @@ public function getEditForm($id = null, $fields = null)

return $form;
}

public function getSearchContext()
{
$context = parent::getSearchContext();
$fields = $context->getFields();
$subclasses = $this->blockManager->getBlockClasses();
if (sizeof($subclasses) > 1) {
$fields->dataFieldByName('q[ClassName]')->setSource($subclasses);
$fields->dataFieldByName('q[ClassName]')->setEmptyString('(any)');
} else {
$fields->removeByName('q[ClassName]');
}
return $context;
}
}
28 changes: 24 additions & 4 deletions code/dataobjects/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ class Block extends DataObject implements PermissionProvider
'UsageListAsString' => 'Used on',
);

private static $searchable_fields = array(
'Title' => array(
'title' => 'Title'
),
'ClassName' => array(
'title' => 'Block Type'
)
);

public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$results = $this->blockManager->getBlockClasses();
if (sizeof($results) > 1) {
$classfield = new DropdownField('ClassName', 'Block Type');
$classfield->setSource($results);
$classfield->setEmptyString('(any)');
$context->addField($classfield);
}
return $context;
}

/**
* @var array
*/
Expand Down Expand Up @@ -176,17 +198,15 @@ public function validate()
**/
public function forTemplate()
{
$controller = $this->getController();

if ($this->BlockArea) {
$template = array($this->class.'_'.$this->BlockArea);

if (SSViewer::hasTemplate($template)) {
return $controller->renderWith($template);
return $this->renderWith($template);
}
}

return $controller->renderWith($this->ClassName);
return $this->renderWith($this->ClassName);
}

/**
Expand Down
58 changes: 30 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
{
"name": "sheadawson/silverstripe-blocks",
"description": "An alternative to the SilverStripe Widgets module.",
"type": "silverstripe-module",
"keywords": ["silverstripe", "blocks", "widgets"],
"homepage": "http://github.com/sheadawson/silverstripe-blocks",
"authors": [
{
"name": "Shea Dawson",
"email": "shea@silverstripe.com.au"
}
],

"require":
{
"composer/installers": "*",
"silverstripe/framework": "~3.1",
"silverstripe/cms": "~3.1",
"silverstripe-australia/gridfieldextensions": "~1.0",
"silverstripe/multivaluefield": "~2.0",
"unclecheese/betterbuttons": "~1.2"
},
"suggest": {
"unisolutions/silverstripe-copybutton": "Duplicate Blocks in Block Admin",
"micschk/silverstripe-gridfieldsitetreebuttons": "Edit pages directly from a Block's 'used on page' list"
"name": "sheadawson/silverstripe-blocks",
"description": "An alternative to the SilverStripe Widgets module.",
"type": "silverstripe-module",
"keywords": [
"silverstripe",
"blocks",
"widgets"
],
"homepage": "http://github.com/sheadawson/silverstripe-blocks",
"authors": [
{
"name": "Shea Dawson",
"email": "shea@silverstripe.com.au"
}
],
"require": {
"composer/installers": "*",
"silverstripe/framework": "~3.1",
"silverstripe/cms": "~3.1",
"silverstripe-australia/gridfieldextensions": "~1.0",
"silverstripe/multivaluefield": "~2.0",
"unclecheese/betterbuttons": "~1.2"
},
"extra": {
"installer-name": "blocks"
}
}
"suggest": {
"unisolutions/silverstripe-copybutton": "Duplicate Blocks in Block Admin",
"micschk/silverstripe-gridfieldsitetreebuttons": "Edit pages directly from a Block's 'used on page' list"
},
"extra": {
"installer-name": "blocks"
}
}
2 changes: 1 addition & 1 deletion javascript/block-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
self.append('<div class="block_preview_overlay"></div><div class="block_preview_label">' + label + '</div>');
});
});

}(jQuery));

0 comments on commit c14e98d

Please sign in to comment.