Thank you very much, donatj, for the simple PHP calendar rendering class. I’d like to contribute something to it.
Whilst looking for an alternative to Nextcloud, I came across this repository
New features
- Easily configure calendar settings.
- Custom language using language files. Based on the phpBB language function. Very simple.
- Display short or long Weeknames.
- Week numbers can be shown or hidden via the settings.
- View previous calendar days / events and upcoming calendar days / events
Tested with PHP Version 8.5.7.
You can view a Live Demo. This demo incorporates my build_holidays library, which automatically generates German public holidays from 1900 to 2038. It is worth considering whether this can be integrated directly or as an add-on.
I'm currently working on integrating with a calendar server (Baikal). This should resolve issue #3.
If you like the new features, I can add them here wintstar#5.
Parameters / options
| Parameter |
Description |
Default |
Valid values |
calendarTimezone string |
Sets the default timezone |
UTC |
The timezone identifier, like UTC, America/Vancouver, Asia/Hong_Kong, or Europe/Berlin etc. Look List of Supported Timezones. |
calendarWeekStart int or string |
Sets the first day of the week |
$offset |
Day the week starts on. ex: "Monday" or 0-6 where 0 is Sunday |
calendarDate \DateTimeInterface false or string or null |
Sets the date for the calendar |
null |
$date - DateTimeInterface for the calendar date. If null set to current timestamp. |
calendarToday \DateTimeInterface or string or null |
Sets "today"'s date. Defaults to today. |
null |
$today - null will default to today, false will disable the rendering of Today. |
calenderLang string |
Sets the User Language for text strings |
en |
de To add another language, create a translation and name the file according to this template calendar_fr.php For example, for French. Insert the language file into the vendor/donatj/simplecalendar/src/ directory/language. |
shortWeekname bool |
Sets the display of weekday names in short or full form |
true |
true for short weekday names
false for long weekday names |
displayWeeknumber bool |
Sets the display of weeknumber |
false |
true for display
false for hide |
calendar
leading_day
trailing_day
today
event
events array<string,string> |
Sets the class names used in the calendar |
SimpleCalendar
SCprefix
SCsuffix
today
event
events Map of element to class names used by the calendar |
Take a look at the file vendor/donatj/simplecalendar/src/css/SimpleCalendar.css to see how the parameters are used. |
Basic usage
Standard Settings:
- Timezone: UTC
- Weekstart: Sunday
- calendarDate: Current date
- User langage: en
- Display Weekname: short form
<?php
require __DIR__ . '/vendor/autoload.php';
echo '<link rel="stylesheet" href="vendor/donatj/simplecalendar/src/css/SimpleCalendar.css" />';
$calendar = new donatj\SimpleCalendar();
echo $calendar->render();
Examples
Standard Settings:
- calendarDate: Current date
Custom Settings:
- Timezone: Europe/Berlin
- Weekstart: Monday
- User langage: de
- Display Weekname: long form
<?php
require __DIR__ . '/vendor/autoload.php';
echo '<link rel="stylesheet" href="vendor/donatj/simplecalendar/src/css/SimpleCalendar.css" />';
$calendar = new donatj\SimpleCalendar([
'calendarTimezone' => 'Europe/Berlin',
'calendarWeekStart' => 'Monday',
'locacalenderLangle' => 'de',
'shortWeekname' => false,
]);
....
Thank you very much, donatj, for the simple PHP calendar rendering class. I’d like to contribute something to it.
Whilst looking for an alternative to Nextcloud, I came across this repository
New features
Tested with PHP Version 8.5.7.
You can view a Live Demo. This demo incorporates my
build_holidayslibrary, which automatically generates German public holidays from 1900 to 2038. It is worth considering whether this can be integrated directly or as an add-on.I'm currently working on integrating with a calendar server (Baikal). This should resolve issue #3.
If you like the new features, I can add them here wintstar#5.
Parameters / options
calendarTimezonestring
UTCcalendarWeekStartint or string
$offsetDay the week starts on. ex: "Monday" or 0-6 where 0 is SundaycalendarDate\DateTimeInterface false or string or null
null$date- DateTimeInterface for the calendar date. If null set to current timestamp.calendarToday\DateTimeInterface or string or null
null$today-nullwill default to today, false will disable the rendering of Today.calenderLangstring
endeTo add another language, create a translation and name the file according to this template
calendar_
fr.phpFor example, for French. Insert the language file into the
vendor/donatj/simplecalendar/src/ directory/language.shortWeeknamebool
truetruefor short weekday namesfalsefor long weekday namesdisplayWeeknumberbool
falsetruefor displayfalsefor hidecalendarleading_daytrailing_daytodayeventeventsarray<string,string>
SimpleCalendarSCprefixSCsuffixtodayeventeventsMap of element to class names used by the calendar
vendor/donatj/simplecalendar/src/css/SimpleCalendar.cssto see how the parameters are used.Basic usage
Standard Settings:
Examples
Standard Settings:
Custom Settings: