SaveController Class Reference

Detailed Description

SaveController is a controller that saves Node data.

The controller supports the following actions:

Action default
Save the given Node values.

Parameter Description
in / out Key/value pairs of serialized object ids and PersistentObject instances to save
in uploadDir The directory where attached files should be stored on the server (optional) (see SaveController::getUploadDir())
out oid The object id of the last newly created object
Response Actions
ok In all cases

Errors concerning single input fields are added to the session (the keys are the input field names)

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 46 of file SaveController.php.

+ Inheritance diagram for SaveController:

Protected Member Functions

 getFileUtil ()
 
 validate ()
 
 doExecute ()
 
 saveUploadFile (ObjectId $oid, $valueName, array $data)
 
 isFileUpload (array $data)
 
 checkFile (ObjectId $oid, $valueName, $filename, $mimeType=null)
 
 getUploadFilename (ObjectId $oid, $valueName, $filename)
 
 shouldOverride (ObjectId $oid, $valueName, $filename)
 
 getUploadDir (ObjectId $oid, $valueName)
 
 confirmSaveValue ($node, $valueName, $newValue)
 
 confirmSave ($node)
 
 beforeSave ($node)
 
 afterSave ($node)
 
- Protected Member Functions inherited from Controller
 validate ()
 
 executeSubAction ($action)
 
 getLogger ()
 
 getSession ()
 
 getPersistenceFacade ()
 
 getPermissionManager ()
 
 getActionMapper ()
 
 getLocalization ()
 
 getMessage ()
 
 getConfiguration ()
 
 assignResponseDefaults ()
 
 isLocalizedRequest ()
 
 checkLanguageParameter ()
 

Additional Inherited Members

- Public Member Functions inherited from Controller
 __construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration)
 
 initialize (Request $request, Response $response)
 
 execute ($method=null)
 
 getRequest ()
 
 getResponse ()
 

Member Function Documentation

getFileUtil ( )
protected

Get the FileUtil instance.

Returns
FileUtil

Definition at line 54 of file SaveController.php.

validate ( )
protected
See also
Controller::validate()

Definition at line 64 of file SaveController.php.

doExecute ( )
protected
See also
Controller::doExecute()

Definition at line 75 of file SaveController.php.

saveUploadFile ( ObjectId  $oid,
  $valueName,
array  $data 
)
protected

Save uploaded file.

This method calls checkFile which will prevent upload if returning false.

Parameters
$oidThe ObjectId of the object to which the file is associated
$valueNameThe name of the value to which the file is associated
$dataAn assoziative array with keys 'name', 'type', 'tmp_name' as contained in the php $_FILES array.
Returns
The final filename if the upload was successful, null on error

Definition at line 310 of file SaveController.php.

isFileUpload ( array  $data)
protected

Check if the given data defines a file upload.

File uploads are defined in an assoziative array with keys 'name', 'type', 'tmp_name' as contained in the php $_FILES array.

Parameters
$dataArray
Returns
Boolean

Definition at line 361 of file SaveController.php.

checkFile ( ObjectId  $oid,
  $valueName,
  $filename,
  $mimeType = null 
)
protected

Check if the file is valid for a given object value.

The implementation returns true.

Note
subclasses will override this to implement special application requirements.
Parameters
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe name of the file to upload (including path)
$mimeTypeThe mime type of the file (if null it will not be checked) (default: null)
Returns
Boolean whether the file is ok or not.

Definition at line 374 of file SaveController.php.

getUploadFilename ( ObjectId  $oid,
  $valueName,
  $filename 
)
protected

Get the name for the uploaded file.

The implementation replaces all non alphanumerical characters except for ., -, _ with underscores and turns the name to lower case.

Note
subclasses will override this to implement special application requirements.
Parameters
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe name of the file to upload (including path)
Returns
The filename

Definition at line 388 of file SaveController.php.

shouldOverride ( ObjectId  $oid,
  $valueName,
  $filename 
)
protected

Determine what to do if a file with the same name already exists.

The implementation returns true.

Note
subclasses will override this to implement special application requirements.
Parameters
$oidThe ObjectId of the object
$valueNameThe name of the value of the object identified by oid
$filenameThe name of the file to upload (including path)
Returns
Boolean whether to override the file or to create a new unique filename

Definition at line 402 of file SaveController.php.

getUploadDir ( ObjectId  $oid,
  $valueName 
)
protected

Get the name of the directory to upload a file to and make shure that it exists.

The default implementation will first look for a parameter 'uploadDir' and then, if it is not given, for an 'uploadDir'. type key in the configuration file (section 'media') and finally for an 'uploadDir' key at the same place.

Note
subclasses will override this to implement special application requirements.
Parameters
$oidThe ObjectId of the object which will hold the association to the file
$valueNameThe name of the value which will hold the association to the file
Returns
The directory name

Definition at line 416 of file SaveController.php.

confirmSaveValue (   $node,
  $valueName,
  $newValue 
)
protected

Confirm save action on given Node value.

Note
subclasses will override this to implement special application requirements.
Parameters
$nodeA reference to the Node to confirm.
$valueNameThe name of the value to save.
$newValueThe new value to set.
Returns
Boolean whether the value should be changed (default: true).

Definition at line 451 of file SaveController.php.

confirmSave (   $node)
protected

Confirm save action on given Node.

This method is called before modify()

Note
subclasses will override this to implement special application requirements.
Parameters
$nodeA reference to the Node to confirm.
Returns
Boolean whether the Node should be saved (default: true).

Definition at line 461 of file SaveController.php.

beforeSave (   $node)
protected

Called before save.

Note
subclasses will override this to implement special application requirements.
Parameters
$nodeA reference to the Node to be saved.
Returns
Boolean whether the Node was modified (default: false).

Definition at line 471 of file SaveController.php.

afterSave (   $node)
protected

Called after save.

Note
subclasses will override this to implement special application requirements.
Parameters
$nodeA reference to the Node saved.

Definition at line 480 of file SaveController.php.