From bafa4730dfa435fb7da12b5331e8f4a4888bb8fb Mon Sep 17 00:00:00 2001 From: bellalistair <67345123+bellalistair@users.noreply.github.com> Date: Mon, 30 Dec 2024 16:14:04 +0000 Subject: [PATCH 1/2] Update phpc.css Styling for Next/Prev month 'buttons' --- static/phpc.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/phpc.css b/static/phpc.css index cc590a34..616f0a6b 100644 --- a/static/phpc.css +++ b/static/phpc.css @@ -105,6 +105,13 @@ p.phpc-desc { .php-calendar caption { font-weight: bolder; + margin-bottom: 0.5em; +} + +.php-calendar a.phpc-caption { + text-decoration: none; + font-weight: normal; + margin-right: 1em; } .php-calendar tfoot { From 93e621230f24bd09e909b515d9cfc986e7e045e8 Mon Sep 17 00:00:00 2001 From: bellalistair <67345123+bellalistair@users.noreply.github.com> Date: Mon, 30 Dec 2024 16:21:02 +0000 Subject: [PATCH 2/2] Update display_month.php Add links to previous & next months --- src/display_month.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/display_month.php b/src/display_month.php index a35db9a7..f77277ae 100644 --- a/src/display_month.php +++ b/src/display_month.php @@ -58,8 +58,10 @@ function display_month() tag('table', attributes('class="phpc-main phpc-calendar"'), tag('caption', - create_dropdown_list(month_name($month), $months), - create_dropdown_list($year, $years)), + get_month_link($month, -1,$year), + create_dropdown_list(month_name($month), $months), + create_dropdown_list($year, $years), + get_month_link($month, +1,$year)), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), @@ -73,6 +75,30 @@ function display_month() tag('thead', $heading_html), create_month($month, $year))); } +// creates a link to another month at some offset from that given +/** + * @param int $month + * @param int $diff + * @param int $year + * @return Html + */ +function get_month_link($month,$diff,$year) { + $newtime = mktime(0, 0, 0, $month + $diff, 1, $year); + $newmonth = date('n', $newtime); + $newyear = date('Y', $newtime); + $newmonthname = month_name($newmonth); + $new_args = array('year' => $newyear, 'month' => $newmonth); + if ($diff < 0) { + return create_action_link( "⇐ ".__($newmonthname), 'display_month', + $new_args,'class="phpc-caption ui-state-default"'); + } elseif ($diff > 0) { + return create_action_link( __($newmonthname)." ⇒", 'display_month', + $new_args,'class="phpc-caption ui-state-default"'); + } else { + return create_action_link( __($newmonthname), 'display_month', + $new_args,'class="phpc-caption ui-state-default"'); + } +} // creates a display for a particular month to be embedded in a full view /**