Extension:Calendar (Barrylb)
|
|
WARNING: the code or configuration described here poses a major security risk.
Problem: Open to XSS and SQL injection attacks |
|
Calendar Release status: stable |
|
|---|---|
| Implementation | Tag, Special page |
| Description | These extensions add a <calendar/> tag and a new special page - Special:Events. |
| Author(s) | Barrylb |
| MediaWiki | 1.12 |
| License | Public domain |
| Download | |
| Example | Examples |
|
Check usage (experimental) |
|
These extensions add a <calendar/> tag and a new special page - Special:Events.
You should place each event in its own article, with [[Category:Events]] and a category for the date, in the format [[Category:2006/07/13]]
You can use any article name you like, for example: [[Events/2006/07/13/Employee dinner]]
Each day on the calendar has a link to the Special:Events page to list all the events for that day. Beneath the calendar it optionally shows the next 5 upcoming events. The special page shows the events for a day or month. If you use <calendar>upcoming=off</calendar> it will not show the upcoming events part.
It is only designed to show the current month when shown on regular pages. The Special:Events page is used for the previous and next month links.
New features released August 2007:
- Previous and next month links can now use AJAX to cycle through months without going to a separate page. Use <calendar>ajaxprevnext=on</calendar>. To combine with other options use a vertical bar - eg <calendar>ajaxprevnext=on|upcoming=off</calendar>
- First day of the week is now Monday - you can easily change the code back to the previous default of Sunday though
- Current day is now more visible by default
- Various parts of the appearance are easier to change with the CSS stylesheets (highlighting weekends, current day, event days)
Contents |
[edit] Usage
[edit] Adding a calendar event
Add the following to a page:
[[Category:Events]]
[[Category:2009/10/20]]
and that's it!
[edit] Adding a calendar to a page
Add the following to a page:
<calendar></calendar>
or
<calendar>upcoming=off</calendar>
or
<calendar>calendar=off</calendar>
[edit] Calendar in Sidebar
I use this on the left column of my wiki and modified the MonoBook.php file to include it.
Use the following lines in your MonoBook.php file: <div class="portlet" id="p-calendar"> <?php $this->msgWiki( 'Leftnav' ) ?> </div>. Place this just above the toolbox portlet <div class="portlet" id="p-tb">.
Then edit MediaWiki:Leftnav on your wiki and set its contents to <calendar /> or <calendar>upcoming=off</calendar> and it should work.
[edit] Small Fixes
[edit] Links
If using the standard title convention (index.php?title=...), the links will not work because of a url parsing issue. This can be fixed by modifying Calendar.php (or using Calendar2.php). Change all instances of "Events?year" to "Events&year". There is also one instance of "Events?category" that must be updated to "Events&category" near the end of the file. This comes about because the first variable in the url is indicated by a question mark ('?'), and the rest are delimited with an ampersand ('&'). If you are using the first variable as the title, the year variable becomes the second variable in the url, and thus must be marked with an ampersand, not a question mark:
...Events?year... --> ...Events&year... ...Events?category... --> ...Events&category...
[edit] AJAX
If AJAX links are not working, one must surround the calendar tag with a <div id="p-calendar"> to help the script identify the location of the calendar block:
<div id="p-calendar"> <calendar>ajaxprevnext=on</calendar> </div>
[edit] Files
Here are the files you need. You should place them in your extensions directory and include them in your LocalSettings.php. Add lines like
require_once("extensions/Calendar.php"); require_once("extensions/SpecialEvents.php");
Visit each of the links below and copy out the code:
- Calendar.php
- If your wiki uses URLs like index.php?title=Special:Events, use Calendar2.php instead.
- SpecialEvents.php
- CSS changes - add to your site's MediaWiki:Common.css and customize to your liking (this is not the file under the skins/common directory in the file structure, but the actual MediaWiki:Common.css wiki page!)
- Javascript code - add to your site's MediaWiki:Common.js if you want to use the AJAX feature for previous and next month links
You are welcome to contribute enhancements to these files. I release them to the public domain.

