Merge pull request #156 from marc1706/birthday/ahead_date

[birthday/ahead_date] Add span title with date to birthday ahead list
This commit is contained in:
Marc Alexander
2013-10-26 08:38:52 -07:00
3 changed files with 26 additions and 4 deletions

View File

@@ -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);
}
}

View File

@@ -25,7 +25,7 @@
<img src="{T_THEME_PATH}/images/portal/portal_user.png" width="16" height="16" alt="" />
</span>
<span style="float:left; padding-left:5px; padding-top:2px;">
{board3_birthday_ahead_list.USER}
<span title="{board3_birthday_ahead_list.DATE}">{board3_birthday_ahead_list.USER}</span>
</span>
<span style="float: right;">
<!-- IF board3_birthday_ahead_list.AGE -->{board3_birthday_ahead_list.AGE}<!-- ENDIF -->
@@ -35,4 +35,4 @@
{L_NO_BIRTHDAYS_AHEAD}
<!-- ENDIF -->
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}

View File

@@ -31,7 +31,7 @@
<img src="{T_THEME_PATH}/images/portal/portal_user.png" width="16" height="16" alt="" />
</span>
<span style="float:left; padding-left:5px; padding-top:2px;">
{board3_birthday_ahead_list.USER}
<span title="{board3_birthday_ahead_list.DATE}">{board3_birthday_ahead_list.USER}</span>
</span>
<span style="float: right;">
<!-- IF board3_birthday_ahead_list.AGE -->{board3_birthday_ahead_list.AGE}<!-- ENDIF -->
@@ -44,4 +44,4 @@
</tr>
<!-- ENDIF -->
</table>
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}