SproutCMS

This is the code documentation for the SproutCMS project

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

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2019-06-18
**/
class NewClassName extends ManagedAdminController {
    
    /**
    * Multi-tag some items. Uses AJAX. Returns JSON.
    **/
    public function postJsonMultiTag () {
        // Method code goes here
    }
    
    /**
    * Called when the import form is being built.
    * 
    * Returns HTML of extra options to display, or null if no extra options.
    **/
    protected function _importExtraOptions () {
        // Method code goes here
    }
    
    /**
    * Called at the beginning of the the import process.
    * Is called from within a transaction.
    * Return FALSE to abort the import.
    **/
    protected function _importPre () {
        // Method code goes here
    }
    
    /**
    * Called after the field data has been determined, but before the insert or update is run.
    * 
    * Return FALSE to skip the record.
    **/
    protected function _importPreRecord (array $new_data, array $raw_data) {
        // Method code goes here
    }
    
    /**
    * Called after a record has been inserted or updated.
    **/
    protected function _importPostRecord (int $record_id, array $new_data, array $existing_record, string $type, array $raw_data) {
        // Method code goes here
    }
    
    /**
    * Delete multiple records
    **/
    public function postMultiDelete () {
        // Method code goes here
    }
    
    /**
    * Creates the identifier used in the heading, and for reordering.
    **/
    public function _identifier (array $item) {
        // Method code goes here
    }
    
    /**
    * Form to delete multiple records
    **/
    public function _extraMultiDelete () {
        // Method code goes here
    }
    
    /**
    * Returns tools to show in the left hand navigation. Return an empty array if no tools.
    **/
    public function _getTools () {
        // Method code goes here
    }
    
    /**
    * Return the navigation for this controller
    * Should return HTML
    **/
    public function _getNavigation () {
        // Method code goes here
    }
    
    public function _actionLog () {
        // Method code goes here
    }
    
    /**
    * Return HTML which represents the form for duplicating a record
    **/
    public function _getDuplicateForm (int $id) {
        // Method code goes here
    }
    
    /**
    * Hook called by _getDuplicateForm() just before the view is rendered
    **/
    protected function _duplicatePreRender ($view, $item_id) {
        // Method code goes here
    }
    
    /**
    * Process the saving of a duplication. Basic version just calls _editSave
    **/
    public function _duplicateSave (int $id) {
        // Method code goes here
    }
    
    /**
    * Return HTML which represents the form for deleting a record
    **/
    public function _getDeleteForm (int $id) {
        // Method code goes here
    }
    
    /**
    * Check if deletion of a particular record is allowed
    * This method may be overridden if ignoring the $main_delete property is desired
    **/
    public function _isDeleteSaved (int $item_id) {
        // Method code goes here
    }
    
    /**
    * Return the sub-actions for deleting a record (e.g. cancel)
    * These are rendered into HTML using {@see AdminController::renderSubActions}
    **/
    public function _getDeleteSubActions ($item_id) {
        // Method code goes here
    }
    
    /**
    * Does custom actions before _deleteSave method is called, e.g. extra security checks
    **/
    public function _deletePreSave (int $item_id) {
        // Method code goes here
    }
    
    /**
    * Does custom actions after the _deleteSave method is called, e.g. clearing cache data
    **/
    public function _deletePostSave (int $item_id) {
        // Method code goes here
    }
    
    /**
    * Deletes an item and logs the deleted data
    **/
    public function _deleteSave (int $item_id) {
        // Method code goes here
    }
    
    /**
    * 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 function _invalidateCaches (string $action, int $item_id) {
        // Method code goes here
    }
    
    /**
    * Return the sub-actions for duplicating a record
    * These are rendered into HTML using {@see AdminController::renderSubActions}
    **/
    public function _getDuplicateSubActions ($item_id) {
        // Method code goes here
    }
    
    /**
    * Optional custom HTML for the save box
    * Return NULL to use the default HTML
    **/
    public function _getCustomDuplicateSaveHTML (return $item_id) {
        // Method code goes here
    }
    
    /**
    * Return the sub-actions for editing a record (e.g. deleting)
    * These are rendered into HTML using {@see AdminController::renderSubActions}
    **/
    public function _getEditSubActions ($item_id) {
        // Method code goes here
    }
    
    /**
    * Return the URL to use for the 'view live site' button, when editing a given record
    **/
    public function _getEditLiveUrl (int $item_id) {
        // Method code goes here
    }
    
    /**
    * Hook called by _getEditForm() just before the view is rendered
    **/
    protected function _editPreRender ($view, $item_id) {
        // Method code goes here
    }
    
    /**
    * Process the saving of a record.
    **/
    public function _editSave (int $item_id) {
        // Method code goes here
    }
    
    protected function _preSave ($id, $data) {
        // Method code goes here
    }
    
    /**
    * Process the saving of an add.
    **/
    public function _addSave (int $item_id) {
        // Method code goes here
    }
    
    /**
    * Returns a page title and HTML for a form to edit a record
    **/
    public function _getEditForm (int $id) {
        // Method code goes here
    }
    
    /**
    * Is the &quot;edit&quot; action saved?
    * These may be false if the UI provides its own save mechanism
    **/
    public function _isEditSaved ($item_id) {
        // Method code goes here
    }
    
    /**
    * Optional custom HTML for the save box
    * Return NULL to use the default HTML
    **/
    public function _getCustomEditSaveHTML (return $item_id) {
        // Method code goes here
    }
    
    /**
    * Hook called by _getAddForm() just before the view is rendered
    **/
    protected function _addPreRender ($view) {
        // Method code goes here
    }
    
    /**
    * Inject the visiblity fields into a loaded json configuration, so they actually save
    **/
    protected function injectVisiblityFields (array $conf) {
        // Method code goes here
    }
    
    /**
    * Return the sub-actions for adding a record (e.g. preview)
    * These are rendered into HTML using {@see AdminController::renderSubActions}
    **/
    public function _getAddSubActions () {
        // Method code goes here
    }
    
    /**
    * Returns a page title and HTML for a form to add a record
    **/
    public function _getAddForm () {
        // Method code goes here
    }
    
    /**
    * Is the &quot;add&quot; action saved?
    * These may be false if the UI provides its own save mechanism (e.g. multi-add)
    **/
    public function _isAddSaved () {
        // Method code goes here
    }
    
    /**
    * Optional custom HTML for the save box
    * Return NULL to use the default HTML
    **/
    public function _getCustomAddSaveHTML () {
        // Method code goes here
    }
    
    /**
    * Return the fields to show in the sidebar when adding or editing a record.
    * These fields are shown under a heading of &quot;Visibility&quot;
    * 
    * Key is the field name, value is the field label
    **/
    public function _getVisibilityFields () {
        // Method code goes here
    }
    
    /**
    * Formats a resultset of items into an Itemlist
    **/
    public function _getContentsViewList (Traversable $items, anything $unused) {
        // Method code goes here
    }
    
    /**
    * 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'.
    **/
    protected function _getContentsQuery (string $where, string $order, array $params) {
        // Method code goes here
    }
    
    /**
    * Return HTML which represents a list of records for this controller
    **/
    public function _getContents () {
        // Method code goes here
    }
    
    /**
    * Return HTML for a resultset of items
    * The returned HTML will be sandwiched between the refinebar and the pagination bar.
    **/
    public function _getContentsView (Traversable $items, string $mode, anything $unused) {
        // Method code goes here
    }
    
    /**
    * Return HTML for a search form
    **/
    public function _getSearchForm () {
        // Method code goes here
    }
    
    /**
    * 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'.
    **/
    protected function _getRefineClause (string $key, string $val, array $query_params) {
        // Method code goes here
    }
    
    /**
    * 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 function _importPost () {
        // Method code goes here
    }
    
    /**
    * Does the actual import
    **/
    public function _importData (string $filename) {
        // Method code goes here
    }
    
    /**
    * 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.
    **/
    protected function _importColGuess (string $csv_heading) {
        // Method code goes here
    }
    
    /**
    * Returns form for doing exports
    **/
    public function _getExport () {
        // Method code goes here
    }
    
    /**
    * Does the actual export. Return false on error.
    **/
    public function _exportData () {
        // Method code goes here
    }
    
    /**
    * Returns the intro HTML for this controller.
    **/
    public function _intro () {
        // Method code goes here
    }
    
    /**
    * Returns the SQL query for use by the export tools.
    * The query does MUST NOT include a LIMIT clause.
    **/
    protected function _getExportQuery (string $where) {
        // Method code goes here
    }
    
    /**
    * Applies filters defined in the query string using a LIKE contains
    * Only fields which exist in the RefineBar will be filtered
    **/
    protected function applyRefineFilter (array $source_data) {
        // Method code goes here
    }
    
    /**
    * Returns a form which contains options for doing an export
    **/
    public function _getImport ($filename) {
        // Method code goes here
    }
    
    /**
    * Gets the name of the controller to use for the top nav
    **/
    public function getTopnavName () {
        // Method code goes here
    }
    
    /**
    * Initialises the table name if it isn't already set, using the plural of the shorthand controller name
    **/
    protected function initTableName () {
        // Method code goes here
    }
    
    /**
    * 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 function initRefineBar () {
        // Method code goes here
    }
    
    /**
    * Constructor. This must be called in the extending class.
    **/
    public function __construct () {
        // Method code goes here
    }
    
}
?>

Tags:   module-api   api