PHP

The PHP API v0.2

Introduction

You will find here the detailed API of the Atlas toolkit for PHP. The API overview contains also useful information about the API.

Static functions of the Atlas class

launch

function launch( string $newSessionAction )

Launches the server. newSessionAction is the value returned by below getAction(...) function when a new session is launched.

NOTA: in some examples, a launch function with extraneous parameters is used. For your own developments, you don't need to give this extraneous parameters.

Global

DOM constructor

Takes no parameter.

alert

function alert( string $message )

Displays an alert box with the string message as message.

confirm

function confirm( string $message )

Displays a confirmation dialog box with message as message. The returned value is true when the user clicks the OK button, and false when the user clicks the cancel button.

focus

function focus( string $id )

Gives the focus to element of id id.

headUp

headUp( string $html )

When used, this method must be called before the setLayout[XSL](...) method.

This puts the content of html in the head section of the application's main page. You can put here the links to CSS files, for example.

getAction

function getAction( &$id )

When an event occurs, returns the corresponding action (as defined in the data-xdh-event(s) attributes). id is the id of the element on which the event occurs. This function is blocking.

Attribute

getAttribute

function getAttribute( string $id, string $name )

Returns the value of the attribute named name of the element of id id.

removeAttribute

function removeAttribute( string $id, string $name )

Removes attribute named name from element of id id.

setAttribute

function setAttribute( string $id, string $name, string $value ) 

Set value as value for the attribute named name of the element of id id.

Class

Following methods allows to handle classes (the CSS related class attributes of HTML tags), by respectively add, remove or toggle (i.e. adds if not present, otherwise removes) a class to elements identified by their ids (the content of the id attribute from HTML tags).

idsAndClasses must have following form:

[
    "id1" => "class1",
    "id2" => "class2",
    "id3" => "class3",
    ...
]

addClass

function addClass( string $id, string $class  )

addClasses

function addClasses( array $idsAndClasses )

removeClass

function removeClass( string $id, string $class  )

removeClasses

function removeClasses( array $idsAndClasses )

toggleClass

function toggleClass( string $id, string $class  )

toggleClasses

function toggleClasses( array $idsAndClasses )

Content

getContent

function getContent( string $id )

Retrieve the content of the element of id id.

getContents

function getContents( array $ids )

Retrieves the content of the elements of ids ids in the same order.

setContent

function setContent( string $id, string $content )

Set the content of element of id id to value.

setContents

function setContents( array $idsAndContents )

Set the content of all element which id are in idsAndContents to corresponding content.

idsAndContents must have following form:

[
    "id1" => "content1",
    "id2" => "content2",
    "id3" => "content3",
    ...
]

Element

enableElement

function enableElements( array $ids )

Enable element of id id.

enableElements

function enableElements( array $ids )

Enable element of ids ids.

disableElement

function disableElement( string $id ) {

Disable element of if id.

disableElements

function disableElements( array $ids )

Disable element of ids ids (array of strings).

Layout

setLayout

function setLayout(string  $id, string $html )

Replaces the content of element with string id as id with the content of html.

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

The content of html can be generated with the template engine of your choice. For XSL(T), you can used the dedicated method setLayoutXSL(...).

setLayoutXSL

function setLayoutXSL(string  $id, string $xml, string $xslFilename )

Replaces the content of element with id as id with the result of the transformation of the XSL file with name xslFilename applied to the content of xml, which must be valid XML.

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

Property

getProperty

function getProperty( string $id, string $name )

Returns the value of property named name of the element of id id.

setProperty

function setProperty( string $id, string $name, string $value )

Set value as value for the property named name of the element of id id.

Widget

dressWidgets

function dressWidgets( string $id )

Create the widget for each elements which are children of the element of id id and which have a data-xdh-widget attribute.

If id is an empty string, the entire document is handled.