From 340b336a492fa671337a77d90e9898a1ae54c1d8 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 18 Dec 2012 13:24:19 -0500 Subject: [PATCH] Controller bug and Distance class Fixed a bug in the Controller that was throwing some notices when a module didn't return any data. Also finished up the calculateDistance() method in the Distance class. Seems I left it in somewhat of a bug filled incomplete state last week. --- classes/Controller.php | 2 +- classes/Distance.php | 9 ++++----- jar.php | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/classes/Controller.php b/classes/Controller.php index dce6f3e..46713e4 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -385,7 +385,7 @@ class Controller extends Object { $module_return = $module->$default_method(); - if ($module_return === null) + if (!is_array($module_return)) { $module_return = $module->return; } diff --git a/classes/Distance.php b/classes/Distance.php index ab0dc1f..1f94b46 100644 --- a/classes/Distance.php +++ b/classes/Distance.php @@ -41,7 +41,6 @@ class Distance if (count($pieces) == 2) { - var_dump($arguments[0], $pieces[0], $pieces[1]); return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]); } @@ -113,15 +112,15 @@ class Distance * @static * @param mixed $latitude_from starting latitude * @param mixed $longitude_from starting longitude - * @param mixed $latitude_from starting latitude - * @param mixed $longitude_from starting longitude + * @param mixed $latitude_to ending latitude + * @param mixed $longitude_to ending longitude * @param string $unit optional units to return, miles by default * @return mixed distance between the points in the desired unit */ - public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $latitude_from, $unit = 'miles') + public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $longitude_to, $unit = 'miles') { $unit = ucwords(strtolower($unit)); - $theta = $lontitude_from - $longitude_to; + $theta = $longitude_from - $longitude_to; $distance = sin(deg2rad($latitude_from)) diff --git a/jar.php b/jar.php index 21bc5f6..5699bcc 100755 --- a/jar.php +++ b/jar.php @@ -1413,7 +1413,7 @@ class Controller extends Object { $module_return = $module->$default_method(); - if ($module_return === null) + if (!is_array($module_return)) { $module_return = $module->return; } @@ -2908,7 +2908,6 @@ class Distance if (count($pieces) == 2) { - var_dump($arguments[0], $pieces[0], $pieces[1]); return Distance::convertUnit($arguments[0], $pieces[0], $pieces[1]); } @@ -2980,15 +2979,15 @@ class Distance * @static * @param mixed $latitude_from starting latitude * @param mixed $longitude_from starting longitude - * @param mixed $latitude_from starting latitude - * @param mixed $longitude_from starting longitude + * @param mixed $latitude_to ending latitude + * @param mixed $longitude_to ending longitude * @param string $unit optional units to return, miles by default * @return mixed distance between the points in the desired unit */ - public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $latitude_from, $unit = 'miles') + public static function calculateDistance($latitude_from, $longitude_from, $latitude_to, $longitude_to, $unit = 'miles') { $unit = ucwords(strtolower($unit)); - $theta = $lontitude_from - $longitude_to; + $theta = $longitude_from - $longitude_to; $distance = sin(deg2rad($latitude_from))