DLTab

Use in conjunction with DLSupportJS.Tab to hanlde a tab collection.

Summary
DLTabUse in conjunction with DLSupportJS.Tab to hanlde a tab collection.
Private Data
$content_wrapper(string) The ID of the content wrapper.
$tab_wrapper(string) The ID of the tab wrapper.
$tabs(array) An array containing all of tabs and their content.
Class Construction
__constructCreate a new instance of DLTab.
Tab Management
AddTabAdd a new tab to the list of tabs.
HTML Retrieval
GetAllHTMLGet all of the HTML.
GetContentHTMLRetrieve the HTML for the Contents.
GetJavaScriptGet the HTML for the initialization of the script.
GetTabHTMLRetrieve the HTML for the Tabs.

Private Data

$content_wrapper

private $content_wrapper

(string) The ID of the content wrapper.

$tab_wrapper

private $tab_wrapper

(string) The ID of the tab wrapper.

$tabs

private $tabs

(array) An array containing all of tabs and their content.

The array has the following structure

array(
     {id of tab} => Array (
         tab_id => {
            (string) The ID of the tab.
        },
         name => {
            (string) The title of the tab.
        },
         data => {
            (string) The data for the content of the tab.
        },
         is_link => {
            (boolean) Whether or not the data is a link.
        },
         load_once => {
            (boolean) Whether link should only be loaded once.
        }
     ),
     ...
)

Class Construction

__construct

public function __construct($tab_wrapper,
$content_wrapper)

Create a new instance of DLTab.

Parameters

$tab_wrapper(string) The tab wrapper’s ID.
$content_wrapper(string) The content wrapper’s ID.

Returns

An instance of DLTab.

Tab Management

AddTab

public function AddTab($id,  
$name,  
$data,  
$options =  array())

Add a new tab to the list of tabs.

Parameters

$id(string) The ID of the tab.  Set this to an empty string to have an ID automatically generated for it.
$name(string) The title of the tab.
$data(string) The data for the content of the tab.
$options(array) An associative array containing various options used by this method.  Defaults to an empty array.

The structure of the $options parameter, if given, should look like the following:

array(
    link => {
        (boolean) If this is set to TRUE, then the given *$data*
        should be the URL for which the content should be retrieved.
        Defaults to FALSE.
    },
    once => {
        (boolean) If this is set to TRUE and if the option *link* is
        also TRUE, then the content will only be fetched once.
        Defaults to FALSE.
    }
)

HTML Retrieval

GetAllHTML

public function GetAllHTML()

Get all of the HTML.

Returns

(string) All of the HTML.

GetContentHTML

public function GetContentHTML()

Retrieve the HTML for the Contents.

Returns

(string) The HTML for the Content wrapper and its contents.

GetJavaScript

public function GetJavaScript($name =  '',
$default =  '')

Get the HTML for the initialization of the script.

Note that this does not include the actual source code itself as that should have already been loaded via DLSupportJS.

Parameters

$name(string) Optional and defaults to an empty string.  The tab collection name.  Leave it as an empty string to use a randomly generated string.
$default(string) Optional and defaults to an empty string.  The ID of the tab that should be first shown to the user.  Leave it as an empty string to use the first tab declared.

Returns

(string) The HTML for the JavaScript initialization.

GetTabHTML

public function GetTabHTML()

Retrieve the HTML for the Tabs.

Returns

The HTML for the Tab wrapper and its tabs.

Sub class of DLSupportJS providing support for the tabs.
private $content_wrapper
(string) The ID of the content wrapper.
private $tab_wrapper
(string) The ID of the tab wrapper.
private $tabs
(array) An array containing all of tabs and their content.
public function __construct($tab_wrapper,
$content_wrapper)
Create a new instance of DLTab.
public function AddTab($id,  
$name,  
$data,  
$options =  array())
Add a new tab to the list of tabs.
public function GetAllHTML()
Get all of the HTML.
public function GetContentHTML()
Retrieve the HTML for the Contents.
public function GetJavaScript($name =  '',
$default =  '')
Get the HTML for the initialization of the script.
public function GetTabHTML()
Retrieve the HTML for the Tabs.