From 23346d5e76a171efb407612dc54a92740863dfbc Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 14 Feb 2015 18:55:55 -0500 Subject: Move function to the right place (pull-request) and improve board task icons --- app/Core/Helper.php | 27 +++++++++++++++ app/Locale/da_DK/translations.php | 3 ++ app/Locale/de_DE/translations.php | 3 ++ app/Locale/es_ES/translations.php | 3 ++ app/Locale/fi_FI/translations.php | 3 ++ app/Locale/fr_FR/translations.php | 3 ++ app/Locale/hu_HU/translations.php | 3 ++ app/Locale/it_IT/translations.php | 3 ++ app/Locale/ja_JP/translations.php | 3 ++ app/Locale/pl_PL/translations.php | 3 ++ app/Locale/pt_BR/translations.php | 3 ++ app/Locale/ru_RU/translations.php | 3 ++ app/Locale/sv_SE/translations.php | 3 ++ app/Locale/th_TH/translations.php | 3 ++ app/Locale/zh_CN/translations.php | 3 ++ app/Template/board/task.php | 70 ++++++++++++++++----------------------- app/functions.php | 26 ++------------- 17 files changed, 99 insertions(+), 66 deletions(-) (limited to 'app') diff --git a/app/Core/Helper.php b/app/Core/Helper.php index d60e29d4..57d1b98a 100644 --- a/app/Core/Helper.php +++ b/app/Core/Helper.php @@ -49,6 +49,33 @@ class Helper return $this->container[$name]; } + /** + * Get the age of an item in quasi human readable format. + * It's in this format: <1h , NNh, NNd + * + * @access public + * @param integer $timestamp Unix timestamp of the artifact for which age will be calculated + * @param integer $now Compare with this timestamp (Default value is the current unix timestamp) + * @return string + */ + public function getTaskAge($timestamp, $now = null) + { + if ($now === null) { + $now = time(); + } + + $diff = $now - $timestamp; + + if ($diff < 3600) { + return t('<1h'); + } + else if ($diff < 86400) { + return t('%dh', $diff / 3600); + } + + return t('%dd', ($now - $timestamp) / 86400); + } + /** * Proxy cache helper for acl::isManagerActionAllowed() * diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index db91895f..b6186a33 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 967d5f62..f954ce78 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index c69d9084..60a90c9a 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 0dd29c37..42054646 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 7872dec4..26372c48 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -721,4 +721,7 @@ return array( 'fixes' => 'corrige', 'is fixed by' => 'est corrigée par', 'This task' => 'Cette tâche', + '<1h' => '<1h', + '%dh' => '%dh', + '%b %e' => '%e %b', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 1f8de0ea..487492b2 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index afd41d5c..f395caff 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 9d06b83f..ab62128c 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 2ebfc219..688230fa 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index ded6e0db..d7759fc8 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index de792516..0afd3643 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 838b426a..c9a9b041 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 66c7712b..502b1135 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 32278e21..75690708 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -719,4 +719,7 @@ return array( // 'fixes' => '', // 'is fixed by' => '', // 'This task' => '', + // '<1h' => '', + // '%dh' => '', + // '%b %e' => '', ); diff --git a/app/Template/board/task.php b/app/Template/board/task.php index 075eab92..638078c3 100644 --- a/app/Template/board/task.php +++ b/app/Template/board/task.php @@ -20,10 +20,6 @@ - - e($task['score']) ?> - -
a($this->e($task['title']), 'task', 'readonly', array('task_id' => $task['id'], 'token' => $project['token'])) ?>
@@ -59,7 +55,7 @@ a( - (! empty($task['owner_id']) ? t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) : t('Nobody assigned')), + (! empty($task['owner_id']) ? ($task['assignee_name'] ?: $task['assignee_username']) : t('Nobody assigned')), 'board', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), @@ -68,13 +64,9 @@ t('Change assignee') ) ?> - - - - - - e($task['score']) ?> - + + getTaskAge($task['date_creation']) ?> + getTaskAge($task['date_moved']) ?>
a($this->e($task['title']), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, '', t('View this task')) ?> @@ -99,40 +91,34 @@
+
+ + +   + + - - -
diff --git a/app/functions.php b/app/functions.php index a748f005..439375be 100644 --- a/app/functions.php +++ b/app/functions.php @@ -63,31 +63,9 @@ function dt($format, $timestamp) * @todo Improve this function * @return mixed */ -function p($value, $t1, $t2) { +function p($value, $t1, $t2) +{ return $value > 1 ? $t2 : $t1; } -/** - * Get the age of an item in quasi human readable format. - * It's in this format: <1h , NNh, NNd - * - * @access public - * @param int $time - * Unix timestamp of the artifact for which age will be calculated - * @param int $currenttime - * Comepare with timestamp. Default current unix timestamp - * @return string - */ -function getAgeShort($time, $currenttime = NULL) { - if (! $currenttime) { - $currenttime = time (); - } - $diff = $currenttime - $time; - if ($diff < 3600) - return "<1h"; - elseif ($diff < 86400) { - return intval ( ($diff / 3600) ) . "h"; - } - return intval ( ((floor ( $currenttime ) - floor ( $time )) / 86400) ) . "d"; -} -- cgit v1.2.3