PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Rich Gubby   Wapple Architect Mobilization   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example usage file
Class: Wapple Architect Mobilization
Create pages adapted to all mobile devices
Author: By
Last change:
Date: 14 years ago
Size: 3,395 bytes


Class file image Download
 * This is an example of how to use the wapl package.
 * - You'll need to get a free dev key from, and enter that below
 * - Line 20 checks if the given device is a mobile device,
 * and line 116 transforms the WAPL and outputs the markup to the device.
 * - How you build the WAPL is up to you, either:
 * - Use the $wapl->builder class to build your wapl programatically , as seen below
 * - Use your own templating method, calling $wapl->displayMarkupFromWapl
 * on the output ofthe template.
 * @author Rich Gubby
 * @version 1.0
 * @package WappleArchitect

$wapl = new wapl;

//Check to see if it's a mobile device hitting us and if so, use WAPL
//Builds the WAPL start tag
$string = $wapl->builder->start();
//Builds the WAPL head tag with title and CSS child elements
$string .= $wapl->builder->head(array(
'value'=>'WAPL Test Page'
//Build the WAPL layout tag, telling it to leave the tag open
$string .= $wapl->builder->layout(array('end' => false));
//Build a WAPL image element
$string .= $wapl->builder->image(
'url' => '',
'filetype' => 'png'
//Get a value from POST if it exists otherwise let's just say hello
$name = isset($_POST['your_name']) ? '"'.$_POST['your_name'].'"' : "Mundo";
$question = isset($_POST['your_name']) ? '[p]'.utf8_encode('Cómo estás?').'[/p]' : "";
$greeting = "[p][b]Hola {$name}[/b][/p] $question";

//Adds some text to the page
$string .= $wapl->builder->chars(
//We'll add the row and cell manually as an example
$string .= $wapl->builder->rowStart();
$string .= $wapl->builder->cellStart();
//Adds a form to the page
$string .= $wapl->builder->form(
'row'=>false, //Don't wrap it in a row - we built it above
'cell'=>false, //Don't wrap it in a cell - we built it above
'label'=>'Enter your name...',
'value'=>'in this box',
'label'=>'Click me'
//Ends the row and cell
$string .= $wapl->builder->cellEnd();
$string .= $wapl->builder->rowEnd();
//Adds a WAPL link to the bottom of the page
$string .= $wapl->builder->link(
'label'=>'Made with WAPL',
//End the layout tag
$string .= $wapl->builder->layout(array('start' => false));
//End the WAPL document
$string .= $wapl->builder->end();
//Echo the correct markup out to the device
//The device is not a mobile device, so just carry on with what you'd normally do.