The following is a collection of tips and tricks for coding that elucidate some of the darker corners of WIKINDX programming.
For conserving the browser state variables, WIKINDX can use either standard server sessions or its own storage mechanism designated browserTabID. In many cases, standard server session are fine with the state variables being common to all browser windows and tabs.
But, in other cases, it can be useful to open multiple browser windows or tabs in order to view, for example, different lists of resources. In such cases, the relevant state variables must be unique to each window or tab. In WIKINDX, this is accomplished using the browserTabID, and this storage mechanism must be enabled by the WIKINDX administrator in the Admin > Configure > Miscellaneous interface. A unique ID is generated for each window or tab and is used as the row identifier in the temp_storage database table. Rows in this table are deleted automatically if their timestamps are older than three days. This ID can be accessed in your code using:
$browserTabID = GLOBALS::getBrowserTabID()
and should be passed in a querystring as:
'&browserTabID=' . $browserTabID;
Passing the browserTabID in a querystring is especially important if you are redirecting using header(Location: index.php?xxxx)
and the browserTabID is not FALSE.
If you are using a form in your code, the variable ‘browserTabID’ is automatically added as a hidden form element.
Plugins
In most cases, the coding of plugins using the browserTabID proceeds as described here. In some cases, especially if the browserTabID is enabled and your plugin uses AJAX, you will run into trouble even if you are using standard server sessions: in this case
$BT
and setting it to FALSE in the constructor of your plugin’s index.php. (Note that it is not necessary to define and set $BT
to TRUE if you wish to use the browserTabID)formHeader()
, formHeaderVisibleAction()
, or formHeaderName()
with the BT parameter set to FALSE. For example, \FORM\formHeader('action string', 'javascript string', FALSE)
.You should generally access the browser state variables with the routines in the STORE library:
$store = FACTORY_STORE::getInstance();
This library handles either standard server sessions or browserTabID variables transparently depending on the WIKINDX configuration.
Note that some browser state variables must be accessed with the routines in the SESSION library:
$session = FACTORY_SESSION::getInstance();
as they are common to all browser windows and tabs. These variables include individual session variables:
and session variable arrays: