PHP Class Grav\Plugin\Admin\AdminBaseController

Show file Open project: getgrav/grav-plugin-admin

Public Properties

Property Type Description
$blacklist_views array
$data array | null
$grav Grav\Common\Grav
$post array
$route string
$task string
$view string

Protected Properties

Property Type Description
$admin Admin
$redirect string
$redirectCode integer
$upload_errors
$uri Grav\Common\Uri

Public Methods

Method Description
execute ( ) : boolean Performs a task.
redirect ( ) Redirect to the route stored in $this->redirect
setRedirect ( string $path, integer $code = 303 ) Sets the page redirect.
taskFilesSessionRemove ( ) : boolean Removes a file from the flash object session, before it gets saved
taskFilesUpload ( ) : boolean Handles ajax upload for files.
taskRemoveMedia ( ) : boolean Handles removing a media file

Protected Methods

Method Description
authorizeTask ( string $task = '', array $permissions = [] ) : boolean Checks if the user is allowed to perform the given task with its associated permissions
canEditMedia ( string $type = 'media' ) : boolean Determine if the user can edit media
cleanDataKeys ( $source = [] )
dataPermissions ( ) : array Gets the permissions needed to access a given view
filterAcceptedFiles ( $file, $settings )
getPost ( array $post ) : array Prepare and return POST data.
isMultilang ( ) : boolean Return true if multilang is active
jsonDecode ( array $data ) : array Recursively JSON decode data.
normalizeFiles ( array $data, string $key = '' ) : object Internal method to normalize the $_FILES array
prepareData ( array $data ) : array Gets the configuration data for a given view & post
storeFiles ( Grav\Common\Page\Page | Grav\Common\Data\Data $obj ) : Grav\Common\Page\Page | Grav\Common\Data\Data
taskGetFilesInFolder ( ) Used by the filepicker field to get a list of files in a folder.
taskRemoveFileFromBlueprint ( ) : boolean Handle deleting a file from a blueprint
validateNonce ( )

Method Details

authorizeTask() protected method

Checks if the user is allowed to perform the given task with its associated permissions
protected authorizeTask ( string $task = '', array $permissions = [] ) : boolean
$task string The task to execute
$permissions array The permissions given
return boolean True if authorized. False if not.

canEditMedia() protected method

Determine if the user can edit media
protected canEditMedia ( string $type = 'media' ) : boolean
$type string
return boolean True if the media action is allowed

cleanDataKeys() protected method

protected cleanDataKeys ( $source = [] )

dataPermissions() protected method

Gets the permissions needed to access a given view
protected dataPermissions ( ) : array
return array An array of permissions

execute() public method

Performs a task.
public execute ( ) : boolean
return boolean True if the action was performed successfully.

filterAcceptedFiles() protected method

protected filterAcceptedFiles ( $file, $settings )

getPost() protected method

Prepare and return POST data.
protected getPost ( array $post ) : array
$post array
return array

isMultilang() protected method

Return true if multilang is active
protected isMultilang ( ) : boolean
return boolean True if multilang is active

jsonDecode() protected method

Recursively JSON decode data.
protected jsonDecode ( array $data ) : array
$data array
return array

normalizeFiles() protected method

Internal method to normalize the $_FILES array
protected normalizeFiles ( array $data, string $key = '' ) : object
$data array $_FILES starting point data
$key string
return object a new Object with a normalized list of files

prepareData() protected method

Gets the configuration data for a given view & post
protected prepareData ( array $data ) : array
$data array
return array

redirect() public method

Redirect to the route stored in $this->redirect
public redirect ( )

setRedirect() public method

Sets the page redirect.
public setRedirect ( string $path, integer $code = 303 )
$path string The path to redirect to
$code integer The HTTP redirect code

storeFiles() protected method

protected storeFiles ( Grav\Common\Page\Page | Grav\Common\Data\Data $obj ) : Grav\Common\Page\Page | Grav\Common\Data\Data
$obj Grav\Common\Page\Page | Grav\Common\Data\Data
return Grav\Common\Page\Page | Grav\Common\Data\Data

taskFilesSessionRemove() public method

Removes a file from the flash object session, before it gets saved
public taskFilesSessionRemove ( ) : boolean
return boolean True if the action was performed.

taskFilesUpload() public method

Stores in a flash object the temporary file and deals with potential file errors.
public taskFilesUpload ( ) : boolean
return boolean True if the action was performed.

taskGetFilesInFolder() protected method

Used by the filepicker field to get a list of files in a folder.
protected taskGetFilesInFolder ( )

taskRemoveFileFromBlueprint() protected method

Handle deleting a file from a blueprint
protected taskRemoveFileFromBlueprint ( ) : boolean
return boolean True if the action was performed.

taskRemoveMedia() public method

Handles removing a media file
public taskRemoveMedia ( ) : boolean
return boolean True if the action was performed

validateNonce() protected method

protected validateNonce ( )

Property Details

$admin protected property

protected Admin,Grav\Plugin\Admin $admin
return Admin

$blacklist_views public property

public array $blacklist_views
return array

$data public property

public array|null $data
return array | null

$grav public property

public Grav,Grav\Common $grav
return Grav\Common\Grav

$post public property

public array $post
return array

$redirect protected property

protected string $redirect
return string

$redirectCode protected property

protected int $redirectCode
return integer

$route public property

public string $route
return string

$task public property

public string $task
return string

$upload_errors protected property

protected $upload_errors

$uri protected property

protected Uri,Grav\Common $uri
return Grav\Common\Uri

$view public property

public string $view
return string