Class: Plugins_admin
Source Location: /qp_inc/plugins/model/_plugins_admin.class.php
Class Plugins_admin
Class Overview
|
A Plugins object that loads all Plugins, not just the enabled ones.
This is needed for the backoffice plugin management. This extends the basic Plugins by adding all the functionnality needed for administering plugins in addition to just using the already enabled plugins.
Located in /qp_inc/plugins/model/_plugins_admin.class.php [line 40]
Plugins
|
--Plugins_admin
|
Properties
|
Methods
|
Inherited Properties, Constants, and Methods
Method Summary
| int|array |
count_regs() |
Count # of registrations of same plugin. Optionally returns the sequence number to be used for the next instance of a plugin as well. |
| void |
discover() |
Discover and register all available plugins in the $plugins_path folder/subfolders. |
| string |
filter_contents() |
Filter (post) contents by calling the relevant filter plugins. |
| array |
get_apply_rendering_values() |
Get the list of all possible values for apply_rendering (defines when a rendering Plugin can apply). |
| void |
load_events() |
(Re)load Plugin Events for enabled (normal use) or all (admin use) plugins. |
| boolean |
save_events() |
Save the events that the plugin provides into DB, while removing obsolete entries (that the plugin does not register anymore). |
| boolean|integer|string |
set_code() |
Set the code for a given Plugin ID. |
| boolean|integer |
set_priority() |
Set the priority for a given Plugin ID. |
| void |
sort() |
Sort the list of plugins. |
| void |
sort_Plugin_group() |
Callback function to sort plugins by group, sub-group and name. |
| void |
sort_Plugin_priority() |
Callback function to sort plugins by priority (and classname, if they have same priority). |
| string |
unfilter_contents() |
UnFilter (post) contents by calling the relevant filter plugins. |
| boolean |
unregister() |
Un-register a plugin, only if forced. |
Methods
int|array count_regs(
string
$classname, [boolean
$get_seq_number = false]
)
|
|
Count # of registrations of same plugin. Optionally returns the sequence number to be used for the next instance of a plugin as well.
Plugins with negative ID (auto-generated; not installed (yet)) will not get considered.
Parameters:
|
string |
$classname: |
class name |
|
boolean |
$get_seq_number: |
Return next sequence number as well (will be 1 if there are no other instances of this plugin). |
API Tags:
| Return: | # of regs or array( $regs, $next_seq_number ) if $get_seq_number is true |
Discover and register all available plugins in the $plugins_path folder/subfolders.
string filter_contents(
string
&$title, array
&$content,
$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 lost 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: |
content to render (by reference) |
|
array |
&$content: |
renderer codes to use for opt-out, opt-in and lazy |
|
|
$renderers: |
|
API Tags:
array get_apply_rendering_values(
[boolean
$with_desc = false]
)
|
|
Get the list of all possible values for apply_rendering (defines when a rendering Plugin can apply).
Parameters:
|
boolean |
$with_desc: |
Return an associative array with description for the values? |
Information Tags:
array get_registered_events(
$Plugin
)
|
|
Discover plugin events from its source file.
Get a list of methods that are supported as events out of the Plugin's class definition.
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 all events/hooks supported by the plugin framework.
Also puts in additional events provided by plugins. fp> please provide an example/use case 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
- DisplayTemplate (called on a template from GetProvidedTemplates())
- ExecCronJob
- GetDefaultSettings
- GetDefaultUserSettings
- GetExtraEvents
- GetSrvcMethods
- 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)
- 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) |
Plugin &install(
string
$classname, [string
$plug_status = 'enabled'], [string
$classfile_path = NULL]
)
|
|
Install a plugin into DB.
NOTE: this won't install necessary DB changes and not trigger Plugin::AfterInstall!
Parameters:
|
string |
$classname: |
Classname of the plugin to install |
|
string |
$plug_status: |
Initial DB Status of the plugin ("enabled", "disabled", "needs_config", "broken") |
|
string |
$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. |
(Re)load Plugin Events for enabled (normal use) or all (admin use) plugins.
This is the same as Plugins::load_events() except that it loads all Plugins (not just enabled ones)
Redefinition of:
- Plugins::load_events()
- (Re)load Plugin Events for enabled (normal use) or all (admin use) plugins.
Redefined in descendants as:
boolean save_events(
Plugin
$Plugin, [array
$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 |
$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 |
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:
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:
boolean unregister(
Plugin
&$Plugin, [boolean
$force = false]
)
|
|
Un-register a plugin, only if forced.
This does not un-install it from DB, just from the internal indexes.
Parameters:
|
Plugin |
&$Plugin: |
|
|
boolean |
$force: |
Force unregistering |
API Tags:
| Return: | True, if unregistered |
Redefinition of:
- Plugins::unregister()
- Un-register a plugin.
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. |
|
|