From d2438e712b9528e4486fe511a26d7b7ec952663d Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Mon, 2 Sep 2013 12:13:29 -0400 Subject: [PATCH] Use CSS for date styling Removed BOINC code dependency and added boincwork module function to set CSS classes for styling deadline datestamps --- .../work_and_host_stats.views_default.inc | 63 +++++-------------- .../boincwork/includes/boincwork.helpers.inc | 27 +++++++- 2 files changed, 39 insertions(+), 51 deletions(-) diff --git a/drupal/sites/all/features/work_and_host_stats/work_and_host_stats.views_default.inc b/drupal/sites/all/features/work_and_host_stats/work_and_host_stats.views_default.inc index 2de4399581..2c0a0d7fb6 100644 --- a/drupal/sites/all/features/work_and_host_stats/work_and_host_stats.views_default.inc +++ b/drupal/sites/all/features/work_and_host_stats/work_and_host_stats.views_default.inc @@ -224,14 +224,16 @@ function work_and_host_stats_views_default_views() { 'relationship' => 'none', ), 'phpcode' => array( - 'label' => 'Time reported or deadline [use CSS!]', + 'label' => 'Time reported or deadline', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', + 'absolute' => 0, 'link_class' => '', 'alt' => '', + 'rel' => '', 'prefix' => '', 'suffix' => '', 'target' => '', @@ -246,21 +248,8 @@ function work_and_host_stats_views_default_views() { 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, - 'value' => 'result_received_time) { - $r = time_str($data->result_received_time); - } else if ($data->result_report_deadline) { - if ($data->result_report_deadline>time()) { - $r = "" . time_str($data->result_report_deadline) . ""; - } else { - $r = "" . time_str($data->result_report_deadline) . ""; - } - } else { - $r = "---"; - } - return $r; -?>', + 'hide_alter_empty' => 1, + 'value' => 'result_received_time, $data->result_report_deadline); ?>', 'exclude' => 0, 'id' => 'phpcode', 'table' => 'customfield', @@ -5558,14 +5547,16 @@ else { 'relationship' => 'none', ), 'phpcode' => array( - 'label' => 'Time reported or deadline [use CSS!]', + 'label' => 'Time reported or deadline', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', + 'absolute' => 0, 'link_class' => '', 'alt' => '', + 'rel' => '', 'prefix' => '', 'suffix' => '', 'target' => '', @@ -5580,21 +5571,8 @@ else { 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, - 'value' => 'result_received_time) { - $r = time_str($data->result_received_time); - } else if ($data->result_report_deadline) { - if ($data->result_report_deadline>time()) { - $r = "" . time_str($data->result_report_deadline) . ""; - } else { - $r = "" . time_str($data->result_report_deadline) . ""; - } - } else { - $r = "---"; - } - return $r; -?>', + 'hide_alter_empty' => 1, + 'value' => 'result_received_time, $data->result_report_deadline); ?>', 'exclude' => 0, 'id' => 'phpcode', 'table' => 'customfield', @@ -8799,14 +8777,16 @@ else { 'relationship' => 'none', ), 'phpcode' => array( - 'label' => 'Time reported or deadline [use CSS!]', + 'label' => 'Time reported or deadline', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', + 'absolute' => 0, 'link_class' => '', 'alt' => '', + 'rel' => '', 'prefix' => '', 'suffix' => '', 'target' => '', @@ -8821,21 +8801,8 @@ else { 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, - 'value' => 'result_received_time) { - $r = time_str($data->result_received_time); - } else if ($data->result_report_deadline) { - if ($data->result_report_deadline>time()) { - $r = "" . time_str($data->result_report_deadline) . ""; - } else { - $r = "" . time_str($data->result_report_deadline) . ""; - } - } else { - $r = "---"; - } - return $r; -?>', + 'hide_alter_empty' => 1, + 'value' => 'result_received_time, $data->result_report_deadline); ?>', 'exclude' => 0, 'id' => 'phpcode', 'table' => 'customfield', diff --git a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc index 0f5699c866..ee81112fe3 100644 --- a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc +++ b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc @@ -1427,7 +1427,7 @@ function boincwork_validate_datatype($data, $datatype = NULL) { /** * Determine output for host list views when no hosts are found. */ -function boincwork_views_host_list_empty_text($context = null) { +function boincwork_views_host_list_empty_text($context = NULL) { // Pull the BOINC user ID from the view arguments to get show_hosts // preference for that user @@ -1470,7 +1470,7 @@ function boincwork_views_host_list_empty_text($context = null) { /** * Determine output for task list views when no tasks are found. */ -function boincwork_views_task_list_empty_text($context = null) { +function boincwork_views_task_list_empty_text($context = NULL) { // $output = ''; @@ -1485,7 +1485,7 @@ function boincwork_views_task_list_empty_text($context = null) { /** * Determine output for host last contact time */ -function boincwork_host_last_contact($timestamp, $context = null) { +function boincwork_host_last_contact($timestamp, $context = NULL) { $output = '---'; $log_name = 'NO_SUCH_LOG'; if ($timestamp) { @@ -1497,3 +1497,24 @@ function boincwork_host_last_contact($timestamp, $context = null) { } return $output; } + +/** + * Determine output for task reported time / deadline + */ +function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) { + $output = '---'; + if ($received_time OR $deadline) { + $timestamp = ($received_time) ? $received_time : $deadline; + $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC'; + // Add a wrapper to deadline text + if (!$received_time) { + if (time() < $deadline) { + $output = '' . $output . ''; + } + else { + $output = '' . $output . ''; + } + } + } + return $output; +}