On 11-01-01 09:10 PM, jidanni@jidanni.org wrote:
Well OK, just hope none of what I wrote breaks.
function JidanniLessRedContentActions($sktemplate,$content_actions){ //Besides Monobook, (our target), this even also gets run by Vector skin but doesn't affect it apparently 11/2010 if(array_key_exists('talk', $content_actions)&&'new'==$content_actions['talk']['class']&& !$sktemplate->mTitle->quickUserCan('createtalk')){unset($content_actions['talk'],$content_actions['watch']);} if(array_key_exists('nstab-category',$content_actions)&&'selected new'==$content_actions['nstab-category']['class']){ $content_actions['nstab-category']['class']='selected';} return true;} $wgHooks['SkinTemplateTabs'][]='JidanniLessRedContentActions'; //Bug 17963 function JidanniLessRedContentActionsVectorTypeSkins($sktemplate,$links){ if(isset($links['namespaces'])&& is_array($links['namespaces'])&& !$sktemplate->mTitle->quickUserCan('createtalk')){ foreach(array_keys($links['namespaces']) as $ns){ if(strpos($ns,'talk')!==false){ if(isset($links['namespaces'][$ns]['class'])&& 'new'==$links['namespaces'][$ns]['class']){ unset($links['namespaces'][$ns]);}}} if(isset($links['actions']['watch'])){unset($links['actions']['watch']);}} if(isset($links['namespaces']['category']['class'])&& 'selected new'==$links['namespaces']['category']['class']){ $links['namespaces']['category']['class']='selected';} return true;} $wgHooks['SkinTemplateNavigation'][]='JidanniLessRedContentActionsVectorTypeSkins';
Maybe I can even remove the first function soon.
That code is a mess... but as long as you have that second hook things will work. Monobook and other skins will use the first hook and Vector will use the second up to 1.17, in 1.18 all skins will use the second hook. I would suggest not depending on the exact order and equality of class strings, it's possible that future code changes may add new classes or change the order of those. My code changes might affect your 'watch' use in that code, don't know if that's a good thing or not. Previously Vector built the watch tab conditionally based on the use watch icon setting. If it was enabled watch ended up inside views instead of actions. Now the watch tab is 'always' put into actions... vector relocates it to views and turns the icon on afterwards if that feature is enabled.
And yes, in 1.17 and before SkinTemplateTabs is run in vector but ignored... that's because it's SkinTemplate that runs it, so all of our normal skins run it whether they use it to build tabs or not. It's not really anything special if you look over SkinTemplate... SkinTemplate basically preloads whatever QuickTemplate based template you have with a bunch of skin keys with data and then executes the template... it doesn't build them on demand or anything.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]