Contentserv PHP API

CSRecordPlugin 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.
getActions()  : array<string|int, mixed>
Adds some actions (in form of popups or buttons[editor]) similar to the tree, list and editor
getAdditionalData()  : array<string|int, mixed>
Adds some more fields to a record data section. If it is not defined for additional format, the CONTENTSERV default values 0 and '' are used
getAdditionalFormat()  : array<string|int, mixed>
Adds some more fields to a record format section.
getAdditionalSearchableFields()  : array<string|int, mixed>
Adds additional Searchable fields to a record section.
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.
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.
importValue()  : bool
Imports a value into the given record It can be used if additional colums should be imported or prepared before importing them
isAvailable()  : bool
This method is called to check, whether the plugin is available.
resetLoadedPlugins()  : mixed
reset the internal plugins cache for loaded plugins
updateCSVFromExportData()  : array<string|int, mixed>
Prepares the csv export data for a CSV Export.

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

getActions()

Adds some actions (in form of popups or buttons[editor]) similar to the tree, list and editor

public getActions(Record $record, string $type) : array<string|int, mixed>
Parameters
$record : Record

The record for which the actions should be returned

$type : string

The type of the request ('list', 'tree', 'editor') to be able to add the action only to specific components

Tags
Return values
array<string|int, mixed>

an array containing the each action as own array in the form: array(name => array(icon, label, phpCode, menuName, javascript, popupIndex, groupIdentifier, groupIndex))

Where:

  • name => is the unique identifier name of the action
  • icon => is the icon relative to the admin/images directory
  • label => is the label of the label of the action
  • phpCode => The phpCode which should be executed, if the action is selected where the current Record could be accessed using $record
  • menuName => The name of the menubar in the editor
  • javascript => javascript which is executed before the action is applied. The action can be cancelled using "return 'CANCEL';". Otherwise the return value is appended to the request
  • popupIndex => The index in a popup (0=top, null=end)
  • groupIdentifier => The identifier to add the popup item to a group, which has separator at the beginning and at the end.
  • groupIndex => The index of the group. The index will be used to order the groups. The lowest index will be taken of all popup items inside of a group. Example: return array( 'test' => array( 'add.gif', 'Test', 'alert("test ok");', 'MENU_FILE', 'if (!confirm("really?")) return "CANCEL";', null, CSGuiPopup::GROUP_IDENTIFIER_, CSGuiPopup::GROUP_INDEX_ ) );

getAdditionalData()

Adds some more fields to a record data section. If it is not defined for additional format, the CONTENTSERV default values 0 and '' are used

public getAdditionalData(string $className) : array<string|int, mixed>
Parameters
$className : string

the name of the record where fields should be added to

Tags
Return values
array<string|int, mixed>

the additional data in the form name => value

getAdditionalFormat()

Adds some more fields to a record format section.

public getAdditionalFormat(string $className) : array<string|int, mixed>
Parameters
$className : string

the name of the record where fields should be added to

Tags
Return values
array<string|int, mixed>

the additional formats in the form name => databaseformat

getAdditionalSearchableFields()

Adds additional Searchable fields to a record section.

public getAdditionalSearchableFields(string $sClassName) : array<string|int, mixed>
Parameters
$sClassName : string

the name of the record where fields should be added to

Tags
Return values
array<string|int, mixed>

the additional fields to add to the search

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

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

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

importValue()

Imports a value into the given record It can be used if additional colums should be imported or prepared before importing them

public importValue(Record $record, string $key, string $value, array<string|int, mixed> $dataArray) : bool
Parameters
$record : Record

the record where the value should be imported to

$key : string

the key of the value which should be imported

$value : string

the new value which should be imported

$dataArray : array<string|int, mixed>

all values which should be imported to the Record

Tags
Return values
bool

whether the value had been imported and no other import should be called

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

resetLoadedPlugins()

reset the internal plugins cache for loaded plugins

public static resetLoadedPlugins() : mixed
Tags
@return

void;

access

public

Return values
mixed

updateCSVFromExportData()

Prepares the csv export data for a CSV Export.

public updateCSVFromExportData(array<string|int, mixed> $csv, array<string|int, mixed> $exportData, array<string|int, mixed> $fields, mixed $record) : array<string|int, mixed>

It can be used, if additional columns should be added or some should be removed in the CSV Export

Parameters
$csv : array<string|int, mixed>

the array containing the prepared CSV data in the form [COLUMN] => [VALUE]

$exportData : array<string|int, mixed>

the array containing the real data

$fields : array<string|int, mixed>

the fields which should be exported

$record : mixed
Tags
Return values
array<string|int, mixed>

the new csv data array


        

Search results