本文整理匯總了PHP中Incident_Model::get_neighbouring_incidents方法的典型用法代碼示例。如果您正苦於以下問題:PHP Incident_Model::get_neighbouring_incidents方法的具體用法?PHP Incident_Model::get_neighbouring_incidents怎麽用?PHP Incident_Model::get_neighbouring_incidents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Incident_Model
的用法示例。
在下文中一共展示了Incident_Model::get_neighbouring_incidents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetNeighbouringIncidents
/**
* Tests Incident_Model::get_neigbouring_incidents
* @test
* @dataProvider providerTestGetNeighbouringIncidents
*/
public function testGetNeighbouringIncidents($incident_id, $num_neighbours)
{
// Get the neighbouring incidents
$neighbours = Incident_Model::get_neighbouring_incidents($incident_id, FALSE, 0, $num_neighbours);
if (empty($neighbours)) {
$this->markTestSkipped('The incident table is empty.');
} else {
// Check if the no. of returned incidents matches the no. of neighbours specified in @param $neighbours
$this->assertEquals($num_neighbours, $neighbours->count());
}
}
示例2: view
//.........這裏部分代碼省略.........
// Notify Admin Of New Comment
$send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/view/' . $id);
// Redirect
url::redirect('reports/view/' . $id);
} else {
// No! We have validation errors, we need to show the form again, with the errors
// Repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// Populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('comments'));
$form_error = TRUE;
}
}
// Filters
$incident_title = $incident->incident_title;
$incident_description = nl2br($incident->incident_description);
Event::run('ushahidi_filter.report_title', $incident_title);
Event::run('ushahidi_filter.report_description', $incident_description);
// Add Features
$this->template->content->features_count = $incident->geometry->count();
$this->template->content->features = $incident->geometry;
$this->template->content->incident_id = $incident->id;
$this->template->content->incident_title = $incident_title;
$this->template->content->incident_description = $incident_description;
$this->template->content->incident_location = $incident->location->location_name;
$this->template->content->incident_latitude = $incident->location->latitude;
$this->template->content->incident_longitude = $incident->location->longitude;
$this->template->content->incident_date = date('M j Y', strtotime($incident->incident_date));
$this->template->content->incident_time = date('H:i', strtotime($incident->incident_date));
$this->template->content->incident_category = $incident->incident_category;
// Incident rating
$this->template->content->incident_rating = $incident->incident_rating == '' ? 0 : $incident->incident_rating;
// Retrieve Media
$incident_news = array();
$incident_video = array();
$incident_photo = array();
foreach ($incident->media as $media) {
if ($media->media_type == 4) {
$incident_news[] = $media->media_link;
} elseif ($media->media_type == 2) {
$incident_video[] = $media->media_link;
} elseif ($media->media_type == 1) {
$incident_photo[] = $media->media_link;
}
}
$this->template->content->incident_verified = $incident->incident_verified;
// Retrieve Comments (Additional Information)
$this->template->content->comments = "";
if (Kohana::config('settings.allow_comments')) {
$this->template->content->comments = new View('reports_comments');
$incident_comments = array();
if ($id) {
$incident_comments = Incident_Model::get_comments($id);
}
$this->template->content->comments->incident_comments = $incident_comments;
}
}
// Add Neighbors
$this->template->content->incident_neighbors = Incident_Model::get_neighbouring_incidents($id, TRUE, 0, 5);
// News Source links
$this->template->content->incident_news = $incident_news;
// Video links
$this->template->content->incident_videos = $incident_video;
// Images
$this->template->content->incident_photos = $incident_photo;
// Create object of the video embed class
$video_embed = new VideoEmbed();
$this->template->content->videos_embed = $video_embed;
// Javascript Header
$this->themes->map_enabled = TRUE;
$this->themes->photoslider_enabled = TRUE;
$this->themes->videoslider_enabled = TRUE;
$this->themes->js = new View('reports_view_js');
$this->themes->js->incident_id = $incident->id;
$this->themes->js->default_map = Kohana::config('settings.default_map');
$this->themes->js->default_zoom = Kohana::config('settings.default_zoom');
$this->themes->js->latitude = $incident->location->latitude;
$this->themes->js->longitude = $incident->location->longitude;
$this->themes->js->incident_zoom = $incident->incident_zoom;
$this->themes->js->incident_photos = $incident_photo;
// Initialize custom field array
$this->template->content->custom_forms = new View('reports_view_custom_forms');
$form_field_names = customforms::get_custom_form_fields($id, $incident->form_id, FALSE, "view");
$this->template->content->custom_forms->form_field_names = $form_field_names;
// Are we allowed to submit comments?
$this->template->content->comments_form = "";
if (Kohana::config('settings.allow_comments')) {
$this->template->content->comments_form = new View('reports_comments_form');
$this->template->content->comments_form->user = $this->user;
$this->template->content->comments_form->form = $form;
$this->template->content->comments_form->form_field_names = $form_field_names;
$this->template->content->comments_form->captcha = $captcha;
$this->template->content->comments_form->errors = $errors;
$this->template->content->comments_form->form_error = $form_error;
}
// If the Admin is Logged in - Allow for an edit link
$this->template->content->logged_in = $this->logged_in;
// Rebuild Header Block
$this->template->header->header_block = $this->themes->header_block();
}
示例3: single
/**
* Retrieve Single Marker (and its neighbours)
*
* @param int $incident_id
*/
public function single($incident_id = 0)
{
$json_features = array();
$incident_id = intval($incident_id);
// Check if incident valid/approved
if (!Incident_Model::is_valid_incident($incident_id, TRUE)) {
throw new Kohana_404_Exception();
}
// Load the incident
// @todo avoid the double load here
$marker = ORM::factory('incident')->where('incident.incident_active', 1)->with('location')->find($incident_id);
if (!$marker->loaded) {
throw new Kohana_404_Exception();
}
// Get geojson features for main incident (including geometry)
$json_features = $this->markers_geojson(array($marker), 0, null, null, TRUE);
// Get the neigbouring incidents & their json (without geometries)
$neighbours = Incident_Model::get_neighbouring_incidents($incident_id, FALSE, 20, 100);
if ($neighbours) {
$json_features = array_merge($json_features, $this->markers_geojson($neighbours, 0, null, null, FALSE));
}
Event::run('ushahidi_filter.json_single_features', $json_features);
$this->render_geojson($json_features);
}
示例4: single
/**
* Retrieve Single Marker
*/
public function single($incident_id = 0)
{
$json = "";
$json_item = "";
$json_array = array();
// Get the neigbouring incidents
$neighbours = Incident_Model::get_neighbouring_incidents($incident_id, FALSE, 20, 100);
if ($neighbours) {
// Load the incident
// @todo Get this fixed
$marker = ORM::factory('incident', $incident_id);
// Get the incident/report date
$incident_date = date('Y-m', strtotime($marker->incident_date));
foreach ($neighbours as $row) {
$json_item = "{";
$json_item .= "\"type\":\"Feature\",";
$json_item .= "\"properties\": {";
$json_item .= "\"id\": \"" . $row->id . "\", ";
$encoded_title = utf8tohtml::convert($row->incident_title, TRUE);
$encoded_title = str_ireplace('"', '"', $encoded_title);
$encoded_title = json_encode($encoded_title);
$encoded_title = str_ireplace('"', '', $encoded_title);
$json_item .= "\"name\":\"" . str_replace(chr(10), ' ', str_replace(chr(13), ' ', "<a href='" . url::base() . "reports/view/" . $row->id . "'>" . $encoded_title . "</a>")) . "\",";
$json_item .= "\"link\": \"" . url::base() . "reports/view/" . $row->id . "\", ";
$json_item .= "\"category\":[0], ";
$json_item .= "\"timestamp\": \"" . strtotime($row->incident_date) . "\"";
$json_item .= "},";
$json_item .= "\"geometry\": {";
$json_item .= "\"type\":\"Point\", ";
$json_item .= "\"coordinates\":[" . $row->longitude . ", " . $row->latitude . "]";
$json_item .= "}";
$json_item .= "}";
array_push($json_array, $json_item);
}
// Single Main Incident
$json_single = "{";
$json_single .= "\"type\":\"Feature\",";
$json_single .= "\"properties\": {";
$json_single .= "\"id\": \"" . $marker->id . "\", ";
$encoded_title = utf8tohtml::convert($marker->incident_title, TRUE);
$json_single .= "\"name\":\"" . str_replace(chr(10), ' ', str_replace(chr(13), ' ', "<a href='" . url::base() . "reports/view/" . $marker->id . "'>" . $encoded_title . "</a>")) . "\",";
$json_single .= "\"link\": \"" . url::base() . "reports/view/" . $marker->id . "\", ";
$json_single .= "\"category\":[0], ";
$json_single .= "\"timestamp\": \"" . strtotime($marker->incident_date) . "\"";
// Get Incident Geometries
$geometry = $this->_get_geometry($marker->id, $marker->incident_title, $marker->incident_date);
// If there are no geometries, use Single Incident Marker
if (!count($geometry)) {
$json_item = "{";
$json_item .= "\"type\":\"Feature\",";
$json_item .= "\"properties\": {";
$json_item .= "\"id\": \"" . $marker->id . "\", ";
$encoded_title = utf8tohtml::convert($marker->incident_title, TRUE);
$json_item .= "\"name\":\"" . str_replace(chr(10), ' ', str_replace(chr(13), ' ', "<a href='" . url::base() . "reports/view/" . $marker->id . "'>" . $encoded_title . "</a>")) . "\",";
$json_item .= "\"link\": \"" . url::base() . "reports/view/" . $marker->id . "\", ";
$json_item .= "\"category\":[0], ";
$json_item .= "\"timestamp\": \"" . strtotime($marker->incident_date) . "\"";
$json_item .= "},\"geometry\":";
$json_item .= "{\"type\":\"Point\", ";
$json_item .= "\"coordinates\":[" . $marker->location->longitude . ", " . $marker->location->latitude . "]";
$json_item .= "}";
$json_item .= "}";
} else {
$json_item = implode(",", $geometry);
}
array_push($json_array, $json_item);
}
$json = implode(",", $json_array);
header('Content-type: application/json; charset=utf-8');
$this->template->json = $json;
}
示例5: single
/**
* Retrieve Single Marker
*/
public function single($incident_id = 0)
{
$json = "";
$json_item = "";
$json_features = array();
$incident_id = intval($incident_id);
// Check if incident valid/approved
if (!Incident_Model::is_valid_incident($incident_id, TRUE)) {
throw new Kohana_404_Exception();
}
// Get the neigbouring incidents
$neighbours = Incident_Model::get_neighbouring_incidents($incident_id, FALSE, 20, 100);
if ($neighbours) {
// Load the incident
// @todo Get this fixed
$marker = ORM::factory('incident')->where('incident.incident_active', 1)->find($incident_id);
if (!$marker->loaded) {
throw new Kohana_404_Exception();
}
// Get the incident/report date
$incident_date = date('Y-m', strtotime($marker->incident_date));
foreach ($neighbours as $row) {
$link = url::base() . "reports/view/" . $row->id;
$item_name = $this->get_title($row->incident_title, $link);
$json_item = array();
$json_item['type'] = 'Feature';
$json_item['properties'] = array('id' => $row->id, 'name' => $item_name, 'link' => $link, 'category' => array(0), 'timestamp' => strtotime($row->incident_date));
$json_item['geometry'] = array('type' => 'Point', 'coordinates' => array($row->longitude, $row->latitude));
array_push($json_features, $json_item);
}
// Get Incident Geometries
$geometry = $this->_get_geometry($marker->id, $marker->incident_title, $marker->incident_date);
// If there are no geometries, use Single Incident Marker
if (!count($geometry)) {
// Single Main Incident
$link = url::base() . "reports/view/" . $marker->id;
$item_name = $this->get_title($marker->incident_title, $link);
$json_item = array();
$json_item['type'] = 'Feature';
$json_item['properties'] = array('id' => $marker->id, 'name' => $item_name, 'link' => $link, 'category' => array(0), 'timestamp' => strtotime($marker->incident_date));
$json_item['geometry'] = array('type' => 'Point', 'coordinates' => array($marker->location->longitude, $marker->location->latitude));
array_push($json_features, $json_item);
} else {
foreach ($geometry as $g) {
array_push($json_features, $g);
}
}
}
Event::run('ushahidi_filter.json_single_features', $json_features);
$json = json_encode(array("type" => "FeatureCollection", "features" => $json_features));
header('Content-type: application/json; charset=utf-8');
echo $json;
}