FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
FO_Plugin Class Reference

This is the Plugin class. All plugins should: More...

Inherits Fossology\Lib\Plugin\Plugin.

Inherited by acme_review, acme_review, admin_bucket_pool, admin_folder_delete, admin_license_file, admin_obligation_file, admin_scheduler, admin_tag, admin_tag_manage, agent_copyright_once, agent_demomod, agent_nomos_once, agent_wget_agent, ajax_filebucket, ajax_filelic, ajax_schedule_agent, ajax_tags, AjaxClearingView, changeLicenseProcessPost, ClearingView, copyright_list, CopyrightHistogramProcessPost, core_auth, core_debug, core_debug_fileloc, core_debug_menus, core_init, core_smauth, core_uploads, dashboard, dashboardReporting, debug_flush_cache, debug_user, foconfig, folder_create, folder_properties, Fossology\UI\Ajax\AjaxShowJobs, group_add, HistogramBase, LicenseListFiles, list_bucket_files, maintagent, PopupLicense, search, showjobs, ui_browse, ui_buckets, ui_demomod, ui_diff_buckets, ui_download, ui_nomos_diff, ui_picker, ui_refresh, ui_report_conf, ui_reunpack, ui_tag, ui_topnav, ui_treenav, ui_view, ui_view_info, UIExportList, upload_properties, upload_tagging, user_add, and user_del.

Collaboration diagram for FO_Plugin:
Collaboration graph

Public Member Functions

 Install ()
 This function (when defined) is only called when the plugin is first installed. It should make sure all requirements are available and create anything it needs to run. It returns 0 on success, non-zero on failure. A failed install is not inserted in the system. More...
 
 Remove ()
 This function (when defined) is only called once, when the plugin is removed. It should uninstall and remove all items that are only used by this plugin. There should be no residues – if the plugin is ever installed again, it should act like a clean install. Thus, any DB, files, or state variables specific to this plugin must be removed. This function must always succeed.
 
 __construct ()
 base constructor. Most plugins will just use this More...
 
 Initialize ()
 dummy stub till all references are removed.
 
 PostInitialize ()
 This function is called before the plugin is used and after all plugins have been initialized. If there is any initialization step that is dependent on other plugins, put it here. More...
 
 RegisterMenus ()
 While menus can be added to any time at or after the PostInitialize phase, this is the standard location for registering this item with menus. More...
 
 Destroy ()
 This is a destructor called after the plugin is no longer needed. It should assume that PostInitialize() was already run one time (this session) and succeeded. This function must always succeed.
 
 OutputOpen ()
 This function is called when user output is requested. This function is responsible for assigning headers.
 
 OutputUnSet ()
 Similar to OutputClose, this ends the output type for this object. However, this does NOT change any global settings. This is called when this object is a dependency for another object.
 
 getResponse ()
 
 Output ()
 This function is called when user output is requested. This function is responsible for content. (OutputOpen and Output are separated so one plugin can call another plugin's Output.)
 
 getTemplateName ()
 
 renderString ($templateName, $vars=null)
 
 renderScripts ($scripts)
 Render JavaScript in the template's footer. More...
 
 getRequest ()
 
 execute ()
 
 preInstall ()
 
 postInstall ()
 
 unInstall ()
 
 getName ()
 
 __toString ()
 

Public Attributes

 $State = PLUGIN_STATE_INVALID
 
 $Name = ""
 
 $Version = "1.0"
 
 $Title = ""
 
 $DBaccess = PLUGIN_DB_NONE
 
 $LoginFlag = 0
 
 $NoMenu = 0
 
 $NoHeader = 0
 
 $PluginLevel = 10
 
 $Dependency = array()
 
 $InitOrder = 0
 
 $MenuList = NULL
 
 $MenuOrder = 0
 
 $MenuTarget = NULL
 
 $OutputType = "HTML"
 
 $OutputToStdout = 0
 

Protected Member Functions

 render ($templateName, $vars=null)
 

Protected Attributes

 $microMenu
 
 $renderer
 
 $vars = array()
 

Private Attributes

 $menu
 
 $request
 
 $headers = array()
 

Detailed Description

This is the Plugin class. All plugins should:

  1. Use this class or extend this class.
  2. After defining the necessary functions and values, the plugin must add the new element to the Plugins array. For example: $NewPlugin = new Plugin; $NewPlugin->Name="Fred"; if ($NewPlugin->Initialize() != 0) { destroy $NewPlugin; }
Examples:
/home/travis/build/GMishx/fossology/src/www/ui/ui-picker.php.

Definition at line 67 of file FO_Plugin.php.

Constructor & Destructor Documentation

FO_Plugin::__construct ( )

base constructor. Most plugins will just use this

Makes sure the plugin is in the correct state. If so, the plugin is inserted into the Plugins data structure.

The constructor assumes that Install() was already run one time (possibly years ago and not during this object's creation).

Returns
true on success, false on failure.

On failure the plugin is not used by the system. NOTE: This function must NOT assume that other plugins are installed. See PostInitialize.

Definition at line 211 of file FO_Plugin.php.

Member Function Documentation

FO_Plugin::getName ( )
Returns
string

Implements Fossology\Lib\Plugin\Plugin.

Definition at line 495 of file FO_Plugin.php.

FO_Plugin::getRequest ( )
Returns
Request

Definition at line 456 of file FO_Plugin.php.

FO_Plugin::getResponse ( )
Returns
Response

Definition at line 380 of file FO_Plugin.php.

FO_Plugin::Install ( )

This function (when defined) is only called when the plugin is first installed. It should make sure all requirements are available and create anything it needs to run. It returns 0 on success, non-zero on failure. A failed install is not inserted in the system.

These next variables define required functionality. If the functions exist, then they are called. However, plugins are not required to define any of these.

Note
It may be called multiple times. It must check that changes are needed BEFORE doing any changes. Also, it must check for partial installs in case the user is recovering from an installation failure.

Definition at line 178 of file FO_Plugin.php.

FO_Plugin::PostInitialize ( )

This function is called before the plugin is used and after all plugins have been initialized. If there is any initialization step that is dependent on other plugins, put it here.

Returns
true on success, false on failure.
Note
Do not assume that the plugin exists! Actually check it!

Definition at line 241 of file FO_Plugin.php.

FO_Plugin::RegisterMenus ( )

While menus can be added to any time at or after the PostInitialize phase, this is the standard location for registering this item with menus.

Note
1: Menu registration may be plugin specific!
2: This is intended for cross-plugin registration and not for the main menu.

Definition at line 281 of file FO_Plugin.php.

FO_Plugin::render (   $templateName,
  $vars = null 
)
protected
Parameters
string$templateName
array$vars
Returns
Response

Definition at line 442 of file FO_Plugin.php.

FO_Plugin::renderScripts (   $scripts)

Render JavaScript in the template's footer.

Parameters
string$scripts

Definition at line 432 of file FO_Plugin.php.

FO_Plugin::renderString (   $templateName,
  $vars = null 
)
Parameters
string$templateName
array$vars
Returns
string

Definition at line 422 of file FO_Plugin.php.

Member Data Documentation

FO_Plugin::$DBaccess = PLUGIN_DB_NONE

Access level restrictions

Definition at line 86 of file FO_Plugin.php.

FO_Plugin::$MenuList = NULL

Plugins may define a menu item. The menu name defines where it belongs. Each menu item belongs in a category (menu list) and could be in subcategories (menu sublists). The MenuList identifies the list (and sublists) where this item belongs. The menu heirarchy is defined by a name and a "::" to denote a submenu item.

The MenuName defines the name for this item in the menu.

Finally, multiple plugins may place multiple items under the same menu. The MenuOrder assigns a numeric ranking for items. All items at the same level are sorted alphabetically by MenuName.

For example, to define an "About" menu item under the "Help" menu: $MenuList = "Help::About"; $MenuOrder=0; And a "delete" agent under the tool, administration menu would be: $MenuList = "Tools::Administration::Delete"; $MenuOrder=0;

Since menus may link to results that belong in a specific window, $MenuTarget can identify the window. If not defined, the UI will use a default results window.

/note

  1. If the MenuList location does not exist, then it will be created.
  2. If a plugin does not have a menulist item, then it will not appear in any menus.
  3. MenuList is case and SPACE sensitive. "Help :: About" defines "Help " and " About". While "Help::About" defines "Help" and "About".

Definition at line 156 of file FO_Plugin.php.

FO_Plugin::$Name = ""

Name defines the official name of this plugin. Other plugins may call this plugin based on this name.

Definition at line 79 of file FO_Plugin.php.

FO_Plugin::$NoMenu = 0

Common for HTML output

Definition at line 92 of file FO_Plugin.php.

FO_Plugin::$OutputType = "HTML"

The output functions generate "output" for use in a text CLI or web page. For agents, the outputs generate status information.

Definition at line 307 of file FO_Plugin.php.

FO_Plugin::$PluginLevel = 10

This array lists plugin dependencies by name and initialization order. These are used to call PostInitialize in the correct order. PostInitialize will be called when all dependencies are ready. InitOrder says "after all dependencies are ready, do higher value items first." For example, this allows for menus to be initialized before anything else. (You probably won't need to change InitOrder.)

Definition at line 103 of file FO_Plugin.php.

FO_Plugin::$State = PLUGIN_STATE_INVALID

All public fields can be empty, indicating that it does not apply.

Definition at line 73 of file FO_Plugin.php.


The documentation for this class was generated from the following file: