PluginSDK

From WoWRosterWiKi
Jump to: navigation, search
WR.net

Important note: When you edit this page, you agree to release your contribution into the public domain.
If you do not want this or can not do this because of license restrictions, please do not edit.

Contents


Plugin SDK

Most of the Plugin install system is like the Addon system see the AddOn SDK for more info some changes are as such

Each install.def.php for each plugin has to have these vars at the top after the class is started

class eventsInstall
{
	/*
	*	These Vars are used with the new Plugin installer 
	*	@var name - unique name for the plugin
	*	@var parent - the intended addon to use this plugin
	*/
	var $active = true;
	var $name = 'events';
	var $filename = 'events.php';
	var $parent = 'main';
	var $scope = 'guild';
	var $icon = 'achievement_worldevent_childrensweek';
	var $version = '1.0';
	var $oldversion = '';
	var $wrnet_id = '';
 
	var $fullname = 'WoW Events';
	var $description = 'Creates a display of the current ingame event.';
	var $credits = array(
		array(	"name"=>	"Ulminia <Ulminia@gmail.com>",
			"info"=>	"WoW Events (Alpha Release)"),
	);

Install Class

function install()

All the same functions you can use in addon install class work here BUT you cannot create menu buttons this is the only limitation

Plugin Class

Plugins are loaded as class objects for addons so using the events plugin as an example we declare our class in the php file names the same as the folder of the plugin events.php

class events
{
 
	var $output;
	
	/*
	*	These Vars are used with the new Plugin installer 
	*	@var name - unique name for the plugin
	*	@var parent - the intended addon to use this plugin
	*
	*/
	var $active = true;
	var $name = 'events';
	var $parent = 'main';
	var $icon = 'achievement_worldevent_childrensweek';
	var $version = '1.0';
	var $oldversion = '';
	var $wrnet_id = '';

Again much the same as the installer this just help with loading the plugins

Calling Tables

Calling tables in your plugin has 1 extra value that has to be set

$roster->db->table($tablename,$pluginname,$type)

Addon Plugin Init

This function is customized for each addon and is included in the functions or main file for the addon to get plugin data

This is the Function used in the new WoWRoster Portal

function _initPlugins()
{
	global $roster, $addon;
	$plugins = $roster->plugin_data;
	if( !empty($plugins) )
	{
		foreach( $plugins as $plugin_name => $plugin )
		{
			if ($plugin['parent'] == $addon['basename'])
			{
				if ($roster->plugin_data[$plugin_name]['active'] == '1')
				{
					$xplugin = getplugin($plugin_name);
					
					foreach( $roster->multilanguages as $lang )
					{
						$roster->locale->add_locale_file($xplugin['locale_dir'] . $lang . '.php', $lang);
					}
					$plugin['scope'] = explode('|',$plugin['scope']);
					if (in_array( $roster->scope, $plugin['scope'] ) )
					{
						$classfile = ROSTER_PLUGINS . $plugin_name . DIR_SEP . $plugin_name . '.php';
						require($classfile);
						$pluginstuff = new $plugin_name($xplugin);
							$this->block[] = array(
							'name'   => $roster->locale->act[$plugin_name]['title'],//$pluginstuff->fullname,
							'output' => $pluginstuff->output,
							'icon'   => $pluginstuff->icon
						);
							unset($pluginstuff);
					}
				}
			}
		}
	}
	return true;
}

after $pluginstuff = new $plugin_name($xplugin); is where custom variables are declared for each addon these do change from addon to addon $this->block is passed to the index.php and looped to output the custom blocks for this plugin.

Personal tools
Namespaces
Variants
Actions
WoWRoster
Navigation
Toolbox