Permalink
Browse files

Merge remote-tracking branch 'origin/3.1'

Conflicts:
.travis.yml
  • Loading branch information...
2 parents 61ebe08 + 1f4d9e4 commit b3699281c076f1452ec5da5f312f70e56795b909 @tractorcow tractorcow committed May 5, 2014
View
@@ -26,6 +26,9 @@ matrix:
env: DB=MYSQL CORE_RELEASE=master
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
+ allow_failures:
+ - php: 5.6
+ env: DB=MYSQL CORE_RELEASE=master
before_script:
- composer self-update
@@ -38,7 +41,7 @@ before_script:
- php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST
script:
- - "if [ \"$BEHAT_TEST\" = \"\" ]; then phpunit cms/tests; fi"
+ - "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit cms/tests; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @cms; fi"
after_failure:
@@ -17,6 +17,14 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
private static $tree_class = 'Folder';
/**
+ * Amount of results showing on a single page.
+ *
+ * @config
+ * @var int
+ */
+ private static $page_length = 15;
+
+ /**
* @config
* @see Upload->allowedMaxFileSize
* @var int
@@ -98,17 +106,19 @@ public function getList() {
// Don't filter list when a detail view is requested,
// to avoid edge cases where the filtered list wouldn't contain the requested
// record due to faulty session state (current folder not always encoded in URL, see #7408).
- if(!$folder->ID && $this->request->requestVar('ID') === null && ($this->request->param('ID') == 'field')) {
+ if(!$folder->ID
+ && $this->request->requestVar('ID') === null
+ && ($this->request->param('ID') == 'field')
+ ) {
return $list;
}
// Re-add previously removed "Name" filter as combined filter
// TODO Replace with composite SearchFilter once that API exists
- if(isset($params['Name'])) {
- $list = $list->where(sprintf(
- '"Name" LIKE \'%%%s%%\' OR "Title" LIKE \'%%%s%%\'',
- Convert::raw2sql($params['Name']),
- Convert::raw2sql($params['Name'])
+ if(!empty($params['Name'])) {
+ $list = $list->filterAny(array(
+ 'Name:PartialMatch' => $params['Name'],
+ 'Title:PartialMatch' => $params['Name']
));
}
@@ -117,23 +127,26 @@ public function getList() {
// If a search is conducted, check for the "current folder" limitation.
// Otherwise limit by the current folder as denoted by the URL.
- if(!$params || @$params['CurrentFolderOnly']) {
+ if(empty($params) || !empty($params['CurrentFolderOnly'])) {
$list = $list->filter('ParentID', $folder->ID);
}
// Category filter
- if(isset($params['AppCategory'])) {
- if(isset(File::config()->app_categories[$params['AppCategory']])) {
- $exts = File::config()->app_categories[$params['AppCategory']];
- } else {
- $exts = array();
- }
- $categorySQLs = array();
- foreach($exts as $ext) $categorySQLs[] = '"File"."Name" LIKE \'%.' . $ext . '\'';
- // TODO Use DataList->filterAny() once OR connectives are implemented properly
- if (count($categorySQLs) > 0) {
- $list = $list->where('(' . implode(' OR ', $categorySQLs) . ')');
- }
+ if(!empty($params['AppCategory'])
+ && !empty(File::config()->app_categories[$params['AppCategory']])
+ ) {
+ $exts = File::config()->app_categories[$params['AppCategory']];
+ $list = $list->filter('Name:PartialMatch', $exts);
+ }
+
+ // Date filter
+ if(!empty($params['CreatedFrom'])) {
+ $fromDate = new DateField(null, null, $params['CreatedFrom']);
+ $list = $list->filter("Created:GreaterThanOrEqual", $fromDate->dataValue());
+ }
+ if(!empty($params['CreatedTo'])) {
+ $toDate = new DateField(null, null, $params['CreatedTo']);
+ $list = $list->filter("Created:LessThanOrEqual", $toDate->dataValue());
}
return $list;
@@ -150,9 +163,9 @@ public function getEditForm($id = null, $fields = null) {
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldToolbarHeader(),
new GridFieldSortableHeader(),
- new GridFieldFilterHeader(),
+ new GridFieldFilterHeader(),
new GridFieldDataColumns(),
- new GridFieldPaginator(15),
+ new GridFieldPaginator(self::config()->page_length),
new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldDetailForm(),
@@ -342,6 +355,21 @@ public function getSearchContext() {
foreach($context->getFilters() as $filter) $filter->setFullName(sprintf('q[%s]', $filter->getFullName()));
// Customize fields
+ $context->addField(
+ new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4)
+ );
+ $context->addField(
+ DateField::create(
+ 'q[CreatedFrom]',
+ _t('CMSSearch.FILTERDATEFROM', 'From')
+ )->setConfig('showcalendar', true)
+ );
+ $context->addField(
+ DateField::create(
+ 'q[CreatedTo]',
+ _t('CMSSearch.FILTERDATETO', 'To')
+ )->setConfig('showcalendar', true)
+ );
$appCategories = array(
'image' => _t('AssetAdmin.AppCategoryImage', 'Image'),
'audio' => _t('AssetAdmin.AppCategoryAudio', 'Audio'),
@@ -382,7 +410,7 @@ public function SearchForm() {
$fields = $context->getSearchFields();
$actions = new FieldList(
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))
- ->addExtraClass('ss-ui-action-constructive'),
+ ->addExtraClass('ss-ui-action-constructive'),
Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset'))
);
@@ -27,6 +27,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
private static $subitem_class = "Member";
+ /**
+ * Amount of results showing on a single page.
+ *
+ * @config
+ * @var int
+ */
+ private static $page_length = 15;
+
private static $allowed_actions = array(
'buildbrokenlinks',
'deleteitems',
@@ -726,7 +734,7 @@ public function ListViewForm() {
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
- new GridFieldPaginator(15)
+ new GridFieldPaginator(self::config()->page_length)
);
if($parentID){
$gridFieldConfig->addComponent(
Oops, something went wrong.

0 comments on commit b369928

Please sign in to comment.