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:
|
Properties
|
Methods
|
Property Summary
| array |
$curr |
Currently set variables |
| 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 |
Method Summary
| array |
getBoundVars() |
Returns an array of the current bounding information |
| array |
getLinkIds() |
Remove cruft from a list of IDs |
| array |
getMapVars() |
Returns an array of the current map's info. |
| 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 |
| object SForm |
initSForm() |
Create an SForm object |
| void |
setPxDim() |
Set the pixel dimensions of this tile |
Properties
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:
Defaults
When a visitor first visits the page, the settings should be these. API Tags:
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:
Store the geography
Set by the constructor API Tags:
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:
Store the language package
Set by the constructor API Tags:
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:
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:
The incoming request variables
Use whatever method you wish to place the appropriate request in this array. API Tags:
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:
Use a SForm to handle all user transactions
http://www.phpclasses.org/browse/package/3465.html API Tags:
Methods
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:
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 |
void addScrSizeElm(
$form,
$bounds,
$zoom
)
|
|
Add the SForm screen size selector element
Parameters:
|
SForm_Container |
$form: |
|
|
|
$bounds: |
|
|
|
$zoom: |
|
API Tags:
array decodeTileGrid(
string
$str
)
|
|
Decode the tile grid
Parameters:
|
string |
$str: |
The encoded grid |
API Tags:
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:
Handles a submitted user form
Sets up the correct structure of the SForm with the correct defaults, elements, values, etc.
API Tags:
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:
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:
API Tags:
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 |
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:
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:
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:
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:
What are the pixel dimensions for each screen size selector
$array[$optionValue] = array($pixelsWide, $pixelsHigh, $forPrint)
API Tags:
Return the form that we are using
API Tags:
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:
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:
Init the default array
API Tags:
Init the prefernce array
Handle things here like reading a users preferences from a database, session, or cookie.
API Tags:
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:
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:
void setPxDim(
integer
$x, integer
$y
)
|
|
Set the pixel dimensions of this tile
Parameters:
|
integer |
$x: |
X px |
|
integer |
$y: |
Y px |
API Tags:
|
|