Browse Source

fix passwordable without auth set manually

euromark 12 years ago
parent
commit
6a9bc9b490

+ 10 - 1
Controller/MyController.php

@@ -37,6 +37,10 @@ class MyController extends Controller {
 	 * If you use another setup (like localhost/app/webroot) where you use multiple htaccess files or rewrite
 	 * rules you need to raise it accordingly.
 	 *
+	 * @param string|array $url A string or array-based URL
+	 * @param integer $status Optional HTTP status code (eg: 404)
+	 * @param boolean $exit If true, exit() will be called after the redirect
+	 * @return void
 	 * 2013-03-02 ms
 	 */
 	public function redirect($url, $status = null, $exit = true) {
@@ -54,7 +58,12 @@ class MyController extends Controller {
 		return parent::redirect($url, $status, $exit);
 	}
 
-	public function _encodeUrlPiece($value, $run) {
+	/**
+	 * @param mixed Url piece
+	 * @param int $run How many times does the value have to be escaped
+	 * @return mixed Escaped piece
+	 */
+	protected function _encodeUrlPiece($value, $run) {
 		if (!is_array($value)) {
 			for ($i = 0; $i < $run; $i++) {
 				$value = urlencode($value);

+ 12 - 6
Model/Behavior/PasswordableBehavior.php

@@ -124,14 +124,20 @@ class PasswordableBehavior extends ModelBehavior {
 			trigger_error('No user id given');
 			return false;
 		}
+
+		$authClass = 'Auth';
 		if (empty($this->settings[$Model->alias]['auth']) && class_exists('AuthExtComponent')) {
-			$this->Auth = new AuthExtComponent(new ComponentCollection());
-		} elseif (class_exists(($this->settings[$Model->alias]['auth'] ? $this->settings[$Model->alias]['auth'] : 'Auth') . 'Component')) {
-			$auth = $this->settings[$Model->alias]['auth'].'Component';
-			$this->Auth = new $auth(new ComponentCollection());
-		} else {
-			throw new CakeException('No Authentication class found (' . $this->settings[$Model->alias]['auth'] . ')');
+			$authClass = 'AuthExt';
+		} elseif ($this->settings[$Model->alias]['auth']) {
+			$authClass = $this->settings[$Model->alias]['auth'];
+		}
+		$auth = $authClass . 'Component';
+		if (!class_exists($auth)) {
+			throw new CakeException('No Authentication class found (' . $auth. ')');
 		}
+
+		$this->Auth = new $auth(new ComponentCollection());
+
 		# easiest authenticate method via form and (id + pwd)
 		$this->Auth->authenticate = array(
 			'Form' => array(

+ 74 - 14
View/Helper/GoogleMapV3Helper.php

@@ -884,6 +884,7 @@ var iconShape = {
 	 * - avoidHighways: Boolean,
 	 * - avoidTolls: Boolean
 	 * - region: String
+	 * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsRequest
 	 * @return void
 	 */
 	public function addDirections($from, $to, $options = array()) {
@@ -904,22 +905,22 @@ var iconShape = {
 			{$id}Display.setMap(".$this->name().");
 			";
 
-			if (!empty($options['directionsDiv'])) {
-				$directions .= "{$id}Display.setPanel(document.getElementById('" . $options['directionsDiv'] . "'));";
-			}
+		if (!empty($options['directionsDiv'])) {
+			$directions .= "{$id}Display.setPanel(document.getElementById('" . $options['directionsDiv'] . "'));";
+		}
 
-			if (is_array($from)) {
-				$from = 'new google.maps.LatLng(' . (float)$from['lat'] . ', ' . (float)$from['lng'] . ')';
-			} else {
-				$from = '\'' . h($from) . '\'';
-			}
-			if (is_array($to)) {
-				$to = 'new google.maps.LatLng(' . (float)$to['lat'] . ', ' . (float)$to['lng'] . ')';
-			} else {
-				$to = '\'' . h($to) . '\'';
-			}
+		if (is_array($from)) {
+			$from = 'new google.maps.LatLng(' . (float)$from['lat'] . ', ' . (float)$from['lng'] . ')';
+		} else {
+			$from = '\'' . h($from) . '\'';
+		}
+		if (is_array($to)) {
+			$to = 'new google.maps.LatLng(' . (float)$to['lat'] . ', ' . (float)$to['lng'] . ')';
+		} else {
+			$to = '\'' . h($to) . '\'';
+		}
 
-			$directions .= "
+		$directions .= "
 			var request = {
 				origin: $from,
 				destination: $to,
@@ -936,6 +937,65 @@ var iconShape = {
 	}
 
 	/**
+	 * Add a polyline
+	 *
+	 * This method adds a line between 2 points
+	 *
+	 * @param array|string $from Location as array(fixed lat/lng pair) or string (to be geocoded at runtime)
+	 * @param array|string $to Location as array(fixed lat/lng pair) or string (to be geocoded at runtime)
+	 * @param array $options
+	 * - color (#FFFFFF ... #000000)
+	 * - opacity (0.1 ... 1, defaults to 1)
+	 * - weight in pixels (defaults to 2)
+	 * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline
+	 * @return void
+	 */
+	public function addPolyline($from, $to, $options = array()) {
+		if (is_array($from)) {
+			$from = 'new google.maps.LatLng(' . (float)$from['lat'] . ', ' . (float)$from['lng'] . ')';
+		} else {
+			throw new CakeException('not implemented yet, use array of lat/lng');
+			$from = '\'' . h($from) . '\'';
+		}
+		if (is_array($to)) {
+			$to = 'new google.maps.LatLng(' . (float)$to['lat'] . ', ' . (float)$to['lng'] . ')';
+		} else {
+			throw new CakeException('not implemented yet, use array of lat/lng');
+			$to = '\'' . h($to) . '\'';
+		}
+
+		$defaults = array(
+			'color' => '#FF0000',
+			'opacity' => 1.0,
+			'weight' => 2,
+		);
+		$options += $defaults;
+
+		if( !isset($strokeColor) )		$strokeColor = $this->defaultStrokeColor;
+		if( !isset($strokeOpacity) )	$strokeOpacity = $this->defaultStrokeOpacity;
+		if( !isset($strokeWeight) )		$strokeWeight = $this->defaultStrokeWeight;
+
+		$id = 'p' . self::$MARKER_COUNT++;
+
+		$polyline = "var start = $from;";
+		$polyline .= "var end = $to;";
+		$polyline .= "
+				var poly = [
+					start,
+					end
+				];
+				var {$id}Polyline = new google.maps.Polyline({
+					path: poly,
+					strokeColor: '" . $options['color'] . "',
+					strokeOpacity: " . $options['opacity'] . ",
+					strokeWeight: " . $options['weight'] . "
+				});
+				{$id}Polyline.setMap(".$this->name().");
+			";
+		$this->map .= $polyline;
+	}
+
+	/**
 	 * @param string $content (html/text)
 	 * @param int $infoWindowCount
 	 * @return void