CSOptionsPlugin
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.
To define a new plugin, this class should be inherited in a file placed within a plugins directory. Those plugin folders can be placed in all licensed modules, extensions and the admin/core, admin.local and project folders. It must be in a relative subdirectory defined with the PluginPath Since 5.1.2 all plugins support subfolders which name describes the module where the plugin should work within. If used, this improves performance as only the plugins from a module and not from all modules must be loaded and called. If given, a Plugin must succeed the FileNamePattern syntax.
Example: A CSGuiListPlugin should be placed e.g. in the folder plugins/gui with a FileName ending with List.php. A defined plugin is used for all lists in all modules, if it is placed directly in this folder. If it is placed in plugins/gui/pdm the plugin is only loaded and called, when displaying components within the pdm module.
If the PluginPath points to a single file, the plugin defined within this file is returned. Otherwise the directory is searched for matching plugins. For the plugin concept there is the following naming convention: The objects defined in the file XYZ.php must have the class name XYZ.
The order in which the plugins are returned is defined by the getLevel method. This method is called for sorting and the objects are returned in descending order (highest value first).
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
- The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.
- addAlternativePluginFolder() : void
- A path to a specific folder in which should be search for plugins.
- addOption() : void
- Adds an option to the option editor
- addOptions() : void
- This method is called to define options using the utility methods.
- getAlternativePluginFolder() : array<string|int, mixed>
- 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.
- getLocalOptions() : array<string|int, mixed>
- Returns an array of all options which are stored in each CONTENTSERV installation seperately.
- 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
- 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.
- init() : mixed
- isAvailable() : bool
- This method is called to check, whether the plugin is available.
- onGetLocalOption() : string
- Called when a local option is requested. Can be used to transform option values on the fly.
- onGetOption() : string
- Called when an option is requested. Can be used to transform option values on the fly.
- onSetLocalOption() : string
- Gets called when a local option value is about to be set. The value can be manipulated by returning a new value. Local values are stored in the file system to be accessible without database.
- onSetOption() : string
- Gets called when an option value is about to be set. The value can be manipulated by returning a new value.
- optionsStored() : mixed
- This function is called whenever the options are stored.
- prepareOptionsStorageFromEditor() : array<string|int, mixed>
- This method is called when a user saved the options dialog in CONTENTSERV.
- resetLoadedPlugins() : mixed
- reset the internal plugins cache for loaded plugins
- setExpander() : void
- Sets the expander and tree pane for the current plugin for all options beeing defined after this method call.
- setSubTreePane() : void
- Sets the tree pane for the current plugin relative to the product name for all options beeing defined after this method call.
- setTreePane() : void
- Sets the tree pane for the current plugin for all options beeing defined after this method call.
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()
The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.
public
_construct() : void
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 —addOption()
Adds an option to the option editor
public
addOption(string $name, string $label, string $description[, string $type = '' ][, string $default = '' ][, array<string|int, mixed> $additionalOptions = array() ]) : void
Parameters
- $name : string
-
the name of the field
- $label : string
-
the label of the field
- $description : string
-
the description of the field
- $type : string = ''
-
the type of the field as documented at
- $default : string = ''
-
the default value of this field
- $additionalOptions : array<string|int, mixed> = array()
-
further option as documented at
Tags
Return values
void —addOptions()
This method is called to define options using the utility methods.
public
addOptions() : void
It should be overwritten in the plugin
Tags
Return values
void —getAlternativePluginFolder()
public
static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —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
getLocalOptions()
Returns an array of all options which are stored in each CONTENTSERV installation seperately.
public
getLocalOptions() : array<string|int, mixed>
If a backup is installed those options are not overwritten for the Server. Internally those Options are stored in PROJECT/data/options.php. If this Options file is missing the Options are restored from the Database It should be overwritten in a OptionsPlugin implementation, if required
Tags
Return values
array<string|int, mixed> —of server options as values in the form "MODULE:OPTIONNAME" OR "OPTIONNAME" if the "MODULE" is the Plugins module, e.g. array("mam:CatalogingFolder")
getMetaData()
Returns the CSMetaData of the current plugin.
public
getMetaData() : CSMetaData
Tags
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 —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
init()
public
init() : mixed
Tags
Return values
mixed —isAvailable()
This method is called to check, whether the plugin is available.
public
isAvailable() : bool
If further arguments are added to the CSPlugin::getPlugins call, they are added as arguments to this method.
For simpler usage of the plugin concept: This method should be overwritten with the correct signature for a plugin call, if arguments are passed.
Tags
Return values
bool —whether the plugin is available for the given arguments
onGetLocalOption()
Called when a local option is requested. Can be used to transform option values on the fly.
public
onGetLocalOption(string $sName, string $sValue) : string
Parameters
- $sName : string
-
The name of the requested local option.
- $sValue : string
-
The value of the requested local option that will be returned unless it gets changed by the return value of this method.
Tags
Return values
string —If other than null, it will be used as new value for the local option. The old one will be discarded.
onGetOption()
Called when an option is requested. Can be used to transform option values on the fly.
public
onGetOption(string $sName, string $sValue) : string
Parameters
- $sName : string
-
The name of the requested option.
- $sValue : string
-
The value of the requested option that will be returned unless it gets changed by the return value of this method.
Tags
Return values
string —If other than null, it will be used as new value for the option. The old one will be discarded.
onSetLocalOption()
Gets called when a local option value is about to be set. The value can be manipulated by returning a new value. Local values are stored in the file system to be accessible without database.
public
onSetLocalOption(string $sName, string $sValue, bool $bPermanent) : string
Parameters
- $sName : string
-
The name of the local option that is about to be set.
- $sValue : string
-
The value that will be written to the local option.
- $bPermanent : bool
-
If true, the value is about to be stored permanently (database and file for local options), else it is only set temporary (for current request)
Tags
Return values
string —If other than null, it will be used as new value for the local option. The old one will be discarded.
onSetOption()
Gets called when an option value is about to be set. The value can be manipulated by returning a new value.
public
onSetOption(string $sName, string $sValue, bool $bPermanent) : string
Parameters
- $sName : string
-
The name of the option that is about to be set.
- $sValue : string
-
The value that will be written to the option.
- $bPermanent : bool
-
If true, the value is about to be stored permanently (database and file for local options), else it is only set temporary (for current request)
Tags
Return values
string —If other than null, it will be used as new value for the option. The old one will be discarded.
optionsStored()
This function is called whenever the options are stored.
public
optionsStored() : mixed
You may use this opportunity to handle some custom actions, like storing options in text files, etc.
Tags
Return values
mixed —prepareOptionsStorageFromEditor()
This method is called when a user saved the options dialog in CONTENTSERV.
public
prepareOptionsStorageFromEditor(array<string|int, mixed> $aValues) : array<string|int, mixed>
At this point it is possible to manipulate the options-array to alter/remove particular options.
Parameters
- $aValues : array<string|int, mixed>
-
The options as key/value pairs.
Tags
Return values
array<string|int, mixed> —The final options array that should be stored inside the database.
resetLoadedPlugins()
reset the internal plugins cache for loaded plugins
public
static resetLoadedPlugins() : mixed
Tags
Return values
mixed —setExpander()
Sets the expander and tree pane for the current plugin for all options beeing defined after this method call.
public
setExpander(string $expander[, string $treePane = null ]) : void
Parameters
- $expander : string
-
the expander the options should be visible in
- $treePane : string = null
-
the tree slidepane the options should be visible in
Tags
Return values
void —setSubTreePane()
Sets the tree pane for the current plugin relative to the product name for all options beeing defined after this method call.
public
setSubTreePane(string $treePane[, string $expander = '' ][, string $productName = '' ]) : void
Parameters
- $treePane : string
-
the tree slidepane the options should be visible in
- $expander : string = ''
-
the expander the options should be visible in
- $productName : string = ''
-
the optional product name
Tags
Return values
void —setTreePane()
Sets the tree pane for the current plugin for all options beeing defined after this method call.
public
setTreePane(string $treePane[, string $expander = '' ]) : void
Parameters
- $treePane : string
-
the tree slidepane the options should be visible in
- $expander : string = ''
-
the expander the options should be visible in
