1 |
<?php |
---|
2 |
/** |
---|
3 |
* CompassPoint Widget class |
---|
4 |
* |
---|
5 |
* @project CWC2 |
---|
6 |
* @revision $Id: CompassPoint.widget.php,v 1.6 2005/01/11 12:32:19 pspencer Exp $ |
---|
7 |
* @purpose CompassPoint Widget class |
---|
8 |
* @author DM Solutions Group (assefa@dmsolutions.ca) |
---|
9 |
* @copyright |
---|
10 |
* <b>Copyright (c) 2002, DM Solutions Group Inc.</b> |
---|
11 |
* Permission is hereby granted, free of charge, to any person obtaining a |
---|
12 |
* copy of this software and associated documentation files (the "Software"), |
---|
13 |
* to deal in the Software without restriction, including without limitation |
---|
14 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
15 |
* and/or sell copies of the Software, and to permit persons to whom the |
---|
16 |
* Software is furnished to do so, subject to the following conditions: |
---|
17 |
* |
---|
18 |
* The above copyright notice and this permission notice shall be included |
---|
19 |
* in all copies or substantial portions of the Software. |
---|
20 |
* |
---|
21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
22 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
24 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
27 |
* DEALINGS IN THE SOFTWARE. |
---|
28 |
*/ |
---|
29 |
include_once(dirname(__FILE__)."/../NavTool.php"); |
---|
30 |
|
---|
31 |
define( "NORTHEAST", NORTH_EAST ); |
---|
32 |
define( "NORTHWEST", NORTH_WEST ); |
---|
33 |
define( "SOUTHEAST", SOUTH_EAST ); |
---|
34 |
define( "SOUTHWEST", SOUTH_WEST ); |
---|
35 |
|
---|
36 |
/** |
---|
37 |
* CompassPoint is an active pan arrow that can navigate the map |
---|
38 |
* in one of eight directions by an optional factor. |
---|
39 |
*/ |
---|
40 |
class CompassPoint extends NavTool |
---|
41 |
{ |
---|
42 |
var $mszImageName = ""; |
---|
43 |
var $mfPanPercent = 0.50; |
---|
44 |
var $mszDirection = ""; |
---|
45 |
|
---|
46 |
/** |
---|
47 |
* constructor |
---|
48 |
*/ |
---|
49 |
function CompassPoint( ) |
---|
50 |
{ |
---|
51 |
// invoke constructor of parent |
---|
52 |
parent::NavTool(); |
---|
53 |
|
---|
54 |
// set the description for this widget |
---|
55 |
$this->szWidgetDescription = <<<EOT |
---|
56 |
The CompassPoint widget is a clickable image that the user can click to pan |
---|
57 |
in a given direcion. |
---|
58 |
EOT; |
---|
59 |
|
---|
60 |
//CWCImage requires this attribute by default, this widget doesn't want it though. |
---|
61 |
$this->maAttributes["IMAGE"] = new StringAttribute("IMAGE", false); |
---|
62 |
$this->maAttributes["DIRECTION"] = new StringAttribute( "DIRECTION", true, |
---|
63 |
array( 'NORTHEAST', 'NORTH', 'NORTHWEST', 'WEST', 'SOUTHWEST', 'SOUTH', 'SOUTHEAST', 'EAST' ) ); |
---|
64 |
$this->maAttributes["PANPERCENT"] = new IntegerAttribute( "PANPERCENT", false, 0, 100 ); |
---|
65 |
$this->mnMaturityLevel = MATURITY_TECHNICALRELEASE; |
---|
66 |
|
---|
67 |
} |
---|
68 |
|
---|
69 |
/** |
---|
70 |
* initialize default values |
---|
71 |
*/ |
---|
72 |
function InitDefaults() |
---|
73 |
{ |
---|
74 |
parent::InitDefaults(); |
---|
75 |
|
---|
76 |
if (isset($this->maParams["PANPERCENT"])) |
---|
77 |
$this->mfPanPercent = floatval($this->maParams["PANPERCENT"])/100; |
---|
78 |
if ( $this->mfPanPercent < 0.0 ) |
---|
79 |
$this->mfPanPercent = 0.5; |
---|
80 |
if ( $this->mfPanPercent > 1.0 ) |
---|
81 |
$this->mfPanPercent = 1.0; |
---|
82 |
|
---|
83 |
if (isset($this->maParams["DIRECTION"])) |
---|
84 |
$this->mszDirection = $this->maParams["DIRECTION"]; |
---|
85 |
|
---|
86 |
$this->SetNavCommand("COMPASS_POINT_".$this->mszDirection); |
---|
87 |
|
---|
88 |
if (isset($this->maParams["IMAGE"])) |
---|
89 |
{ |
---|
90 |
$this->mszImageName = $this->maParams["IMAGE"]; |
---|
91 |
} |
---|
92 |
$this->mbSubmitOnClick = 1; |
---|
93 |
} |
---|
94 |
|
---|
95 |
/** |
---|
96 |
* look through the URL parameters for something that indicates a |
---|
97 |
* pan is requested and perform it if necessary |
---|
98 |
*/ |
---|
99 |
function ParseURL() |
---|
100 |
{ |
---|
101 |
parent::ParseURL(); |
---|
102 |
|
---|
103 |
$szCmd = ""; |
---|
104 |
if ($this->isVarSet("NAV_CMD")) |
---|
105 |
$szCmd = $this->getVar("NAV_CMD"); |
---|
106 |
|
---|
107 |
if (substr($szCmd, 0, 13) == "COMPASS_POINT") |
---|
108 |
{ |
---|
109 |
$szDirection = strtoupper(substr( $szCmd, 14 )); |
---|
110 |
|
---|
111 |
if (strcasecmp($this->mszDirection, $szDirection) == 0) |
---|
112 |
{ |
---|
113 |
eval("\$this->moMapNavigator->pan( $szDirection, \$this->mfPanPercent );"); |
---|
114 |
} |
---|
115 |
} |
---|
116 |
|
---|
117 |
return true; |
---|
118 |
} |
---|
119 |
|
---|
120 |
/** |
---|
121 |
* publish this widget |
---|
122 |
* @return string the html code representing this widget |
---|
123 |
*/ |
---|
124 |
function DrawPublish() |
---|
125 |
{ |
---|
126 |
if (strlen($this->mszDirection) == 0) |
---|
127 |
return "<!-- MISSING DIRECTION IN COMPASSPOINT WIDGET -->"; |
---|
128 |
|
---|
129 |
if ($this->mbVisible == false) |
---|
130 |
return "<!-- CompassPoint $this->mszDirection is hidden -->"; |
---|
131 |
|
---|
132 |
return parent::DrawPublish(); |
---|
133 |
} |
---|
134 |
} |
---|
135 |
?> |
---|