PHP Class KickAssets

Inheritance: extends LeftAndMain
显示文件 Open project: unclecheese/silverstripe-kickassets Class Usage Examples

Public Methods

Method Description
JSONConfig ( ) : string Creates a JSON string of all the variables that can be set in the Config
canView ( Member $member = null ) : boolean Defines the canView permission
createFileJSON ( File $file, Folder $folder = null ) : array Given a File object, create an array of its properties and values ready to be transformed to JSON
createFolderJSON ( Folder $folder ) : array Given a Folder object, create an array of its properties and values ready to be transformed to JSON
handleCreateFolder ( SS_HTTPRequest $r ) : SS_HTTPResponse Creates a folder, ensures uniqueness
handleDelete ( SS_HTTPRequest $r ) : SS_HTTPResponse Deletes a list of files
handleFile ( SS_HTTPRequest $r ) : KickAssets_FileRequest Handles a specific file request
handleFolderContents ( SS_HTTPRequest $r ) : SS_HTTPResponse Gets the contents of a folder, and applies a sort. Splits the response into folder metadata and folder children
handleFolders ( SS_HTTPRequest $r ) : SS_HTTPResponse Gets a list of all the folders in the system
handleIndex ( $r ) : SSViewer Index action, renders the main template
handleMove ( SS_HTTPRequest $r ) : SS_HTTPResponse Moves a list of files ('ids') to a new folder ('newFolder' named file path or ID) If newFolder is a string, the folder will be created if it doesn't exist.
handleRecentItems ( SS_HTTPRequest $r ) : SS_HTTPResponse Gets recently updated items
handleSearch ( SS_HTTPRequest $r ) : SS_HTTPResponse Searches for files by PartialMatch
handleUpload ( SS_HTTPRequest $r ) : SS_HTTPResponse The endpoint for file uploads. Hands off to Dropzone module
init ( ) Bootstraps the module, adds JavaScript
remove_assets_dir ( string $filename ) : string Strips the assets directory from the beginning of a folder name

Protected Methods

Method Description
createBreadcrumbJSON ( Folder $folder ) : array Creates an array of breadcrumbs for a given Folder, ready to be transformed to JSON
getSortClause ( string $sort ) : string Given a sort field, generate a string of SQL to apply the sort

Method Details

JSONConfig() public method

Creates a JSON string of all the variables that can be set in the Config
public JSONConfig ( ) : string
return string

canView() public method

Defines the canView permission
public canView ( Member $member = null ) : boolean
$member Member
return boolean

createBreadcrumbJSON() protected method

Creates an array of breadcrumbs for a given Folder, ready to be transformed to JSON
protected createBreadcrumbJSON ( Folder $folder ) : array
$folder Folder
return array

createFileJSON() public method

Given a File object, create an array of its properties and values ready to be transformed to JSON
public createFileJSON ( File $file, Folder $folder = null ) : array
$file File
$folder Folder
return array

createFolderJSON() public method

Given a Folder object, create an array of its properties and values ready to be transformed to JSON
public createFolderJSON ( Folder $folder ) : array
$folder Folder
return array

getSortClause() protected method

Given a sort field, generate a string of SQL to apply the sort
protected getSortClause ( string $sort ) : string
$sort string
return string

handleCreateFolder() public method

Creates a folder, ensures uniqueness
public handleCreateFolder ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleDelete() public method

Deletes a list of files
public handleDelete ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleFile() public method

Handles a specific file request
public handleFile ( SS_HTTPRequest $r ) : KickAssets_FileRequest
$r SS_HTTPRequest
return KickAssets_FileRequest

handleFolderContents() public method

Gets the contents of a folder, and applies a sort. Splits the response into folder metadata and folder children
public handleFolderContents ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleFolders() public method

Gets a list of all the folders in the system
public handleFolders ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleIndex() public method

Index action, renders the main template
public handleIndex ( $r ) : SSViewer
return SSViewer

handleMove() public method

Moves a list of files ('ids') to a new folder ('newFolder' named file path or ID) If newFolder is a string, the folder will be created if it doesn't exist.
public handleMove ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleRecentItems() public method

Gets recently updated items
public handleRecentItems ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleSearch() public method

Searches for files by PartialMatch
public handleSearch ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

handleUpload() public method

The endpoint for file uploads. Hands off to Dropzone module
public handleUpload ( SS_HTTPRequest $r ) : SS_HTTPResponse
$r SS_HTTPRequest
return SS_HTTPResponse

init() public method

Bootstraps the module, adds JavaScript
public init ( )

remove_assets_dir() public static method

Strips the assets directory from the beginning of a folder name
public static remove_assets_dir ( string $filename ) : string
$filename string
return string