Extension talk:Calendar (Cdamian)

email me
you can also contact me at christof@damian.net that will be answered quicker. I don't check this page too often.

Things I'd like to see...

 * css (or css-like) stuff for customising the style of days which have entries (dependent on the categories of those entries, perhaps)
 * Ability to merge separate calendars - e.g. a group of friends have their own calendars, but would like to have all those calendars show on a single page - for arranging get-togethers, or just to have a single point of entry. ( name="john,bob,jules" view="year" ?)
 * A way to show the first line of any calendar entry within a date range
 * A variant of the above - auto-generated summary by-month pages. e.g. CalName_2005_10 would have a summary of all the entries for October 2005

I'm not sure if any of these are possible, or whether they are possible but difficult...I'm just brainstorming a wishlist from my (limited) use of the extension :)

--MNJones


 * css: I can put some more css classes/ids in the next version to make this possible (without the categories though)
 * merge calendars: I thought about that too, it would be useful for my site, shouldn't be to difficult. There is a question about which, calendar will be edited though. Maybe editing will be disabled then.
 * first line: maybe a bit special -- or could this be done with css ?
 * month summary: I played with this too with full inclusion, but it didn't really work nicely
 * --Cdamian 22:29, 11 October 2005 (UTC)


 * As far as the "first line" idea goes, you already do something similar with the week view. My idea was to remove any entries that had *no* corresponding pages - i.e. a list of "what's coming up".
 * &rarr; Is there a way to determine whether a page has (relevant) content?


 * &rarr; As tricky as (relevant) content determination may be, I can see a good use for this. ie: a recurring event has it's own wiki page.  It would be very useful to be able to somehow show when the next scheduled occurance of that event will be (according to the calendar).  More specifically, if we have chips and salsa for lunch together once a month, it would be neat to schedule it on the calendar and then have the next lunch date: automagically show up on the chips_and_salsa_for_lunch page. --68.93.222.34 21:08, 11 November 2005 (UTC)


 * (One of) the applications I'm looking at using it for is a list of reenactment events - there are maybe one or two events per month, so listing *every* day's entry would be unwieldy. All I need is to list which days what events are on. Still not sure that this is the best medium for it, but it's what I'm currently playing with.


 * The CSS idea occurred when I was looking at a month-view, and thought "It would be nice if all the events had a coloured background to distinguish them from other entries..."


 * --Mnjones 10:04, 14 October 2005 (UTC)

Cache problem
Today's date is always in the past. Freshly edited events do not appear. How do I keep calendar pages from being cached by viewers?
 * In Calendar.php, moving the clearCache call in renderCalendar to the end after the $wgParser->parse line, right before the return, seems to fix the cache problem. --Austin 21:59, 17 February 2006 (UTC)
 * this fix is also in the 1.7 version, thanks go to [OpenWetWare:User:Austin|Austin]]. --Cdamian 14:58, 1 March 2006 (UTC)

Kudos
Just wanted to say thanks - this is a great extension!

Skipempty-Option
This option must be implemented as skipempty=TRUE to enable its function. --213.168.102.97 17:00, 7 March 2006 (UTC)

Bug when including >1 Calendar by template

 * There seems to be a bug, when you have two template pages with each one having a ("threemonths"-calendars). When both pages are included in a single page, only one calendar shows up - the other one is filled with a lenghty UNIQ30293.... - 84.132.129.8 18:00, 7 May 2006 (UTC)
 * I think there is a problem with templates and extensions in general --Cdamian 10:07, 17 May 2006 (UTC)
 * This is easily fixed, well this has done it OK for me. Edit Calendar.php and change:
 * thats in 1.12 now. --Cdamian 09:15, 29 September 2006 (UTC)

Help translate to Russian
Please point to plase in PHP code for transtation

function WeekdayShort($dow) { $a = array('Пн','Вт','Ср','Чт','Пт','Сб','Вс'); return $a[$dow-1]; } function WeekdayLong($dow) { $a = array('Понедельник','Вторник','Среда','Четверг','Пятница','Субота','Воскресение'); return $a[$dow-1]; } function MonthName($month) { $a = array("Январь", "Февраль", "Март", "Апрель",               "Май", "Июнь", "Июль", "Август",                "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"); return $a[$month-1]; }

After i`m translate this in CalendarClass.php calendar did`t display short day names properly without translation the same situation, but ?? symbols instead &&

Implementing PhpWiki's calendar's functions

 * switching months
 * separate calendar for every page (well, besides discussion-pages etc.)

In Calendar.php replace: $calstr = $cal->displayMonth; with: if (!is_null($_GET["CalendarDisplayMonth"])) { $month = (int)substr((string)$_GET["CalendarDisplayMonth"], 4); $year = (int)substr((string)$_GET["CalendarDisplayMonth"], 0, 4); } else { $month = 0; $year = 0; }   $calstr .= $cal->displayMonth($month,$year);

In CalendarClass.php add functions: function prevMonth($month,$year) { return $month == 1 ? ($year - 1). 12 : $year. ($month - 1 < 10 ? 0 : ''). ($month - 1); }

function nextMonth($month,$year) { return $month == 12 ? ($year + 1). 0 . 1 : $year. ($month + 1 < 10 ? 0 : ''). ($month + 1); } and replace in function displayMonth: $r = ''; $dim = $this->DaysInMonth($month, $year); $dow = $this->DayOfWeek(1,$month,$year);

$r .= ' '; $r .= $this->MonthName($month); $r .= ' '; with: $query = ereg_replace("(\?|(\&))action=submit", "", ereg_replace("(\?|(\&))CalendarDisplayMonth=[0-9]*", "", $_SERVER["REQUEST_URI"])); $linkStart = '['.(!is_null($_SERVER["HTTPS"]) ? 'https' : 'http').'://'.$_SERVER["SERVER_NAME"].$query.(strpos($query, '?') ? '&amp;' : '?').'CalendarDisplayMonth='; $prevMonthLink = $linkStart.$this->prevMonth($month,$year).' &lt;&lt;] '; $nextMonthLink = ' '.$linkStart.$this->nextMonth($month,$year).' &gt;&gt;]'; $monthHeader = $prevMonthLink.$this->MonthName($month).", ".$year.$nextMonthLink; $r = ''; $dim = $this->DaysInMonth($month, $year); $dow = $this->DayOfWeek(1,$month,$year);

$r .= ' '; $r .= $monthHeader; $r .= ' ';

In WikiCalendarClass.php replace: if ($title and $title->getArticleID==0) { return .$day.; } else { return "$day"; //"$day"; } with: return "$day"; PS. replaced if is useless (and will probably be removed in the future) as both returns are totally equivalent.

Alternatives
Are there any alternatives to your approach? -- JanCK 19:05, 29 July 2006 (UTC)

Problems

 * Does anyone have a problem with   being displayed before and after the calendar today function?
 * I do, using 1.10.0 and the latest calendar version (1.13?), and then only after dates in the "This Week" section of the full calendar view (at least so far). It seems that the are converted to symbols in those closing tags, causing the tag to show up literally rather than usefully.  Not sure why.  Anyone?  The removal of closing td and dd tags didn't help...
 * I have the same problem on MW 1.10.0 / Calendar 1.13 --Zabwung 19:39, 20 August 2007 (UTC)
 * Oops! Solution already provided under Requests in main airticle page :-) --Zabwung 23:02, 24 August 2007 (UTC)

Merge
The merge functionallity is great, but for some reason I get the chars: '' at the start of any listing coming from a merged calendar if there are no events from the name = calendar also. This is running on MW 1.6.8 - does anyone else have this issue? Also, merge seems to have no effect whatsoever in the month view. --OneSeven 08:36, 23 September 2006 (UTC)

Fixed!.. The problem described above can be fixed by editing the WikiCalendarClass.php file. In the function displayWeekday, insert the line: $r = str_replace( " ", "", $r ); just before the return $r; statement. --OneSeven 04:31, 28 September 2006 (UTC)

Great timing, glad someone's been working on this -- as I just started to wrestle with it today -- but your fix didn't work for me?? Ideas? what version of MW are you on? --Fizik aka Chris E 21:26, 28 September 2006 (UTC)


 * that is fixed in 1.12 now (though with a different solution) --Cdamian

Hack to hide events from Special:Wantedpages
(works on MW 1.6.8, untested on anything else)

It seems that creating a calendar can flood the Special:Wantedpages with links to the the event pages that don't yet exist. With multiple calendars, this can easily equate to hundreds of unwanted 'wanted' pages. The only way that I've found to avoid this is to modify the includes/SpecialWantedpages.php getSQL function to exclude calendar events. There are two ways to go about this -

Method 1
This is the easier, but less flexible option. It's fine if you only have/need one or two different calendars. It is possible though to accidentally hide more than just the calendar events pages, depending on how you've named them.

Find the section of includes/SpecialWantedpages.php that has: WHERE pg1.page_namespace IS NULL AND pg2.page_namespace != 8 GROUP BY pl_namespace, pl_title

And change it to: WHERE pg1.page_namespace IS NULL AND pg2.page_namespace != 8 AND NOT pl_title LIKE 'calendar_name%' GROUP BY pl_namespace, pl_title

--replace calendar_name with the name of the calendar you want to exclude. You can add more AND NOT pl_title LIKE 'calendar_name%' lines if you have multiple calendars with different names, but keep in mind that this may impact performace as the SQL query gets more complicated. NB. for those new to SQL - the '%' sign is a Wildcard_character in SQL, equivilant of the more common '*'. This means that any article that starts with calendar_name will not be shown on the wanted page list.

Method 2
In this method we use a custom namespace for all calendar events so that we can filter the links out based on namespace, which is a much nicer solution IMO.

Step 1 - Create a custom namespace for your calendars to live in. The rest of this section assumes that the custom namespace are numbered and named as shown: 100 => "Calendar" 101 => "Calendar_Talk"

Step 2 - In extensions/WikiCalendar/Calendar.php change if (!isset($p['format'])) { $p['format'] = '%name_%year_%month_%day'; }; to if (!isset($p['format'])) { $p['format'] = 'Calendar:%name_%year_%month_%day'; }; This will ensure that calendars use the newly created namespace by default.

Step 3 - Finally, find the section of includes/SpecialWantedpages.php that has: WHERE pg1.page_namespace IS NULL AND pg2.page_namespace != 8 GROUP BY pl_namespace, pl_title And change it to: WHERE pg1.page_namespace IS NULL AND pg2.page_namespace != 8 AND pl_namespace != 100 GROUP BY pl_namespace, pl_title This will prevent anything in the namespace that we just created from showing up on Special:Wantedpages.

--OneSeven 03:12, 27 September 2006 (UTC)

Parser failure
I tried to install the extension with 1.7 I got all kinds of parser errors when trying to use your example calendar


 * version 1.13 now has a fix for one problem with mediawiki 1.7, please try that version --Cdamian 21:29, 9 October 2006 (UTC)

That seems to work, thanks. In week mode, how do you make it so that the dates aren't linked? --68.18.108.243 22:59, 10 October 2006 (UTC)

Never mind, I figured it out, just had to edit a php file. --68.18.108.243 00:48, 12 October 2006 (UTC)

Any way to preload templates?
Is there any way to make the calendar pre-load a template when clicking on a date that doesn't have an entry? (IE, action=edit&preload=template) Please let me know!! HotMonkeyAC 16:49, 17 October 2006 (UTC)

Template and year
The above question is also for me.... a template for each date of year that isn't edit yet. Also like to know if you can name a year instead of -1 year or -2 year... when doing that now its richt that year 2006 is -1 but when it is 2008 that page wil be 2007... so is there a soloution or anser?

greets Tom (dvine2000@gmail.com)

Method for alternate weekviews
There's probably a better solution, but I implemented the following changes to Calendar.php and to allow for "wholemonth" week view option. Changes to Calendar.php switch ($p["view"] case "wholemonth":    $dim = $cal->DaysInMonth($p['month'],$p['year']);    $calstr = $cal->displayDays($dim);    break; --Zerobeat 01:13, 21 May 2007 (UTC)

Template:Extension cleanup
As per your request (Cdamian) I tried to do some cleanup. However, some things require the source code and yours is compressed and not so easy to view on line.

For future reference:
 * In the rendered template, the label next to any parameter links to documentation on the parameter. Although it takes you directly to the line for that particular parameter, you can scroll up and down to see the rest of the documentation.
 * The template is dumb: to handle fields with multiple values, you have to do them in order: e.g. type/type1= |type2= |type3, .... Your value for type wasn't showing up because it was assigned to parameter type2 but type1 (alias type) was missing.
 * The type field stores "how I did it", not "why use this" (so we can put together coding examples to help other developers). The value set only covers MediaWiki specific techniques - for a discussion see Template_talk:Extension.  I assigned it tag.  I hope that was OK.  Note: To capture its purpose (i.e. a calendar), use category (as you have done)  Egfrank 06:44, 19 September 2007 (UTC)
 * that was my request, thanks --Zven 07:08, 19 September 2007 (UTC)