This abstraction of responsibilities and the decoupling of key tasks that results allows for painless integration with a Smarty template system. The result is the ability to easily produce applications that are very extensible and flexible from the points of view of both visual and programming design.
<form method="post"> <?php require_once('webapp/mapapp.php'); // MapApps are designed to run under a session session_start(); if (!isset($_SESSION['mapapp'])) { // we must set up the map // create a map to use $map_manager = new MapManager('mapfile.map'); // initialise the primary package object $_SESSION['mapapp'] = new MapApp($map_manager); // initialise the map $_SESSION['mapapp']->init(); } else { // we need to update the map with any new user actions $_SESSION['mapapp']->update(); } // output the updated map to the screen print $_SESSION['mapapp']->toString(); ?> </form>
Assuming a correctly configured mapfile, this example provides all the code needed to run an online mapping application. Customisations to the visual design are performed by altering the Smarty template and customisations to the code are accomplished by extending the MapApp class. The MapApp class documentation illustrates how to do this.