MINOR Code formatting tidy up in ModelAdmin

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@71302 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-02-03 20:34:13 +00:00
parent fea613c19f
commit 06a007f394

View File

@ -210,12 +210,17 @@ abstract class ModelAdmin extends LeftAndMain {
*/ */
function getManagedModels() { function getManagedModels() {
$models = $this->stat('managed_models'); $models = $this->stat('managed_models');
if(is_string($models)) $models = array($models); if(is_string($models)) {
if(!count($models)) user_error('ModelAdmin::getManagedModels(): $models = array($models);
You need to specify at least one DataObject subclass in protected static $managed_models. }
Make sure the visibility of your property is set to "protected"', if(!count($models)) {
E_USER_ERROR user_error(
); 'ModelAdmin::getManagedModels():
You need to specify at least one DataObject subclass in protected static $managed_models.
Make sure the visibility of your property is set to "protected"',
E_USER_ERROR
);
}
return $models; return $models;
} }
@ -342,11 +347,10 @@ class ModelAdmin_CollectionController extends Controller {
public function CreateForm() { public function CreateForm() {
$modelName = $this->modelClass; $modelName = $this->modelClass;
if ($this->hasMethod('alternatePermissionCheck')) { if($this->hasMethod('alternatePermissionCheck')) {
if (!$this->alternatePermissionCheck()) return false; if(!$this->alternatePermissionCheck()) return false;
} } else {
else { if(!singleton($modelName)->canCreate(Member::currentUser())) return false;
if (!singleton($modelName)->canCreate(Member::currentUser())) return false;
} }
$buttonLabel = sprintf(_t('ModelAdmin.CREATEBUTTON', "Create '%s'", PR_MEDIUM, "Create a new instance from a model class"), singleton($modelName)->i18n_singular_name()); $buttonLabel = sprintf(_t('ModelAdmin.CREATEBUTTON', "Create '%s'", PR_MEDIUM, "Create a new instance from a model class"), singleton($modelName)->i18n_singular_name());
@ -354,6 +358,7 @@ class ModelAdmin_CollectionController extends Controller {
$actions = new FieldSet( $actions = new FieldSet(
$createButton = new FormAction('add', $buttonLabel) $createButton = new FormAction('add', $buttonLabel)
); );
$createButton->dontEscape = true; $createButton->dontEscape = true;
return new Form($this, "CreateForm", new FieldSet(), $actions); return new Form($this, "CreateForm", new FieldSet(), $actions);
@ -837,7 +842,7 @@ class ModelAdmin_RecordController extends Controller {
* @return mixed * @return mixed
*/ */
function view($request) { function view($request) {
if ($this->currentRecord) { if($this->currentRecord) {
$form = $this->ViewForm(); $form = $this->ViewForm();
return $form->forAjaxTemplate(); return $form->forAjaxTemplate();
} else { } else {