Roster:Addon:AddonSDK
Contents |
WoWRoster v1.8.0 AddOn Development
Readme Updated: 15:26, 6 May 2007 (PDT)
You can view the open source project at http://www.wowroster.net
For corrections and/or suggestions - http://www.wowroster.net
Thanks to:
http://www.wowroster.com
And Everyone involved in the project.
Download the Roster AddOnSDK
Certified WoWRoster AddOn
AddOns that conform to our Coding Standards and the basic outline described within this document, will be given a "AddOn Framework Standards Compliant" stamp of approval.
Requirements for Approval
- Unique naming of variables in conf.php
-
$addon_conf['addon_name']['variable_name']
- or
-
$addonname_variablename
- This prevents each AddOns' variables from overwriting other AddOns' variables
- Unique locale variables
- Use Roster base locale strings whenever possible
- Don't overwrite existing locale strings
- Roster has some protection against this, but AddOns can still overwrite other AddOns' strings
- No funky text (BOM characters displaying above the menu for example)
- (ie: strange characters appearing on top of the roster's menu)
- Valid XHTML 1.0 Transitional - http://validator.w3.org
- Proper use of the DB layer - $roster->db
- Roster main files are not edited
- Roster main database tables are not edited, unless you provide a clean way to revert the data
Basics of an AddOn
The following are required to run the WoWRoster back-end and to be able to run any AddOns
>Roster Requirements<The AddOn system is designed so that you can mod the roster base without having to change the base code as it could change a lot between versions.
Hopefully with this system we will be closer to having a drop-in module system without having to mod a lot of the base files each time.We will be constantly refining the system as we go along.
So with each new version of Roster, some AddOns may break (not work in the new WoWRoster)IMPORTANT:
DO NOT use php short tags in your php files
This is also stated in the WoWRoster Coding Standards
NO!<? ?>
YES<?php ?>
Use the "long tags" as the short ones can break web servers with short_tags set to "off"
AddOn Framework
Ok so here we are, working on a AddOn and you're thinking, "How am I going to get the conf and language variables to use in my AddOn?"
Well our answer to that is, it's done for you!
Features
- Uses output buffering, which means all the output is stored in a variable that is sent to the browser
- Do not have to include Roster's conf.php
- Do not have to include/declare $roster object
- Do not have to connect to Roster's database
- Do not have to include your conf.php
- AddOn files: conf.php, style.css, and locale files are OPTIONAL!
- Even additional locale files are optional, enUS.php is the default locale, and is required if you have locale files
What it does
- Includes all Roster config variables for you to use ($roster->config)
- Includes all Roster sql functions for your use ($roster->db)
- Includes all Roster language variables for you ($roster->locale->wordings, $roster->locale->act)
- Includes all Roster css styles
- The Roster header, footer, and menu are included to your files.
- These can be disabled if needed, more below...
Best of all, this is transparent to you!
AddOn Directory Structure
Here is an example of an AddOn's directory structure
roster/ |_ addons/ |_ addonname/ |_ admin/ | |_ index.php | |_ other.php | |_ char/ | |_ index.php | |_ other.php | |_ guild/ | |_ index.php | |_ other.php | |_ inc/ | |_ functions.php | |_ locale/ | |_ deDE.php | |_ enUS.php | |_ esES.php | |_ frFR.php | |_ conf.php |_ index.php |_ install.def.php |_ update_hook.php
admin Folder
The admin folder is to house files for the Roster CP Normally you'll never need files here because the Config API can handle most configuration needs
If you do need a custom config interface, this is where you make it
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=rostercp-addon-addonname
- SEO Link - http://[www.someurl.net]/roster/trunk/rostercp/addon/addonname.html
This will normally grab your AddOn's config data from the 'roster_addon_config' table in the database and display the options using the Config API
If you need your own file, you need only to place index.php in addons/addonname/admin/
You can also have the best of both worlds
For example, the Members List and Character Info AddOns use both the Config API and custom files- Members List uses addons/memberslist/admin/update.php to process data for alt relations
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=rostercp-addon-memberslist-update
- SEO Link - http://[www.someurl.net]/roster/trunk/rostercp/addon/memberslist/update.html
- Character Info uses addons/info/admin/display.php to control data display for each character
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=rostercp-addon-info-display
- SEO Link - http://[www.someurl.net]/roster/trunk/rostercp/addon/info/display.html
char Folder
Files for use in the Character scope
Data for the requested character is passed to the AddOn
If member= is not specified or if this member does not exist, an error message will displaymember= can be either the member id number, or name@realm text
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=char-info&member=##
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=char-info&member=name@realm
- SEO Link - http://[www.someurl.net]/roster/trunk/char/info.html?member=##
- SEO Link - http://[www.someurl.net]/roster/trunk/char/info.html?member=name@realm
Accessing other files in the char scope is easy
addons/addonname/info/char/bags.php is accessed like this:- Normal Link - http://[www.someurl.net]/roster/trunk/?p=char-info-bags&member=##
- SEO Link - http://[www.someurl.net]/roster/trunk/char/info/bags.html?member=##
guild Folder
Files for use in the Guild scope
Data for the requested guild is passed to the AddOn
If guild= is not specified, the default guild/realm name set in Roster CP will show
If the guild does not exist or if there is no data for this guild, an error message will displayguild= can be either the guild id number, or name@realm text
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=guild-memberslist&guild=##
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=guild-memberslist&guild=name@realm
- SEO Link - http://[www.someurl.net]/roster/trunk/guild/memberslist.html?guild=##
- SEO Link - http://[www.someurl.net]/roster/trunk/guild/memberslist.html?guild=name@realm
Accessing other files in the guild scope is easy
addons/addonname/memberslist/guild/honorlist.php is accessed like this:- Normal Link - http://[www.someurl.net]/roster/trunk/?p=guild-memberslist-honorlist&guild=##
- SEO Link - http://[www.someurl.net]/roster/trunk/guild/memberslist/honorlist.html?guild=##
inc Folder
Other folders that house files not meant for direct access by the AddOn Framework
This does not necessarily need to be called inc
It can be lib, library, functions, etc...Place any files here that you do not or should not be accessed by the AddOn Framework
locale Folder
Where locale translation files go
See below for more info Locale Files
Other Files and the util Scope
Files not in these folders are considered under the util scope
This scope is not restricted if there is no guild or character information and can be accessed before data is in the database- Normal Link - http://[www.someurl.net]/roster/trunk/?p=util-addonname
- Normal Link - http://[www.someurl.net]/roster/trunk/?p=util-addonname
- SEO Link - http://[www.someurl.net]/roster/trunk/util/addonname.html
- SEO Link - http://[www.someurl.net]/roster/trunk/util/addonname.html
Accessing other files in the util scope is easy
addons/addonname/addonname/file.php is accessed like this:- Normal Link - http://[www.someurl.net]/roster/trunk/?p=util-addonname-file&guild=##
- SEO Link - http://[www.someurl.net]/roster/trunk/util/addonname/file.html?guild=##
Note that conf.php, install.def.php, and update_hook.php cannot be access this way
- conf.php - This is included before any other addon file, any initialization can be done here
- index.php - The main file for the util scope
- install.def.php - The main file for the util scope
- style.css - A custom css style for the AddOn
Required Files
There are a few files that you must have
- addons/addoname/install.def.php (AddOn install/upgrade/uninstall file)
Linking to AddOns
You can link to any file in the AddOn folder (except conf.php, install.def.php, and update_hook.php)
The url to access each page is simple
- Normal Link - http://[www.someurl.net]/roster/?p=scope-addonname-file
- SEO Link - http://[www.someurl.net]/roster/scope/addonname/file.html
The values explained
- scope - One of three values; guild, char, util
- Guild (guild) is a page that uses guild information (guild=id# or guild=name@server can be appended to the url)
- Character (char) is a page that uses character information (member=id# or member=name@server must be appended to the url)
- Utility (util) is a page that doesn't use either, or could use either, most of the Roster pages are utility pages (rostercp, update, credits)
- addonname - The name of the AddOn you are accessing
- file - The file you are accessing
Creating the Installer
This installer requires a similar install file definition as DragonFly CMS, with some important exeptions:
- SQL entries are the same as as passing it to mysql_query() using $installer->add_query($sqlstring)
- No rollback data per query. Instead, call the BACKUP command for each table you want restored in case of an upgrade/uninstall failure.
- Any backup tables you create are automatically deleted in rollback.
- A lot of different required variables to be set.
You should create a file called install.def.php with in it a class that is named identical to your AddOn's install directory name.
This name will be referred to as your AddOn's basename.- var $active
- Boolean, set to true to activate this AddOn after installing, set to false if it has to be configured first.
- var $version
- String, the current version of your AddOn.
- Needs to be compatible with php's version_compare().
- Should be incremented on every update that includes a database update, or any update if you wish.
- var $icon
- String, an icon to display for your AddOn in the AddOn management page in RosterCP
- Valid icons are from the Interface ImagePack
- var $fullname
- String, the full name of the AddOn for display.
- var $description
- String, used as a tooltip in serveral places.
- var $credits
- Credits information.
array( array( "name"=> "Name", "info"=> "Some Info"), array( "name"=> "Another Name", "info"=> "More Info"), );
Functions
- install()
- Here you can add all queries for a fresh install.
- No parameters.
- Return true on success, false on failure.
- upgrade($oldversion)
- Here you can add all queries for an upgrade.
- $oldversion, the version you are upgrading from.
- Return true on success, false on failure.
- You should supply your own file to be called for upgrades of a Roster 1.7.x AddOn since Roster 1.8 cannot detect these AddOns.
- Here you can add all queries for an upgrade.
- uninstall()
- Here you should add all queries for an uninstall.
- No parameters.
- Return true on success, false on failure
Adding Queries
Queries are added to the install using the $installer functions.
- $installer->add_query($sqlstring);
- Any valid SQL query
- $installer->add_backup($table)
- Makes a temporary copy of a table and its contents that is put back in case of a rollback
- $installer->add_drop($table)
- Have a table be dropped on rollback
- $installer->add_config($sqlstring);
- Add config sql to `roster_addon_config` table
- Format is "'id','config_name','config_value','form_type','config_type'"
- These entries will be used to build a config page through Roster's config page API
Creating/Editing Menu Entries
There are 3 separate functions for this.
Note the title should be unique per AddOn.- $installer->add_menu_button($title, $scope, $url)
- Adds a menu button. Parameters:
- $title
- The localization key for the menu button's title.
- $scope
- The scope of the link ('util','guild','char')
- $url
- The url parameters this button should call the AddOn with
- $installer->update_menu_button($title, $scope, $url)
- Changes menu button. Parameters:
- $title
- The localization key for the menu button's title.
- $scope
- The scope of the link ('util','guild','char')
- $url
- The url parameters this button should call the AddOn with
- $installer->remove_menu_button($title)
- Removes a menu button. Parameters:
- $title
- The localization key for the menu button's title.
Example File
Here is an example of an AddOn install file
From the "Members List" AddOn<?php /** * WoWRoster.net WoWRoster * * LICENSE: Licensed under the Creative Commons * "Attribution-NonCommercial-ShareAlike 2.5" license * * @copyright 2002-2007 WoWRoster.net * @license http://creativecommons.org/licenses/by-nc-sa/2.5 Creative Commons "Attribution-NonCommercial-ShareAlike 2.5" * @version SVN: $Id: install.def.php 908 2007-05-06 23:47:02Z Zanix $ * @link http://www.wowroster.net */ if ( !defined('ROSTER_INSTALLED') ) { exit('Detected invalid access to this file!'); } class memberslist { var $active = true; var $icon = 'inv_letter_06'; var $upgrades = array(); // There are no previous versions to upgrade from var $version = '0.3.0.0'; var $fullname = 'Members List'; var $description = 'A sortable, filterable member list.'; var $credits = array( array( "name"=> "PleegWat", "info"=> "Sortable/filterable member list"), ); function install() { global $installer; # Master data for the config file $installer->add_config("1,'startpage','display','display','master'"); # Config menu entries $installer->add_config("110,'display',NULL,'blockframe','menu'"); $installer->add_config("120,'members',NULL,'blockframe','menu'"); $installer->add_config("130,'stats',NULL,'blockframe','menu'"); $installer->add_config("140,'honor',NULL,'blockframe','menu'"); $installer->add_config("150,'log',NULL,'blockframe','menu'"); $installer->add_config("160,'build',NULL,'blockframe','menu'"); $installer->add_config("170,'documentation', 'http://www.wowroster.net/wiki/index.php/Roster:Addon:SortMember', 'newlink','menu'"); $installer->add_config("180,'updMainAlt','rostercp-addon-memberslist-update','makenewlink','menu'"); # Generic display settings $installer->add_config("1000,'openfilter','0','radio{Show^1|Hide^0','display'"); $installer->add_config("1010,'nojs','0','radio{Server^1|Client^0','display'"); $installer->add_config("1020,'def_sort','','select{Default Sort^|Name^name|Class^class|Level^level|Guild Title^guild_title|Highest Rank^lifetimeHighestRank|Note^note|Hearthstone Location^hearth|Zone Location^zone|Last Online^last_online_f|Last Updated^last_update','display'"); $installer->add_config("1030,'member_tooltip','1','radio{On^1|Off^0','display'"); $installer->add_config("1040,'group_alts','1','radio{On^1|Off^0','display'"); $installer->add_config("1050,'icon_size','16','select{8px^8|9px^9|10px^10|11px^11|12px^12|13px^13|14px^14|15px^15|16px^16|17px^17|18px^18|19px^19|20px^20','display'"); $installer->add_config("1060,'class_icon','1','radio{On^1|Off^0','display'"); $installer->add_config("1070,'class_color','1','radio{On^1|Off^0','display'"); $installer->add_config("1080,'level_bar','1','radio{On^1|Off^0','display'"); $installer->add_config("1090,'honor_icon','1','radio{On^1|Off^0','display'"); $installer->add_config("1100,'compress_note','1','radio{On^1|Off^0','display'"); $installer->add_config("1110,'page_size','0','text{4|30','display'"); # Per page settings: Memberlist $installer->add_config("2000,'member_update_inst','1','radio{Off^0|On^1','members'"); $installer->add_config("2010,'member_motd','1','radio{Off^0|On^1','members'"); $installer->add_config("2020,'member_hslist','1','radio{Off^0|On^1','members'"); $installer->add_config("2030,'member_pvplist','1','radio{Off^0|On^1','members'"); $installer->add_config("2040,'member_class','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2050,'member_level','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2060,'member_gtitle','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2070,'member_hrank','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2080,'member_prof','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2090,'member_hearth','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2100,'member_zone','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2110,'member_online','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2120,'member_update','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2130,'member_note','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); $installer->add_config("2140,'member_onote','0','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','members'"); # Per page settings: Statslist $installer->add_config("3000,'stats_update_inst','0','radio{Off^0|On^1','stats'"); $installer->add_config("3010,'stats_motd','0','radio{Off^0|On^1','stats'"); $installer->add_config("3020,'stats_hslist','0','radio{Off^0|On^1','stats'"); $installer->add_config("3030,'stats_pvplist','0','radio{Off^0|On^1','stats'"); $installer->add_config("3040,'stats_class','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3050,'stats_level','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3060,'stats_str','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3070,'stats_agi','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3080,'stats_sta','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3090,'stats_int','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3100,'stats_spi','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3110,'stats_sum','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3120,'stats_health','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3130,'stats_mana','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3140,'stats_armor','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3150,'stats_dodge','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3160,'stats_parry','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3170,'stats_block','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); $installer->add_config("3180,'stats_crit','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','stats'"); # Per page settings: Honorlist $installer->add_config("4000,'honor_update_inst','0','radio{Off^0|On^1','honor'"); $installer->add_config("4010,'honor_motd','0','radio{Off^0|On^1','honor'"); $installer->add_config("4020,'honor_hslist','1','radio{Off^0|On^1','honor'"); $installer->add_config("4030,'honor_pvplist','1','radio{Off^0|On^1','honor'"); $installer->add_config("4040,'honor_class','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4050,'honor_level','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4060,'honor_thk','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4070,'honor_tcp','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4080,'honor_yhk','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4090,'honor_ycp','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4100,'honor_lifehk','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4110,'honor_hrank','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4120,'honor_hp','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); $installer->add_config("4130,'honor_ap','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','honor'"); # Per page settings: Member Log $installer->add_config("5000,'log_update_inst','0','radio{Off^0|On^1','log'"); $installer->add_config("5010,'log_motd','0','radio{Off^0|On^1','log'"); $installer->add_config("5020,'log_hslist','0','radio{Off^0|On^1','log'"); $installer->add_config("5030,'log_pvplist','0','radio{Off^0|On^1','log'"); $installer->add_config("5040,'log_class','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5050,'log_level','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5060,'log_gtitle','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5070,'log_type','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5080,'log_date','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5090,'log_note','2','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); $installer->add_config("5100,'log_onote','0','radio{Force Hidden^0|Default Hidden^1|Default Shown^2|Force Shown^3','log'"); # Main/Alt Build settings $installer->add_config("6000,'getmain_regex','/ALT-([\\\\w]+)/i','text{50|30','build'"); $installer->add_config("6010,'getmain_field','Note','select{Public Note^Note|Officer Note^OfficerNote','build'"); $installer->add_config("6020,'getmain_match','1','text{2|30','build'"); $installer->add_config("6030,'getmain_main','Main','text{20|30','build'"); $installer->add_config("6040,'defmain','1','radio{Main^1|Mainless Alt^0','build'"); $installer->add_config("6050,'invmain','0','radio{Main^1|Mainless Alt^0','build'"); $installer->add_config("6060,'altofalt','alt','select{Try to resolve^resolve|Leave in table^leave|Set as main^main|Set as mainless alt^alt','build'"); $installer->add_config("6070,'update_type','1','select{None^0|Guild^1|Character^2|Both^3','build'"); $installer->add_query("DROP TABLE IF EXISTS `" . $installer->table('alts') . "`;"); $installer->add_query(" CREATE TABLE `" . $installer->table('alts') . "` ( `member_id` int(11) unsigned NOT NULL default '0', `main_id` int(11) unsigned NOT NULL default '0', `alt_type` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`member_id`) ) TYPE=MyISAM;"); # Roster menu entry $installer->add_menu_button('memberslist_Members','guild',''); $installer->add_menu_button('memberslist_Stats','guild','-statslist'); $installer->add_menu_button('memberslist_Honor','guild','-honorlist'); $installer->add_menu_button('memberslist_Log','guild','-log'); return true; } function upgrade($oldversion) { // Nothing to upgrade from yet return false; } function uninstall() { global $installer; $installer->remove_all_config(); $installer->add_query("DROP TABLE IF EXISTS `" . $installer->table('alts') . "`;"); $installer->remove_menu_button('memberslist_Members'); $installer->remove_menu_button('memberslist_Stats'); $installer->remove_menu_button('memberslist_Honor'); $installer->remove_menu_button('memberslist_Log'); return true; } }
Roster Config API
This is the current functionality of the Roster Config API.
There are two classes of form types:- Option blocks for layout
- Actual options
Items of the page, pageframe, and pagehide class contain option blocks.
Items of the blockframe or blockhide class contain options.
Menu Bar Items
- page, pageframe, pagehide, blockframe, blockhide:
- A page of options that gets selected with javascript
- $installer->add_config("'110','config_name',NULL,'blockframe','menu'")
- $installer->add_config("'150', 'config_name', NULL, 'page{1', 'menu'")
- link
- An external link to be opened in the same window
- $installer->add_config("120,'config_name','link_value','link','menu'")
- newlink
- An external link to be opened in a new window
- $installer->add_config("170,'config_name','http://www.someurl.com','newlink','menu'")
- makelink
- Passes this through Roster's makelink() function to generate a correct link to another page in Roster.
- $installer->add_config("120,'config_name','link_value','makelink','menu'")
- makenewlink
- Same as makelink, except it opens a new browser window.
- $installer->add_config("180,'config_name','link_value','makenewlink','menu'")
Options Blocks
- page{n
- n columns of options blocks
- $installer->add_config("'4001', 'menu_conf_wide', NULL, 'page{2', 'menu_conf'")
- pageframe{n
- n columns of options blocks in a border
- $installer->add_config("'4025', 'menu_conf_left', NULL, 'pageframe{3', 'menu_conf'")
- pagehide{n
- n columns of options blocks in a border, with a show/hide option
- $installer->add_config("'4020', 'menu_conf_hidden', NULL, 'pagehide{1', 'menu_conf'")
- blockframe
- A list of options in a border
- $installer->add_config("'4000, 'menu_conf_top', NULL, 'blockframe', 'menu_conf'")
- blockhide
- A list of options in a border, with a show/hide option
- $installer->add_config("'4050, 'menu_conf_bottom', NULL, 'blockhide', 'menu_conf'")
- function{name
- Calls the function called name with no parameters to produce the HTML for the page.
- If this is a tab (directly linked from the switch menu on the left side) it is put outside the main form so you can put forms in it.
- $installer->add_config("'4470', 'menu_conf_right', NULL, 'function{newForm', 'menu_conf_top'")
Options
- text{n|m
- A text box m characters wide, maximum of n characters input
- $installer->add_config("'1110','page_size','0','text{4|30','menu_conf_top'")
- radio{op1^val1|op2^val2|op3^val3...
- A list of radio buttons with labels op1, op2, op3,...
- Which produce values val1, val2, val3,...
- Labels are literal, not localization keys.
- $installer->add_config("'1010','nojs','0','radio{Server^1|Client^0','menu_conf_top'")
- select{op1^val1|op2^val2|op3^val3...
- A dropdown box with options op1, op2, op3,...
- Which produce values val1, val2, val3,...
- Labels are literal, not localization keys.
- $installer->add_config("'1020','def_sort','Note','select{Public Note^Note|Officer Note^OfficerNote','menu_conf_top'")
- function{name
- Calls the function called name with the option record as parameter to produce the HTML for the option.
- $installer->add_config("'4270', 'left_text', 'VERANDA.TTF', 'function{fontFiles', 'menu_conf_top'")
- display
- Displays the option's setting.
- $installer->add_config("'3, 'help_text', 'This is to help', 'display', 'menu_conf_top'")
- color
- Enables the use of the color picker javascript to pick a color from a pallet
- $installer->add_config("'4230', 'menu_left_barcolor', '#3e0000', 'color', 'menu_conf_top'")
AddOn Config Function File
addons/addonname/admin/config.func.php
- Both function types call functions that can be defined in a file called 'config.func.php' in your AddOn's admin/ directory.
- If this file has a function named topBox(), the html returned by this function will be put above the options in the middle column.
Locale Files
These are used in translating any text in your AddOn if you want to support multi-langages.
As you can see in the example below, we have a file for deDE which is the German language, enUS which is the English language, frFR for French, and esES for Spanish.Roster currently supports deDE, enUS, frFR, and esES, these are taken out of character profiler based on what region of WOW they are using.
The folder structure for locale files is as follows:
roster/ |_ addons/ |_ addonname/ |_ locale/ |_ deDE.php |_ enUS.php |_ esES.php |_ frFR.php
When using locale files, it is absolutely necessary to ALWAYS have enUS.php
The AddOn Framework will default to this file if a locale is not found for a specific localeExample:
- You make an AddOn and only create it in English (enUS.php only, no other locale files)
- Someone downloads your AddOn for a deDE Roster
- The AddOn Framework automatically inserts the enUS locale strings into the deDE locale
- This way, you only need to have enUS.php
- Later, if other locales are translated, they can be placed into the locale folder and Roster will detect them
Using Locale Strings
When using these them in your script you can use something similar to this
$header_title = $roster->locale->wordings['locale_key']['some_key'];
or
$header_title = $roster->locale->act['some_key'];
The first example is to get a specific locale value
The second is a reference to the current locale set in RosterRemember that Roster's locale files are already added, so you only have to add the stuff that is custom to your AddOn.
So if you need to check to make sure we have don't already have a translation, you can open the files in the "localization/" directory to see the default words that you don't have to duplicate.
Duplication may cause errors in the main Roster code, if you duplicate a main Roster locale variable, you will incur the wrath of the WoWRoster.net Dev Team
Example File
Example from the PvPLog Roster AddOn
addons/questlist/locale/deDE.php<?php /** * WoWRoster.net WoWRoster * * LICENSE: Licensed under the Creative Commons * "Attribution-NonCommercial-ShareAlike 2.5" license * * @copyright 2002-2007 WoWRoster.net * @license http://creativecommons.org/licenses/by-nc-sa/2.5 Creative Commons "Attribution-NonCommercial-ShareAlike 2.5" * @version SVN: $Id: deDE.php 899 2007-05-06 10:16:36Z Zanix $ * @link http://www.wowroster.net */ $lang['bglog']='BG Übersicht'; $lang['pvplog']='PvP Übersicht'; $lang['duellog']='Duell Übersicht'; $lang['duelsummary']='Duell Summary'; $lang['totalwins']='Gewinne total'; $lang['totallosses']='Verluste total'; $lang['totaloverall']='Gesamt'; $lang['win_average']='Durchschnittliche Level Differenz (Gewinne)'; $lang['loss_average']='Durchschnittliche Level Differenz (Verluste)'; // These need to be EXACTLY what PvPLog stores them as $lang['alterac_valley']='Alteractal'; $lang['arathi_basin']='Arathibecken'; $lang['warsong_gulch']='Kriegshymnenschlucht'; $lang['world_pvp']='Welt-PvP'; $lang['versus_guilds']='Gegengilden'; $lang['versus_players']='Gegenspieler'; $lang['bestsub']='Beste Subzone'; $lang['worstsub']='Schlechteste Subzone'; $lang['killedmost']='Am meisten getötet'; $lang['killedmostby']='Am meisten getötet durch'; $lang['gkilledmost']='Am meisten getötete Spieler der Gilde'; $lang['gkilledmostby']='Am meister getötet durch Spieler der Gilde'; $lang['wins']='Gewinne'; $lang['losses']='Verluste'; $lang['overall']='Gesamt'; $lang['best_zone']='Beste Zone'; $lang['worst_zone']='Schlechteste Zone'; $lang['most_killed']='Meisten getötet'; $lang['most_killed_by']='Meisten getötet durch'; $lang['leveldiff']='LevelDiff'; $lang['bg']='Schlachtfeld'; $lang['kills']='Kills'; // guildpvp strings $lang['guildwins'] = 'Wins by Guild'; $lang['guildlosses'] = 'Losses by Guild'; $lang['enemywins'] = 'Wins by Enemy'; $lang['enemylosses'] = 'Losses by Enemy'; $lang['purgewins'] = 'Guild Member Kills'; $lang['purgelosses'] = 'Guild Member Deaths'; $lang['purgeavewins'] = 'Best Win/Level-Diff Average'; $lang['purgeavelosses'] = 'Best Loss/Level-Diff Average'; $lang['pvpratio'] = 'Solo Win/Loss Ratios'; $lang['playerinfo'] = 'Player Info'; $lang['kill_lost_hist']='Kill/Loss history for %1$s (%2$s %3$s) of %4$s'; $lang['kill_lost_hist_guild'] = 'Kill/Loss history for Guild "%1$s"'; $lang['solo_win_loss'] = 'Solo Win/Loss Ratios (Level differences -7 to +7 counted)'; $lang['guildinfo'] = 'Guild Info'; $lang['admin']['pvpconfig'] = "PvPLog Config|Configure PvPLog main options"; $lang['admin']['minPvPLogver'] = "Min PvPLog version|Minimum PvPLog Version zum Upload";
CSS Styles
/****************************** * $Id: default.css,v 1.7.2 2006/05/23 07:16:03 zanix Exp $ ******************************/ /* EXAMPLE FILE ONLY FOR THE DUMMY PAGE */ .dummyStyle { border: 30px green solid; }
I assume you know what css is...
AddOn Update Hook
<?php /** * WoWRoster.net WoWRoster * * LICENSE: Licensed under the Creative Commons * "Attribution-NonCommercial-ShareAlike 2.5" license * * @copyright 2002-2007 WoWRoster.net * @license http://creativecommons.org/licenses/by-nc-sa/2.5 Creative Commons "Attribution-NonCommercial-ShareAlike 2.5" * @version SVN: $Id: update_hook.php 899 2007-05-06 10:16:36Z Zanix $ * @link http://www.wowroster.net */ if ( !defined('ROSTER_INSTALLED') ) { exit('Detected invalid access to this file!'); } /** * Addon Update class * This MUST be the same name as the addon basename */ class recipeUpdate { var $messages = ''; // Update messages var $data = array(); // Addon config data automatically pulled from the addon_config table var $files = array(); /** * Class instantiation * The name of this function MUST be the same name as the class name * * @param array $data | Addon data * @return recipe */ function recipeUpdate($data) { $this->data = $data; } /** * Resets addon messages */ function reset_messages() { $this->messages = ''; } function update() { global $roster; $this->messages .= "<span class=\"green\">This is a non CP hook</span><br />\n"; return true; } function guild_pre( $data ) { global $roster; $this->messages .= "<span class=\"green\">This is a guild_pre hook</span><br />\n"; return true; } function guild( $data , $memberid ) { global $roster; $this->messages .= "<span class=\"yellow\">This is a guild hook</span><br />\n"; return true; } function guild_post( $data ) { global $roster; $this->messages .= "<span class=\"red\">This is a guild_post hook</span><br />\n"; return true; } function char_pre( $data ) { global $roster; $this->messages .= "<span class=\"green\">This is a char_pre hook</span><br />\n"; return true; } function char( $data , $memberid ) { global $roster; $this->messages .= "<span class=\"yellow\">This is a char hook</span><br />\n"; return true; } function char_post( $data ) { global $roster; $this->messages .= "<span class=\"red\">This is a char_post hook</span><br />\n"; return true; } }
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.
-