\ModelAdmin
Generates a three-pane UI for editing model classes, with an automatically generated search panel, tabular results and edit forms.
Relies on data such as and to scaffold interfaces "out of the box", while at the same time providing
flexibility to customize the default output.
Add a route (note - this doc is not currently in sync with the code, need to update)
<code>
Director::addRules(50, array('admin/mymodel/$Class/$Action/$ID' => 'MyModelAdmin'));
</code>
Synopsis
class ModelAdmin
extends LeftAndMain
{
- // members
- public static string $url_rule = '/$Action';
- public static array|string $managed_models = NULL;
- public static array $allowed_actions = ;
- public static string $collection_controller_class = "ModelAdmin_CollectionController";
- public static string $record_controller_class = "ModelAdmin_RecordController";
- public static array $url_handlers = ;
- private boolean $currentModel = false;
- public boolean $showImportForm = true;
- public static $model_importers = NULL;
- public static integer $page_length = 30;
- protected string $resultsTableClassName = 'TableListField';
- // Inherited members from LeftAndMain
- public static string $url_base;
- public static $url_segment;
- public static string $url_rule;
- public static $menu_title;
- public static integer $menu_priority;
- public static integer $url_priority;
- public static $tree_class;
- public static $ForceReload;
- public static string $help_link;
- public static array $allowed_actions;
- protected static array $extra_requirements;
- public static String $application_name;
- public static String $application_logo_text;
- public static string $application_link;
- public static unknown_type $application_logo;
- public static String $application_logo_style;
- protected static string $loading_image;
- // methods
- public void resultsTableClassName()
- public void init()
- public static void set_page_length()
- public static void get_page_length()
- public string getCollectionControllerClass()
- public string getRecordControllerClass()
- public void defineMethods()
- public void bindModelController()
- public String: SearchClassSelector()
- protected DataObjectSet getModelForms()
- public array getManagedModels()
- public array getModelImporters()
- // Inherited methods from LeftAndMain
- public boolean canView()
- public void init()
- public void handleRequest()
- public boolean ShowSwitchView()
- public string Link()
- public static void menu_title_for_class()
- public void show()
- public void getitem()
- public void getLastFormIn()
- public DataObjectSet MainMenu()
- public void CMSTopMenu()
- protected void getTemplatesWithSuffix()
- public void Left()
- public void Right()
- public void getRecord()
- public void getSiteTreeFor()
- public void getsubtree()
- public void returnItemToUser()
- public void save()
- public string getActionUpdateJS()
- public string addTreeNodeJS()
- public string deleteTreeNodeJS()
- public static void ForceReload()
- public void ajaxupdateparent()
- public void ajaxupdatesort()
- public void CanOrganiseSitetree()
- public void deleteitems()
- public Form EmptyForm()
- public void EditForm()
- public void myprofile()
- public void Member_ProfileForm()
- public void printable()
- public void currentPageID()
- public void setCurrentPageID()
- public void currentPage()
- public void isCurrentPage()
- public void EditorToolbar()
- public string CMSVersion()
- public array SwitchView()
- public static void setApplicationName()
- public String getApplicationName()
- public String getApplicationLogoText()
- public void ApplicationLink()
- public void SectionTitle()
- public static void setLogo()
- public static void set_loading_image()
- public void LoadingImage()
- public void LogoStyle()
- public void MceRoot()
- public void callPageMethod()
- public static void require_javascript()
- public static void require_css()
- public static void require_themed_css()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
31+ | saving logic (should mostly use Form->saveInto() and iterate over relations) |
31+ | ajax form loading and saving |
31+ | ajax result display |
31+ | relation formfield scaffolding (one tab per relation) - relations don't have DBField sublclasses, we do we define the scaffold defaults. can be ComplexTableField instances for a start. |
31+ | has_many/many_many relation autocomplete field (HasManyComplexTableField doesn't work well with larger datasets) Long term TODOs: |
31+ | Hook into RESTful interface on DataObjects (yet to be developed) |
31+ | Permission control via datamodel and Form class |
142+ | remove reliance on urlParams |
Members
private
- $currentModel
—
string
Model object currently in manipulation queue. Used for updating Link to point to the correct generic data object in generated URLs.
protected
- $extra_requirements
—
array
Register additional requirements through the {@link Requirements class}. - $loading_image
-
$resultsTableClassName
Class name of the form field used for the results list. Overloading this in subclasses can let you customise the results table field.
public
- $ForceReload
-
$allowed_actions
More actions are dynamically added in {@link defineMethods()} below. - $allowed_actions
-
$application_link
Set the application name, and the logo text. - $application_logo
—
unknown_type
The application logo path. Customisable by calling LeftAndMain::setLogo() - the first parameter. - $application_logo_style
—
String
The application logo style. Customisable by calling LeftAndMain::setLogo() - the second parameter. - $application_logo_text
—
String
The application logo text. Customisable by calling LeftAndMain::setApplicationName() - the second parameter. - $application_name
—
String
The application name. Customisable by calling LeftAndMain::setApplicationName() - the first parameter. - $collection_controller_class
-
$help_link
The url used for the link in the Help tab in the backend Value can be overwritten if required in _config.php - $managed_models
—
array|string
List of all managed {@link DataObject}s in this interface. - $model_importers
—
array
List of all {@link DataObject}s which can be imported through a subclass of {@link BulkLoader} (mostly CSV data). - $page_length
—
int
Amount of results showing on a single page. - $record_controller_class
-
$showImportForm
Change this variable if you don't want the Import from CSV form to appear. - $tree_class
- $url_base
—
string
The 'base' url for CMS administration areas. -
$url_handlers
Forward control to the default action handler - $url_priority
- $url_rule
- $url_rule
- $url_segment
Methods
protected
- getModelForms() — Returns managed models' create, search, and import forms
public
- SearchClassSelector() — This method can be overloaded to specify the UI by which the search class is chosen.
- bindModelController() — Base scaffolding method for returning a generic model instance.
- defineMethods() — Add mappings for generic form constructors to automatically delegate to a scaffolded form object.
- getCollectionControllerClass() — Return the class name of the collection controller
- getManagedModels()
- getModelImporters() — Returns all importers defined in {@link self::$model_importers}.
- getRecordControllerClass() — Return the class name of the record controller
- get_page_length() — Return the static page_length of the admin, default as 30
- init() — Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins.
- resultsTableClassName() — Return {@link $this->resultsTableClassName}
- set_page_length() — overwrite the static page_length of the admin panel, should be called in the project _config file.
Inherited from LeftAndMain
protected
- getTemplatesWithSuffix() — Return a list of appropriate templates for this class, with the given suffix
public
- ApplicationLink()
- CMSTopMenu()
- CMSVersion() — Return the version number of this application.
- CanOrganiseSitetree()
- EditForm()
- EditorToolbar() — Return the CMS's HTML-editor toolbar
- EmptyForm() — Returns a placeholder form, used by {@link getEditForm()} if no record is selected.
- ForceReload() — Sets a static variable on this class which means the panel will be reloaded.
- Left()
- Link() — You should implement a Link() function in your subclass of LeftAndMain, to point to the URL of that particular controller.
- LoadingImage()
- LogoStyle()
- MainMenu() — Returns the main menu of the CMS. This is also used by init() to work out which sections the user has access to.
- MceRoot() — Return the base directory of the tiny_mce codebase
- Member_ProfileForm()
- Right()
- SectionTitle() — Return the title of the current section, as shown on the main menu
- ShowSwitchView() — If this is set to true, the "switchView" context in the template is shown, with links to the staging and publish site.
- SwitchView()
- addTreeNodeJS() — Returns a javascript snippet to generate a tree node for the given page, if visible
- ajaxupdateparent() — Ajax handler for updating the parent of a tree node
- ajaxupdatesort() — Ajax handler for updating the order of a number of tree nodes $_GET[ID]: An array of node ids in the correct order $_GET[MovedNodeID]: The node that actually got moved
- callPageMethod() — Use this as an action handler for custom CMS buttons.
- canView()
- currentPage()
- currentPageID()
- deleteTreeNodeJS() — Returns a javascript snippet to remove a tree node for the given page, if it exists.
- deleteitems() — Delete a number of items
- getActionUpdateJS() — Returns a javascript snippet that will update the actions of the main form
- getApplicationLogoText() — Get the application logo text.
- getApplicationName() — Get the application name.
- getLastFormIn()
- getRecord()
- getSiteTreeFor() — Get a site tree displaying the nodes under the given objects
- getitem()
- getsubtree() — Get a subtree underneath the request param 'ID'.
- handleRequest()
- init()
- isCurrentPage()
- myprofile()
- printable()
- require_css() — Register the given stylesheet file as required.
- require_javascript() — Register the given javascript file as required in the CMS.
- require_themed_css() — Register the given "themeable stylesheet" as required.
- returnItemToUser() — Allows you to returns a new data object to the tree (subclass of sitetree) and updates the tree via javascript.
- save() — Save and Publish page handler
- setApplicationName()
- setCurrentPageID()
- setLogo() — Set the CMS application logo.
- set_loading_image() — Set the image shown when the CMS is loading.
- show()