SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class AdminController

Main class to handle admin processing.
This delegates processing to controllers registered with Register::adminControllers

Variables

NameVisibilityDescription
$action_log
Should this controller log add/edit/delete actions?

Functions

NameVisibilityDescription
__callpublicHandles methods that do not exist.
__constructpublicDoes some general admin loading
_runpublicThe router/kohana will invoke this method to invoke an action.
addpublicShows an add form for the specified item
addSavepublicExecutes the save action for a specific item
ajaxUnlockpublicUnlock a record.
autoSetEmptyParamprotectedAuto-set the "empty" param for fields with foreign keys to be NULL
callpublicDirectly calls a method provided by an admin controller
checkAccessprivateCheck access for a given controller/access flag combo
checkRecordAccesspublicChecks that an admin user has access to an individual record
cleanupCommonPostDataprivateEnsure 'active' flag and 'tags' POST fields have values set, if they are nonexistant
closeFirstrunpublicCloses the 'first run' box, which is shown on the admin dashboard
contentspublicShows an edit form for the specified item
cronGenericActivatepublicActivates AutoLaunch revisions
dashboardpublicDashboard shown when a user first logs in to the admin
deletepublicShows a delete form for the specified item
deleteRecordprotectedDeletes a record, and logs the deletion
deleteSavepublicExecutes the delete action for a specific item
duplicatepublicShows a duplication form for the specified item
duplicateSavepublicExecutes the save action for a record duplication
editpublicShows an edit form for the specified item
editSavepublicExecutes the save action for a specific item
errorprivateShows an error message in the admin skin
exportpublicShows an edit form for the specified item
exportActionpublicExecutes the save action for a specific item
extrapublicCalls any 'extra' commands that might be provided by the controller
generateFormViewprotectedGenerates a form view from a JSON config file
getControllerprivateReturns an instance of a controller class for a given type
getCssClassNamepublicReturn the class name for this controller, expressed in CSS style, i.e. with dashes
getModulePathpublicGets the relative path to the module the controller lives in, or sprout itself
heartbeatpublic 
importActionpublicExecutes the import action
importOptionspublicShows the import form for the specified item
importUploadpublicFile upload box for importing, options are the next step
importUploadActionpublicCopies the file to a temporary directory
indexpublicHome page of admin area
intropublicShows an introduction for a specified type.
jsonExtraValidateprotectedDo any additional validation prior to saving the record
loadEditJsonprotectedLoads a JSON config file for an automated edit-type form for this controller
loadFormJsonprotectedLoads a config file for a JsonForm associated with this controller
loadRecordprotectedFetches the pre-update record from the database.
lockprivateDoes lock checking, locking, or lock messages.
logActionprotectedStores a history item in the database, recording an add (i.e. insert), edit, or delete.
logAddprotectedLogs an add action. This is a wrapper for Controller::logAction
logAddCategoryprotectedLogs the adding of a record to a category. This is a wrapper for Controller::logAction
logDeleteprotectedLogs a delete action. This is a wrapper for Controller::logAction
logDeleteCategoryprotectedLogs the removal of a record from a category. This is a wrapper for Controller::logAction
logEditprotectedLogs an edit action. This is a wrapper for Controller::logAction
loginpublicShows a login form
loginActionpublicProcesses a user login
loginCompleteprivateSet up various login params and redirect into admin
loginTwoFactorpublicShow the two-factor-auth ui for a half-logged-in operator
loginTwoFactorActionpublicProcess the result of a two-factor-auth for a half-logged-in operator
logoutpublicProcesses a user logout
moderatepublicModeration
moderateActionpublicProcesses the moderation form
perRecordPermissionsFieldsprotectedGenerates HTML for fields relating to per-record permissions in the 'save changes' box
renderSubActionsprivateRender a list of sub-actions into HTML as links
replaceSetprotectedInserts records which are in $new_records, but are not in the specified table
restorepublicRestore a deleted record from log data
saveJsonDataprotectedAutomatically saves the data associated with a submission on a JSON-generated form
searchpublicShows a search form for the specified item
setActiveSubsitepublicSets the active subsite, and then redirects back to the admin area.
setDefaultMainviewParamsprivateSets the a bunch of parameters for a the main view.
setNavigationprivateSets up the sidebar navigation for a view to show the navigation for a specific controller.
styleGuidepublicView the various styles available in the admin area
unlockprivateUnlocks lock for a given record/controller, all records for a controller, or all locks
userAgentpublicBrowser information

public __call (from BaseController)

void $BaseController->__call ( string $method , array $args );

Handles methods that do not exist.

public __construct

void $AdminController->__construct ( );

Does some general admin loading

public _run (from BaseController)

void $BaseController->_run ( mixed $method , mixed $args );

The router/kohana will invoke this method to invoke an action.

If you please, you may wrap this method to create before/after hooks.

public add

void $AdminController->add ( string $type );

Shows an add form for the specified item

public addSave

void $AdminController->addSave ( string $type );

Executes the save action for a specific item

public ajaxUnlock

void $AdminController->ajaxUnlock ( );

Unlock a record.
Called via ajax in the beforeunload javascript event

protected autoSetEmptyParam (from Controller)

null $Controller->autoSetEmptyParam ( array &$conf );

Auto-set the "empty" param for fields with foreign keys to be NULL

This greatly reduces the number of foreign-key constraints hit in day-to-day use,
especially with file fields.

public call

void $AdminController->call ( string $class , string $method );

Directly calls a method provided by an admin controller
Suports varargs - additional args are passed to the underlying function

private checkAccess

True $AdminController->checkAccess ( ManagedAdminController $ctlr , string $access_flag , bool $action );

Check access for a given controller/access flag combo
If this returns false, it will echo out an error message; the calling code should just return.

public checkRecordAccess

bool $AdminController->checkRecordAccess ( ManagedAdminController $ctlr , int $item_id );

Checks that an admin user has access to an individual record

private cleanupCommonPostData

void $AdminController->cleanupCommonPostData ( ManagedAdminController $ctlr );

Ensure 'active' flag and 'tags' POST fields have values set, if they are nonexistant

public closeFirstrun

void $AdminController->closeFirstrun ( );

Closes the 'first run' box, which is shown on the admin dashboard

public contents

void $AdminController->contents ( string $type );

Shows an edit form for the specified item

public cronGenericActivate

unknown $AdminController->cronGenericActivate ( );

Activates AutoLaunch revisions

public dashboard

void $AdminController->dashboard ( );

Dashboard shown when a user first logs in to the admin

public delete

void $AdminController->delete ( string $type , int $id );

Shows a delete form for the specified item

protected deleteRecord (from Controller)

int $Controller->deleteRecord ( string $table , int $record_id [, int $parent_log_id ] );

Deletes a record, and logs the deletion
This should be used by all _deleteSave methods
Starts a transaction and commits it if not already in a transaction when called

public deleteSave

void $AdminController->deleteSave ( string $type , int $id );

Executes the delete action for a specific item

public duplicate

void $AdminController->duplicate ( string $type , int $id );

Shows a duplication form for the specified item
This uses the edit form with some string replacements

public duplicateSave

void $AdminController->duplicateSave ( string $type , int $orig_id );

Executes the save action for a record duplication

public edit

void $AdminController->edit ( string $type , int $id );

Shows an edit form for the specified item

public editSave

void $AdminController->editSave ( string $type , int $id );

Executes the save action for a specific item

private error

void $AdminController->error ( string $message [, ManagedAdminController $ctlr ] );

Shows an error message in the admin skin

public export

void $AdminController->export ( string $type );

Shows an edit form for the specified item

public exportAction

void $AdminController->exportAction ( string $type );

Executes the save action for a specific item

public extra

void $AdminController->extra ( string $class , string $method );

Calls any 'extra' commands that might be provided by the controller

Method names will be prefixed with '_extra' and must be public
Names which are lower_cased will be converted to camelCase

Supports varargs - additional args are passed to the underlying function
Called method should return an array, with two keys:
    title     string    Main title
    content   string    HTML for the main content area

protected generateFormView (from Controller)

array $Controller->generateFormView ( mixed $file_name );

Generates a form view from a JSON config file

private getController

Controller $AdminController->getController ( string $type );

Returns an instance of a controller class for a given type

public getCssClassName (from BaseController)

string $BaseController->getCssClassName ( );

Return the class name for this controller, expressed in CSS style, i.e. with dashes

Example: When called from BlogPostController --> 'blog-post-controller'

public getModulePath (from BaseController)

string $BaseController->getModulePath ( );

Gets the relative path to the module the controller lives in, or sprout itself

public heartbeat

void $AdminController->heartbeat ( );

This function does not have a description

public importAction

void $AdminController->importAction ( string $type );

Executes the import action

public importOptions

void $AdminController->importOptions ( string $type );

Shows the import form for the specified item

public importUpload

void $AdminController->importUpload ( string $type );

File upload box for importing, options are the next step

public importUploadAction

void $AdminController->importUploadAction ( mixed $type );

Copies the file to a temporary directory

public index

void $AdminController->index ( );

Home page of admin area

public intro

void $AdminController->intro ( string $type );

Shows an introduction for a specified type.

protected jsonExtraValidate (from Controller)

void $Controller->jsonExtraValidate ( int $id , Validator $validator );

Do any additional validation prior to saving the record

protected loadEditJson (from Controller)

array $Controller->loadEditJson ( );

Loads a JSON config file for an automated edit-type form for this controller

protected loadFormJson (from Controller)

array $Controller->loadFormJson ( string $file_name );

Loads a config file for a JsonForm associated with this controller

protected loadRecord (from Controller)

bool|array $Controller->loadRecord ( string $table , int $record_id );

Fetches the pre-update record from the database.
Used by the action log system, and disabled if the action log system has been turned off

private lock

void $AdminController->lock ( string $type , int $id , View $view );

Does lock checking, locking, or lock messages.

protected logAction (from Controller)

int $Controller->logAction ( string $table , int $record_id , int $type , array $data [, int $parent_log_id ] );

Stores a history item in the database, recording an add (i.e. insert), edit, or delete.
Should be called AFTER the action has been made.
N.B. This is a low-level method; the friendlier wrapper methods are preferred;
e.g. Controller::logAdd, Controller::logEdit

protected logAdd (from Controller)

int $Controller->logAdd ( string $table , int $record_id );

Logs an add action. This is a wrapper for Controller::logAction

protected logAddCategory (from Controller)

int $Controller->logAddCategory ( string $table , int $record_id , int $cat_id );

Logs the adding of a record to a category. This is a wrapper for Controller::logAction

protected logDelete (from Controller)

int $Controller->logDelete ( string $table , int $record_id , array $data [, int $parent_log_id ] );

Logs a delete action. This is a wrapper for Controller::logAction

protected logDeleteCategory (from Controller)

int $Controller->logDeleteCategory ( string $table , int $record_id , int $cat_id );

Logs the removal of a record from a category. This is a wrapper for Controller::logAction

protected logEdit (from Controller)

int $Controller->logEdit ( string $table , int $record_id , array $data );

Logs an edit action. This is a wrapper for Controller::logAction

public login

void $AdminController->login ( );

Shows a login form

public loginAction

void $AdminController->loginAction ( );

Processes a user login

private loginComplete

void $AdminController->loginComplete ( );

Set up various login params and redirect into admin

Called after a successful login (either one-factor or two-factor)

public loginTwoFactor

void $AdminController->loginTwoFactor ( );

Show the two-factor-auth ui for a half-logged-in operator

public loginTwoFactorAction

void $AdminController->loginTwoFactorAction ( );

Process the result of a two-factor-auth for a half-logged-in operator

public logout

void $AdminController->logout ( );

Processes a user logout

public moderate

void $AdminController->moderate ( );

Moderation

public moderateAction

void $AdminController->moderateAction ( );

Processes the moderation form

protected perRecordPermissionsFields

string $AdminController->perRecordPermissionsFields ( ManagedAdminController $ctlr , int $item_id );

Generates HTML for fields relating to per-record permissions in the 'save changes' box

private renderSubActions

HTML $AdminController->renderSubActions ( array $list );

Render a list of sub-actions into HTML as links

Each sub-action should be an array, with the following keys:
   url     Link URL
   name    Link text
   class   Optional class
   new_tab Optional bool to show in new window/tab

Use a special entry with a key of "_preview" and a value of the
preview URL to set up a preview button

protected replaceSet (from Controller)

void $Controller->replaceSet ( string $table , array $new_records , array $conditions );

Inserts records which are in $new_records, but are not in the specified table
Deletes records which are in the specified table, but not in $new_records
Updates records which are in both

Matching is done on the 'id' field, as a result the $new_records arrays MUST contain an id field.

public restore

void $AdminController->restore ( int $log_id );

Restore a deleted record from log data

protected saveJsonData (from Controller)

bool $Controller->saveJsonData ( array $conf , int &$item_id [, string $mode ] );

Automatically saves the data associated with a submission on a JSON-generated form

public search

void $AdminController->search ( string $type );

Shows a search form for the specified item

public setActiveSubsite

void $AdminController->setActiveSubsite ( );

Sets the active subsite, and then redirects back to the admin area.
Uses the post variable "subsite".

private setDefaultMainviewParams

void $AdminController->setDefaultMainviewParams ( View $view );

Sets the a bunch of parameters for a the main view.

private setNavigation

void $AdminController->setNavigation ( View $view , Controller $ctlr );

Sets up the sidebar navigation for a view to show the navigation for a specific controller.

public styleGuide

void $AdminController->styleGuide ( mixed $section );

View the various styles available in the admin area

private unlock

void $AdminController->unlock ( [ mixed $type [, mixed $id ]] );

Unlocks lock for a given record/controller, all records for a controller, or all locks

public userAgent

void $AdminController->userAgent ( );

Browser information