phpDocumentor SMap
[ class tree: SMap ] [ index: SMap ] [ all elements ]

Class: SMap_Form

Source Location: /SMap/Form.php

Class SMap_Form

Class Overview

This is partially user interface, but mostly a form controller

It controls all interaction between the user. Nothing here should throw exceptions unless passed an incorrect object. We can't trust the user, so incomplete vars are just set to default.

Located in /SMap/Form.php [line 54]



		
				Author(s):
		
API Tags:
Abstract:  

Properties

Methods

[ Top ]
Property Summary
array   $curr   Currently set variables
array   $defs   Defaults
string   $formPrefix   GET variable prefix
object   $geo   Store the geography
boolean   $isTile   Is the environment a tile image?
object   $lang   Store the language package
array   $perm   Permanent variables
array   $prefs   Any user preferences should be stored here.
array   $request   The incoming request variables
array   $scrSizeSel   Options for the screen size selection
object   $sform   Use a SForm to handle all user transactions

[ Top ]
Method Summary
SMap_Form   __construct()   Init the form object
array   addCheckedElms()   Add a set of checkable elements
void   addScrSizeElm()   Add the SForm screen size selector element
array   decodeTileGrid()   Decode the tile grid
string   encodeTileGrid()   Encode the tile grid
void   formSubmitted()   Handles a submitted user form
array   getBoundVars()   Returns an array of the current bounding information
array   getClickCoords()   Get the click coordinates
array   getLinkIds()   Remove cruft from a list of IDs
string   getLinkXHTML()   Returns the XHTML for a link view.
array   getMapVars()   Returns an array of the current map's info.
string   getMapXHTML()   Returns the XHTML for a map view.
string   getPageLink()   Create a map URL
array   getScrPxDim()   What are the pixel dimensions for each screen size selector
object This   getSForm()   Return the form that we are using
array   getTileVars()   Returns an array of the current tile's info.
array   getViewDim()   Returns the dim of the viewport
void   initDefs()   Init the default array
void   initPrefs()   Init the prefernce array
void   initRequest()   Init the request array
object SForm   initSForm()   Create an SForm object
void   setPxDim()   Set the pixel dimensions of this tile

[ Top ]
Properties
array   $curr = array() [line 145]

Currently set variables

Once the form variables are deciphered, they are set here. After object construction, the final value of the form's values should be stored here. When in doubt, use these values.

API Tags:
Usedby:  SMap_Form::formSubmitted()
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
array   $defs = array() [line 175]

Defaults

When a visitor first visits the page, the settings should be these.

API Tags:
Usedby:  SMap_Form::initDefs()
Access:  protected


[ Top ]
string   $formPrefix = 'm' [line 68]

GET variable prefix

Set so the mapping vars don't collide with anything else. Altering this will theoretically allow people to place more than one map on a page without them interfering with eachother.

Note that there are static variables in the layout engine that may collide, so exercise caution.

API Tags:
Usedby:  SMap_Form::initSForm()
Access:  public


[ Top ]
object   $geo [line 115]

Store the geography

Set by the constructor

API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
boolean   $isTile [line 185]

Is the environment a tile image?

Set when we will be drawing the image for a single tile. The process is normally that a script pretends to be

API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
object   $lang [line 106]

Store the language package

Set by the constructor

API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
array   $perm = array('views'=>array(),'layers'=>array()) [line 134]

Permanent variables

All values set here are permanently set. For example, if you want a view to always be shown, set its ID in here. Same thing for layer(s).

API Tags:
Access:  protected


[ Top ]
array   $prefs = array() [line 166]

Any user preferences should be stored here.

Variables in this array will take priority over the defaults, but will be slave to the $request variables.

API Tags:
Usedby:  SMap_Form::initPrefs()
Access:  protected


[ Top ]
array   $request = array() [line 155]

The incoming request variables

Use whatever method you wish to place the appropriate request in this array.

API Tags:
Usedby:  SMap_Form::initRequest()
Access:  protected


[ Top ]
array   $scrSizeSel = array(
'Standard' => array(
'800x600 (small)' => '800x600',
'1024x768 (medium)' => '1024x768',
'1280x1024 (large)' => '1280x1024',
'1600x1200 (x-large)' => '1600x1200' ),'Widescreen'=>array('1024x640 (small)'=>'1024x640','1280x800 (medium)'=>'1280x800','1600x1000 (large)'=>'1600x1000','1920x1200 (x-large)'=>'1920x1200'),'Print'=>array('US Letter'=>'1075x1395p','US Legal'=>'1075x1775p','A5'=>'740x1050p','A4'=>'1050x1485p','A3'=>'1485x2100p'))
[line 79]

Options for the screen size selection

Here are some suggestions for common opt groups, option labels, and option values. Values are automatically parsed via regex in getScrPxDim().

API Tags:
Usedby:  SMap_Form::getScrPxDim()
Usedby:  SMap_Form::addScrSizeElm()
Access:  protected


[ Top ]
object   $sform [line 124]

Use a SForm to handle all user transactions

http://www.phpclasses.org/browse/package/3465.html

API Tags:
Usedby:  SMap_Form::getSForm()
Usedby:  SMap_Form::formSubmitted()
Usedby:  SMap_Form::initRequest()
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 209]

  SMap_Form __construct( SMap_Lang $lang, SMap_Geo $geo, boolean $isTile  )

Init the form object

The construction of the SMap_Form should handle all of the input, and from here on out the values in $curr should be constant.

Parameters:
object Language   $lang:  used
object Geographic   $geo:  def
boolean   $isTile:  Are we drawing a single tile?

API Tags:
Uses:  SMap_Form::initPrefs()
Uses:  SMap_Form::initDefs()
Uses:  SMap_Form::initRequest()
Uses:  SMap_Util::normalizeBounds()
Uses:  SMap_Util::wrapBounds()
Uses:  SMap_Form::getViewDim()
Uses:  SMap_Form::formSubmitted()
Uses:  SMap_Form::$geo
Uses:  SMap_Form::$isTile
Uses:  SMap_Form::$lang
Uses:  SMap_Form::$sform
Uses:  SMap_Form::$curr


[ Top ]
addCheckedElms  [line 733]

  array addCheckedElms( $grp, string $type, array $elmDefs, array $checkedElms, array $permElms, [object Select $sel = null]  )

Add a set of checkable elements

Adds a set of checkboxes or radio buttons to a given SForm container. The container can be a group, fieldset, form, or whatever. The element definitions define the id of each layer or view as the keys, and the element's label as the values. The status of the elements is an array of the currently enabled id's.

If $sel is used the set turns dynamic. Elements selected by $sel appear in the checked list. Elements that are unchecked dissappear from the checked list, but reappear in $sel.

Parameters:
object Container   $grp:  to add the elements too
string   $type:  Type of checkable to add.
array   $elmDefs:  Element definitions. 'elm id' => 'checkbox label'
array   $checkedElms:  Current status of elements.
array   $permElms:  Permanent elements
object Select   $sel:  element to dynamically add checkable elements

API Tags:
Return:  New set of enabled element.
Access:  protected


[ Top ]
addScrSizeElm  [line 812]

  void addScrSizeElm( $form, $bounds, $zoom  )

Add the SForm screen size selector element

Parameters:
SForm_Container   $form: 
   $bounds: 
   $zoom: 

API Tags:
Usedby:  SMap_Form::formSubmitted()
Access:  protected
Uses:  SMap_Form::$scrSizeSel


[ Top ]
decodeTileGrid  [line 613]

  array decodeTileGrid( string $str  )

Decode the tile grid

Parameters:
string   $str:  The encoded grid

API Tags:
Return:  The decoded grid
Uses:  SMap_Util::dec()
Access:  protected
Uses:  SMap_Tile::VIEWY
Uses:  SMap_Tile::VIEWX
Uses:  SMap_Tile::POSX
Uses:  SMap_Tile::POSY
See:  SMap_Form::encodeTileGrid()


[ Top ]
encodeTileGrid  [line 549]

  string encodeTileGrid( array &$tg, [integer $usage = null]  )

Encode the tile grid

Generates a string of 3-4 chars which contains all tileGrid info. Pass a usage mask, generally SMap_Tile::tileGridNeeded. If no mask is passed, we assume you want the whole grid encoded.

Output is undefined if the tilegrid is greater than 62 tiles in either dimension. It really shouldn't be that large anyway.

Parameters:
array   &$tg:  Tile grid
integer   $usage:  Usage mask

API Tags:
Return:  Encoded tilegrid
Uses:  SMap_Util::enc()
Access:  protected
Uses:  SMap_Tile::VIEWY
Uses:  SMap_Tile::VIEWX
Uses:  SMap_Tile::POSY
Uses:  SMap_Tile::POSX


[ Top ]
formSubmitted  [line 399]

  void formSubmitted( )

Handles a submitted user form

Sets up the correct structure of the SForm with the correct defaults, elements, values, etc.


API Tags:
Access:  public
Usedby:  SMap_Form::__construct()
See:  SMap_Form::addCheckedElms()
Uses:  SMap_Form::getScrPxDim()
Uses:  SMap_Form::$sform
Uses:  SMap_Form::addScrSizeElm()
Uses:  SMap_Form::$curr


[ Top ]
getBoundVars  [line 494]

  array getBoundVars( )

Returns an array of the current bounding information

The bounding array. All bounding indicies used in SMap are defined in SMap. Specifically: SMap::MAXX, SMap::MAXY, SMap::MINX, and SMap::MINY.


API Tags:
Return:  Current bounds
Access:  public
Usedby:  SMap::__construct()
Uses:  SMap::MINY
Uses:  SMap::MINX
Uses:  SMap::MAXY
Uses:  SMap::MAXX


[ Top ]
getClickCoords  [line 936]

  array getClickCoords( array $B  )

Get the click coordinates

This is one of the few methods that uses the raw query string to parse out the location that the user clicked on the tile.

Parameters:
array   $B:  Tile bounds

API Tags:
Return:  Location clicked
Usedby:  SMap::handleImageMap()
Access:  public


[ Top ]
getLinkIds  [line 965]

  array getLinkIds( string $index, array &$orig, [array $rep = null]  )

Remove cruft from a list of IDs

This is intended to be used before creating a link to remove permenent IDs from a list. The normal targets are views and layers.

Parameters:
string   $index:  The ID index
array   &$orig:  The original IDs
array   $rep:  The replacement IDs (optional)

API Tags:
Return:  The minimal list of IDs
Access:  protected


[ Top ]
getLinkXHTML  [line 696]

  string getLinkXHTML( SMap_View $view, array $tileSet  )

Returns the XHTML for a link view.

The link view is a view that doesn't use images, all links that would otherwise be in the images are simply presented as links in a table (or whatever the template dictates). The link view is useful for accessibility and search engine reasons. Without a link view, a search engine couldn't crawl the map or a person with disabilities use the map. I'm not saying that it's easy to use the map using only the links in the table, but at least it's possible.

Expects a fully layered set and an array describing the current cell (see also getCurrentCell()). Also expects the view ID to determine which view we expect to be looking at. This can be useful if different view IDs have different templates, or whatever.

Returns the XHTML for the form + view templates.

(note: This has not been used yet.)

Parameters:
object View   $view:  to draw
array   $tileSet:  Assembled set of tiles

API Tags:
Return:  View XHTML
Access:  public
Abstract:  
See:  SMap_Form::encodeTileGrid()
See:  SMap_Tile::getImageMap()
See:  SMap_Form::$formPrefix


[ Top ]
getMapVars  [line 474]

  array getMapVars( )

Returns an array of the current map's info.

The returned array is the set of variables that describe the current map view. These include an array of all currently enabled views ['views'], layers ['layers'], the zoom level ['zoom'], and the language ['lang']. The language variable is a three letter ISO 639-2 language code.


API Tags:
Usedby:  SMap::getViewXHTML()
Usedby:  SMap::__construct()
Access:  public


[ Top ]
getMapXHTML  [line 667]

  string getMapXHTML( SMap_View $view, array $tileSet  )

Returns the XHTML for a map view.

The map view is a view with a set of arranged images of tiles. There are actions that can happen by clicking on each tile, those are determined by the layers that are passed in (zooming in would be a common one). The user can also pan the view around the view. Any actions that involve clicking on the view are handled by layers.

Returns the XHTML for the form + view templates.

Parameters:
object View   $view:  to draw
array   $tileSet:  Assembled set of tiles

API Tags:
Return:  View XHTML
Abstract:  
Access:  public
Usedby:  SMap_View_Raster::getXHTML()
See:  SMap_Util::transPng()
See:  SMap_Form::encodeTileGrid()
See:  SMap_Tile::getImageGET()
See:  SMap_Tile::getImageMap()
See:  SMap_Form::$formPrefix


[ Top ]
getPageLink  [line 710]

  string getPageLink( array $replacements  )

Create a map URL

Creates and customizes a URL that can be used for clicking on this view.

Parameters:
array   $replacements:  Override current variable(s)

API Tags:
Return:  A URL
Usedby:  SMap_Layer_Zoom::getZoomURL()
Usedby:  SMap_Layer_Zoom::getMapObjs()
Usedby:  SMap_Layer_Pan::getShiftedURL()
Access:  public
Abstract:  
See:  SMap_Form::getTileVars()
See:  SMap_Form::getMapVars()
See:  SMap_Form::getLinkIds()
See:  SMap_Form::$formPrefix


[ Top ]
getScrPxDim  [line 879]

  array getScrPxDim( )

What are the pixel dimensions for each screen size selector

$array[$optionValue] = array($pixelsWide, $pixelsHigh, $forPrint)


API Tags:
Usedby:  SMap_Form::formSubmitted()
Access:  protected
Uses:  SMap_Form::$scrSizeSel


[ Top ]
getSForm  [line 867]

  object This getSForm( )

Return the form that we are using


API Tags:
Return:  form's internal SForm
Access:  public
Uses:  SMap_Form::$sform


[ Top ]
getTileVars  [line 524]

  array getTileVars( )

Returns an array of the current tile's info.

This returns the positioning information array that should represent either. The positioning information includes positioning info ['tileGrid'] and view ID ['viewId']. Also included is ['isTile'], which defines if the map is being drawn as a single tile (as opposed to a set of tiles).

The tile grid is an array of integers with keys at SMap_Tile::POSX, VIEWX, POSY, VIEWY. The array describes the position of the tile that we are viewing in relation to the other tiles. It contains enough information to determine which edge a tile is on.

The position 1,1 is the tile in the upper left. If the view is 7 tiles wide and 4 tiles high then the numbers in VIEWX and VIEWY will be 7 and 4 respectively. The tile in the upper right corner will be at position 7,1.

The tile grid is optional. If a tile has no need to know it's position relative to the other tiles, then it shouldn't be used. Most tiles should be able to do just fine by just using the bounds. If the grid is not defined, then the grid contains only VIEWX and VIEWY.


API Tags:
Usedby:  SMap::__construct()
Access:  public


[ Top ]
getViewDim  [line 916]

  array getViewDim( array $bounds, array $scale  )

Returns the dim of the viewport

Derived from the bounds and zoom scale. Returns dimensions in number of tiles.

Parameters:
array   $bounds:  Bounds of the view
array   $scale:  Scaling factor

API Tags:
Return:  Number of tiles in each direction
Usedby:  SMap_Form::__construct()
Access:  protected


[ Top ]
initDefs  [line 298]

  void initDefs( )

Init the default array


API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected
Uses:  SMap_Form::$defs


[ Top ]
initPrefs  [line 311]

  void initPrefs( )

Init the prefernce array

Handle things here like reading a users preferences from a database, session, or cookie.


API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected
Uses:  SMap_Form::$prefs


[ Top ]
initRequest  [line 326]

  void initRequest( )

Init the request array

Uses the SForm to construct an appropriate request array from the user's input. If you want to use something other than the SForm, you can always take care of that urge here. Just construct the $request array correctly and you're good to go.


API Tags:
Usedby:  SMap_Form::__construct()
Access:  protected
Uses:  SMap_Form::$sform
Uses:  SMap_Form::$request


[ Top ]
initSForm  [line 276]

  object SForm initSForm( )

Create an SForm object

SForm is another of my packages. I've kept it loosly coupled with SMap. If you wish to use some other method than SForm, you'll have to override this method, and possible any other method which uses the SForm. It is, however, possible.


API Tags:
Return:  with appropriate elements
Access:  protected
Uses:  SMap_Form::$formPrefix


[ Top ]
setPxDim  [line 998]

  void setPxDim( integer $x, integer $y  )

Set the pixel dimensions of this tile

Parameters:
integer   $x:  X px
integer   $y:  Y px

API Tags:
Access:  public


[ Top ]

Documentation generated on Mon, 09 Apr 2007 18:52:20 -0500 by phpDocumentor 1.3.0