CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- File List
- File Members

Plugin.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: PluginManager.php
4 #
5 # Part of the ScoutLib application support library
6 # Copyright 2009-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu
8 #
9
13 abstract class Plugin {
14
15 # ----- PUBLIC INTERFACE -------------------------------------------------
16
24 abstract function Register();
25
35 function SetUpConfigOptions()
36 {
37 return NULL;
38 }
39
47 function Initialize()
48 {
49 return NULL;
50 }
51
59 function HookEvents()
60 {
61 return array();
62 }
63
71 function DeclareEvents()
72 {
73 return array();
74 }
75
82 function Install()
83 {
84 return NULL;
85 }
86
95 function Upgrade($PreviousVersion)
96 {
97 return NULL;
98 }
99
105 function Uninstall()
106 {
107 return NULL;
108 }
109
114 final function GetAttributes()
115 {
116 return array(
117 "Name" => $this->Name,
118 "Version" => $this->Version,
119 "Description" => $this->Description,
120 "Author" => $this->Author,
121 "Url" => $this->Url,
122 "Email" => $this->Email,
123 "EnabledByDefault" => $this->EnabledByDefault,
124 "Requires" => $this->Requires,
125 "CfgSetup" => $this->CfgSetup,
126 "CfgPage" => $this->CfgPage,
127 "Instructions" => $this->Instructions,
128 );
129 }
130
138 final function ConfigSetting($SettingName, $NewValue = NULL)
139 {
140 if (func_num_args() > 1)
141 {
142 if ($NewValue === NULL)
143 {
144 unset($this->Cfg[$SettingName]);
145 }
146 else
147 {
148 $this->Cfg[$SettingName] = $NewValue;
149 }
150 if (is_callable($this->CfgSaveCallback))
151 {
152 call_user_func_array($this->CfgSaveCallback,
153 array(get_class($this), $this->Cfg));
154 }
155 }
156 return isset($this->Cfg[$SettingName]) ? $this->Cfg[$SettingName] : NULL;
157 }
158
159
160 # ----- PROTECTED INTERFACE ----------------------------------------------
161
163 protected $Name = NULL;
165 protected $Version = NULL;
167 protected $Description = NULL;
169 protected $Author = NULL;
171 protected $Url = NULL;
173 protected $Email = NULL;
177 protected $Instructions = NULL;
179 protected $EnabledByDefault = FALSE;
180
188 protected $Requires = array();
189
197 protected $CfgSetup = array();
198
202 protected $CfgPage = NULL;
203
204
205 # ----- PRIVATE INTERFACE ------------------------------------------------
206
208 private $Cfg;
210 private $CfgSaveCallback;
211
217 final public function SetAllCfg($NewValues)
218 {
219 $this->Cfg = $NewValues;
220 }
229 final public function SetCfgSaveCallback($Callback)
230 {
231 $this->CfgSaveCallback = $Callback;
232 }
234 }
235
236
Plugin\Install
Install()
Perform any work needed when the plugin is first installed (for example, creating database tables)...
Definition: Plugin.php:82
Plugin\$Email
$Email
Contact email for the plugin's author.
Definition: Plugin.php:173
Plugin\Register
Register()
Set the plugin attributes.
Plugin\Upgrade
Upgrade($PreviousVersion)
Perform any work needed when the plugin is upgraded to a new version (for example, adding fields to database tables).
Definition: Plugin.php:95
Plugin\$EnabledByDefault
$EnabledByDefault
Whether the plugin should be enabled by default when installed.
Definition: Plugin.php:179
Plugin\$Version
$Version
Version number of plugin in the format X.X.X (for example: 1.2.12).
Definition: Plugin.php:165
Plugin\$Author
$Author
Name of the plugin's author.
Definition: Plugin.php:169
Plugin\HookEvents
HookEvents()
Hook methods to be called when specific events occur.
Definition: Plugin.php:59
Email
Electronic mail message.
Definition: Email.php:14
Plugin\$CfgSetup
$CfgSetup
Associative array describing the configuration values for the plugin.
Definition: Plugin.php:197
Plugin\$Requires
$Requires
Array with plugin base (class) names for the index and minimum version numbers for the values...
Definition: Plugin.php:188
Plugin\SetUpConfigOptions
SetUpConfigOptions()
Set up plugin configuration options.
Definition: Plugin.php:35
Plugin\DeclareEvents
DeclareEvents()
Declare events defined by this plugin.
Definition: Plugin.php:71
Plugin
Base class for all plugins.
Definition: Plugin.php:13
PHP
PHP
Definition: OAIClient.php:39
Plugin\GetAttributes
GetAttributes()
Retrieve plugin information.
Definition: Plugin.php:114
Plugin\$CfgPage
$CfgPage
Name of configuration page for plugin.
Definition: Plugin.php:202
Plugin\$Description
$Description
Text description of the plugin.
Definition: Plugin.php:167
Plugin\$Name
$Name
Proper (human-readable) name of plugin.
Definition: Plugin.php:163
Plugin\Initialize
Initialize()
Initialize the plugin.
Definition: Plugin.php:47
Plugin\$Url
$Url
Web address for more information about the plugin.
Definition: Plugin.php:171
Plugin\ConfigSetting
ConfigSetting($SettingName, $NewValue=NULL)
Get/set plugin configuration setting.
Definition: Plugin.php:138
Plugin\$Instructions
$Instructions
Instructions for configuring the plugin (displayed on the automatically-generated configuration page ...
Definition: Plugin.php:177
Plugin\Uninstall
Uninstall()
Perform any work needed when the plugin is uninstalled.
Definition: Plugin.php:105