Contentserv PHP API

CSFileUploadPlugin extends CSPlugin
in package

This class represents the parent class of all plugin apis and offers some utilitiy methods which should be available in every plugin.

Tags

Table of Contents

__call()  : mixed|string
All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.
_construct()  : void
Is called before isAvailable-method.
addAlternativePluginFolder()  : void
A path to a specific folder in which should be search for plugins.
createFileConfigCheckboxField()  : CSUploadFileConfigCheckboxField
Creates a CSUploadFileConfigCheckboxField object with given ID
createFileConfigField()  : CSUploadFileConfigField
Creates CSUploadFileConfigField with given ID
createFileConfigFieldData()  : CSUploadFileConfigFieldData
Creates an CSUploadFileConfigFieldData object
createFileConfigSelectField()  : CSUploadFileConfigSelectField
Creates a CSUploadFileConfigSelectField object with given ID
createUploadedResult()  : CSUploadedFileResult
Creates an CSUploadedFileResult object which should be returned in an array in the methods: - onHandleSuccessFile - onHandleErrorFile
createUploadedResultAsMainType()  : CSUploadedFileResult
Creates an upload result with defined type CSUploadConst::RESULT_TYPE_MAIN
createUploadedResultAsReportType()  : CSUploadedFileResult
Creates an upload result with defined type CSUploadConst::RESULT_TYPE_REPORT
getAlternativePluginFolder()  : array<string|int, mixed>
getFileConfigFields()  : array<string|int, CSUploadFileConfigField>
Returns an array of CSUploadFileConfigField objects.
getHandledFileTypes()  : array<string|int, mixed>
Define which file type plugin is supporting.
getInitArguments()  : null
Returns the init arguments.
getLevel()  : int
The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.
getMetaData()  : CSMetaData
Returns the CSMetaData of the current plugin.
getModule()  : CSModule
Returns the module, if the plugin is defined within a module.
getPlugin()  : CSPlugin|null
Returns a CSPlugin for the given plugin type and plugin class name.
getPluginChooser()  : array<string|int, mixed>
Returns an array all defined CSPlugins for the current plugin type
getPluginData()  : mixed
getPluginDataContext()  : string
Defines the return context type.
getPluginDefinitionFile()  : string
Returns the path to the file, the plugin is defined.
getPluginName()  : mixed
getPlugins()  : array<string|int, CSPlugin>
Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.
getPluginsInModule()  : array<string|int, mixed>
Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.
getUploadParam()  : CSFileUploadParam
Possible external (POST) Parameter All params on plugin construct
initForUpload()  : void
This method is called after gathering all CSFileUploadPlugins (after isAvailable-method) and is only called for file upload request. (for example not for file config request) The getLevel-method is considered also, higher level plugins are called first.
isAvailable()  : bool
This method is called to check, whether the plugin is available.
isAvailableForCurrentConfig()  : bool
Checks if the plugin should be available for the current file config.
isAvailableForFileType()  : bool
Checks the plugin if the current proceed file type should be handled by this plugin.
onAfterHandleFiles()  : void
Is called after all files (error and success) have been proceeded.
onBeforeHandleFiles()  : void
This method is called at first before calling: onHandleErrorFile-method, onHandleSuccessFile-method So it can be used to define global settings before calling each file by methods described above.
onHandleErrorFile()  : array<string|int, CSUploadedFileResult>
This method is called with an error in CSUploadedCacheFile object.
onHandleException()  : void
Is called always if a plugin throws an error with throwError-method.
onHandleSuccessFile()  : array<string|int, CSUploadedFileResult>
This method is called with an $oUploadedFile object with information like: getFileName ... The file representing an file which is already stored in CS cache upload folder
resetLoadedPlugins()  : mixed
reset the internal plugins cache for loaded plugins
shouldCallOtherPlugins()  : bool
Defines if other plugins should be called after your plugin was called.
throwError()  : void
Throws an CSUploadedFileException defined for the Upload process.

Methods

__call()

All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.

public __call(mixed $methodName, mixed $methodArguments) : mixed|string
Parameters
$methodName : mixed
$methodArguments : mixed
Tags
Return values
mixed|string

_construct()

Is called before isAvailable-method.

public _construct([null $mArguments = null ]) : void
Parameters
$mArguments : null = null
Tags
Return values
void

addAlternativePluginFolder()

A path to a specific folder in which should be search for plugins.

public static addAlternativePluginFolder(mixed $sPluginFolder) : void
Parameters
$sPluginFolder : mixed
Tags
Return values
void

createFileConfigCheckboxField()

Creates a CSUploadFileConfigCheckboxField object with given ID

public createFileConfigCheckboxField(string $sId) : CSUploadFileConfigCheckboxField
Parameters
$sId : string
Tags
Return values
CSUploadFileConfigCheckboxField

createFileConfigField()

Creates CSUploadFileConfigField with given ID

public createFileConfigField(string $sId) : CSUploadFileConfigField
Parameters
$sId : string
Tags
Return values
CSUploadFileConfigField

createFileConfigFieldData()

Creates an CSUploadFileConfigFieldData object

public createFileConfigFieldData(string $mValue, string $sText) : CSUploadFileConfigFieldData
Parameters
$mValue : string

Used as hidden value

$sText : string

Used as displayed value

Tags
Return values
CSUploadFileConfigFieldData

createFileConfigSelectField()

Creates a CSUploadFileConfigSelectField object with given ID

public createFileConfigSelectField(string $sId) : CSUploadFileConfigSelectField
Parameters
$sId : string
Tags
Return values
CSUploadFileConfigSelectField

createUploadedResult()

Creates an CSUploadedFileResult object which should be returned in an array in the methods: - onHandleSuccessFile - onHandleErrorFile

public createUploadedResult([null|CSUploadedCacheFile $oUploadedCacheFile = null ]) : CSUploadedFileResult
Parameters
$oUploadedCacheFile : null|CSUploadedCacheFile = null

A instance of the cache file. Static information are copied form CSUploadedCacheFile instance to the CSUploadedFileResult instance.

Tags
Return values
CSUploadedFileResult

createUploadedResultAsMainType()

Creates an upload result with defined type CSUploadConst::RESULT_TYPE_MAIN

public createUploadedResultAsMainType([null|CSUploadedCacheFile $oUploadedCacheFile = null ]) : CSUploadedFileResult
Parameters
$oUploadedCacheFile : null|CSUploadedCacheFile = null
Tags
Return values
CSUploadedFileResult

createUploadedResultAsReportType()

Creates an upload result with defined type CSUploadConst::RESULT_TYPE_REPORT

public createUploadedResultAsReportType([null|CSUploadedCacheFile $oUploadedCacheFile = null ]) : CSUploadedFileResult
Parameters
$oUploadedCacheFile : null|CSUploadedCacheFile = null
Tags
Return values
CSUploadedFileResult

getAlternativePluginFolder()

public static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

getFileConfigFields()

Returns an array of CSUploadFileConfigField objects.

public getFileConfigFields(string $sFileType, string $sFileName, int $iFileSize) : array<string|int, CSUploadFileConfigField>

The returned fields are considered in the CSGuiUploadFileConfigDialog.

Parameters
$sFileType : string

A file type

$sFileName : string

The file name (with extension)

$iFileSize : int

File size in Bytes.

Tags
Return values
array<string|int, CSUploadFileConfigField>

getHandledFileTypes()

Define which file type plugin is supporting.

public getHandledFileTypes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

An array with file types (lower case)

getInitArguments()

Returns the init arguments.

public getInitArguments() : null
Tags
Return values
null

getLevel()

The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.

public getLevel() : int

The method can also be set for all plugins within a module by overwriting the modules getLevel method.

Tags
Return values
int

the level of the plugin where it is called

getMetaData()

Returns the CSMetaData of the current plugin.

public getMetaData() : CSMetaData
Tags
access

public

Return values
CSMetaData

getModule()

Returns the module, if the plugin is defined within a module.

public getModule() : CSModule

This method can be used in the plugin api and the plugin wherever access to the defining module is required. If it is used in the Api, it should be noticed that this method may return null, if the plugin is directly defined in the projects or admin.local plugins directory.

Tags
Return values
CSModule

the module object, if the plugin defined in a module or null otherwise

getPlugin()

Returns a CSPlugin for the given plugin type and plugin class name.

public static getPlugin(string $pluginApiPath, string $className[, mixed $arguments = NULL ]) : CSPlugin|null

As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.

Parameters
$pluginApiPath : string

The relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$className : string

The target plugin class name, which should be loaded.

$arguments : mixed = NULL

one or multiple arguments which should be passed to the isAvailable method.

Tags
Return values
CSPlugin|null

Returns the requested plugin for the given parameter.

getPluginChooser()

Returns an array all defined CSPlugins for the current plugin type

public static getPluginChooser(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
$pluginApiPath : string

the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, mixed>

of CSPlugins in the form [CLASSNAME => LABEL] where the CLASSNAME may be used in the CSPlugin::getPlugin method

getPluginData()

public getPluginData() : mixed
Tags
Return values
mixed

getPluginDataContext()

Defines the return context type.

public getPluginDataContext() : string

For example: "mam" so the return value generated by GuiUploadRestservice will have this context in JSON response

Tags
Return values
string

getPluginDefinitionFile()

Returns the path to the file, the plugin is defined.

public getPluginDefinitionFile() : string
Tags
Return values
string

the path to the plugin

getPluginName()

public getPluginName() : mixed
Tags
Return values
mixed

getPlugins()

Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.

public static getPlugins(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, CSPlugin>

As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.

Parameters
$pluginApiPath : string

the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, CSPlugin>

array of CSPlugin objects matching the defined plugin criteria

getPluginsInModule()

Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.

public static getPluginsInModule(string $moduleName, string $pluginApiPath[, mixed $sFileNamePattern = '' ][, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
$moduleName : string

the module which should be searched for plugins

$pluginApiPath : string

the relative path in filesystem for the requested plugin api.

$sFileNamePattern : mixed = ''
$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, mixed>

of CSPlugin objects matching the defined plugin criterias

getUploadParam()

Possible external (POST) Parameter All params on plugin construct

public getUploadParam() : CSFileUploadParam

The object will be passed by GuiUploadRestservice with all POST parameter it was called with.

Tags
Return values
CSFileUploadParam

initForUpload()

This method is called after gathering all CSFileUploadPlugins (after isAvailable-method) and is only called for file upload request. (for example not for file config request) The getLevel-method is considered also, higher level plugins are called first.

public initForUpload([null $initArguments = null ]) : void

The getUploadParam-method can be used here.

Parameters
$initArguments : null = null

Possible init arguments (are not used at the moment). Use getUploadParam-method to retrieve further information.

Tags
Return values
void

isAvailable()

This method is called to check, whether the plugin is available.

public isAvailable([CSFileUploadParam $oFileUploadParam = null ]) : bool

Pay attention this method is also called for FileConfig Request.

Parameters
$oFileUploadParam : CSFileUploadParam = null
Tags
Return values
bool

isAvailableForCurrentConfig()

Checks if the plugin should be available for the current file config.

public isAvailableForCurrentConfig(CSFileUploadParam $oUploadParam) : bool

This method is considered in the Upload Request (not FileConfig Request)

  • Upload Request is the final request with all data like UploadedFile and external Params (FileOverwrite, ....)
  • FileConfig Request is performed upon opening the CSGuiUploadFileConfigDialog

Use $this->getUploadParam()->getFileConfigDataArray() to retrieve possible data.

Parameters
$oUploadParam : CSFileUploadParam
Tags
Return values
bool

isAvailableForFileType()

Checks the plugin if the current proceed file type should be handled by this plugin.

public isAvailableForFileType(string $sFileType) : bool
Parameters
$sFileType : string
Tags
Return values
bool

onAfterHandleFiles()

Is called after all files (error and success) have been proceeded.

public onAfterHandleFiles(array<string|int, mixed> $aaoHandledFiles) : void

It can be used to delete temp folders ....

Parameters
$aaoHandledFiles : array<string|int, mixed>
Tags
Return values
void

onBeforeHandleFiles()

This method is called at first before calling: onHandleErrorFile-method, onHandleSuccessFile-method So it can be used to define global settings before calling each file by methods described above.

public onBeforeHandleFiles(array<string|int, CSUploadedCacheFile$aoUploadedFileSuccessList, array<string|int, CSUploadedCacheFile$aoUploadedFileErrorList) : void
Parameters
$aoUploadedFileSuccessList : array<string|int, CSUploadedCacheFile>

An array with CSUploadedCacheFile objects without an error Which are passed also to onHandleSuccessFile-method later on.

$aoUploadedFileErrorList : array<string|int, CSUploadedCacheFile>

An array with CSUploadedCacheFile objects with an error The error may occurred during PHP internal upload process or the move process to CS upload cache folder.

Tags
Return values
void

onHandleErrorFile()

This method is called with an error in CSUploadedCacheFile object.

public onHandleErrorFile(CSUploadedCacheFile $oUploadedFile, array<string|int, CSUploadedFileResult$aoUploadedResult) : array<string|int, CSUploadedFileResult>

A CSUploadedCacheFile object with an error. The error may occurred during PHP internal upload process or the move process to CS upload cache folder.

The isAvailableForCurrentConfig-method is not considered on calling this method

Parameters
$oUploadedFile : CSUploadedCacheFile
$aoUploadedResult : array<string|int, CSUploadedFileResult>
Tags
Return values
array<string|int, CSUploadedFileResult>

An array with CSUploadedFileResult results (you dont have to merge the array with passed parameter) Use the createUploadedResult-method to create an instance.

onHandleException()

Is called always if a plugin throws an error with throwError-method.

public onHandleException(CSUploadedFileException $oException[, CSUploadedCacheFile|null $oUploadedFile = null ][, array<string|int, CSUploadedFileResult>|null $aoUploadedResult = array() ]) : void
Parameters
$oException : CSUploadedFileException
$oUploadedFile : CSUploadedCacheFile|null = null
$aoUploadedResult : array<string|int, CSUploadedFileResult>|null = array()
Tags
Return values
void

onHandleSuccessFile()

This method is called with an $oUploadedFile object with information like: getFileName ... The file representing an file which is already stored in CS cache upload folder

public onHandleSuccessFile(CSUploadedCacheFile $oUploadedFile, array<string|int, CSUploadedFileResult$aoUploadedResult) : array<string|int, CSUploadedFileResult>

Attention: It is recommended to copy (with copyTo-method) the file and proceed with file operation like unzip...

Parameters
$oUploadedFile : CSUploadedCacheFile
$aoUploadedResult : array<string|int, CSUploadedFileResult>

An array of CSUploadedFileResult with rich information like StatusMessage: what happend to file FileName: the new file name after for example renaming It is possible to define Information what happened to the uploaded file.

Attention! The array is passed to all plugins

Tags
Return values
array<string|int, CSUploadedFileResult>

An array with CSUploadedFileResult results (you dont have to merge the array with passed parameter) Use the createUploadedResult-method to create an instance.

resetLoadedPlugins()

reset the internal plugins cache for loaded plugins

public static resetLoadedPlugins() : mixed
Tags
@return

void;

access

public

Return values
mixed

shouldCallOtherPlugins()

Defines if other plugins should be called after your plugin was called.

public shouldCallOtherPlugins() : bool
Tags
Return values
bool

throwError()

Throws an CSUploadedFileException defined for the Upload process.

public throwError(string $sMessage, int $iCode) : void

This exceptions are caught by the framework and mutating the Result object.

Parameters
$sMessage : string

A translated error message.

$iCode : int
Tags
throws
CSUploadedFileException
Return values
void

        

Search results