3 # FILE: PluginManager.php
5 # Part of the ScoutLib application support library
6 # Copyright 2009-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu
15 # ----- PUBLIC INTERFACE -------------------------------------------------
119 "Author" => $this->Author,
120 "CfgPage" => $this->CfgPage,
121 "CfgSetup" => $this->CfgSetup,
122 "Description" => $this->Description,
123 "Email" => $this->
Email,
124 "EnabledByDefault" => $this->EnabledByDefault,
125 "InitializeAfter" => is_array($this->InitializeAfter)
126 ? $this->InitializeAfter : array($this->InitializeAfter),
127 "InitializeBefore" => is_array($this->InitializeBefore)
128 ? $this->InitializeBefore : array($this->InitializeBefore),
129 "Instructions" => $this->Instructions,
130 "Name" => $this->Name,
131 "Requires" => $this->Requires,
133 "Version" => $this->Version,
146 # if a new value was supplied for the setting
147 if (func_num_args() > 1)
149 # if this setting has a filter function specified
150 if (array_key_exists($SettingName, $this->CfgSetup)
151 && array_key_exists(
"SettingFilter",
152 $this->CfgSetup[$SettingName]))
154 # pass new value through filter function
155 $FilterMethod = $this->CfgSetup[$SettingName][
"SettingFilter"];
156 $NewValue = $this->$FilterMethod($SettingName, $NewValue);
159 # if caller requested that setting be cleared
160 if ($NewValue === NULL)
163 unset($this->Cfg[$SettingName]);
167 # save new value for setting
168 $this->Cfg[$SettingName] = $NewValue;
171 # if we have a way of saving configuration settings
172 if (is_callable($this->CfgSaveCallback))
174 # save new configuration settings
175 call_user_func_array($this->CfgSaveCallback,
176 array(get_class($this), $this->Cfg));
180 # return current value of setting to caller
181 return isset($this->Cfg[$SettingName]) ? $this->Cfg[$SettingName] : NULL;
185 # ----- PROTECTED INTERFACE ----------------------------------------------
234 # ----- PRIVATE INTERFACE ------------------------------------------------
239 private $CfgSaveCallback;
246 final public function SetAllCfg($NewValues)
248 $this->Cfg = $NewValues;
258 final public function SetCfgSaveCallback($Callback)
260 $this->CfgSaveCallback = $Callback;
Install()
Perform any work needed when the plugin is first installed (for example, creating database tables)...
$InitializeAfter
Plugins that should be initialized before us.
$Email
Contact email for the plugin's author.
Register()
Set the plugin attributes.
Upgrade($PreviousVersion)
Perform any work needed when the plugin is upgraded to a new version (for example, adding fields to database tables).
$EnabledByDefault
Whether the plugin should be enabled by default when installed.
$Version
Version number of plugin in the format X.X.X (for example: 1.2.12).
$Author
Name of the plugin's author.
$InitializeBefore
Plugins that should be initialized after us.
HookEvents()
Hook methods to be called when specific events occur.
$CfgSetup
Associative array describing the configuration values for the plugin.
$Requires
Array with plugin base (class) names for the index and minimum version numbers for the values...
SetUpConfigOptions()
Set up plugin configuration options.
DeclareEvents()
Declare events defined by this plugin.
Base class for all plugins.
GetAttributes()
Retrieve plugin information.
$CfgPage
Name of configuration page for plugin.
$Description
Text description of the plugin.
$Name
Proper (human-readable) name of plugin.
Initialize()
Initialize the plugin.
$Url
Web address for more information about the plugin.
ConfigSetting($SettingName, $NewValue=NULL)
Get/set plugin configuration setting.
$Instructions
Instructions for configuring the plugin (displayed on the automatically-generated configuration page ...
Uninstall()
Perform any work needed when the plugin is uninstalled.