Skip to content

Commit

Permalink
JSON::markers_geojson() - Get URLs from object or Incident helper fn u…
Browse files Browse the repository at this point in the history
…shahidi#853

Allows plugins to pass markers with their own url attribute or method
  • Loading branch information
rjmackay committed Oct 1, 2012
1 parent cb39fea commit cdf69ea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion application/controllers/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cdf69ea

Please sign in to comment.