CWIS Developer Documentation
PluginManager.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 
14 
15  # ---- PUBLIC INTERFACE --------------------------------------------------
16 
24  function __construct($AppFramework, $PluginDirectories)
25  {
26  # save framework and directory list for later use
27  $this->AF = $AppFramework;
28  $this->DirsToSearch = $PluginDirectories;
29 
30  # get our own database handle
31  $this->DB = new Database();
32 
33  # hook into events to load plugin PHP and HTML files
34  $this->AF->HookEvent("EVENT_PHP_FILE_LOAD", array($this, "FindPluginPhpFile"),
36  $this->AF->HookEvent("EVENT_HTML_FILE_LOAD", array($this, "FindPluginHtmlFile"),
38 
39  # tell PluginCaller helper object how to get to us
40  PluginCaller::$Manager = $this;
41  }
42 
53  function LoadPlugins($ForcePluginConfigOptLoad = FALSE)
54  {
55  # clear any existing errors
56  $this->ErrMsgs = array();
57 
58  # load list of all base plugin files
59  $this->FindPlugins($this->DirsToSearch);
60 
61  # for each plugin found
62  foreach ($this->PluginNames as $PluginName)
63  {
64  # bring in plugin class file
65  include_once($this->PluginFiles[$PluginName]);
66 
67  # if plugin class was defined by file
68  if (class_exists($PluginName))
69  {
70  # if plugin class is a valid descendant of base plugin class
71  $Plugin = new $PluginName;
72  if (is_subclass_of($Plugin, "Plugin"))
73  {
74  # set hooks needed for plugin to access plugin manager services
75  $Plugin->SetCfgSaveCallback(array(__CLASS__, "CfgSaveCallback"));
76 
77  # register the plugin
78  $this->Plugins[$PluginName] = $Plugin;
79  $this->PluginEnabled[$PluginName] = TRUE;
80  $this->Plugins[$PluginName]->Register();
81 
82  # check required plugin attributes
83  $Attribs[$PluginName] = $this->Plugins[$PluginName]->GetAttributes();
84  if (!strlen($Attribs[$PluginName]["Name"]))
85  {
86  $this->ErrMsgs[$PluginName][] = "Plugin <b>".$PluginName."</b>"
87  ." could not be loaded because it"
88  ." did not have a <i>Name</i> attribute set.";
89  unset($this->PluginEnabled[$PluginName]);
90  unset($this->Plugins[$PluginName]);
91  }
92  if (!strlen($Attribs[$PluginName]["Version"]))
93  {
94  $this->ErrMsgs[$PluginName][] = "Plugin <b>".$PluginName."</b>"
95  ." could not be loaded because it"
96  ." did not have a <i>Version</i> attribute set.";
97  unset($this->PluginEnabled[$PluginName]);
98  unset($this->Plugins[$PluginName]);
99  }
100  }
101  else
102  {
103  $this->ErrMsgs[$PluginName][] = "Plugin <b>".$PluginName."</b>"
104  ." could not be loaded because <i>".$PluginName."</i> was"
105  ." not a subclass of base <i>Plugin</i> class";
106  }
107  }
108  else
109  {
110  $this->ErrMsgs[$PluginName][] = "Expected class <i>".$PluginName
111  ."</i> not found in plugin file <i>"
112  .$this->PluginFiles[$PluginName]."</i>";
113  }
114  }
115 
116  # check plugin dependencies
117  $this->CheckDependencies();
118 
119  # load plugin configurations
120  $this->DB->Query("SELECT BaseName,Cfg FROM PluginInfo");
121  $Cfgs = $this->DB->FetchColumn("Cfg", "BaseName");
122 
123  # for each plugin
124  foreach ($this->Plugins as $PluginName => $Plugin)
125  {
126  # if plugin is enabled
127  if ($this->PluginEnabled[$PluginName])
128  {
129  # if plugin has its own subdirectory
130  if ($this->PluginHasDir[$PluginName])
131  {
132  # if plugin has its own object directory
133  $Dir = dirname($this->PluginFiles[$PluginName]);
134  if (is_dir($Dir."/objects"))
135  {
136  # add object directory to class autoloading list
138  }
139  else
140  {
141  # add plugin directory to class autoloading list
143  }
144  }
145 
146  # set configuration values if available
147  if (isset($Cfgs[$PluginName]))
148  {
149  $Plugin->SetAllCfg(unserialize($Cfgs[$PluginName]));
150  }
151 
152  # install or upgrade plugins if needed
153  $this->InstallPlugin($Plugin);
154  }
155  }
156 
157  # check plugin dependencies again in case an install or upgrade failed
158  $this->CheckDependencies();
159 
160  # set up plugin configuration options
161  foreach ($this->Plugins as $PluginName => $Plugin)
162  {
163  if ($ForcePluginConfigOptLoad || $this->PluginEnabled[$PluginName])
164  {
165  $ErrMsg = $Plugin->SetUpConfigOptions();
166  if ($ErrMsg !== NULL)
167  {
168  $this->ErrMsgs[$PluginName][] = "Configuration option setup"
169  ." failed for plugin <b>".$PluginName."</b>: <i>"
170  .$ErrMsg."</i>";
171  $this->PluginEnabled[$PluginName] = FALSE;
172  }
173  }
174  }
175 
176  # initialize enabled plugins
177  foreach ($this->Plugins as $PluginName => $Plugin)
178  {
179  if ($this->PluginEnabled[$PluginName])
180  {
181  $ErrMsg = $Plugin->Initialize();
182  if ($ErrMsg !== NULL)
183  {
184  $this->ErrMsgs[$PluginName][] = "Initialization failed for"
185  ." plugin <b>".$PluginName."</b>: <i>".$ErrMsg."</i>";
186  $this->PluginEnabled[$PluginName] = FALSE;
187  }
188  }
189  }
190 
191  # register any events declared by enabled plugins
192  foreach ($this->Plugins as $PluginName => $Plugin)
193  {
194  if ($this->PluginEnabled[$PluginName])
195  {
196  $Events = $Plugin->DeclareEvents();
197  if (count($Events)) { $this->AF->RegisterEvent($Events); }
198  }
199  }
200 
201  # hook enabled plugins to events
202  foreach ($this->Plugins as $PluginName => $Plugin)
203  {
204  if ($this->PluginEnabled[$PluginName])
205  {
206  $EventsToHook = $Plugin->HookEvents();
207  if (count($EventsToHook))
208  {
209  foreach ($EventsToHook as $EventName => $PluginMethods)
210  {
211  if (!is_array($PluginMethods))
212  { $PluginMethods = array($PluginMethods); }
213 
214  foreach ($PluginMethods as $PluginMethod)
215  {
216  if ($this->AF->IsStaticOnlyEvent($EventName))
217  {
218  $Caller = new PluginCaller($PluginName, $PluginMethod);
219  $Result = $this->AF->HookEvent(
220  $EventName, array($Caller, "CallPluginMethod"));
221  }
222  else
223  {
224  $Result = $this->AF->HookEvent(
225  $EventName, array($Plugin, $PluginMethod));
226  }
227  if ($Result === FALSE)
228  {
229  $this->ErrMsgs[$PluginName][] =
230  "Unable to hook requested event <i>"
231  .$EventName."</i> for plugin <b>"
232  .$PluginName."</b>";
233  }
234  }
235  }
236  }
237  }
238  }
239 
240  # report to caller whether any problems were encountered
241  return count($this->ErrMsgs) ? FALSE : TRUE;
242  }
243 
249  function GetErrorMessages()
250  {
251  return $this->ErrMsgs;
252  }
253 
259  function GetPlugin($PluginName)
260  {
261  return isset($this->Plugins[$PluginName])
262  ? $this->Plugins[$PluginName] : NULL;
263  }
264 
273  {
274  return $this->GetPlugin($this->PageFilePlugin);
275  }
276 
282  {
283  $Info = array();
284  foreach ($this->Plugins as $PluginName => $Plugin)
285  {
286  $Info[$PluginName] = $Plugin->GetAttributes();
287  $Info[$PluginName]["Enabled"] =
288  isset($this->PluginInfo[$PluginName]["Enabled"])
289  ? $this->PluginInfo[$PluginName]["Enabled"] : FALSE;
290  $Info[$PluginName]["Installed"] =
291  isset($this->PluginInfo[$PluginName]["Installed"])
292  ? $this->PluginInfo[$PluginName]["Installed"] : FALSE;
293  $Info[$PluginName]["ClassFile"] = $this->PluginFiles[$PluginName];
294  }
295  return $Info;
296  }
297 
303  function GetDependents($PluginName)
304  {
305  $Dependents = array();
306  $AllAttribs = $this->GetPluginAttributes();
307  foreach ($AllAttribs as $Name => $Attribs)
308  {
309  if (array_key_exists($PluginName, $Attribs["Requires"]))
310  {
311  $Dependents[] = $Name;
312  $SubDependents = $this->GetDependents($Name);
313  $Dependents = array_merge($Dependents, $SubDependents);
314  }
315  }
316  return $Dependents;
317  }
318 
324  {
325  return array_keys($this->PluginEnabled, 1);
326  }
327 
334  function PluginEnabled($PluginName, $NewValue = NULL)
335  {
336  if ($NewValue !== NULL)
337  {
338  $this->DB->Query("UPDATE PluginInfo"
339  ." SET Enabled = ".($NewValue ? "1" : "0")
340  ." WHERE BaseName = '".addslashes($PluginName)."'");
341  $this->PluginEnabled[$PluginName] = $NewValue;
342  $this->PluginInfo[$PluginName]["Enabled"] = $NewValue;
343  }
344  return array_key_exists($PluginName, $this->PluginEnabled)
345  && $this->PluginEnabled[$PluginName];
346  }
347 
353  function UninstallPlugin($PluginName)
354  {
355  # assume success
356  $Result = NULL;
357 
358  # if plugin is installed
359  if ($this->PluginInfo[$PluginName]["Installed"])
360  {
361  # call uninstall method for plugin
362  $Result = $this->Plugins[$PluginName]->Uninstall();
363 
364  # if plugin uninstall method succeeded
365  if ($Result === NULL)
366  {
367  # remove plugin info from database
368  $this->DB->Query("DELETE FROM PluginInfo"
369  ." WHERE BaseName = '".addslashes($PluginName)."'");
370 
371  # drop our data for the plugin
372  unset($this->Plugins[$PluginName]);
373  unset($this->PluginInfo[$PluginName]);
374  unset($this->PluginEnabled[$PluginName]);
375  unset($this->PluginNames[$PluginName]);
376  unset($this->PluginFiles[$PluginName]);
377  }
378  }
379 
380  # report results (if any) to caller
381  return $Result;
382  }
383 
384 
385  # ---- PRIVATE INTERFACE -------------------------------------------------
386 
387  private $Plugins = array();
388  private $PluginFiles = array();
389  private $PluginNames = array();
390  private $PluginHasDir = array();
391  private $PluginInfo = array();
392  private $PluginEnabled = array();
393  private $PageFilePlugin = NULL;
394  private $AF;
395  private $DirsToSearch;
396  private $ErrMsgs = array();
397  private $DB;
398 
404  private function FindPlugins($DirsToSearch)
405  {
406  # for each directory
407  foreach ($DirsToSearch as $Dir)
408  {
409  # if directory exists
410  if (is_dir($Dir))
411  {
412  # for each file in directory
413  $FileNames = scandir($Dir);
414  foreach ($FileNames as $FileName)
415  {
416  # if file looks like base plugin file
417  if (preg_match("/^[a-zA-Z_][a-zA-Z0-9_]*\.php$/", $FileName))
418  {
419  # add file to list
420  $PluginName = preg_replace("/\.php$/", "", $FileName);
421  $this->PluginNames[$PluginName] = $PluginName;
422  $this->PluginFiles[$PluginName] = $Dir."/".$FileName;
423  $this->PluginHasDir[$PluginName] = FALSE;
424  }
425  # else if file looks like plugin directory
426  elseif (is_dir($Dir."/".$FileName)
427  && preg_match("/^[a-zA-Z_][a-zA-Z0-9_]*/", $FileName))
428  {
429  # if there is a base plugin file in the directory
430  $PluginName = $FileName;
431  $PluginFile = $Dir."/".$PluginName."/".$PluginName.".php";
432  if (file_exists($PluginFile))
433  {
434  # add plugin and directory to lists
435  $this->PluginNames[$PluginName] = $PluginName;
436  $this->PluginFiles[$PluginName] = $PluginFile;
437  $this->PluginHasDir[$PluginName] = TRUE;
438  }
439  # else if we don't already have a base plugin file
440  elseif (!array_key_exists($PluginName, $this->PluginFiles))
441  {
442  $this->ErrMsgs[$PluginName][] =
443  "Expected plugin file <i>".$PluginName.".php</i> not"
444  ." found in plugin subdirectory <i>"
445  .$Dir."/".$PluginName."</i>";
446  }
447  }
448  }
449  }
450  }
451  }
452 
458  private function InstallPlugin($Plugin)
459  {
460  # cache all plugin info from database
461  if (count($this->PluginInfo) == 0)
462  {
463  $this->DB->Query("SELECT * FROM PluginInfo");
464  while ($Row = $this->DB->FetchRow())
465  {
466  $this->PluginInfo[$Row["BaseName"]] = $Row;
467  }
468  }
469 
470  # if plugin was not found in database
471  $PluginName = get_class($Plugin);
472  $Attribs = $Plugin->GetAttributes();
473  if (!isset($this->PluginInfo[$PluginName]))
474  {
475  # add plugin to database
476  $this->DB->Query("INSERT INTO PluginInfo"
477  ." (BaseName, Version, Installed, Enabled)"
478  ." VALUES ('".addslashes($PluginName)."', "
479  ." '".addslashes($Attribs["Version"])."', "
480  ."0, "
481  ." ".($Attribs["EnabledByDefault"] ? 1 : 0).")");
482 
483  # read plugin settings back in
484  $this->DB->Query("SELECT * FROM PluginInfo"
485  ." WHERE BaseName = '".addslashes($PluginName)."'");
486  $this->PluginInfo[$PluginName] = $this->DB->FetchRow();
487  }
488 
489  # store plugin settings for later use
490  $this->PluginEnabled[$PluginName] = $this->PluginInfo[$PluginName]["Enabled"];
491 
492  # if plugin is enabled
493  if ($this->PluginEnabled[$PluginName])
494  {
495  # if plugin has not been installed
496  if (!$this->PluginInfo[$PluginName]["Installed"])
497  {
498  # set default values if present
499  $Attribs = $Plugin->GetAttributes();
500  if (isset($Attribs["CfgSetup"]))
501  {
502  foreach ($Attribs["CfgSetup"] as $CfgValName => $CfgSetup)
503  {
504  if (isset($CfgSetup["Default"]))
505  {
506  $Plugin->ConfigSetting($CfgValName, $CfgSetup["Default"]);
507  }
508  }
509  }
510 
511  # install plugin
512  $ErrMsg = $Plugin->Install();
513 
514  # if install succeeded
515  if ($ErrMsg == NULL)
516  {
517  # mark plugin as installed
518  $this->DB->Query("UPDATE PluginInfo SET Installed = 1"
519  ." WHERE BaseName = '".addslashes($PluginName)."'");
520  $this->PluginInfo[$PluginName]["Installed"] = 1;
521  }
522  else
523  {
524  # disable plugin
525  $this->PluginEnabled[$PluginName] = FALSE;
526 
527  # record error message about installation failure
528  $this->ErrMsgs[$PluginName][] = "Installation of plugin <b>"
529  .$PluginName."</b> failed: <i>".$ErrMsg."</i>";;
530  }
531  }
532  else
533  {
534  # if plugin version is newer than version in database
535  if (version_compare($Attribs["Version"],
536  $this->PluginInfo[$PluginName]["Version"]) == 1)
537  {
538  # upgrade plugin
539  $ErrMsg = $Plugin->Upgrade($this->PluginInfo[$PluginName]["Version"]);
540 
541  # if upgrade succeeded
542  if ($ErrMsg == NULL)
543  {
544  # update plugin version in database
545  $Attribs = $Plugin->GetAttributes();
546  $this->DB->Query("UPDATE PluginInfo"
547  ." SET Version = '".addslashes($Attribs["Version"])."'"
548  ." WHERE BaseName = '".addslashes($PluginName)."'");
549  $this->PluginInfo[$PluginName]["Version"] = $Attribs["Version"];
550  }
551  else
552  {
553  # disable plugin
554  $this->PluginEnabled[$PluginName] = FALSE;
555 
556  # record error message about upgrade failure
557  $this->ErrMsgs[$PluginName][] = "Upgrade of plugin <b>"
558  .$PluginName."</b> from version <i>"
559  .addslashes($this->PluginInfo[$PluginName]["Version"])
560  ."</i> to version <i>"
561  .addslashes($Attribs["Version"])."</i> failed: <i>"
562  .$ErrMsg."</i>";
563  }
564  }
565  # else if plugin version is older than version in database
566  elseif (version_compare($Attribs["Version"],
567  $this->PluginInfo[$PluginName]["Version"]) == -1)
568  {
569  # disable plugin
570  $this->PluginEnabled[$PluginName] = FALSE;
571 
572  # record error message about version conflict
573  $this->ErrMsgs[$PluginName][] = "Plugin <b>"
574  .$PluginName."</b> is older (<i>"
575  .addslashes($Attribs["Version"])
576  ."</i>) than previously-installed version (<i>"
577  .addslashes($this->PluginInfo[$PluginName]["Version"])."</i>).";
578  }
579  }
580  }
581  }
582 
587  private function CheckDependencies()
588  {
589  # look until all enabled plugins check out okay
590  do
591  {
592  # start out assuming all plugins are okay
593  $AllOkay = TRUE;
594 
595  # for each plugin
596  foreach ($this->Plugins as $PluginName => $Plugin)
597  {
598  # if plugin is currently enabled
599  if ($this->PluginEnabled[$PluginName])
600  {
601  # load plugin attributes
602  if (!isset($Attribs[$PluginName]))
603  {
604  $Attribs[$PluginName] =
605  $this->Plugins[$PluginName]->GetAttributes();
606  }
607 
608  # for each dependency for this plugin
609  foreach ($Attribs[$PluginName]["Requires"]
610  as $ReqName => $ReqVersion)
611  {
612  # handle PHP version requirements
613  if ($ReqName == "PHP")
614  {
615  if (version_compare($ReqVersion, phpversion(), ">"))
616  {
617  $this->ErrMsgs[$PluginName][] = "PHP version "
618  ."<i>".$ReqVersion."</i>"
619  ." required by <b>".$PluginName."</b>"
620  ." was not available. (Current PHP version"
621  ." is <i>".phpversion()."</i>.)";
622  }
623  }
624  # handle PHP extension requirements
625  elseif (preg_match("/^PHPX_/", $ReqName))
626  {
627  list($Dummy, $ExtensionName) = split("_", $ReqName, 2);
628  if (!extension_loaded($ExtensionName))
629  {
630  $this->ErrMsgs[$PluginName][] = "PHP extension "
631  ."<i>".$ExtensionName."</i>"
632  ." required by <b>".$PluginName."</b>"
633  ." was not available.";
634  }
635  }
636  # handle dependencies on other plugins
637  else
638  {
639  # load plugin attributes if not already loaded
640  if (isset($this->Plugins[$ReqName])
641  && !isset($Attribs[$ReqName]))
642  {
643  $Attribs[$ReqName] =
644  $this->Plugins[$ReqName]->GetAttributes();
645  }
646 
647  # if target plugin is not present or is disabled or is too old
648  if (!isset($this->PluginEnabled[$ReqName])
649  || !$this->PluginEnabled[$ReqName]
650  || (version_compare($ReqVersion,
651  $Attribs[$ReqName]["Version"], ">")))
652  {
653  # add error message and disable plugin
654  $this->ErrMsgs[$PluginName][] = "Plugin <i>"
655  .$ReqName." ".$ReqVersion."</i>"
656  ." required by <b>".$PluginName."</b>"
657  ." was not available.";
658  $this->PluginEnabled[$PluginName] = FALSE;
659 
660  # set flag indicating plugin did not check out
661  $AllOkay = FALSE;
662  }
663  }
664  }
665  }
666  }
667  } while ($AllOkay == FALSE);
668  }
669 
678  function FindPluginPhpFile($PageName)
679  {
680  # build list of possible locations for file
681  $Locations = array(
682  "local/plugins/%PLUGIN%/pages/%PAGE%.php",
683  "plugins/%PLUGIN%/pages/%PAGE%.php",
684  "local/plugins/%PLUGIN%/%PAGE%.php",
685  "plugins/%PLUGIN%/%PAGE%.php",
686  );
687 
688  # look for file and return (possibly) updated page to caller
689  return $this->FindPluginPageFile($PageName, $Locations);
690  }
701  function FindPluginHtmlFile($PageName)
702  {
703  # build list of possible locations for file
704  $Locations = array(
705  "local/plugins/%PLUGIN%/interface/%ACTIVEUI%/%PAGE%.html",
706  "plugins/%PLUGIN%/interface/%ACTIVEUI%/%PAGE%.html",
707  "local/plugins/%PLUGIN%/interface/default/%PAGE%.html",
708  "plugins/%PLUGIN%/interface/default/%PAGE%.html",
709  "local/plugins/%PLUGIN%/%PAGE%.html",
710  "plugins/%PLUGIN%/%PAGE%.html",
711  );
712 
713  # find HTML file
714  $Params = $this->FindPluginPageFile($PageName, $Locations);
715 
716  # if plugin HTML file was found
717  if ($Params["PageName"] != $PageName)
718  {
719  # add subdirectories for plugin to search paths
720  $Dir = preg_replace("%^local/%", "", dirname($Params["PageName"]));
721  $GLOBALS["AF"]->AddImageDirectories(array(
722  "local/".$Dir."/images",
723  $Dir."/images",
724  ));
725  $GLOBALS["AF"]->AddIncludeDirectories(array(
726  "local/".$Dir."/include",
727  $Dir."/include",
728  ));
729  $GLOBALS["AF"]->AddFunctionDirectories(array(
730  "local/".$Dir."/include",
731  $Dir."/include",
732  ));
733  }
734 
735  # return possibly revised HTML file name to caller
736  return $Params;
737  }
748  private function FindPluginPageFile($PageName, $Locations)
749  {
750  # set up return value assuming we will not find plugin page file
751  $ReturnValue["PageName"] = $PageName;
752 
753  # look for plugin name and plugin page name in base page name
754  preg_match("/P_([A-Za-z].[A-Za-z0-9]*)_([A-Za-z0-9_-]+)/", $PageName, $Matches);
755 
756  # if base page name contained name of enabled plugin with its own subdirectory
757  if ((count($Matches) == 3)
758  && $this->PluginEnabled[$Matches[1]]
759  && $this->PluginHasDir[$Matches[1]])
760  {
761  # for each possible location
762  $ActiveUI = $GLOBALS["AF"]->ActiveUserInterface();
763  $PluginName = $Matches[1];
764  $PageName = $Matches[2];
765  foreach ($Locations as $Loc)
766  {
767  # make any needed substitutions into path
768  $FileName = str_replace(array("%ACTIVEUI%", "%PLUGIN%", "%PAGE%"),
769  array($ActiveUI, $PluginName, $PageName), $Loc);
770 
771  # if file exists in this location
772  if (file_exists($FileName))
773  {
774  # set return value to contain full plugin page file name
775  $ReturnValue["PageName"] = $FileName;
776 
777  # save plugin name as home of current page
778  $this->PageFilePlugin = $PluginName;
779 
780  # set G_Plugin to plugin associated with current page
781  $GLOBALS["G_Plugin"] = $this->GetPluginForCurrentPage();
782 
783  # stop looking
784  break;
785  }
786  }
787  }
788 
789  # return array containing page name or page file name to caller
790  return $ReturnValue;
791  }
792 
800  static function CfgSaveCallback($BaseName, $Cfg)
801  {
802  $DB = new Database();
803  $DB->Query("UPDATE PluginInfo SET Cfg = '".addslashes(serialize($Cfg))
804  ."' WHERE BaseName = '".addslashes($BaseName)."'");
805  }
807 }
808 
821 
828  function __construct($PluginName, $MethodName)
829  {
830  $this->PluginName = $PluginName;
831  $this->MethodName = $MethodName;
832  }
833 
839  function CallPluginMethod()
840  {
841  $Args = func_get_args();
842  $Plugin = self::$Manager->GetPlugin($this->PluginName);
843  return call_user_func_array(array($Plugin, $this->MethodName), $Args);
844  }
845 
850  function GetCallbackAsText()
851  {
852  return $this->PluginName."::".$this->MethodName;
853  }
854 
860  function __sleep()
861  {
862  return array("PluginName", "MethodName");
863  }
864 
866  static public $Manager;
867 
868  private $PluginName;
869  private $MethodName;
870 }
873 ?>
LoadPlugins($ForcePluginConfigOptLoad=FALSE)
Load and initialize plugins.
GetErrorMessages()
Retrieve any error messages generated during plugin loading.
__sleep()
Sleep method, specifying which values are to be saved when we are serialized.
__construct($PluginName, $MethodName)
Class constructor, which stores the plugin name and the name of the method to be called.
Manager to load and invoke plugins.
static CfgSaveCallback($BaseName, $Cfg)
SQL database abstraction object with smart query caching.
UninstallPlugin($PluginName)
Uninstall plugin and (optionally) delete any associated data.
GetDependents($PluginName)
Returns a list of plugins dependent on the specified plugin.
FindPluginPhpFile($PageName)
static AddObjectDirectory($Dir, $Prefix="", $ClassPattern=NULL, $ClassReplacement=NULL)
Add directory to be searched for object files when autoloading.
GetActivePluginList()
Get list of active (i.e.
FindPluginHtmlFile($PageName)
GetPluginAttributes()
Retrieve info about currently loaded plugins.
GetPlugin($PluginName)
Retrieve specified plugin.
PHP
Definition: OAIClient.php:39
PluginEnabled($PluginName, $NewValue=NULL)
Get/set whether specified plugin is enabled.
__construct($AppFramework, $PluginDirectories)
PluginManager class constructor.
GetPluginForCurrentPage()
Retrieve plugin for current page (if any).
GetCallbackAsText()
Get full method name as a text string.
const ORDER_LAST
Run hooked function last (i.e.
static $Manager
PluginManager to use to retrieve appropriate plugins.
CallPluginMethod()
Call the method that was specified in our constructor.