From cdf69ea4d5ea6a52eee89c3ac88eff559d4d3ea5 Mon Sep 17 00:00:00 2001 From: Robbie Mackay <rm@robbiemackay.com> Date: Tue, 28 Aug 2012 14:46:23 +1200 Subject: [PATCH] JSON::markers_geojson() - Get URLs from object or Incident helper fn #853 Allows plugins to pass markers with their own url attribute or method --- application/controllers/json.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/application/controllers/json.php b/application/controllers/json.php index b7bb44669a..0f3a0896e2 100644 --- a/application/controllers/json.php +++ b/application/controllers/json.php @@ -188,7 +188,19 @@ protected function markers_geojson($incidents, $category_id, $color, $icon, $inc } } - $link = url::site("reports/view/".$marker->id); + // Get URL from object, fallback to Incident_Model::get() if object doesn't have url or url() + if (method_exists($marker, 'url')) + { + $link = $marker->url(); + } + elseif (isset($marker->url)) + { + $link = $marker->url; + } + else + { + $link = Incident_Model::get_url($marker); + } $item_name = $this->get_title($marker->incident_title, $link); $json_item = array();