FOSSology  4.4.0
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 AjaxClearingView, AjaxNoticeFiles, ClearingView, CopyrightHistogramProcessPost, FossdashConfig, Fossology\UI\Ajax\AjaxShowJobs, HistogramBase, LicenseListFiles, PopupLicense, SpashtCopyrightHistogramProcessPost, UIExportList, 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, changeLicenseProcessPost, copyright_list, 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, group_add, list_bucket_files, maintagent, search, showjobs, size_dashboard, ui_browse, ui_buckets, ui_demomod, ui_diff_buckets, ui_download, ui_nomos_diff, ui_picker, ui_refresh, ui_report_conf, ui_reunpack, ui_spasht, ui_tag, ui_topnav, ui_treenav, ui_view, ui_view_info, upload_properties, upload_tagging, 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/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 56 of file FO_Plugin.php.

Constructor & Destructor Documentation

◆ __construct()

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.

Reimplemented in user_del, ui_view, ui_view_info, ui_tag, ui_report_conf, ui_refresh, ui_picker, LicenseListFiles, UIExportList, ui_download, ClearingView, ui_browse, showjobs, search, PopupLicense, group_add, core_auth, changeLicenseProcessPost, Fossology\UI\Ajax\AjaxShowJobs, core_uploads, ajax_tags, ajax_schedule_agent, AjaxNoticeFiles, AjaxClearingView, upload_properties, admin_tag, admin_tag_manage, admin_scheduler, admin_obligation_file, admin_license_file, FossdashConfig, size_dashboard, folder_properties, folder_create, dashboardReporting, dashboard, foconfig, ui_spasht, SpashtCopyrightHistogramProcessPost, agent_nomos_once, maintagent, admin_folder_delete, debug_user, core_debug, core_debug_menus, debug_flush_cache, core_debug_fileloc, agent_copyright_once, copyright_list, KeywordHistogram, IpraHistogram, HistogramBase, EmailHistogram, EccHistogram, CopyrightHistogram, CopyrightHistogramProcessPost, list_bucket_files, ui_buckets, ui_diff_buckets, ajax_filebucket, and admin_bucket_pool.

Definition at line 200 of file FO_Plugin.php.

Member Function Documentation

◆ getName()

FO_Plugin::getName ( )
Returns
string

Implements Fossology\Lib\Plugin\Plugin.

Definition at line 487 of file FO_Plugin.php.

◆ getRequest()

FO_Plugin::getRequest ( )
Returns
Request

Definition at line 448 of file FO_Plugin.php.

◆ getResponse()

FO_Plugin::getResponse ( )
Returns
Response

Reimplemented in ui_download.

Definition at line 372 of file FO_Plugin.php.

◆ Install()

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.

Reimplemented in ui_picker, core_smauth, core_auth, ui_nomos_diff, agent_nomos_once, ui_demomod, ui_buckets, and ui_diff_buckets.

Definition at line 167 of file FO_Plugin.php.

◆ PostInitialize()

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!

Reimplemented in search, core_init, core_auth, AjaxNoticeFiles, core_debug_menus, and core_debug_fileloc.

Definition at line 230 of file FO_Plugin.php.

◆ RegisterMenus()

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.

Reimplemented in ui_view, ui_view_info, ui_tag, ui_report_conf, ui_picker, LicenseListFiles, UIExportList, ui_download, ClearingView, ui_browse, showjobs, search, admin_obligation_file, admin_license_file, acme_review, agent_wget_agent, ui_spasht, ui_nomos_diff, agent_nomos_once, ui_demomod, agent_demomod, agent_copyright_once, copyright_list, KeywordHistogram, IpraHistogram, EmailHistogram, EccHistogram, CopyrightHistogram, acme_review, list_bucket_files, and ui_buckets.

Definition at line 270 of file FO_Plugin.php.

◆ render()

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

Definition at line 434 of file FO_Plugin.php.

◆ renderScripts()

FO_Plugin::renderScripts (   $scripts)

Render JavaScript in the template's footer.

Parameters
string$scripts

Definition at line 424 of file FO_Plugin.php.

◆ renderString()

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

Definition at line 414 of file FO_Plugin.php.

Member Data Documentation

◆ $DBaccess

FO_Plugin::$DBaccess = PLUGIN_DB_NONE

Access level restrictions

Definition at line 75 of file FO_Plugin.php.

◆ $MenuList

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 145 of file FO_Plugin.php.

◆ $Name

FO_Plugin::$Name = ""

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

Definition at line 68 of file FO_Plugin.php.

◆ $NoMenu

FO_Plugin::$NoMenu = 0

Common for HTML output

Definition at line 81 of file FO_Plugin.php.

◆ $OutputType

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 296 of file FO_Plugin.php.

◆ $PluginLevel

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 92 of file FO_Plugin.php.

◆ $State

FO_Plugin::$State = PLUGIN_STATE_INVALID

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

Definition at line 62 of file FO_Plugin.php.


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