SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class ManagedAdminController

This is a generic controller which all controllers which are managed in the admin area should extend.

Required fields for a managed controller table:
  id

Variables

NameVisibilityDescription
$action_log
Should this controller log add/edit/delete actions?
$add_defaults
Default values used for adding a record.
$controller_name
This is the name of the controller - should match the class name, but without the '_Controller' bit.
$duplicate_defaults
Default values used for duplicating a record.
$duplicate_enabled
Flag to turn duplication on or off
$export_modifiers
Modifiers applied to data prior to export
Should be a class which extends ColModifier
Can be an object instance or string of a class name
$friendly_name
This is the friendly name of the controller. In 99% of cases, should be the plural form of the controller name
$import_columns
The columns to allow import for
$import_duplicates
The default selection for the "duplicates" option
Values are "new", "merge", "merge_blank" and "skip".
$import_headings
If a client is providing CSVs which don't have headings
You'll need to provide them in this array
$import_id_column
Typically, we don't want to import the ID, and just let autoinc do it's thing
$main_actions
Actions for the itemlist
$main_add
Should a link be shown above the list for adding records? (default yes)
$main_columns
The columns to use for the main view
$main_delete
Is deletion allowed, with an option shown in the UI? (default: no)
$main_modes
Different modes available for the main view
By default, there is only one mode: list
$main_order
Order of main view records
$main_where
An additional where clause for the main view
$navigation_name
The friendly name used in the sidebar navigation. Defaults to matching the friendly name.
$per_subsite
Should a UI for editing the "subsite_id" field on a record be shown?
If enabled by extending classes, then the table should contain a 'subsite_id' INT UNSIGNED column
$records_per_page
The default number of records to show per page
$refine_bar
Defines the widgets for the refine bar
$table_name
This is the name of the table to get data from. Will be automatically deducted from the controller name if not specified

Functions

NameVisibilityDescription
__constructpublicConstructor. This must be called in the extending class.
_actionLogpublic 
_addPreRenderprotectedHook called by _getAddForm() just before the view is rendered
_addSavepublicProcess the saving of an add.
_deletePostSavepublicDoes custom actions after the _deleteSave method is called, e.g. clearing cache data
_deletePreSavepublicDoes custom actions before _deleteSave method is called, e.g. extra security checks
_deleteSavepublicDeletes an item and logs the deleted data
_duplicatePreRenderprotectedHook called by _getDuplicateForm() just before the view is rendered
_duplicateSavepublicProcess the saving of a duplication. Basic version just calls _editSave
_editPreRenderprotectedHook called by _getEditForm() just before the view is rendered
_editSavepublicProcess the saving of a record.
_exportDatapublicDoes the actual export. Return false on error.
_extraMultiDeletepublicForm to delete multiple records
_getAddFormpublicReturns a page title and HTML for a form to add a record
_getAddSubActionspublicReturn the sub-actions for adding a record (e.g. preview)
_getContentspublicReturn HTML which represents a list of records for this controller
_getContentsQueryprotectedReturns the SQL query for use by the contents list.
_getContentsViewpublicReturn HTML for a resultset of items
_getContentsViewListpublicFormats a resultset of items into an Itemlist
_getCustomAddSaveHTMLpublicOptional custom HTML for the save box
_getCustomDuplicateSaveHTMLpublicOptional custom HTML for the save box
_getCustomEditSaveHTMLpublicOptional custom HTML for the save box
_getDeleteFormpublicReturn HTML which represents the form for deleting a record
_getDeleteSubActionspublicReturn the sub-actions for deleting a record (e.g. cancel)
_getDuplicateFormpublicReturn HTML which represents the form for duplicating a record
_getDuplicateSubActionspublicReturn the sub-actions for duplicating a record
_getEditFormpublicReturns a page title and HTML for a form to edit a record
_getEditLiveUrlpublicReturn the URL to use for the 'view live site' button, when editing a given record
_getEditSubActionspublicReturn the sub-actions for editing a record (e.g. deleting)
_getExportpublicReturns form for doing exports
_getExportQueryprotectedReturns the SQL query for use by the export tools.
_getImportpublicReturns a form which contains options for doing an export
_getNavigationpublicReturn the navigation for this controller
_getRefineClauseprotectedReturn the WHERE clause to use for a given key which is provided by the RefineBar
_getSearchFormpublicReturn HTML for a search form
_getToolspublicReturns tools to show in the left hand navigation. Return an empty array if no tools.
_getVisibilityFieldspublicReturn the fields to show in the sidebar when adding or editing a record.
_identifierpublicCreates the identifier used in the heading, and for reordering.
_importColGuessprotectedTry to guess the database name for a given CSV heading.
_importDatapublicDoes the actual import
_importExtraOptionsprotectedCalled when the import form is being built.
_importPostprotectedCalled at the end of the the import process, after everything has been done.
_importPostRecordprotectedCalled after a record has been inserted or updated.
_importPreprotectedCalled at the beginning of the the import process.
_importPreRecordprotectedCalled after the field data has been determined, but before the insert or update is run.
_intropublicReturns the intro HTML for this controller.
_invalidateCachespublicThis is called after every add, edit and delete, as well as other (i.e. bulk) actions.
_isAddSavedpublicIs the "add" action saved?
_isDeleteSavedpublicCheck if deletion of a particular record is allowed
_isEditSavedpublicIs the "edit" action saved?
_modeSelectorprotectedReturns HTML for a ui component to update the current main view mode
_paginationBarprotectedBuilds the HTML for showing the navigation through pages in the admin.
_preSaveprotected 
applyRefineFilterprotectedApplies filters defined in the query string using a LIKE contains
getControllerNamepublicReturns the defined controller name.
getDuplicateEnabledpublicReturns the duplication enabling flag
getFriendlyNamepublicReturns the defined controller friendly name
getNavigationNamepublicReturns the defined controller navigation name
getTableNamepublicReturns the defined table name
getTopnavNamepublicGets the name of the controller to use for the top nav
initRefineBarprotectedInitialises the refine bar if it isn't already set, with a search widget for the 'name' field if it exists
initTableNameprotectedInitialises the table name if it isn't already set, using the plural of the shorthand controller name
injectVisiblityFieldsprotectedInject the visiblity fields into a loaded json configuration, so they actually save
isPerSubsitepublicIf true, then a UI for editing the "subsite_id" for a record should be shown
postJsonMultiTagpublicMulti-tag some items. Uses AJAX. Returns JSON.
postMultiDeletepublicDelete multiple records

public __construct

void $ManagedAdminController->__construct ( );

Constructor. This must be called in the extending class.

public _actionLog

unknown $ManagedAdminController->_actionLog ( );

This function does not have a description

protected _addPreRender

void $ManagedAdminController->_addPreRender ( mixed $view );

Hook called by _getAddForm() just before the view is rendered

public _addSave

boolean $ManagedAdminController->_addSave ( int &$item_id );

Process the saving of an add.

public _deletePostSave

void $ManagedAdminController->_deletePostSave ( int $item_id );

Does custom actions after the _deleteSave method is called, e.g. clearing cache data

public _deletePreSave

void $ManagedAdminController->_deletePreSave ( int $item_id );

Does custom actions before _deleteSave method is called, e.g. extra security checks

public _deleteSave

unknown $ManagedAdminController->_deleteSave ( int $item_id );

Deletes an item and logs the deleted data

protected _duplicatePreRender

void $ManagedAdminController->_duplicatePreRender ( mixed $view , mixed $item_id );

Hook called by _getDuplicateForm() just before the view is rendered

public _duplicateSave

boolean $ManagedAdminController->_duplicateSave ( int $id );

Process the saving of a duplication. Basic version just calls _editSave

protected _editPreRender

void $ManagedAdminController->_editPreRender ( mixed $view , mixed $item_id );

Hook called by _getEditForm() just before the view is rendered

public _editSave

boolean $ManagedAdminController->_editSave ( int $item_id );

Process the saving of a record.

public _exportData

array $ManagedAdminController->_exportData ( );

Does the actual export. Return false on error.

public _extraMultiDelete

unknown $ManagedAdminController->_extraMultiDelete ( );

Form to delete multiple records

public _getAddForm

array $ManagedAdminController->_getAddForm ( );

Returns a page title and HTML for a form to add a record

public _getAddSubActions

array $ManagedAdminController->_getAddSubActions ( );

Return the sub-actions for adding a record (e.g. preview)
These are rendered into HTML using AdminController::renderSubActions

public _getContents

unknown $ManagedAdminController->_getContents ( );

Return HTML which represents a list of records for this controller

protected _getContentsQuery

string $ManagedAdminController->_getContentsQuery ( string $where , string $order , array &$params );

Returns the SQL query for use by the contents list.

The query MUST NOT include a LIMIT clause.
The query MUST include a SQL_CALC_FOUND_ROWS clause.
The main table SHOULD be aliased to 'item'.

public _getContentsView

unknown $ManagedAdminController->_getContentsView ( Traversable $items , string $mode , anything $unused );

Return HTML for a resultset of items
The returned HTML will be sandwiched between the refinebar and the pagination bar.

public _getContentsViewList

unknown $ManagedAdminController->_getContentsViewList ( Traversable $items , anything $unused );

Formats a resultset of items into an Itemlist

public _getCustomAddSaveHTML

unknown $ManagedAdminController->_getCustomAddSaveHTML ( );

Optional custom HTML for the save box
Return NULL to use the default HTML

public _getCustomDuplicateSaveHTML

unknown $ManagedAdminController->_getCustomDuplicateSaveHTML ( return $item_id );

Optional custom HTML for the save box
Return NULL to use the default HTML

public _getCustomEditSaveHTML

unknown $ManagedAdminController->_getCustomEditSaveHTML ( return $item_id );

Optional custom HTML for the save box
Return NULL to use the default HTML

public _getDeleteForm

string $ManagedAdminController->_getDeleteForm ( int $id );

Return HTML which represents the form for deleting a record

public _getDeleteSubActions

array $ManagedAdminController->_getDeleteSubActions ( mixed $item_id );

Return the sub-actions for deleting a record (e.g. cancel)
These are rendered into HTML using AdminController::renderSubActions

public _getDuplicateForm

unknown $ManagedAdminController->_getDuplicateForm ( int $id );

Return HTML which represents the form for duplicating a record

public _getDuplicateSubActions

array $ManagedAdminController->_getDuplicateSubActions ( mixed $item_id );

Return the sub-actions for duplicating a record
These are rendered into HTML using AdminController::renderSubActions

public _getEditForm

array $ManagedAdminController->_getEditForm ( int $id );

Returns a page title and HTML for a form to edit a record

public _getEditLiveUrl

null|string $ManagedAdminController->_getEditLiveUrl ( int $item_id );

Return the URL to use for the 'view live site' button, when editing a given record

public _getEditSubActions

array $ManagedAdminController->_getEditSubActions ( mixed $item_id );

Return the sub-actions for editing a record (e.g. deleting)
These are rendered into HTML using AdminController::renderSubActions

public _getExport

unknown $ManagedAdminController->_getExport ( );

Returns form for doing exports

protected _getExportQuery

unknown $ManagedAdminController->_getExportQuery ( [ string $where ] );

Returns the SQL query for use by the export tools.
The query does MUST NOT include a LIMIT clause.

public _getImport

unknown $ManagedAdminController->_getImport ( mixed $filename );

Returns a form which contains options for doing an export

public _getNavigation

void $ManagedAdminController->_getNavigation ( );

Return the navigation for this controller
Should return HTML

protected _getRefineClause

string $ManagedAdminController->_getRefineClause ( string $key , string $val , array &$query_params );

Return the WHERE clause to use for a given key which is provided by the RefineBar
This must be called in the extending class if no clause can be determined,
i.e. return parent::_getRefineClause()

Allows custom non-table clauses to be added.
Is only called for key names which begin with an underscore.
The base table is aliased to 'item'.

public _getSearchForm

unknown $ManagedAdminController->_getSearchForm ( );

Return HTML for a search form

public _getTools

unknown $ManagedAdminController->_getTools ( );

Returns tools to show in the left hand navigation. Return an empty array if no tools.

public _getVisibilityFields

array $ManagedAdminController->_getVisibilityFields ( );

Return the fields to show in the sidebar when adding or editing a record.
These fields are shown under a heading of "Visibility"

Key is the field name, value is the field label

public _identifier

string $ManagedAdminController->_identifier ( array $item );

Creates the identifier used in the heading, and for reordering.

protected _importColGuess

string $ManagedAdminController->_importColGuess ( string $csv_heading );

Try to guess the database name for a given CSV heading.
If you can't figure it out, return NULL.
If NULL is returned, the rudimentry almost-exact guesser will be run.

public _importData

unknown $ManagedAdminController->_importData ( string $filename );

Does the actual import

protected _importExtraOptions

unknown $ManagedAdminController->_importExtraOptions ( );

Called when the import form is being built.

Returns HTML of extra options to display, or null if no extra options.

protected _importPost

unknown $ManagedAdminController->_importPost ( );

Called at the end of the the import process, after everything has been done.
Is called from within a transaction.
Return FALSE to abort the import.

protected _importPostRecord

boolean $ManagedAdminController->_importPostRecord ( int $record_id , array $new_data , array $existing_record , string $type , array $raw_data );

Called after a record has been inserted or updated.

protected _importPre

unknown $ManagedAdminController->_importPre ( );

Called at the beginning of the the import process.
Is called from within a transaction.
Return FALSE to abort the import.

protected _importPreRecord

unknown $ManagedAdminController->_importPreRecord ( array &$new_data , array $raw_data );

Called after the field data has been determined, but before the insert or update is run.

Return FALSE to skip the record.

public _intro

void $ManagedAdminController->_intro ( );

Returns the intro HTML for this controller.

public _invalidateCaches

void $ManagedAdminController->_invalidateCaches ( string $action [, int $item_id ] );

This is called after every add, edit and delete, as well as other (i.e. bulk) actions.
Use it to clear any frontend caches. The default is an empty method.

public _isAddSaved

bool $ManagedAdminController->_isAddSaved ( );

Is the "add" action saved?
These may be false if the UI provides its own save mechanism (e.g. multi-add)

public _isDeleteSaved

bool $ManagedAdminController->_isDeleteSaved ( int $item_id );

Check if deletion of a particular record is allowed
This method may be overridden if ignoring the $main_delete property is desired

public _isEditSaved

bool $ManagedAdminController->_isEditSaved ( mixed $item_id );

Is the "edit" action saved?
These may be false if the UI provides its own save mechanism

protected _modeSelector

unknown $ManagedAdminController->_modeSelector ( mixed $current_mode );

Returns HTML for a ui component to update the current main view mode

protected _paginationBar

HTML $ManagedAdminController->_paginationBar ( The $current_page , The $total_row_count );

Builds the HTML for showing the navigation through pages in the admin.
This method is FINAL to help keep the user interface consistent.

protected _preSave

void $ManagedAdminController->_preSave ( mixed $id , mixed &$data );

This function does not have a description

protected applyRefineFilter

array $ManagedAdminController->applyRefineFilter ( [ array $source_data ] );

Applies filters defined in the query string using a LIKE contains
Only fields which exist in the RefineBar will be filtered

public getControllerName

unknown $ManagedAdminController->getControllerName ( );

Returns the defined controller name.

public getDuplicateEnabled

unknown $ManagedAdminController->getDuplicateEnabled ( );

Returns the duplication enabling flag

public getFriendlyName

unknown $ManagedAdminController->getFriendlyName ( );

Returns the defined controller friendly name

public getNavigationName

unknown $ManagedAdminController->getNavigationName ( );

Returns the defined controller navigation name

public getTableName

unknown $ManagedAdminController->getTableName ( );

Returns the defined table name

public getTopnavName

unknown $ManagedAdminController->getTopnavName ( );

Gets the name of the controller to use for the top nav

protected initRefineBar

void $ManagedAdminController->initRefineBar ( );

Initialises the refine bar if it isn't already set, with a search widget for the 'name' field if it exists
Most controllers which need a custom refine bar should call this before adding their own search widgets

protected initTableName

void $ManagedAdminController->initTableName ( );

Initialises the table name if it isn't already set, using the plural of the shorthand controller name

protected injectVisiblityFields

void $ManagedAdminController->injectVisiblityFields ( array &$conf );

Inject the visiblity fields into a loaded json configuration, so they actually save

public isPerSubsite

unknown $ManagedAdminController->isPerSubsite ( );

If true, then a UI for editing the "subsite_id" for a record should be shown

public postJsonMultiTag

void $ManagedAdminController->postJsonMultiTag ( );

Multi-tag some items. Uses AJAX. Returns JSON.

public postMultiDelete

void $ManagedAdminController->postMultiDelete ( );

Delete multiple records

Tags:   module-api   api