On Thu, 02 Dec 2004 14:42:59 -0800, Amgine <amgine(a)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 BSc
[IMSoP]