From 70a77ca298711e4c9473ce4d101a58c29bb0d153 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 26 Oct 2013 17:37:56 +0200 Subject: [PATCH] [birthday/ahead_date] Add span title with date to birthday ahead list --- root/portal/modules/portal_birthday_list.php | 22 +++++++++++++++++++ .../portal/modules/birthdays_side.html | 4 ++-- .../portal/modules/birthdays_side.html | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/root/portal/modules/portal_birthday_list.php b/root/portal/modules/portal_birthday_list.php index 583fb875..b1378179 100644 --- a/root/portal/modules/portal_birthday_list.php +++ b/root/portal/modules/portal_birthday_list.php @@ -105,6 +105,7 @@ class portal_birthday_list_module $template->assign_block_vars('board3_birthday_ahead_list', array( 'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '', + 'DATE' => $this->format_birthday($user, $row['user_birthday'], 'd M'), )); } } @@ -154,4 +155,25 @@ class portal_birthday_list_module WHERE ' . $db->sql_in_set('config_name', $del_config); return $db->sql_query($sql); } + + /** + * Format birthday for span title + * + * @param object $user phpBB user object + * @param string $birthday User's birthday from database + * @param string $date_settings Settings for date() function + */ + protected function format_birthday($user, $birthday, $date_settings) + { + if (!preg_match('/(?:[0-9])+-+(?:[0-9]{2})+-+(?:[0-9]{4})/', $birthday, $match)) + { + return ''; + } + + $date = explode('-', $birthday); + $time = mktime(0, 0, 0, $date[1], $date[0], $date[2]); + $lang_dates = $user->lang['datetime']; + + return strtr(date($date_settings, $time), $lang_dates); + } } diff --git a/root/styles/prosilver/template/portal/modules/birthdays_side.html b/root/styles/prosilver/template/portal/modules/birthdays_side.html index 83f4a7be..7064d91d 100644 --- a/root/styles/prosilver/template/portal/modules/birthdays_side.html +++ b/root/styles/prosilver/template/portal/modules/birthdays_side.html @@ -25,7 +25,7 @@ - {board3_birthday_ahead_list.USER} + {board3_birthday_ahead_list.USER} {board3_birthday_ahead_list.AGE} @@ -35,4 +35,4 @@ {L_NO_BIRTHDAYS_AHEAD} -{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} \ No newline at end of file +{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} diff --git a/root/styles/subsilver2/template/portal/modules/birthdays_side.html b/root/styles/subsilver2/template/portal/modules/birthdays_side.html index 8c1cf575..24bc4336 100644 --- a/root/styles/subsilver2/template/portal/modules/birthdays_side.html +++ b/root/styles/subsilver2/template/portal/modules/birthdays_side.html @@ -31,7 +31,7 @@ - {board3_birthday_ahead_list.USER} + {board3_birthday_ahead_list.USER} {board3_birthday_ahead_list.AGE} @@ -44,4 +44,4 @@ -{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} \ No newline at end of file +{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}