Constructor. Sets $plugins_path and load events.
boolean are_events_available(
array|string
$events, [boolean
$by_one_plugin = false]
)
|
|
Check if the requested list of events is provided by any or one plugin.
Parameters:
|
array|string |
$events: |
A single event or a list thereof |
|
boolean |
$by_one_plugin: |
Make sure there's at least one plugin that provides them all? This is useful for event pairs like "CaptchaPayload" and "CaptchaValidated", which should be served by the same plugin. |
boolean call_by_code(
string
$code, [array
$params = array()]
)
|
|
Call a specific plugin by its code.
This will call the SkinTag event handler.
Parameters:
|
string |
$code: |
plugin code |
|
array |
$params: |
Associative array of parameters (gets passed to the plugin) |
NULL|mixed call_method(
integer
$plugin_ID, string
$method, array
&$params
)
|
|
Call a method on a Plugin.
This makes sure that the Timer for the Plugin gets resumed.
Parameters:
|
integer |
$plugin_ID: |
Plugin ID |
|
string |
$method: |
Method name. |
|
array |
&$params: |
Params (by reference). |
API Tags:
| Return: | Return value of the plugin's method call or NULL if no such method. |
NULL|mixed call_method_if_active(
integer
$plugin_ID, string
$method, array
&$params
)
|
|
Call a method on a Plugin if it is not deactivated.
This is a wrapper around call_method().
Parameters:
|
integer |
$plugin_ID: |
Plugin ID |
|
string |
$method: |
Method name. |
|
array |
&$params: |
Params (by reference). |
API Tags:
| Return: | Return value of the plugin's method call or NULL if no such method (or inactive). |
int count_regs(
string
$classname
)
|
|
Count # of registrations of same plugin.
Plugins with negative ID (auto-generated; not installed (yet)) will not get considered.
Parameters:
|
string |
$classname: |
class name |
API Tags:
Discover and register all available plugins.
string filter_contents(
string
&$title, string
&$content, array
$renderers
)
|
|
Filter (post) contents by calling the relevant filter plugins.
Works very much like render() except that it's called at insert/update time and BEFORE validation. Gives an opportunity to do some serious cleanup on what the user has typed.
This uses the list of renderers, because filtering may need to work in conjunction with rendering, e-g: code display: you want to filter out tags before validation and later you want to render color/fixed font. For brute force filtering, use 'always' or 'stealth' modes.
Parameters:
|
string |
&$title: |
title to render (by reference) |
|
string |
&$content: |
content to render (by reference) |
|
array |
$renderers: |
renderer codes to use for opt-out, opt-in and lazy |
API Tags:
void forget_events(
$plugin_ID
)
|
|
Forget the events a Plugin has registered.
This gets used when unregistering a Plugin or if Plugin::PluginInit() returned false, which means "do not use it for subsequent events in the request".
Parameters:
array get_apply_rendering_values(
[boolean
$with_desc = false]
)
|
|
Get the list of values for when a rendering Plugin can apply (apply_rendering).
Parameters:
|
boolean |
$with_desc: |
Return an associative array with description for the values? |
Information Tags:
Plugin|false &get_by_classname(
$classname
)
|
|
Get a plugin by its classname.
Parameters:
Plugin &get_by_code(
string
$plugin_code
)
|
|
Get a specific Plugin by its code.
Parameters:
|
string |
$plugin_code: |
plugin code |
API Tags:
| Return: | (false in case of error) |
Plugin|false &get_by_ID(
integer
$plugin_ID
)
|
|
Get a specific plugin by its ID.
This is the workhorse when it comes to lazy-instantiate a Plugin.
Parameters:
|
integer |
$plugin_ID: |
plugin ID |
array get_enabled_events(
integer
$plugin_ID
)
|
|
Get a list of (enabled) events for a given Plugin ID.
Parameters:
|
integer |
$plugin_ID: |
Plugin ID |
array get_list_by_all_events(
$events
)
|
|
Get a list of plugins that provide all given events.
Parameters:
API Tags:
| Return: | plugin_ID => & Plugin |
array get_list_by_event(
string
$event
)
|
|
Get a list of Plugins for a given event.
Parameters:
|
string |
$event: |
Event name |
API Tags:
| Return: | plugin_ID => & Plugin |
array get_list_by_events(
array
$events
)
|
|
Get a list of Plugins for a list of events. Every Plugin is only once in this list.
Parameters:
|
array |
$events: |
Array of events |
API Tags:
| Return: | plugin_ID => & Plugin |
Get next plugin in the list.
NOTE: You'll have to call restart() or load_plugins_table() before using it.
API Tags:
| Return: | (false if no more plugin). |
void get_object_from_cacheplugin_or_create(
string
$objectName, [string
$eval_create_object = NULL]
)
|
|
Load an object from a Cache plugin or create a new one if we have a cache miss or no caching plugins.
It registers a shutdown function, that refreshes the data to the cache plugin which is not optimal, but we have no hook to see if data retrieved from a DataObjectCache derived class has changed.
Parameters:
|
string |
$objectName: |
object name |
|
string |
$eval_create_object: |
eval this to create the object. Default is to create an object of class $objectName. |
array get_Plugins_in_group(
$group
)
|
|
Will return an array that contents are references to plugins that have the same group, regardless of the sub_group.
Parameters:
array get_Plugins_in_sub_group(
$group, [
$sub_group = '']
)
|
|
Will return an array that contents are references to plugins that have the same group and sub_group.
Parameters:
array get_plugin_groups(
)
|
|
Get a list of available Plugin groups.
array get_registered_events(
$Plugin
)
|
|
Get a list of methods that are supported as events out of the Plugin's source file.
Parameters:
Information Tags:
| Todo: | Extend to get list of defined classes and global functions and check this list before sourcing/including a Plugin! (prevent fatal error) |
array get_supported_events(
)
|
|
Get the list of supported/available events/hooks.
Additional to the returned event methods (which can be disabled), there are internal ones which just get called on the plugin (and get not remembered in T_pluginevents), e.g.:
- AfterInstall
- BeforeEnable
- BeforeDisable
- BeforeInstall
- BeforeUninstall
- BeforeUninstallPayload
- DisplaySkin (called on a skin from GetProvidedSkins())
- ExecCronJob
- GetDefaultSettings
- GetDefaultUserSettings
- GetExtraEvents
- GetHtsrvMethods
- PluginInit
- PluginSettingsUpdateAction (Called as action before updating the plugin's settings)
- PluginSettingsEditAction (Called as action before editing the plugin's settings)
- PluginSettingsEditDisplayAfter (Called after standard plugin settings are displayed for editing)
- PluginSettingsValidateSet (Called before setting a plugin's setting in the backoffice)
- PluginUserSettingsUpdateAction (Called as action before updating the plugin's user settings)
- PluginUserSettingsEditAction (Called as action before editing the plugin's settings)
- PluginUserSettingsEditDisplayAfter (Called after displaying normal user settings)
- PluginUserSettingsValidateSet (Called before setting a plugin's user setting in the backoffice)
- PluginVersionChanged (Called when we detect a version change)
The max length of event names is 40 chars (T_pluginevents.pevt_event).
API Tags:
| Return: | Name of event (key) => description (value) |
Information Tags:
| Todo: | Finish/Complete descriptions |
mixed get_trigger_event(
string
$event, [array
$params = NULL], [string
$get = 'data']
)
|
|
Trigger an $event and return an index of $params.
Parameters:
|
string |
$event: |
Event name, see Plugins::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
|
string |
$get: |
Index of $params that should get returned |
API Tags:
| Return: | The requested index of $params |
mixed get_trigger_event_first_return(
string
$event, [array
$params = NULL]
)
|
|
Trigger an event and return the first return value of a plugin.
Parameters:
API Tags:
| Return: | NULL if no Plugin returned something or the return value of the first Plugin |
mixed get_trigger_event_first_true(
string
$event, [array
$params = NULL], [string
$get = 'data']
)
|
|
The same as get_trigger_event(), but stop when the first Plugin returns true.
Parameters:
|
string |
$event: |
Event name, see Plugins::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
|
string |
$get: |
Index of $params that should get returned |
API Tags:
| Return: | The requested index of $params |
boolean has_event(
integer
$plugin_ID, string
$event
)
|
|
Has a plugin a specific event registered/enabled?
Parameters:
|
integer |
$plugin_ID: |
|
|
string |
$event: |
|
void init_settings(
Plugin
&$Plugin
)
|
|
Init Plugin::Settings and Plugin::UserSettings, either by unsetting them for PHP5's overloading or instantiating them for PHP4.
Parameters:
string|Plugin &install(
string
$classname, [string
$plug_status = 'enabled'], [string|NULL
$classfile_path = NULL]
)
|
|
Install a plugin into DB.
Parameters:
|
string |
$classname: |
Classname of the plugin to install |
|
string |
$plug_status: |
Initial DB Status of the plugin ("enabled", "disabled", "needs_config", "broken") |
|
string|NULL |
$classfile_path: |
Optional classfile path, if not default (used for tests). |
API Tags:
| Return: | The installed Plugin (perhaps with $install_dep_notes set) or a string in case of error. |
Plugin|false &instantiate(
$row
)
|
|
Callback, which gets used for Results.
Parameters:
(Re)load Plugin Events for enabled (normal use) or all (admin use) plugins.
Redefined in descendants as:
void load_plugins_table(
)
|
|
Load Plugins data from T_plugins (only once), ordered by priority.
This fills the needed indexes to lazy-instantiate a Plugin when requested.
Redefined in descendants as:
string quick(
string
$plugin_code, array
$params
)
|
|
Quick-render a string with a single plugin and format it for output.
Parameters:
|
string |
$plugin_code: |
Plugin code (must have render() method) |
|
array |
$params: |
'data': Data to render 'format: format to output, see format_to_output() |
API Tags:
string render(
string
&$content, array
$renderers, string
$format, array
$params, [
$event_prefix = 'Render']
)
|
|
Render the content of an item by calling the relevant renderer plugins.
Parameters:
|
string |
&$content: |
content to render (by reference) |
|
array |
$renderers: |
renderer codes to use for opt-out, opt-in and lazy |
|
string |
$format: |
Output format, see format_to_output(). Only 'htmlbody', 'entityencoded', 'xml' and 'text' are supported. |
|
array |
$params: |
Additional params to the Render* methods (e.g. "Item" for items). Do not use "data" or "format" here, because it gets used internally. |
|
|
$event_prefix: |
|
API Tags:
Load plugins table and rewind iterator used by get_next().
boolean save_events(
Plugin
$Plugin, [array|NULL
$enable_events = NULL], [array
$disable_events = NULL]
)
|
|
Save the events that the plugin provides into DB, while removing obsolete entries (that the plugin does not register anymore).
Parameters:
|
Plugin |
$Plugin: |
Plugin to save events for |
|
array|NULL |
$enable_events: |
List of events to save as enabled for the Plugin. By default all provided events get saved as enabled. Pass array() to discover only new ones. |
|
array |
$disable_events: |
List of events to save as disabled for the Plugin. By default, no events get disabled. Disabling an event takes priority over enabling. |
API Tags:
| Return: | True, if events have changed, false if not. |
boolean set_apply_rendering(
$plugin_ID,
$apply_rendering
)
|
|
Set the apply_rendering value for a given Plugin ID.
It makes sure that the index is handled and writes it to DB.
Parameters:
|
|
$plugin_ID: |
|
|
|
$apply_rendering: |
|
API Tags:
| Return: | true if set to new value, false in case of error or if already set to same value |
boolean|integer|string set_code(
string
$plugin_ID, string
$code
)
|
|
Set the code for a given Plugin ID.
It makes sure that the index is handled and writes it to DB.
Parameters:
|
string |
$plugin_ID: |
Plugin ID |
|
string |
$code: |
Code to set the plugin to |
API Tags:
| Return: | true, if already set to same value. string: error message (already in use, wrong format) - in case of setting it into DB (number of affected rows).
false, if invalid Plugin. |
boolean set_event_status(
$plugin_ID,
$plugin_event,
$enabled
)
|
|
Set the status of an event for a given Plugin.
Parameters:
|
|
$plugin_ID: |
|
|
|
$plugin_event: |
|
|
|
$enabled: |
|
API Tags:
| Return: | True, if status has changed; false if not |
void set_Plugin_status(
Plugin
&$Plugin, string
$status
)
|
|
Sets the status of a Plugin in DB and registers it into the internal indices when "enabled".
Otherwise it gets unregistered, but only when we're not in Plugins_admin, because we want to keep it in then in our indices.
{@ object, not $admin_Plugins. }}
Parameters:
|
Plugin |
&$Plugin: |
|
|
string |
$status: |
New status ("enabled", "disabled", "needs_config", "broken") |
boolean|integer set_priority(
$plugin_ID,
$priority
)
|
|
Set the priority for a given Plugin ID.
It makes sure that the index is handled and writes it to DB.
Parameters:
API Tags:
| Return: | true, if already set to same value. false if another Plugin uses that priority already. - in case of setting it into DB.
|
void sort(
[string
$order = 'priority']
)
|
|
Sort the list of $Plugins.
WARNING: do NOT sort by anything else than priority unless you're handling a list of NOT-YET-INSTALLED plugins!
Parameters:
|
string |
$order: |
Order: 'priority' (default), 'name' |
void sort_Plugin_group(
&$a_ID,
&$b_ID
)
|
|
Callback function to sort plugins by group, sub-group and name.
Those, which have a group get sorted above the ones without one.
WARNING: do NOT sort by anything else than priority unless you're handling a list of NOT-YET-INSTALLED plugins
Parameters:
void sort_Plugin_name(
&$a_ID,
&$b_ID
)
|
|
Callback function to sort plugins by name.
WARNING: do NOT sort by anything else than priority unless you're handling a list of NOT-YET-INSTALLED plugins
Parameters:
void sort_Plugin_priority(
&$a_ID,
&$b_ID
)
|
|
Callback function to sort plugins by priority (and classname, if they have same priority).
Parameters:
Stop propagation of events to next plugins in trigger_event().
array trigger_collect(
string
$event, [array
$params = NULL], [boolean
$ignore_empty = true]
)
|
|
Trigger an event and return an array of all return values of the relevant plugins.
Parameters:
|
string |
$event: |
Event name, see Plugins::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
|
boolean |
$ignore_empty: |
Ignore empty() return values? |
API Tags:
| Return: | List of return values, indexed by Plugin ID |
boolean trigger_event(
string
$event, [array
$params = NULL]
)
|
|
Call all plugins for a given event.
Parameters:
|
string |
$event: |
event name, see Plugin::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
API Tags:
| Return: | True, if at least one plugin has been called. |
array trigger_event_first_false(
string
$event, [array
$params = NULL]
)
|
|
Call all plugins for a given event, until the first one returns false.
Parameters:
|
string |
$event: |
event name, see Plugin::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
API Tags:
| Return: | The (modified) params array with key "plugin_ID" set to the last called plugin; Empty array if no Plugin returned true or no Plugin has this event registered. |
array trigger_event_first_return(
string
$event, [array|NULL
$params = NULL], [array|NULL
$search = NULL]
)
|
|
Call all plugins for a given event, until the first one returns a value (not NULL) (and $search is fulfilled, if given).
Parameters:
|
string |
$event: |
event name, see Plugin::get_supported_events() |
|
array|NULL |
$params: |
Associative array of parameters for the Plugin |
|
array|NULL |
$search: |
If provided, the return value gets checks against this criteria. Can be: - ( 'in_array' => 'needle' )
|
API Tags:
| Return: | The (modified) params array with key "plugin_ID" set to the last called plugin and 'plugin_return' set to the return value; Empty array if no Plugin returned true or no Plugin has this event registered. |
array trigger_event_first_true(
string
$event, [array
$params = NULL]
)
|
|
Call all plugins for a given event, until the first one returns true.
Parameters:
|
string |
$event: |
event name, see Plugin::get_supported_events() |
|
array |
$params: |
Associative array of parameters for the Plugin |
API Tags:
| Return: | The (modified) params array with key "plugin_ID" set to the last called plugin; Empty array if no Plugin returned true or no Plugin has this event registered. |
integer|NULL trigger_karma_collect(
string
$event, array
$params
)
|
|
Trigger a karma collecting event in order to get Karma percentage.
Parameters:
|
string |
$event: |
Event |
|
array |
$params: |
Params to the event |
API Tags:
| Return: | Spam Karma (-100 - 100); "100" means "absolutely spam"; NULL if no plugin gave us a karma value |
string unfilter_contents(
string
&$title, string
&$content, array
$renderers
)
|
|
UnFilter (post) contents by calling the relevant filter plugins.
This is the opposite of filter_content. It is used to restore some specifcs before editing text. For example, this can be used to replace complex sequences of tags with a custome meta-tag, e-g: <strong> can become <s> for convenient editing.
This uses the list of renderers, because un/filtering may need to work in conjunction with rendering, e-g: code display: you want to filter in/out tags before validation and later you want to render color/fixed font. For brute force unfiltering, use 'always' or 'stealth' modes.
Parameters:
|
string |
&$title: |
title to render (by reference) |
|
string |
&$content: |
content to render (by reference) |
|
array |
$renderers: |
renderer codes to use for opt-out, opt-in and lazy |
API Tags:
Information Tags:
| Todo: | fp> it would probably make sense to do the unfiltering in reverse order compared to filtering |
boolean uninstall(
$plugin_ID
)
|
|
Uninstall a plugin.
Removes the Plugin, its Settings and Events from the database.
Parameters:
API Tags:
void unregister(
&$Plugin
)
|
|
Un-register a plugin.
This does not un-install it from DB, just from the internal indexes.
Parameters:
array validate_dependencies(
Plugin
&$Plugin, string
$mode
)
|
|
Validate dependencies of a Plugin.
Parameters:
|
Plugin |
&$Plugin: |
|
|
string |
$mode: |
Mode of check: either 'enable' or 'disable' |
API Tags:
| Return: | The key 'note' holds an array of notes (recommendations), the key 'error' holds a list of messages for dependency errors. |
array validate_list(
[array
$renderers = array('default')]
)
|
|
Validate renderer list.
Parameters:
|
array |
$renderers: |
renderer codes ('default' will include all "opt-out"-ones) |
API Tags:
| Return: | validated array of renderer codes |