| 
<?php 
/*
 * This is an example of how to use the wapl package.
 *
 *  - You'll need to get a free dev key from http://wapl.info, 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
 */
 require_once('wapl.php');
 
 $wapl = new wapl;
 $wapl->setDevKey('YOUR-DEV-KEY');
 
 
 //Check to see if it's a mobile device hitting us and if so, use WAPL
 if($wapl->isMobileDevice())
 {
 //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(
 'children'=>array(
 'title'=>array(
 'tag'=>'title',
 'options'=>array(
 'value'=>'WAPL Test Page'
 )
 ),
 'mobileCSS'=>array(
 'tag'=>'css',
 'options'=>array(
 'url'=>'http://wapple.net/css/mobile2.css'
 )
 )
 )
 ));
 //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(
 array(
 'url' => 'http://wapl.info/img/logo.png',
 '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(
 array(
 'value'=>$greeting,
 'make_safe'=>'true'
 )
 );
 
 
 //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(
 array(
 '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
 'action'=>'',
 'children'=>array(
 'name'=>array(
 'tag'=>'formItem',
 'options'=>array(
 'item_type'=>'text',
 'label'=>'Enter your name...',
 'value'=>'in this box',
 'name'=>'your_name'
 )
 ),
 'submit'=>array(
 'tag'=>'formItem',
 'options'=>array(
 'item_type'=>'submit',
 '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(
 array(
 'external'=>true,
 'url'=>'http://wapl.info/',
 '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
 $wapl->displayMarkupFromWapl($string);
 }
 else{
 //The device is not a mobile device, so just carry on with what you'd normally do.
 }
 ?>
 |