Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into deprecation_fixes

  • Loading branch information...
2 parents aca2b2f + e307594 commit 0d8151fd3d0618ca3a15faabf80580b4465c3aa7 @halkyon halkyon committed Mar 9, 2012
Showing with 214 additions and 281 deletions.
  1. +1 −1 admin/code/ModelAdmin.php
  2. +2 −2 admin/code/SecurityAdmin.php
  3. +2 −2 admin/tests/SecurityAdminTest.php
  4. +16 −13 control/Director.php
  5. +20 −20 docs/en/topics/grid-field.md
  6. +2 −2 forms/HtmlEditorField.php
  7. +2 −2 forms/UploadField.php
  8. +1 −1 forms/gridfield/GridField.php
  9. +4 −4 forms/gridfield/{GridFieldRelationAdd.php → GridFieldAddExistingAutocompleter.php}
  10. +1 −1 forms/gridfield/GridFieldComponent.php
  11. +16 −16 forms/gridfield/GridFieldConfig.php
  12. +1 −1 forms/gridfield/{GridFieldDefaultColumns.php → GridFieldDataColumns.php}
  13. +41 −22 forms/gridfield/GridFieldDeleteAction.php
  14. +3 −3 forms/gridfield/{GridFieldPopupForms.php → GridFieldDetailForm.php}
  15. +3 −3 forms/gridfield/{GridFieldEditAction.php → GridFieldEditButton.php}
  16. +1 −1 forms/gridfield/{GridFieldExporter.php → GridFieldExportButton.php}
  17. +6 −6 forms/gridfield/{GridFieldFilter.php → GridFieldFilterHeader.php}
  18. +0 −106 forms/gridfield/GridFieldRelationDelete.php
  19. +2 −2 forms/gridfield/{GridFieldTitle.php → GridFieldToolbarHeader.php}
  20. +2 −2 model/MySQLDatabase.php
  21. +4 −4 security/Group.php
  22. 0 templates/{GridFieldPopupForms.ss → GridFieldDetailForm.ss}
  23. 0 templates/Includes/{GridFieldRelationAdd.ss → GridFieldAddExistingAutocompleter.ss}
  24. 0 templates/Includes/{GridFieldEditAction.ss → GridFieldEditButton.ss}
  25. 0 templates/Includes/{GridFieldFilter_Row.ss → GridFieldFilterHeader_Row.ss}
  26. 0 templates/Includes/{GridFieldTitle.ss → GridFieldToolbarHeader.ss}
  27. +6 −6 tests/forms/GridFieldTest.php
  28. +9 −9 tests/forms/gridfield/{GridFieldRelationAddTest.php → GridFieldAddExistingAutocompleterTest.php}
  29. +17 −0 tests/forms/gridfield/GridFieldDeleteActionTest.php
  30. +29 −29 tests/forms/gridfield/{GridFieldPopupFormsTest.php → GridFieldDetailFormTest.php}
  31. +17 −0 tests/forms/gridfield/GridFieldDetailFormTest.yml
  32. +2 −2 tests/forms/gridfield/{GridFieldEditActionTest.php → GridFieldEditButtonTest.php}
  33. +0 −17 tests/forms/gridfield/GridFieldPopupFormsTest.yml
  34. +4 −4 tests/forms/gridfield/{GridFieldTitleTest.php → GridFieldToolbarHeaderTest.php}
@@ -710,7 +710,7 @@ function getResultsTable($searchCriteria) {
false,
$datalist,
$fieldConfig = GridFieldConfig_RecordEditor::create($numItemsPerPage)
- ->addComponent(new GridFieldExporter())->removeComponentsByType('GridFieldFilter')
+ ->addComponent(new GridFieldExportButton())->removeComponentsByType('GridFieldFilterHeader')
)->setDisplayFields($this->getResultColumns($searchCriteria));
return $tf;
@@ -48,9 +48,9 @@ public function getEditForm($id = null, $fields = null) {
false,
DataList::create('Member'),
$memberListConfig = GridFieldConfig_RecordEditor::create()
- ->addComponent(new GridFieldExporter())
+ ->addComponent(new GridFieldExportButton())
)->addExtraClass("members_grid");
- $memberListConfig->getComponentByType('GridFieldPopupForms')->setValidator(new Member_Validator());
+ $memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$groupList = Object::create('GridField',
'Groups',
@@ -9,7 +9,7 @@ class SecurityAdminTest extends FunctionalTest {
protected $extraDataObjects = array('LeftAndMainTest_Object');
- // TODO Fix export feature (moved from MemberTableField to GridFieldExporter)
+ // TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// function testGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
@@ -27,7 +27,7 @@ class SecurityAdminTest extends FunctionalTest {
// $this->assertRegExp('/"","","admin@example.com"/', $lines[1], "Member values are correctly exported");
// }
- // TODO Fix export feature (moved from MemberTableField to GridFieldExporter)
+ // TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// function testEmptyGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
View
@@ -802,19 +802,31 @@ static function isLive() {
/**
* This function will return true if the site is in a development environment.
* For information about environment types, see {@link Director::set_environment_type()}.
+ * @param $dontTouchDB If true, the database checks are not performed, which allows certain DB checks
+ * to not fail before the DB is ready. If false (default), DB checks are included.
*/
- static function isDev() {
+ static function isDev($dontTouchDB = false) {
// This variable is used to supress repetitions of the isDev security message below.
static $firstTimeCheckingGetVar = true;
+
+ $result = false;
+
+ if(isset($_SESSION['isDev']) && $_SESSION['isDev']) $result = true;
+ if(self::$environment_type && self::$environment_type == 'dev') $result = true;
+
+ if(!empty(Director::$dev_servers)) {
+ Deprecation::notice('3.0', 'Director::$dev_servers doesn\'t work anymore');
+ }
// Use ?isDev=1 to get development access on the live server
- if(isset($_GET['isDev'])) {
+ if(!$dontTouchDB && !$result && isset($_GET['isDev'])) {
if(Security::database_is_ready()) {
if($firstTimeCheckingGetVar && !Permission::check('ADMIN')){
BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN");
}
$_SESSION['isDev'] = $_GET['isDev'];
- if($firstTimeCheckingGetVar) $firstTimeCheckingGetVar = false;
+ $firstTimeCheckingGetVar = false;
+ $result = $_GET['isDev'];
} else {
if($firstTimeCheckingGetVar && DB::connection_attempted()) {
echo "<p style=\"padding: 3px; margin: 3px; background-color: orange;
@@ -826,16 +838,7 @@ static function isDev() {
}
}
- if(isset($_SESSION['isDev']) && $_SESSION['isDev']) return true;
-
- if(self::$environment_type) return self::$environment_type == 'dev';
-
- // Check if we are running on one of the development servers
- if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
- return true;
- }
-
- return false;
+ return $result;
}
/**
@@ -30,9 +30,9 @@ This example creates exactly the same kind of grid as the previous example, but
:::php
$config = GridFieldConfig::create();
// Provide a header row with filter controls
- $config->addComponent(new GridFieldFilter());
+ $config->addComponent(new GridFieldFilterHeader());
// Provide a default set of columns based on $summary_fields
- $config->addComponent(new GridFieldDefaultColumns());
+ $config->addComponent(new GridFieldDataColumns());
// Provide a header row with sort controls
$config->addComponent(new GridFieldSortableHeader());
// Paginate results to 25 items per page, and show a footer with pagination controls
@@ -44,7 +44,7 @@ If we wanted to make a simpler grid without pagination or filtering, we could do
:::php
$config = GridFieldConfig::create();
// Provide a default set of columns based on $summary_fields
- $config->addComponent(new GridFieldDefaultColumns());
+ $config->addComponent(new GridFieldDataColumns());
// Provide a header row with sort controls
$config->addComponent(new GridFieldPaginator(25));
$field = new GridField("Members", "Members of this group", $this->group->Members(), $config);
@@ -57,11 +57,11 @@ A `GridFieldConfig` is made up of a new of `GridFieldComponent` objects, which a
`GridFieldComponent` is a family of interfaces.
SilverStripe Framework comes with the following components that you can use out of the box.
-### GridFieldDefaultColumns
+### GridFieldDataColumns
This is the one component that, in most cases, you must include. It provides the default columns, sourcing them from the underlying DataObject's `$summary_fields` if no specific configuration is provided.
-Without GridFieldDefaultColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons:
+Without GridFieldDataColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons:
* You may have a grid whose fields are generated purely by another non-standard component.
* It keeps the core of the GridField lean, focused solely on providing APIs to the components.
@@ -99,7 +99,7 @@ You can also specify formatting replacements, to replace column contents with HT
This component will add a header to the grid with sort buttons. It will detect which columns are sortable and only provide sort controls on those columns.
-### GridFieldFilter
+### GridFieldFilterHeader
This component will add a header row with a text field filter for each column, letting you filter the results with text searches. It will detect which columns are filterable and only provide sort controls on those columns.
@@ -109,34 +109,34 @@ This component will limit output to a fixed number of items per page add a foote
### GridFieldAction
-TODO Describe component, including GridFieldEditAction/GridFieldDeleteAction
+TODO Describe component, including GridFieldEditButton/GridFieldDeleteAction
-### GridFieldRelationAdd
+### GridFieldAddExistingAutocompleter
This class is is responsible for adding objects to another object's has_many and many_many relation,
as defined by the `[api:RelationList]` passed to the GridField constructor.
Objects can be searched through an input field (partially matching one or more fields).
Selecting from the results will add the object to the relation.
-Often used alongside `[api:GridFieldRelationDelete]` for detaching existing records from a relatinship.
+Often used alongside `[api:GridFieldRemoveButton]` for detaching existing records from a relatinship.
For easier setup, have a look at a sample configuration in `[api:GridFieldConfig_RelationEditor]`.
-### GridFieldRelationDelete
+### GridFieldRemoveButton
Allows to detach an item from an existing has_many or many_many relationship.
Similar to {@link GridFieldDeleteAction}, but allows to distinguish between
a "delete" and "detach" action in the UI - and to use both in parallel, if required.
Requires the GridField to be populated with a `[api:RelationList]` rather than a plain DataList.
-Often used alongside `[api:GridFieldRelationAdd]` to add existing records to the relationship.
+Often used alongside `[api:GridFieldAddExistingAutocompleter]` to add existing records to the relationship.
-### GridFieldPopupForms
+### GridFieldDetailForm
-TODO Describe component, including how it relates to GridFieldEditAction. Point to GridFieldConfig_RelationEditor for easier defaults.
+TODO Describe component, including how it relates to GridFieldEditButton. Point to GridFieldConfig_RelationEditor for easier defaults.
-### GridFieldTitle
+### GridFieldToolbarHeader
TODO
-### GridFieldExporter
+### GridFieldExportButton
TODO
@@ -152,16 +152,16 @@ It's common for a component to implement several of these interfaces in order to
* `GridField_ActionProvider`, to define the sortasc and sortdesc actions that add sort column and direction to the state.
* `GridField_DataManipulator`, to alter the sorting of the data list based on the sort column and direction values in the state.
- ### GridFieldRelationAdd
+ ### GridFieldAddExistingAutocompleter
-A GridFieldRelationAdd is responsible for adding objects to another object's `has_many` and `many_many` relation,
+A GridFieldAddExistingAutocompleter is responsible for adding objects to another object's `has_many` and `many_many` relation,
as defined by the `[api:RelationList]` passed to the GridField constructor.
Objects can be searched through an input field (partially matching one or more fields).
Selecting from the results will add the object to the relation.
:::php
$group = DataObject::get_one('Group');
- $config = GridFieldConfig::create()->addComponent(new GridFieldRelationAdd(array('FirstName', 'Surname', 'Email'));
+ $config = GridFieldConfig::create()->addComponent(new GridFieldAddExistingAutocompleter(array('FirstName', 'Surname', 'Email'));
$gridField = new GridField('Members', 'Members', $group->Members(), $config);
## Component interfaces
@@ -233,7 +233,7 @@ By default, a grid contains no columns. All the columns displayed in a grid wil
For example, you may create a grid field with several components providing columns:
- * `GridFieldDefaultColumns` could provide basic data columns.
+ * `GridFieldDataColumns` could provide basic data columns.
* An editor component could provide a column containing action buttons on the right.
* A multiselect component clould provide a column showing a checkbox on the left.
@@ -293,7 +293,7 @@ Here is an example in full. The actual implementation of the view and edit form
* - <FormURL>/field/<GridFieldName>/item/<RecordID>
* - <FormURL>/field/<GridFieldName>/item/<RecordID>/edit
*/
- class GridFieldPopupForms implements GridField_URLHandler {
+ class GridFieldDetailForm implements GridField_URLHandler {
public function getURLHandlers($gridField) {
return array(
'item/$ID' => 'handleItem',
@@ -355,8 +355,8 @@ function MediaForm() {
$fileFieldConfig = GridFieldConfig::create();
$fileFieldConfig->addComponent(new GridFieldSortableHeader());
- $fileFieldConfig->addComponent(new GridFieldFilter());
- $fileFieldConfig->addComponent(new GridFieldDefaultColumns());
+ $fileFieldConfig->addComponent(new GridFieldFilterHeader());
+ $fileFieldConfig->addComponent(new GridFieldDataColumns());
$fileFieldConfig->addComponent(new GridFieldPaginator(5));
$fileField = new GridField('Files', false, null, $fileFieldConfig);
$fileField->setList($this->getFiles($parentID));
View
@@ -846,8 +846,8 @@ protected function getListField() {
$folder = $this->getFolder();
$config = GridFieldConfig::create();
$config->addComponent(new GridFieldSortableHeader());
- $config->addComponent(new GridFieldFilter());
- $config->addComponent(new GridFieldDefaultColumns());
+ $config->addComponent(new GridFieldFilterHeader());
+ $config->addComponent(new GridFieldDataColumns());
$config->addComponent(new GridFieldPaginator(10));
$field = new GridField('Files', false, $folder->stageChildren(), $config);
@@ -404,7 +404,7 @@ public function FieldHolder() {
array(
"class" => implode(' ', $classes),
'data-id' => $record->ID,
- // TODO Allow per-row customization similar to GridFieldDefaultColumns
+ // TODO Allow per-row customization similar to GridFieldDataColumns
'data-class' => $record->ClassName,
),
$rowContent
@@ -4,17 +4,17 @@
* as defined by the {@link RelationList} passed to the GridField constructor.
* Objects can be searched through an input field (partially matching one or more fields).
* Selecting from the results will add the object to the relation.
- * Often used alongside {@link GridFieldRelationDelete} for detaching existing records from a relatinship.
+ * Often used alongside {@link GridFieldRemoveButton} for detaching existing records from a relatinship.
* For easier setup, have a look at a sample configuration in {@link GridFieldConfig_RelationEditor}.
*/
-class GridFieldRelationAdd implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator, GridField_URLHandler {
+class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator, GridField_URLHandler {
/**
* Which template to use for rendering
*
* @var string $itemClass
*/
- protected $itemClass = 'GridFieldRelationAdd';
+ protected $itemClass = 'GridFieldAddExistingAutocompleter';
/**
* Which columns that should be used for doing a "StartsWith" search.
@@ -161,7 +161,7 @@ public function doSearch($gridField, $request) {
$searchFields = ($this->getSearchFields()) ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
if(!$searchFields) {
throw new LogicException(
- sprintf('GridFieldRelationAdd: No searchable fields could be found for class "%s"', $dataClass)
+ sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass)
);
}
@@ -36,7 +36,7 @@ function getHTMLFragments($gridField);
/**
* Modify the list of columns displayed in the table.
- * See {@link GridField->getDisplayFields()} and {@link GridFieldDefaultColumns}.
+ * See {@link GridField->getDisplayFields()} and {@link GridFieldDataColumns}.
*
* @param GridField
* @param Array List reference of all column names.
@@ -131,10 +131,10 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
+ $this->addComponent(new GridFieldToolbarHeader());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
- $this->addComponent(new GridFieldDefaultColumns());
+ $this->addComponent(new GridFieldFilterHeader());
+ $this->addComponent(new GridFieldDataColumns());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
}
}
@@ -158,14 +158,14 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
+ $this->addComponent(new GridFieldToolbarHeader());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
- $this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldEditAction());
+ $this->addComponent(new GridFieldFilterHeader());
+ $this->addComponent(new GridFieldDataColumns());
+ $this->addComponent(new GridFieldEditButton());
$this->addComponent(new GridFieldDeleteAction());
$this->addComponent(new GridFieldPaginator($itemsPerPage));
- $this->addComponent(new GridFieldPopupForms());
+ $this->addComponent(new GridFieldDetailForm());
}
}
@@ -181,7 +181,7 @@ public function __construct($itemsPerPage=null) {
* for example to change the field to search.
* <code>
* GridFieldConfig_RelationEditor::create()
- * ->getComponentByType('GridFieldRelationAdd')->setSearchFields('MyField');
+ * ->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields('MyField');
* </code>
*/
class GridFieldConfig_RelationEditor extends GridFieldConfig {
@@ -200,14 +200,14 @@ public static function create($itemsPerPage=null){
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
- $this->addComponent(new GridFieldTitle());
- $this->addComponent(new GridFieldRelationAdd());
+ $this->addComponent(new GridFieldToolbarHeader());
+ $this->addComponent(new GridFieldAddExistingAutocompleter());
$this->addComponent(new GridFieldSortableHeader());
- $this->addComponent(new GridFieldFilter());
- $this->addComponent(new GridFieldDefaultColumns());
- $this->addComponent(new GridFieldEditAction());
- $this->addComponent(new GridFieldRelationDelete());
+ $this->addComponent(new GridFieldFilterHeader());
+ $this->addComponent(new GridFieldDataColumns());
+ $this->addComponent(new GridFieldEditButton());
+ $this->addComponent(new GridFieldDeleteAction(true));
$this->addComponent(new GridFieldPaginator($itemsPerPage));
- $this->addComponent(new GridFieldPopupForms());
+ $this->addComponent(new GridFieldDetailForm());
}
}
@@ -6,7 +6,7 @@
* @package sapphire
* @subpackage fields-relational
*/
-class GridFieldDefaultColumns implements GridField_ColumnProvider {
+class GridFieldDataColumns implements GridField_ColumnProvider {
public function augmentColumns($gridField, &$columns) {
$baseColumns = array_keys($gridField->getDisplayFields());
Oops, something went wrong.

0 comments on commit 0d8151f

Please sign in to comment.