SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class FileUploadController

Handles file uploads in chunks using the JS File API and XMLHttpRequest

Variables

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

Functions

NameVisibilityDescription
__callpublicHandles methods that do not exist.
__constructpublic 
_runpublicThe router/kohana will invoke this method to invoke an action.
autoSetEmptyParamprotectedAuto-set the "empty" param for fields with foreign keys to be NULL
chunkSizeCheckpublicPerform a size check on a set of uploaded chunks.
cleanupChunksprotectedClean up any left-over chunks
clearSessionpublic 
deleteRecordprotectedDeletes a record, and logs the deletion
extraChunkCheckpublicPerform additional checks (beyond the checks already in FileUploadController::uploadChunk) on an uploaded chunk.
fileExtCheckpublicPerform a file extension check.
fileSizeCheckpublicPerform a size check on a completed upload (after chunks have been stitched).
generateFormViewprotectedGenerates a form view from a JSON config file
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
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.
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
replaceSetprotectedInserts records which are in $new_records, but are not in the specified table
saveJsonDataprotectedAutomatically saves the data associated with a submission on a JSON-generated form
sessionpublicGets the session data associated with a file upload
startSessionprotectedCreates a session record for a new file upload, and configures its initial state
stitchChunksprivateStitch together the uploaded file from multiple chunks
uploadBeginpublicSignals that the user would like to upload a file
uploadCancelpublicCancel an upload - delete temporary files.
uploadChunkpublicSave a single chunk of a multi-part file upload
uploadDonepublicStitch together uploaded chunks into an actual file
uploadFormpublicReturns the form for updating a file which has been uploaded
validateCodeprotectedChecks POSTed code matched the expected format

public __call (from BaseController)

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

Handles methods that do not exist.

public __construct (from BaseController)

void $BaseController->__construct ( );

This function does not have a description

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.

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 chunkSizeCheck

void $FileUploadController->chunkSizeCheck ( );

Perform a size check on a set of uploaded chunks.
To be implemented by subclasses

protected cleanupChunks

void $FileUploadController->cleanupChunks ( string $code , int $num_chunks );

Clean up any left-over chunks

public clearSession

void $FileUploadController->clearSession ( );

This function does not have a description

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 extraChunkCheck

void $FileUploadController->extraChunkCheck ( );

Perform additional checks (beyond the checks already in FileUploadController::uploadChunk) on an uploaded chunk.
To be implemented by subclasses

public fileExtCheck

void $FileUploadController->fileExtCheck ( mixed $temp_path );

Perform a file extension check.
To be implemented by subclasses

public fileSizeCheck

void $FileUploadController->fileSizeCheck ( string &$temp_path );

Perform a size check on a completed upload (after chunks have been stitched).
To be implemented by subclasses

protected generateFormView (from Controller)

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

Generates a form view from a JSON config file

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

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

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

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.

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 session

&array $FileUploadController->session ( );

Gets the session data associated with a file upload

protected startSession

&array $FileUploadController->startSession ( );

Creates a session record for a new file upload, and configures its initial state

private stitchChunks

int $FileUploadController->stitchChunks ( string $dest_filename , string $code , string $num_chunks );

Stitch together the uploaded file from multiple chunks

public uploadBegin

void $FileUploadController->uploadBegin ( );

Signals that the user would like to upload a file
Perform basic sanity checks and establish (or reset) their session state

public uploadCancel

void $FileUploadController->uploadCancel ( );

Cancel an upload - delete temporary files.

May receive two different variations on the provided POST data:
   [result][tmp_file]       Whole file was uploaded
   [partial_upload][code]   Only some chunks of the file have been uploaded

public uploadChunk

void $FileUploadController->uploadChunk ( );

Save a single chunk of a multi-part file upload

public uploadDone

void $FileUploadController->uploadDone ( );

Stitch together uploaded chunks into an actual file

Outputs a JSON response.
The field "success" will be checked (= 1) to determine success.
On error, the field "message" will be used as an error message.
Other keys provided are passed to the ajaxDragdropForm method.

public uploadForm

void $FileUploadController->uploadForm ( );

Returns the form for updating a file which has been uploaded

protected validateCode

string $FileUploadController->validateCode ( );

Checks POSTed code matched the expected format