Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add method Helper::timestamp()

  • Loading branch information...
commit a0a003b2dd54ad3b83aa36202ab875ad4107b4ae 1 parent 9f8bd87
Vítor Brandão authored October 06, 2011
18  src/NoiseLabs/ToolKit/GoogleAPI/Maps/BaseMap.php
@@ -55,14 +55,14 @@
55 55
 	/**
56 56
 	 * Array holding all overlays added to this map instance.
57 57
 	 *
58  
-	 * @since 0.2.0-BETA2
  58
+	 * @since 0.2.0
59 59
 	 */
60 60
 	public $overlays = array();
61 61
 
62 62
 	/**
63 63
 	 * Supported overlay types.
64 64
 	 *
65  
-	 * @since 0.2.0-BETA2
  65
+	 * @since 0.2.0
66 66
 	 */
67 67
 	protected $_overlay_types = array('marker', 'polyline');
68 68
 
@@ -167,7 +167,7 @@ public function getId()
167 167
 	}
168 168
 
169 169
 	/**
170  
-	 * @since 0.2.0-BETA2
  170
+	 * @since 0.2.0
171 171
 	 */
172 172
 	public function addOverlay($overlay)
173 173
 	{
@@ -177,7 +177,7 @@ public function addOverlay($overlay)
177 177
 	/**
178 178
 	 * @param $type
179 179
 	 *
180  
-	 * @since 0.2.0-BETA2
  180
+	 * @since 0.2.0
181 181
 	 */
182 182
 	public function getOverlays($type = null)
183 183
 	{
@@ -187,7 +187,7 @@ public function getOverlays($type = null)
187 187
 	/**
188 188
 	 * @param unknown_type $type
189 189
 	 *
190  
-	 * @since 0.2.0-BETA2
  190
+	 * @since 0.2.0
191 191
 	 */
192 192
 	public function hasOverlays($type = null)
193 193
 	{
@@ -195,7 +195,7 @@ public function hasOverlays($type = null)
195 195
 	}
196 196
 
197 197
 	/**
198  
-	 * @since 0.2.0-BETA2
  198
+	 * @since 0.2.0
199 199
 	 */
200 200
 	public function getOverlayTypes()
201 201
 	{
@@ -256,7 +256,7 @@ public function getMarkers()
256 256
 	}
257 257
 
258 258
 	/**
259  
-	 * @since 0.2.0-BETA2
  259
+	 * @since 0.2.0
260 260
 	 */
261 261
 	public function hasFocus()
262 262
 	{
@@ -267,7 +267,7 @@ public function hasFocus()
267 267
 	 * @param $data Marker instance or array index
268 268
 	 * @param $zoom Zoom level to apply
269 269
 	 *
270  
-	 * @since 0.2.0-BETA2
  270
+	 * @since 0.2.0
271 271
 	 */
272 272
 	public function setFocus($data, $zoom = 16)
273 273
 	{
@@ -285,7 +285,7 @@ public function setFocus($data, $zoom = 16)
285 285
 	}
286 286
 
287 287
 	/**
288  
-	 * @since 0.2.0-BETA2
  288
+	 * @since 0.2.0
289 289
 	 */
290 290
 	public function clearFocus()
291 291
 	{
4  src/NoiseLabs/ToolKit/GoogleAPI/Maps/Overlay/BaseOverlay.php
@@ -24,7 +24,7 @@
24 24
  * @copyright (C) 2011 Vítor Brandão <noisebleed@noiselabs.org>
25 25
  * @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html LGPL-3
26 26
  * @link http://www.noiselabs.org
27  
- * @since 0.2.0-BETA2
  27
+ * @since 0.2.0
28 28
  */
29 29
 
30 30
 namespace NoiseLabs\ToolKit\GoogleAPI\Maps\Overlay;
@@ -57,7 +57,7 @@
57 57
  * above.
58 58
  *
59 59
  * @author Vítor Brandão <noisebleed@noiselabs.org>
60  
- * @since 0.2.0-BETA2
  60
+ * @since 0.2.0
61 61
  */
62 62
 abstract class BaseOverlay
63 63
 {
20  src/NoiseLabs/ToolKit/GoogleAPI/Maps/Overlay/Marker.php
@@ -30,14 +30,13 @@
30 30
 namespace NoiseLabs\ToolKit\GoogleAPI\Maps\Overlay;
31 31
 
32 32
 use NoiseLabs\ToolKit\GoogleAPI\ParameterBag;
  33
+use NoiseLabs\ToolKit\GoogleAPI\Maps\Geolocation;
33 34
 use NoiseLabs\ToolKit\GoogleAPI\Maps\Overlay\BaseOverlay;
34 35
 
35 36
 class Marker extends BaseOverlay
36 37
 {
37 38
 	const OVERLAY_TYPE = 'marker';
38  
-
39  
-	protected $latitude;
40  
-    protected $longitude;
  39
+	protected $geolocation;
41 40
 
42 41
 	/**
43 42
 	 * Marker options.
@@ -47,7 +46,7 @@ class Marker extends BaseOverlay
47 46
 	 *  - icon: 	 An icon to show in place of the default icon.
48 47
 	 *  - title:	 Marker title shown as tooltip.
49 48
 	 *
50  
-	 *  @since 0.2.0-BETA2
  49
+	 *  @since 0.2.0
51 50
 	 */
52 51
 	protected function getDefaultOptions()
53 52
 	{
@@ -60,9 +59,8 @@ protected function getDefaultOptions()
60 59
 
61 60
     public static function create($latitude, $longitude, array $options = array())
62 61
     {
63  
-		$marker = new static();
64  
-		$marker->setLatitude($latitude);
65  
-		$marker->setLongitude($longitude);
  62
+		$marker = new static(Geolocation::create($latitude, $longitude));
  63
+
66 64
 		$marker->options->add($options);
67 65
 
68 66
 		return $marker;
@@ -70,22 +68,22 @@ public static function create($latitude, $longitude, array $options = array())
70 68
 
71 69
 	public function setLatitude($latitude)
72 70
 	{
73  
-		$this->latitude = (float) $latitude;
  71
+		$this->geolocation->latitude = (float) $latitude;
74 72
 	}
75 73
 
76 74
 	public function getLatitude()
77 75
 	{
78  
-		return $this->latitude;
  76
+		return $this->geolocation->latitude;
79 77
 	}
80 78
 
81 79
 	public function setLongitude($longitude)
82 80
 	{
83  
-		$this->longitude = (float) $longitude;
  81
+		$this->geolocation->longitude = (float) $longitude;
84 82
 	}
85 83
 
86 84
 	public function getLongitude()
87 85
 	{
88  
-		return $this->longitude;
  86
+		return $this->geolocation->longitude;
89 87
 	}
90 88
 
91 89
 	public function buildJavascriptOutput($js_map_variable, $js_array_name, $js_array_index)
11  src/NoiseLabs/ToolKit/GoogleAPI/Maps/Overlay/Polyline.php
@@ -161,11 +161,11 @@ public function buildJavascriptOutput($js_map_variable, $js_array_name, $js_arra
161 161
 
162 162
   		$output .=
163 163
   		"\t// ".$js_class." ".$js_array_index."\n".
164  
-  		"\tvar ".$js_array_name."[".$js_array_index."] = new google.maps.".$js_class."({\n".
  164
+		"\t".$js_array_name."[".$js_array_index."] = new google.maps.".$js_class."({\n".
165 165
   		"\t\tpath: [";
166 166
   		foreach (array_keys($this->markers) as $k) {
167 167
   			$output .=
168  
-  			"\n\t\t\tnew google.maps.LatLng(".$this->markers[$k]->getLatitude()."., ".$this->markers[$k]->getLongitude().".)";
  168
+			"\n\t\t\tnew google.maps.LatLng(".$this->markers[$k]->getLatitude().", ".$this->markers[$k]->getLongitude().")";
169 169
   			if ($k+1 < count($this->markers)) {
170 170
   				$output .= ",";
171 171
   			}
@@ -177,9 +177,10 @@ public function buildJavascriptOutput($js_map_variable, $js_array_name, $js_arra
177 177
   		"\t\t],\n".
178 178
     	"\t\tstrokeColor: \"".$this->options->get('strokeColor')."\",\n".
179 179
     	"\t\tstrokeOpacity: ".$this->options->get('strokeOpacity').",\n".
180  
-    	"\t\tstrokeWeight: ".$this->options->get('strokeWeight')."\n".
181  
-  		"\t)};\n".
182  
-  		"\t".$js_array_name."[".$js_array_index."].setMap(".$js_map_variable.");\n";
  180
+		"\t\tstrokeWeight: ".$this->options->get('strokeWeight')."\n".
  181
+		"\t});\n".
  182
+		"\t".$js_array_name."[".$js_array_index."].setMap(".$js_map_variable.");\n".
  183
+		"\n";
183 184
 
184 185
   		return $output;
185 186
 	}
14  src/NoiseLabs/ToolKit/Helper.php
@@ -35,6 +35,20 @@
35 35
  */
36 36
 class Helper
37 37
 {
  38
+	const DATETIME_FORMAT = 'Y-m-d G:i:s';
  39
+
  40
+	/**
  41
+	 * Returns current timestamp.
  42
+	 *
  43
+	 * @param string $timestamp
  44
+	 *
  45
+	 * @since 0.2.0
  46
+	 */
  47
+	public static function timestamp($timestamp = null)
  48
+	{
  49
+		return date(static::DATETIME_FORMAT, isset($timestamp) ? $timestamp : time());
  50
+	}
  51
+
38 52
 	/**
39 53
 	 * Returns a safe filename, for a given platform (OS), by replacing all
40 54
 	 * dangerous characters with an underscore.

0 notes on commit a0a003b

Please sign in to comment.
Something went wrong with that request. Please try again.