|
|
(8 intermediate revisions by one user not shown) |
Line 1: |
Line 1: |
− | __NOEDITSECTION__
| + | #REDIRECT [[AddonSDK]] |
− | {{Disclaimer}}
| + | |
− | {{MainMenu|Roster}}
| + | |
− | | + | |
− | =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<br />
| + | |
− | And Everyone involved in the project.
| + | |
− | | + | |
− | | + | |
− | '''Download the [http://www.wowroster.net/Downloads/details/id=32.html Roster AddOnSDK]'''
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | ==Certified WoWRoster AddOn==
| + | |
− | [[Image:Certaddon.png|frame|Certified WoWRoster AddOn]]
| + | |
− | AddOns that conform to our [[Roster:CodingStandards|Coding Standards]] and the basic outline described within this document, will be given a "<span style="color: darkred;">AddOn Framework Standards Compliant</span>" stamp of approval.
| + | |
− | | + | |
− | | + | |
− | ===Requirements for Approval===
| + | |
− | * Unique naming of variables in conf.php
| + | |
− | *: <php>$addon_conf['addon_name']['variable_name']</php>
| + | |
− | *: or
| + | |
− | *: <php>$addonname_variablename</php>
| + | |
− | *: 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 - <span style="color: maroon;">$roster->db</span>
| + | |
− | * 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<br>
| + | |
− | >[[Roster:Requirements|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.<br>
| + | |
− | 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.<br>
| + | |
− | So with each new version of Roster, some AddOns may break (not work in the new WoWRoster)
| + | |
− | | + | |
− | <blockquote style="border:2px outset red;padding:3px;">IMPORTANT:<br>
| + | |
− | DO NOT use php short tags in your php files<br>
| + | |
− | This is also stated in the [[Roster:CodingStandards|WoWRoster Coding Standards]]<br>
| + | |
− | <span style="color:red;">NO!</span> <code><? ?></code><br>
| + | |
− | <span style="color:green;">YES</span> <code><?php ?></code><br>
| + | |
− | Use the "long tags" as the short ones can break web servers with short_tags set to "off"
| + | |
− | </blockquote>
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | ==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?"<br>
| + | |
− | 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
| + | |
− | <pre>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
| + | |
− | </pre>
| + | |
− | | + | |
− | ====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<br>
| + | |
− | 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<br>
| + | |
− | Data for the requested character is passed to the AddOn<br>
| + | |
− | If member= is not specified or if this member does not exist, an error message will display
| + | |
− | | + | |
− | member= 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<br>
| + | |
− | 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<br>
| + | |
− | Data for the requested guild is passed to the AddOn<br>
| + | |
− | If guild= is not specified, the default guild/realm name set in Roster CP will show<br>
| + | |
− | If the guild does not exist or if there is no data for this guild, an error message will display
| + | |
− | | + | |
− | guild= 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<br>
| + | |
− | 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<br>
| + | |
− | This does not necessarily need to be called inc<br>
| + | |
− | 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<br>
| + | |
− | See below for more info [[#Locale Files|Locale Files]]
| + | |
− | | + | |
− | | + | |
− | ====Other Files and the util Scope====
| + | |
− | Files not in these folders are considered under the util scope<br>
| + | |
− | 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<br>
| + | |
− | 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
| + | |
− | * [[#Creating_the_Installer|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
| + | |
− | * [[#Creating_the_Installer|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.<br>
| + | |
− | 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.
| + | |
− | <pre>array(
| + | |
− | array( "name"=> "Name",
| + | |
− | "info"=> "Some Info"),
| + | |
− | array( "name"=> "Another Name",
| + | |
− | "info"=> "More Info"),
| + | |
− | );</pre>
| + | |
− | | + | |
− | | + | |
− | ===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.
| + | |
− | | + | |
− | * 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.<br>
| + | |
− | 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<br>
| + | |
− | From the "Keys" AddOn
| + | |
− | <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: pvp3.php 897 2007-05-06 00:35:11Z Zanix $
| + | |
− | * @link http://www.wowroster.net
| + | |
− | */
| + | |
− | | + | |
− | if ( !defined('ROSTER_INSTALLED') )
| + | |
− | {
| + | |
− | exit('Detected invalid access to this file!');
| + | |
− | }
| + | |
− | | + | |
− | class keys
| + | |
− | {
| + | |
− | var $active = true;
| + | |
− | var $icon = 'inv_misc_key_06';
| + | |
− | | + | |
− | var $upgrades = array(); // There are no previous versions to upgrade from
| + | |
− | | + | |
− | var $version = '1.8.0.0';
| + | |
− | | + | |
− | var $fullname = 'Instance Keys';
| + | |
− | var $description = 'Lists Dungeon keys for members';
| + | |
− | var $credits = array(
| + | |
− | array( "name"=> "WoWRoster Dev Team",
| + | |
− | "info"=> "Original Author")
| + | |
− | );
| + | |
− | | + | |
− | | + | |
− | function install()
| + | |
− | {
| + | |
− | global $installer;
| + | |
− | | + | |
− | // Master and menu entries
| + | |
− | $installer->add_config("'1','startpage','keys_conf','display','master'");
| + | |
− | $installer->add_config("'110','keys_conf',NULL,'blockframe','menu'");
| + | |
− | | + | |
− | $installer->add_config("'1010','colorcmp','#00ff00','color','keys_conf'");
| + | |
− | $installer->add_config("'1020','colorcur','#ffd700','color','keys_conf'");
| + | |
− | $installer->add_config("'1030','colorno','#ff0000','color','keys_conf'");
| + | |
− | | + | |
− | $installer->add_menu_button('keys','guild','');
| + | |
− | return true;
| + | |
− | }
| + | |
− | | + | |
− | function upgrade($oldversion)
| + | |
− | {
| + | |
− | // Nothing to upgrade from yet
| + | |
− | return false;
| + | |
− | }
| + | |
− | | + | |
− | function uninstall()
| + | |
− | {
| + | |
− | global $installer;
| + | |
− | | + | |
− | $installer->remove_all_config();
| + | |
− | | + | |
− | $installer->remove_menu_button('keys');
| + | |
− | return true;
| + | |
− | }
| + | |
− | }</php>
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | ==Roster Config API==
| + | |
− | This is the current functionality of the Roster Config API.<br>
| + | |
− | There are two classes of form types:
| + | |
− | * Option blocks for layout
| + | |
− | * Actual options
| + | |
− | Items of the page, pageframe, and pagehide class contain option blocks.<br>
| + | |
− | 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','<nowiki>http://www.someurl.com</nowiki>','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.<br>
| + | |
− | 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:
| + | |
− | <pre>roster/
| + | |
− | |_ addons/
| + | |
− | |_ addonname/
| + | |
− | |_ locale/
| + | |
− | |_ deDE.php
| + | |
− | |_ enUS.php
| + | |
− | |_ esES.php
| + | |
− | |_ frFR.php</pre>
| + | |
− | When using locale files, it is absolutely necessary to ALWAYS have enUS.php<br>
| + | |
− | The AddOn Framework will default to this file if a locale is not found for a specific locale
| + | |
− | | + | |
− | Example:
| + | |
− | * 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
| + | |
− | <php>$header_title = $roster->locale->wordings['locale_key']['some_key'];</php>
| + | |
− | or
| + | |
− | <php>$header_title = $roster->locale->act['some_key'];</php>
| + | |
− | The first example is to get a specific locale value<br>
| + | |
− | The second is a reference to the current locale set in Roster
| + | |
− | | + | |
− | Remember 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<br>
| + | |
− | addons/questlist/locale/deDE.php
| + | |
− | <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";
| + | |
− | </php>
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | ==CSS Styles==
| + | |
− | <css>/******************************
| + | |
− | * $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;
| + | |
− | }
| + | |
− | </css>
| + | |
− | | + | |
− | I assume you know what css is...
| + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | | + | |
− | ==AddOn Update Hook==
| + | |
− | <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: 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;
| + | |
− | }
| + | |
− | }</php>
| + | |
− | | + | |
− | [[Category:RosterAddon]] | + | |