* Proper use of the DB layer - <span style="color:maroon;">$roster->db</span>

+

* Proper use of the DB layer - [[Roster:FunctionsOverview#.24roster-.3Edb|$roster->db]]

* Roster main files are not edited

* Roster main files are not edited

* Roster main database tables are not edited, unless you provide a clean way to revert the data in your uninstall

* Roster main database tables are not edited, unless you provide a clean way to revert the data in your uninstall

Line 138:

Line 59:

So with each new version of Roster, some AddOns may break (not work in the new WoWRoster)

So with each new version of Roster, some AddOns may break (not work in the new WoWRoster)

−

<div style="margin:5px 0 5px 0;">

+

{{Warning|Important|DO NOT use php short tags in your php files as stated in the [[CodingStandards|WoWRoster Coding Standards]]<br>Use the normal "long tag" as short tags can break page rendering with php "short_tags" set to "Off"<br><br>'''NO!''' <code><?</code><br>'''YES''' <code><?php</code><br>'''NO!''' <code><nowiki><?=$var; ?></nowiki></code><br>'''YES''' <code><nowiki><?php echo $var; ?></nowiki></code>}}

Roster main database tables are not edited, unless you provide a clean way to revert the data in your uninstall

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 as stated in the WoWRoster Coding StandardsUse the normal "long tag" as short tags can break page rendering with php "short_tags" set to "Off"

guild Folder (guild scope)

Files for use in the Guild scope
Data for the requested guild is passed to the AddOn
If a=g: 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 display

You can also use this folder for library, class, and/or function files

Place any files here that you do not or should not be accessed directly by the AddOn Framework

locale Folder

Where locale translation files go
See below for more info Locale Files

realm Folder (realm scope)

Files for use in the Realm scope
Data for the requested realm is passed to the AddOn
If a=r: is not specified, the default realm name set in Roster CP will show
If the realm does not exist or if there is no data for this realm, an error message will display

Creating the Search Class

Get customizable search results on the Roster search page for your AddOn
AddOn search classes are basically just SQL statements with some added functionality for the Search Framework
The search class can search by using SQL and process the data in a readable format for display
The search framework handles pagination, display, and basic form generation (each AddOn can specify additional form fields for its search)

Addon Class

Each AddOn utilizes a hook file /inc/search.inc.php to include a customized search for that AddOn

Properties

var $options

array - Used to to add advanced options to the search page

var $result

array - Search array

var $result_count

int - Counter for results display

var $start_search

int - Time search starts

var $stop_search

int - Time search stops

var $time_search

int - Time spent on search

var $open_table

string - Insert a custom header in the search results

var $close_table

string - Insert a custom footer in the search results

var $search_url

string - Additional data to insert into the prev/next url links

var $data

array - An array that holds all of the addons data, including config

The search framework automatically populates this property

Methods

Constructor

Used to set up data needed for your search class

Use this to populate $this->open_table, $this->close_table, and/or $this->options

search

search( $search , $limit=10 , $page=0 )
The meat and potatoes of your search class
Perform the SQL and process any returned data in this class method

add_result

add_result( $resultarray )
Required function for any search hook used to add result data to the search framework

Return Data

This data is returned to the search framework after your search hook is done processing data
This data must be passed to $this->add_result($item); to show up on the search results page

var $item['results_header']

string - Adds a header before the result row (outside the <tr>) within that addon search

var $item['results_footer']

string - Adds a footer after the result row (outside the </tr>) within that addon search

Usage

In most cases the config_name is a reference to an entry in your locale file. Each entry you make needs to have a unique config name. The entry in the locale file needs to contain at least the prompt text, but can also contain hover help text by seperating them with a vertical bar '|'.

AddOn Config Function File

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.

Template Parser

Available to AddOns is the template parser which enables making the layout of your AddOn easier and easier to edit.
Roster automatically includes the template parser on initialization.

The templates have {CONTAINERS} for the information from php. This {INFO} is replaced by the output of the php code.
This means you have full control of where these containers are displayed or whether they are at all.

Currently the only AddOn in the Roster core that uses templates is "News".
All examples below are from the "News" AddOn.

Getting Started

Create a folder in roster/templates/default/ with your AddOn's basename
Or create a templates/ folder in your addon folder
This folder will hold all the templates for your AddOn

The PHP Side

In your php files, we will be calling the $roster->tpl object to insert data into your template

What happens here is that we are making and setting template variables.
Notice how the variables in available to the template are much simpler than the php variables
'L_POSTEDBY' as opposed to $roster->locale->act['posted_by']

This all all fine and good for variables, but what if you want a repeating section?
This is quite easy actually.

Here we will be reading from the database and creating a template block variable

$roster->output['show_menu'] accepts a string or an array of button panel names to display
When building an addon, you can build your own button listing that only displays on your addon pages
Pass a string for only one set of buttons, or pass an array for multiple sets of buttons

$roster->auth->getMessage() - (string) Message sent from Roster Login, such as "Logged Out" or "Wrong Password"

$roster->auth->getLoginForm() - (string) The Roster Log-in form

Also note that there is a log in box in the menu.

Addon Credits

Link = http://[www.someurl.net]/roster/?p=credits (SEO: http://[www.someurl.net]/roster/credits.html)
To get credits on the main credit page, set the $credits array in the AddOn's inc/install.def.php file