本文整理匯總了PHP中Incident_Model::get_incidents_by_interval方法的典型用法代碼示例。如果您正苦於以下問題:PHP Incident_Model::get_incidents_by_interval方法的具體用法?PHP Incident_Model::get_incidents_by_interval怎麽用?PHP Incident_Model::get_incidents_by_interval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Incident_Model
的用法示例。
在下文中一共展示了Incident_Model::get_incidents_by_interval方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
function index()
{
$this->template->content = new View('admin/dashboard');
$this->template->content->title = 'Dashboard';
$this->template->this_page = 'dashboard';
// $this->template->header = new View('header');
// Retrieve Dashboard Count...
// Total Reports
$this->template->content->reports_total = ORM::factory('incident')->count_all();
// Total Unapproved Reports
$this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all();
// Total Unverified Reports
$this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all();
// Total Categories
$this->template->content->categories = ORM::factory('category')->count_all();
// Total Locations
$this->template->content->locations = ORM::factory('location')->count_all();
// Total Incoming Media
$this->template->content->incoming_media = ORM::factory('feed_item')->count_all();
// Messages By Service
$total_message_count = 0;
$message_services = array();
$services = ORM::factory('service')->find_all();
foreach ($services as $service) {
$message_count = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service->id)->where('message_type', '1')->count_all();
$message_services[] = array('id' => $service->id, 'name' => $service->service_name, 'count' => $message_count);
$total_message_count += $message_count;
}
$this->template->content->message_services = $message_services;
// Total Messages
$this->template->content->message_count = $total_message_count;
// Get reports for display
$incidents = ORM::factory('incident')->limit(5)->orderby('incident_dateadd', 'desc')->find_all();
$this->template->content->incidents = $incidents;
// Get Incoming Media (We'll Use NewsFeeds for now)
$this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all();
// Javascript Header
$this->template->flot_enabled = TRUE;
$this->template->js = new View('admin/dashboard_js');
// Graph
$this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL', NULL, NULL, 'all');
$this->template->js->current_date = date('Y') . '/' . date('m') . '/01';
}
示例2: index
function index()
{
$this->template->content = new View('admin/dashboard');
$this->template->content->title = 'Dashboard';
$this->template->this_page = 'dashboard';
// $this->template->header = new View('header');
// Retrieve Dashboard Count...
// Total Reports
$this->template->content->reports_total = ORM::factory('incident')->count_all();
// Total Unapproved Reports
$this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all();
// Total Unverified Reports
$this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all();
// Total Categories
$this->template->content->categories = ORM::factory('category')->count_all();
// Total Locations
$this->template->content->locations = ORM::factory('location')->count_all();
// Total Incoming Media
$this->template->content->incoming_media = ORM::factory('feed_item')->count_all();
// Total SMS Messages
$this->template->content->message_sms_count = ORM::factory('message')->count_all();
// Total Twitter Messages
$this->template->content->message_twitter_count = ORM::factory('twitter')->where('hide', 0)->count_all();
// Total Message Count
$this->template->content->message_count = $this->template->content->message_twitter_count + $this->template->content->message_sms_count;
// Get reports for display
$incidents = ORM::factory('incident')->limit(3)->orderby('incident_dateadd', 'desc')->find_all();
$this->template->content->incidents = $incidents;
// Get Incoming Media (We'll Use NewsFeeds for now)
$this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all();
// Javascript Header
$this->template->flot_enabled = TRUE;
$this->template->js = new View('admin/dashboard_js');
// Graph
$this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL', NULL, NULL, 'all');
$this->template->js->current_date = date('Y') . '/' . date('m') . '/01';
}
示例3: index
public function index()
{
$this->template->header->this_page = 'home';
$this->template->content = new View('main');
// Get all active categories
$categories = array();
foreach (ORM::factory('category')->where('category_visible', '1')->find_all() as $category) {
// Create a list of all categories
$categories[$category->id] = array($category->category_title, $category->category_color);
}
$this->template->content->categories = $categories;
// Get Reports
// XXX: Might need to replace magic no. 8 with a constant
$this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all();
$this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_dateadd', 'desc')->find_all();
// Get SMS Numbers
$phone_array = array();
$sms_no1 = Kohana::config('settings.sms_no1');
$sms_no2 = Kohana::config('settings.sms_no2');
$sms_no3 = Kohana::config('settings.sms_no3');
if (!empty($sms_no1)) {
$phone_array[] = $sms_no1;
}
if (!empty($sms_no2)) {
$phone_array[] = $sms_no2;
}
if (!empty($sms_no3)) {
$phone_array[] = $sms_no3;
}
$this->template->content->phone_array = $phone_array;
// Get RSS News Feeds
$this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all();
// Get Slider Dates By Year
$startDate = "";
$endDate = "";
// We need to use the DB builder for a custom query
$db = new Database();
$query = $db->query('SELECT DATE_FORMAT(incident_dateadd, \'%Y\') AS incident_dateadd FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_dateadd, \'%Y\') ORDER BY incident_dateadd');
foreach ($query as $slider_date) {
$startDate .= "<optgroup label=\"" . $slider_date->incident_dateadd . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($slider_date->incident_dateadd . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_dateadd . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $slider_date->incident_dateadd . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($slider_date->incident_dateadd . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\"";
if ($i == 12) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_dateadd . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$this->template->content->all_graphs = $all_graphs;
// Javascript Header
$this->template->header->map_enabled = TRUE;
$this->template->header->main_page = TRUE;
// Cluster Reports on Map?
$clustering = Kohana::config('settings.allow_clustering');
if ($clustering == 1) {
$this->template->header->js = new View('main_cluster_js');
} else {
$this->template->header->js = new View('main_js');
}
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
$this->template->header->js->graph_data = $graph_data;
$this->template->header->js->all_graphs = $all_graphs;
$this->template->header->js->categories = $categories;
// Pack the javascript using the javascriptpacker helper
$myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false);
$this->template->header->js = $myPacker->pack();
}
示例4: index
//.........這裏部分代碼省略.........
foreach ($query as $slider_date) {
$years = $slider_date->incident_date;
$startDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\"";
if ($active_month && (int) $i == $active_month - 1) {
$startDate .= " selected=\"selected\" ";
}
$startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\"";
// Focus on the most active month or set December as month of endDate
if ($active_month && (int) $i == $active_month + 1 || $i == 12 && preg_match('/selected/', $endDate) == 0) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$daily_graphs = Incident_Model::get_incidents_by_interval('day');
$weekly_graphs = Incident_Model::get_incidents_by_interval('week');
$hourly_graphs = Incident_Model::get_incidents_by_interval('hour');
$this->template->content->all_graphs = $all_graphs;
$this->template->content->daily_graphs = $daily_graphs;
// If we are looking at the standard street map set by user
if (!isset($_GET['3dmap'])) {
//echo 'STREET MAP';
// Javascript Header
$this->template->header->map_enabled = 'streetmap';
$this->template->content->map_enabled = 'streetmap';
$this->template->content->map_container = 'map';
$this->template->header->main_page = TRUE;
$this->template->header->validator_enabled = TRUE;
// Map Settings
$clustering = Kohana::config('settings.allow_clustering');
$marker_radius = Kohana::config('map.marker_radius');
$marker_opacity = Kohana::config('map.marker_opacity');
$marker_stroke_width = Kohana::config('map.marker_stroke_width');
$marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity');
// pdestefanis - allows to restrict the number of zoomlevels available
$numZoomLevels = Kohana::config('map.numZoomLevels');
$minZoomLevel = Kohana::config('map.minZoomLevel');
$maxZoomLevel = Kohana::config('map.maxZoomLevel');
// pdestefanis - allows to limit the extents of the map
$lonFrom = Kohana::config('map.lonFrom');
$latFrom = Kohana::config('map.latFrom');
$lonTo = Kohana::config('map.lonTo');
$latTo = Kohana::config('map.latTo');
$this->template->header->js = $clustering ? new View('main_cluster_js') : new View('main_cluster_js');
if ($clustering == 1) {
//$this->template->header->js->cluster = "true"; // not used??
示例5: timeline
public function timeline()
{
$this->auto_render = FALSE;
$this->template = new View('json/timeline');
//$this->template->content = new View('json/timeline');
$interval = 'day';
$start_date = NULL;
$end_date = NULL;
$active = 'true';
if (isset($_GET['i'])) {
$interval = $_GET['i'];
}
if (isset($_GET['s'])) {
$start_date = $_GET['s'];
}
if (isset($_GET['e'])) {
$end_date = $_GET['e'];
}
if (isset($_GET['active'])) {
$active = $_GET['active'];
}
// get graph data
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval($interval, $start_date, $end_date, $active);
echo $all_graphs;
}
示例6: index
//.........這裏部分代碼省略.........
/** OLD SLIDER SET UP **/
// Next, Get the Range of Years
// $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date');
$query = array();
foreach ($query as $slider_date) {
$years = $slider_date->incident_date;
$startDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\"";
if ($active_month && (int) $i == $active_month - 1) {
$startDate .= " selected=\"selected\" ";
}
$startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\"";
if ($active_month && (int) $i == $active_month + 1 || $i == 12) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
//$this->template->content->startDate = '<select name="startDate" id="startDate"><optgroup label="2010"><option value="1262325600">Jan 2010</option></optgroup></select>';
//$this->template->content->endDate = '<select name="endDate" id="endDate"><optgroup label="2010"><option value="1265003999">Jan 2010</option><option value="1267423199" selected="selected" >Feb 2010</option></optgroup></select>';
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$daily_graphs = Incident_Model::get_incidents_by_interval('day');
$weekly_graphs = Incident_Model::get_incidents_by_interval('week');
$hourly_graphs = Incident_Model::get_incidents_by_interval('hour');
$this->template->content->all_graphs = $all_graphs;
$this->template->content->daily_graphs = $daily_graphs;
// If we are looking at the standard street map set by user
if (!isset($_GET['3dmap'])) {
//echo 'STREET MAP';
// Javascript Header
$this->template->header->map_enabled = 'streetmap';
$this->template->content->map_enabled = 'streetmap';
$this->template->content->map_container = 'map';
$this->template->header->main_page = TRUE;
$this->template->header->validator_enabled = TRUE;
// Map Settings
$clustering = Kohana::config('settings.allow_clustering');
$marker_radius = Kohana::config('map.marker_radius');
$marker_opacity = Kohana::config('map.marker_opacity');
$marker_stroke_width = Kohana::config('map.marker_stroke_width');
$marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity');
$this->template->header->js = $clustering ? new View('main_cluster_js') : new View('main_js');
$this->template->header->js->cluster = $clustering == 1 ? "true" : "false";
$this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5;
$this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9;
$this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2;
$this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9;
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
$this->template->header->js->graph_data = $graph_data;
$this->template->header->js->all_graphs = $all_graphs;
$this->template->header->js->daily_graphs = $daily_graphs;
$this->template->header->js->hourly_graphs = $hourly_graphs;
$this->template->header->js->weekly_graphs = $weekly_graphs;
$this->template->header->js->default_map_all = Kohana::config('settings.default_map_all');
//
$this->template->header->js->active_startDate = $active_startDate;
$this->template->header->js->active_endDate = $active_endDate;
// If we are viewing the 3D map
} else {
//echo '3D MAP';
// Javascript Header
$this->template->header->map_enabled = '3dmap';
$this->template->content->map_enabled = '3dmap';
$this->template->content->map_container = 'map3d';
$this->template->header->main_page = FALSE;
// Setting to false because we don't want all the external controls that the street map has
$this->template->header->js = new View('main_3d_js');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
// Override API URL
$this->template->header->api_url = '<script src="http://www.google.com/jsapi?key=' . Kohana::config('settings.api_google') . '"> </script>';
}
$footerjs = new View('footer_form_js');
// Pack the javascript using the javascriptpacker helper
$this->template->header->js .= $footerjs;
$myPacker = new javascriptpacker($this->template->header->js, 'Normal', true, false);
$this->template->header->js = $myPacker->pack();
}
示例7: index
public function index()
{
$this->template->header->this_page = 'home';
$this->template->content = new View('main');
// Get all active categories
$categories = array();
foreach (ORM::factory('category')->where('category_visible', '1')->find_all() as $category) {
// Create a list of all categories
$categories[$category->id] = array($category->category_title, $category->category_color);
}
$this->template->content->categories = $categories;
// Get all active Shares
$shares = array();
foreach (ORM::factory('sharing')->where('sharing_active', 1)->where('sharing_type', 1)->find_all() as $share) {
$shares[$share->id] = array($share->sharing_site_name, $share->sharing_color);
}
$this->template->content->shares = $shares;
// Get Reports
// XXX: Might need to replace magic no. 8 with a constant
$this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all();
$this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->find_all();
// Get Default Color
$this->template->content->default_map_all = Kohana::config('settings.default_map_all');
// Get Twitter Hashtags
$this->template->content->twitter_hashtag_array = array_filter(array_map('trim', explode(',', Kohana::config('settings.twitter_hashtags'))));
// Get Report-To-Email
$this->template->content->report_email = Kohana::config('email.username');
// Get SMS Numbers
$phone_array = array();
$sms_no1 = Kohana::config('settings.sms_no1');
$sms_no2 = Kohana::config('settings.sms_no2');
$sms_no3 = Kohana::config('settings.sms_no3');
if (!empty($sms_no1)) {
$phone_array[] = $sms_no1;
}
if (!empty($sms_no2)) {
$phone_array[] = $sms_no2;
}
if (!empty($sms_no3)) {
$phone_array[] = $sms_no3;
}
$this->template->content->phone_array = $phone_array;
// Get RSS News Feeds
$this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all();
// Get Slider Dates By Year
$startDate = "";
$endDate = "";
// We need to use the DB builder for a custom query
$db = new Database();
$query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date');
foreach ($query as $slider_date) {
$startDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\"";
if ($i == 12) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$daily_graphs = Incident_Model::get_incidents_by_interval('day');
$weekly_graphs = Incident_Model::get_incidents_by_interval('week');
$hourly_graphs = Incident_Model::get_incidents_by_interval('hour');
$this->template->content->all_graphs = $all_graphs;
$this->template->content->daily_graphs = $daily_graphs;
// Javascript Header
$this->template->header->map_enabled = TRUE;
$this->template->header->main_page = TRUE;
// Map Settings
$clustering = Kohana::config('settings.allow_clustering');
$marker_radius = Kohana::config('map.marker_radius');
$marker_opacity = Kohana::config('map.marker_opacity');
$marker_stroke_width = Kohana::config('map.marker_stroke_width');
$marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity');
$this->template->header->js = $clustering == 1 ? new View('main_cluster_js') : new View('main_js');
$this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5;
$this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9;
$this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2;
$this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9;
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
//.........這裏部分代碼省略.........
示例8: index
//.........這裏部分代碼省略.........
$active_year = date('Y', strtotime($query_active->incident_date));
$active_startDate = strtotime($active_year . "-" . $active_month . "-01");
$active_endDate = strtotime($active_year . "-" . $active_month . "-" . date('t', mktime(0, 0, 0, $active_month, 1)) . " 23:59:59");
}
// Next, Get the Range of Years
$query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date');
foreach ($query as $slider_date) {
$years = $slider_date->incident_date;
$startDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\"";
if ($active_month && (int) $i == $active_month - 1) {
$startDate .= " selected=\"selected\" ";
}
$startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $years . "\">";
for ($i = 1; $i <= 12; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\"";
if ($active_month && (int) $i == $active_month + 1 || $i == 12) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$daily_graphs = Incident_Model::get_incidents_by_interval('day');
$weekly_graphs = Incident_Model::get_incidents_by_interval('week');
$hourly_graphs = Incident_Model::get_incidents_by_interval('hour');
$this->template->content->all_graphs = $all_graphs;
$this->template->content->daily_graphs = $daily_graphs;
// If we are looking at the standard street map set by user
if (!isset($_GET['3dmap'])) {
//echo 'STREET MAP';
// Javascript Header
$this->template->header->map_enabled = 'streetmap';
$this->template->content->map_enabled = 'streetmap';
$this->template->content->map_container = 'map';
$this->template->header->main_page = TRUE;
$this->template->header->validator_enabled = TRUE;
// Map Settings
$clustering = Kohana::config('settings.allow_clustering');
$marker_radius = Kohana::config('map.marker_radius');
$marker_opacity = Kohana::config('map.marker_opacity');
$marker_stroke_width = Kohana::config('map.marker_stroke_width');
$marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity');
$this->template->header->js = new View('main_cluster_js');
$this->template->header->js->cluster = $clustering == 1 ? "true" : "false";
$this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5;
$this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9;
$this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2;
$this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9;
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
$this->template->header->js->graph_data = $graph_data;
$this->template->header->js->all_graphs = $all_graphs;
$this->template->header->js->daily_graphs = $daily_graphs;
$this->template->header->js->hourly_graphs = $hourly_graphs;
$this->template->header->js->weekly_graphs = $weekly_graphs;
$this->template->header->js->default_map_all = Kohana::config('settings.default_map_all');
//
$this->template->header->js->active_startDate = $active_startDate;
$this->template->header->js->active_endDate = $active_endDate;
// If we are viewing the 3D map
} else {
//echo '3D MAP';
// Javascript Header
$this->template->header->map_enabled = '3dmap';
$this->template->content->map_enabled = '3dmap';
$this->template->content->map_container = 'map3d';
$this->template->header->main_page = FALSE;
// Setting to false because we don't want all the external controls that the street map has
$this->template->header->js = new View('main_3d_js');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
// Override API URL
$this->template->header->api_url = '<script src="http://www.google.com/jsapi?key=' . Kohana::config('settings.api_google') . '"> </script>';
}
$footerjs = new View('footer_form_js');
// Pack the javascript using the javascriptpacker helper
$this->template->header->js .= $footerjs;
$myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false);
$this->template->header->js = $myPacker->pack();
}
示例9: index
//.........這裏部分代碼省略.........
}
if (!empty($sms_no3)) {
$phone_array[] = $sms_no3;
}
$this->template->content->phone_array = $phone_array;
// Get the RSS blog feed
$this->template->content->blog_feed = fetch_rss(Kohana::config('settings.blog_rss_url'));
// Get RSS News Feeds
$this->template->content->feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_TEXT)->limit('10')->orderby('item_date', 'desc')->find_all();
// Get video RSS feeds
$this->template->content->video_feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_VIDEO)->limit('3')->orderby('item_date', 'desc')->find_all();
// Get photo RSS feeds
$this->template->content->photo_feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_PHOTO)->limit('4')->orderby('item_date', 'desc')->find_all();
// Get Slider Dates By Year
$startDate = "";
$endDate = "";
// Get the ladeleb.org info
$cache_name = MAGPIE_CACHE_DIR . "/lade_feed";
$mtime = 0;
if (file_exists($cache_name)) {
$mtime = filemtime($cache_name);
}
$lade_reps = array();
$ctx = stream_context_create(array('http' => array('timeout' => 10)));
if (!$mtime || time() - $mtime > LADE_FEED_REFRESH) {
$lade_raw = @file_get_contents(LADE_FEED_URL, 0, $ctx);
if (!$lade_raw) {
$lade_raw = "";
}
$lade_reports;
preg_match_all('/<div class="NewsPTitle"><a href="(.*?)">\\n(.*?)\\n<\\/div>/', $lade_raw, $lade_reports);
for ($i = 0; $i < count($lade_reports[1]); $i++) {
array_push($lade_reps, array('http://www.observe.ladeleb.org' . $lade_reports[1][$i], $lade_reports[2][$i]));
if ($i >= MAX_LADE_FEED) {
break;
}
}
if ($lade_raw) {
file_put_contents($cache_name, serialize($lade_reps));
} else {
touch($cache_name);
}
} else {
$lade_reps = unserialize(file_get_contents($cache_name));
}
$this->template->content->lade_reports = $lade_reps;
// We need to use the DB builder for a custom query
$db = new Database();
// Query
$query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date');
foreach ($query as $slider_date) {
$startDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">";
for ($i = START_REPORTS_MONTH; $i <= END_REPORTS_MONTH; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$startDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>";
}
$startDate .= "</optgroup>";
$endDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">";
for ($i = START_REPORTS_MONTH; $i <= END_REPORTS_MONTH; $i++) {
if ($i < 10) {
$i = "0" . $i;
}
$endDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\"";
if ($i == date("n", time())) {
$endDate .= " selected=\"selected\" ";
}
$endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>";
}
$endDate .= "</optgroup>";
}
$this->template->content->startDate = $startDate;
$this->template->content->endDate = $endDate;
// get graph data
// could not use DB query builder. It does not support parentheses yet
$graph_data = array();
$all_graphs = Incident_Model::get_incidents_by_interval('month');
$this->template->content->all_graphs = $all_graphs;
// Javascript Header
$this->template->header->map_enabled = TRUE;
$this->template->header->main_page = TRUE;
// Cluster Reports on Map?
$clustering = Kohana::config('settings.allow_clustering');
if ($clustering == 1) {
$this->template->header->js = new View('main_cluster_js');
} else {
$this->template->header->js = new View('main_js');
}
$this->template->header->js->default_map = Kohana::config('settings.default_map');
$this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
$this->template->header->js->longitude = Kohana::config('settings.default_lon');
$this->template->header->js->graph_data = $graph_data;
$this->template->header->js->all_graphs = $all_graphs;
$this->template->header->js->categories = $categories;
// Pack the javascript using the javascriptpacker helper
$myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false);
$this->template->header->js = $myPacker->pack();
}