Plugin.php
From e107 Wiki
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
The plugin.php fileThis file is the heart of your plugin - it defines lots of things about your plugin such as the plugin name, preferences and database definitions. In actual fact, it is just a list of well known PHP variables with values assigned. The variables are known to e107 and used during plugin install, upgrade, and uninstall. They are also used for other e107 functionality such as determining if a plugin has menus. These variables are discussed below. There is no required order that the variables are declared in, but convention tends to group similar types of variables together. Note 1: some example values in the following descriptions should really be PHP constant values, defined in your plugins language file. Note 2: all variables are PHP strings unless otherwise stated. General VariablesNote: Setting of some of these variables is used to determine if a plugin requires installation (i.e. the admin must click the install button) or not. A plugin that requires installation is one which has one or more of the following variables set and non-empty:
This roughly translates to a plugin that:
$eplug_nameThe name of your plugin. $eplug_name = "MyPlugin"; $eplug_versionThe version number of your plugin. By convention:
Whatever version numbering system you use, a maximum of 10 characters are stored in the database (may be less if you use utf-8 and non-ASCII characters). In addition, if the plugin is to be uploaded to [www.e107coders.org e107 Coders] for public release the version number can not be more than 5 characters long (including the dots). $eplug_version = "1.0"; $eplug_authorYour name, e107 user name or nickname - your choice. $eplug_author = "bugrain"; $eplug_folderThe folder name that your plugin installs to. $eplug_folder = "myplugin"; $eplug_icon/$eplug_icon_smallImage files to be used as icons for your plugin. Displayed on the Admin->Plugin Manager page. The files should be 32x32 pixels and 16x16 pixels in size. Any image file type should be OK but PNG and GIF are usually used as it allows for transparent backgrounds. $eplug_icon = $eplug_folder."/images/icon_32.png"; $eplug_icon_small = $eplug_folder."/images/icon_16.png"; Note 1: we use the Note 2: prior to e107 0.7 the variable $eplug_urlYour website - advertise yourself! Displayed on the Admin->Plugin Manager' page. A link to it is displayed on the Admin->Plugin Manager' page. $eplug_url = "http://www.mysite.com"; $eplug_emailYour e-mail address, useful to get feedback and bug reports on your plugin. A mailto link to it is displayed on the Admin->Plugin Manager page. $eplug_email = "myname@mysite.com"; $eplug_descriptionA brief description of your plugin. Displayed on the Admin->Plugin Manager page. $eplug_description = "A configurable contact form to allow website visitors to e-mail you without exposing e-mail addresses."; $eplug_compatibleThe lowest version of e107 that your plugin will work with. Displayed on the Admin->Plugin Manager page. $eplug_compatible = "e107v0.7+"; $eplug_readmeThe name of your Read Me file. This can be a simple text file, an HTML file or a PHP file which is fully integrated into e107. A link to it is displayed on the Admin->Plugin Manager page. $eplug_readme = "admin_readme.php"; $eplug_compliantIndicates whether or not your plugin is fully XHTML compliant or not. You can read more about this and check your plugins compliance at the W3C Markup Validation Service website. note: the value should be a PHP boolean (TRUE or FALSE). $eplug_compliant = TRUE; $eplug_menu_nameA plugin can have zero, one or more associated menus. If the plugin has no menus this variable should be set to FALSE (or just don't set it). If the plugin has only one menu, set this variable to the menus source file without the If the plugin has multiple menus set this variable to TRUE. When TRUE this setting simply determines the text that is displayed instead of the Install button on the Admin->Plugin Manager page if your plugin does require installation. $eplug_menu_name = "myplugin_menu"; for multi-language purpose use Note: no Note: In e107 0.6x this was the name of your plugin's menu file (without the $eplug_conffileThe name of your plugin's main admin page. This is the page that will first be displayed when a user navigates to your plugin's admin area and is normally the top item in your plugin's admin menu. To ensure that your admin pages are displayed in the correct Admin theme, these files should all be prefixed with $eplug_conffile = "admin_emails.php"; $eplug_captionText to be used as the title attribute for the link to your plugin's admin pages on the Admin->Plugin Manager page. Most browsers will display this text as a tooltip when the mouse is moved over the link. $eplug_caption = "Configure Contact Form"; $eplug_link/$eplug_link_name/$eplug_link_url/$eplug_link_permsIndicates if a link to your plugins page should be created (in Sitelinks) when it is installed.
If TRUE then you should set Optionally, you can set the viewability of the link that is created.
eg. For an admin-only plugin, you may wish to set $eplug_link = TRUE; $eplug_link_name = "My Plugin"; $eplug_link_url = e_PLUGIN."myplugin/myplugin.php"; $eplug_link_perms = "Admin"; // Optional: Guest, Member, Admin, Everyone $eplug_doneMessage to be displayed when your plugin has been successfully installed. $eplug_done = "Installation Successful..."; $eplug_upgrade_doneMessage to be displayed when your plugin has been successfully upgraded. $eplug_upgrade_done = "Upgrade successful..."; Variables Relating To Preferences$eplug_prefsAn associative array of your plugins preferences and their default values to be added when your plugin is installed. Each preference is defined with the preference name as an array element index and the preference value as the array element value. Preference names should be assigned a prefix to uniquely identify them with your plugin as they are stored globally. Can be set to an empty string if there are none. $eplug_prefs = array( "myplugin_max_items" => "20", "myplugin_visibility" => "0" ); An array value may also be assigned. Note: The area available for storing preferences is limited (by database constraints), so other means (e.g. a separate database record in e107_core) should be used if a plugin has a significant amount of preference data.
$eplug_array_pref(N.B. no ending 's') Used for 'cumulative' preferences - where several plugins may each contribute a value. (For an example see the linkwords plugin, which links itself in as a supplementary parser using the 'tohtml_hook' pref). Such preferences cannot be an array value Value can be omitted, or set to an empty string, if there are no such preferences to add. All the values provided by installed plugins are concatenated into a comma-separated list. Note: This feature was not fully operational prior to e107 version 0.7.8 $eplug_array_pref = array ( "tohtml_hook" => "linkwords" ); $upgrade_add_prefsPreferences to be added when the user upgrades your plugin. Can be set to an empty string if there are none. $upgrade_add_prefs = array ( "myplugin_width" => "50", );
$upgrade_add_array_pref'Array' or 'cumulative' preferences to be added when the user upgrades your plugin.
$upgrade_remove_prefsPreferences to be removed when the user upgrades your plugin. Can be set to an empty string if there are none. $upgrade_remove_prefs = array("
"myplugin_max_items" => "20",
);
$upgrade_remove_array_pref'Array' or 'cumulative' preferences to be removed when the user upgrades your plugin.
Variables Relating To Database TablesAlso see plugin.php Hints and Tips $eplug_table_namesA string array of database tables created by your plugin. Does not require the e107 database prefix. Can be set to an empty string if there is none. $eplug_table_names = array("myplugin_table1");
$eplug_tablesA string array containing the SQL used to create and, if required, populate your database tables when your plugin is installed. You need to use the e107 constant MPREFIX to prefix your table names. Can be set to an empty string if there are none. $eplug_tables = array(
"CREATE TABLE ".MPREFIX."myplugin_table1 (
id int(11) NOT NULL auto_increment,
title varchar(50) NOT NULL default '',
full_name text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;",
"INSERT INTO ".MPREFIX."myplugin_table1 VALUES (1, 'Mr','Plugin Programmer');",
);
$upgrade_alter_tablesA string array containing the SQL used to update your database tables when your plugin is upgraded. You need to use the e107 constant MPREFIX to prefix your table names. Can be set to an empty string if there are none. $upgrade_alter_tables = "array( ALTER TABLE ".MPREFIX."myplugin_table1 ADD approve char(1) NOT NULL default '' AFTER id" )"; FunctionsNote: as the myplugin_install()Define the function This is useful as the plugin.php file is read on many occasions, so this prevents install only functionality from running when it shouldn't. This function is run before any e107 plugin install processing is done. myplugin_upgrade()Define the function This is useful as the plugin.php file is read on many occassions, so this prevents upgrade only functionality from running when it shouldn't. This function is run before any e107 plugin upgrade processing is done. myplugin_uninstall()Define the function This is useful as the plugin.php file is read on many occassions, so this prevents uninstall only functionality from running when it shouldn't. This function is run before any e107 plugin uninstall processing is done. Deprecated Variables (not needed anymore)$eplug_doneIf not defined LAN_INSTALL_SUCCESSFUL is used instead. $eplug_bbReplaced by e_bb.php file in the plugin directory. Used to add plugin specific BB codes. $eplug_latestReplaced by e_latest.php file in the plugin directory. It adds content to the 'latest' menu on the admin page. $eplug_moduleReplaced by e_module.php file in the plugin directory. Used to mark the plugin as a module. $eplug_scReplaced by e_sc.php file in the plugin directory. Used to add plugin specific shortcodes. $eplug_statusReplaced by e_status.php file in the plugin directory. It adds content to the 'status' menu on the admin page. | |||||||

