wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
SaveController Class Reference
+ Inheritance diagram for SaveController:

Public Member Functions

 hasView ()
 
 executeKernel ()
 
 saveUploadFile ($data)
 
 checkFile ($oid, $valueName, $dataType, $filename, $mimeType=null)
 
 getMimeTypes ($oid, $valueName, $dataType)
 
 getImageConstraints ($oid, $valueName, $dataType)
 
 getUploadFilename ($oid, $valueName, $dataType, $filename)
 
 shouldOverride ($oid, $valueName, $dataType, $filename)
 
 getUploadDir ($oid, $valueName, $dataType)
 
 confirmSave (&$node, $valueName, $valueType, $newValue)
 
 modify (&$node, $valueName, $valueType, $oldValue)
 
 afterSave (&$node)
 
- Public Member Functions inherited from Controller
 Controller (&$delegate)
 
 initialize (&$request, &$response)
 
 validate ()
 
 hasView ()
 
 execute ()
 
 executeKernel ()
 
 getErrorMsg ()
 
 setErrorMsg ($msg)
 
 appendErrorMsg ($msg)
 
getRequest ()
 
getResponse ()
 
getView ()
 
getDelegate ()
 
 getViewTemplate ($controller, $context, $action)
 
 getCacheId ()
 
 assignViewDefaults (&$view)
 
 isLocalizedRequest ()
 

Public Attributes

 $_fileUtil = null
 
 $_graphicsUtil = null
 
- Public Attributes inherited from Controller
 $_request = null
 
 $_response = null
 
 $_errorMsg = ''
 
 $_view = null
 
 $_delegate = null
 

Detailed Description

SaveController is a controller that saves Node data.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.SaveController.php 1462 2014-02-04 23:52:27Z iherwig

Input actions:

  • unspecified: Save the given Node values

Output actions:

  • ok In any case
Parameters
[in]<oid>A list of nodes defining what to save. Each node should only contain those values, that should be changed This may be achived by creating the node using the node constructor (instead of using PersistenceFacade::create) and setting the values on it.
[in]uploadDirThe directory where uploaded files should be placed (see SaveController::getUploadDir()) (optional)
[out]oidThe oid of the last Node saved

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 52 of file class.SaveController.php.

Member Function Documentation

SaveController::hasView ( )
See Also
Controller::hasView()

Definition at line 60 of file class.SaveController.php.

SaveController::saveUploadFile (   $data)

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

Parameters
dataAn assoziative array with keys 'oid', 'name', 'dataType', 'value' where value holds an assoziative array with keys 'name', 'type', 'size', 'tmp_name', 'error' as contained in the php $_FILES array.
Returns
True if no upload happened (because no file was given) / False on error / The final filename if the upload was successful

Definition at line 319 of file class.SaveController.php.

References Controller\appendErrorMsg(), checkFile(), Message\get(), InifileParser\getInstance(), getUploadDir(), and shouldOverride().

Referenced by executeKernel().

+ Here is the call graph for this function:

SaveController::checkFile (   $oid,
  $valueName,
  $dataType,
  $filename,
  $mimeType = null 
)

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

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object
valueNameThe name of the value of the object identified by oid
dataTypeThe data type value
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
True/False whether the file is ok or not.
Note
The default implementation checks if the files mime type is contained in the mime types provided by the getMimeTypes method and if the dimensions provided by the getImageConstraints method are met. How to disable the image dimension check is described in the documentation of the getImageConstraints method.

Definition at line 393 of file class.SaveController.php.

References Controller\appendErrorMsg(), Message\get(), getImageConstraints(), and getMimeTypes().

Referenced by executeKernel(), and saveUploadFile().

+ Here is the call graph for this function:

SaveController::getMimeTypes (   $oid,
  $valueName,
  $dataType 
)

Determine possible mime types for an object value.

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object
valueNameThe name of the value of the object identified by oid
dataTypeThe data type value
Returns
An array containing the possible mime types or null meaning 'don't care'.
Note
The default implementation will return null.

Definition at line 448 of file class.SaveController.php.

Referenced by checkFile().

SaveController::getImageConstraints (   $oid,
  $valueName,
  $dataType 
)

Get the image constraints for an object value.

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object
valueNameThe name of the value of the object identified by oid
dataTypeThe data type value
Returns
An assoziative array with keys 'width' and 'height', which hold false meaning 'don't care' or arrays where the first entry is a pixel value and the second is 0 or 1 indicating that the dimension may be smaller than (0) or must exactly be (1) the pixel value.
Note
The default implementation will look for type.valueName.width or imgWidth and type.valueName.height or imgHeight keys in the configuration file (section 'media').

Definition at line 464 of file class.SaveController.php.

References InifileParser\getInstance(), PersistenceFacade\getOIDParameter(), and PersistenceFacade\isValidOID().

Referenced by checkFile().

+ Here is the call graph for this function:

SaveController::getUploadFilename (   $oid,
  $valueName,
  $dataType,
  $filename 
)

Get the name for the uploaded file.

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object
valueNameThe name of the value of the object identified by oid
dataTypeThe data type value
filenameThe name of the file to upload (including path)
Returns
The filename
Note
The default implementation replaces all non alphanumerical characters except for ., -, _ with underscores and turns the name to lower case.

Definition at line 506 of file class.SaveController.php.

SaveController::shouldOverride (   $oid,
  $valueName,
  $dataType,
  $filename 
)

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

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object
valueNameThe name of the value of the object identified by oid
dataTypeThe data type value
filenameThe name of the file to upload (including path)
Returns
True/False wether to override the file or to create a new unique filename
Note
The default implementation returns true.

Definition at line 521 of file class.SaveController.php.

Referenced by saveUploadFile().

SaveController::getUploadDir (   $oid,
  $valueName,
  $dataType 
)

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

Note
subclasses will override this to implement special application requirements.
Parameters
oidThe oid of the object which will hold the association to the file
valueNameThe name of the value which will hold the association to the file
dataTypeThe data type value
Returns
The directory name
Note
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.

Definition at line 536 of file class.SaveController.php.

References InifileParser\getInstance(), PersistenceFacade\getOIDParameter(), PersistenceFacade\isValidOID(), and FileUtil\mkdirRec().

Referenced by executeKernel(), and saveUploadFile().

+ Here is the call graph for this function:

SaveController::confirmSave ( $node,
  $valueName,
  $valueType,
  $newValue 
)

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.
valueTypeThe data type of the value to save.
newValueThe new value to set.
Returns
True/False whether the value should be changed [default: true]. In case of false the assigned error message will be displayed

Definition at line 577 of file class.SaveController.php.

Referenced by executeKernel().

SaveController::modify ( $node,
  $valueName,
  $valueType,
  $oldValue 
)

Modify a given Node value before save action. The new value is already set.

Note
subclasses will override this to implement special application requirements.
Parameters
nodeA reference to the Node to modify.
valueNameThe name of the value to save.
valueTypeThe data type of the value to save.
oldValueThe old value.
Returns
True/False whether the Node was modified [default: false].

Definition at line 590 of file class.SaveController.php.

Referenced by executeKernel().

SaveController::afterSave ( $node)

Called after save.

Note
subclasses will override this to implement special application requirements.
Parameters
nodeA reference to the Node saved.
Note
The method is called for all save candidates even if they are not saved (use PersistentObject::getState() to confirm).

Definition at line 600 of file class.SaveController.php.

Referenced by executeKernel().

Member Data Documentation

SaveController::$_fileUtil = null

Definition at line 54 of file class.SaveController.php.

SaveController::$_graphicsUtil = null

Definition at line 55 of file class.SaveController.php.


The documentation for this class was generated from the following file: