I'm trying to set up a main page with some elements similar to the Wikipedia, but would like to have a weekly featured article. {{CURRENTWEEK}} (giving the week of the year number 0-52) is not currently an available variable, but I suspect I could cobble together a method to calculate it, if I knew where in MediaWiki to stick it.
Is there any way to get the current week? if not, is there a text suggesting where/how to hack it in?
Amgine
On Thu, 02 Dec 2004 14:42:59 -0800, Amgine amgine@saewyc.net wrote:
I'm trying to set up a main page with some elements similar to the Wikipedia, but would like to have a weekly featured article. {{CURRENTWEEK}} (giving the week of the year number 0-52) is not currently an available variable, but I suspect I could cobble together a method to calculate it, if I knew where in MediaWiki to stick it.
I think I'm right in saying that you'll need to make changes in exactly three places: 1) at the top of includes/MagicWord.php: * add "define(MAG_CURRENTWEEK, <some number not used yet>);" * add "MAG_CURRENTWEEK" into the $wgVariableIDs array [this defines the "magic word" within the software]
2) in languages/Language.php (and/or LanguageXx.php for the language your wiki uses): * add "MAG_CURRENTWEEK => array (1, 'CURRENTWEEK') , " into the $wgMagicWordsEn array (or $wgMagicWords<langcode>, as appropriate) [this defines what text your magic word matches]
3) in includes/Parser.php, function getVariableValue: * add the code to actually deal with your new variable, something like: case MAG_CURRENTWEEK: return $wgContLang->formatNum( date('W') );
NB: According to the PHP manual at http://php.net/date, this will give you weeks that start on Monday; and according to one comment there "your last week of a year may be 1 [...] e.g. December 31th[sic] 2002 is in week 1 of the year 2003!"
Having gone this far, I could just give you a diff, but not knowing what version you're running, and having generally rather destroyed my local install anyway, I'll leave the rest to you.
Rowan Collins wrote:
NB: According to the PHP manual at http://php.net/date, this will give you weeks that start on Monday; and according to one comment there "your last week of a year may be 1 [...] e.g. December 31th[sic] 2002 is in week 1 of the year 2003!"
The definition of week numbers used by the ISO 8601 standard (see http://www.cl.cam.ac.uk/~mgk25/iso-time.html) does say that they start on Monday, but they don't span years. The last week of a year is always either 52 or 53, and like week 1, it may be a partial week. I believe Palm OS works this way also. If PHP is doing things differently, it sounds like a bug.
mediawiki-l@lists.wikimedia.org