Last modified: 2011-12-06 20:03:14 UTC
As far as I can see, there isn't any stack keeping track which is the current template/site the parser is processing right now (besides the main title Parser::$mTitle of course). I am not completely sure whether this could even be done with the current parser layout, but I guess it could be done somehow within Parser::braceSubstitution(). There are no hooks getting called at all yet I believe. Knowing which template/site the code processed in various hooks is coming from would be extremely helpful in a hand full of extensions I've been working on, so this info should be publicly accessible from any Parser object. For example, this would give parser functions the information which template they are called from and would allow some {{THISPAGENAME}} variable. Just for fun, I tried to implement this in MW 1.17 but it seems impossible with the current structure (at least as real parser function, some '__PAGENAME__' thingy would probably work).
Actually, the {{THISPAGENAME}} is possible via PPFrame::getTitle() or in older MW versions PPFrame::$mTitle, overlooked that before. I have written an extension 'Parser Fun' which introduces a {{THIS}} variable for that. Still not sure about the whole stack though. Just looked into the code, I think PPTemplateFrame_DOM::$parent works for that.