Last modified: 2012-09-27 01:10:40 UTC
When using the Vector skin, extensions currently have no way to alter the navigation links at the top. For Monobook, this can be done using the SkinTemplateContentActions hook. This is useful e.g. to redirect users to a special edit page. See e.g. http://spiele.j-crew.de/wiki/Die_Expedition, with the edit page being http://spiele.j-crew.de/wiki/Spezial:Spiel_bearbeiten/Die_Expedition. The code to achieve this is simple: $wgHooks['SkinTemplateContentActions'][] = 'wfAlterEditPageLinkHook'; function wfAlterEditPageLinkHook( &$content_actions ) { global $wgTitle, $wgArticle; if( array_key_exists( 'edit', $content_actions ) && $wgTitle->isContentPage() && $wgArticle->isCurrent() ){ $content_actions['edit']['href'] = Title::newFromText( 'Spezial:Spiel_bearbeiten/'. $wgTitle->getPrefixedDBkey() )->escapeLocalURL(); } return true; } Maybe a similar hook can be added to SkinVector::buildNavigationUrls()?
Fixed in r52718 with the introduction of the SkinTemplateNavigation hook. Thanks for fixing this so fast!
In Vector.php we see >// This is instead of SkinTemplateTabs - which uses a flat array >wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) ); However var_dump()s show the structures of the two are quite similar. Are you sure the flat array comment is correct?
Also, using >function JidanniLessRedContentActionsVectorSkin(&$a,&$links){var_dump($a,$links);die();return true;} >$wgHooks['SkinTemplateNavigation'][]='JidanniLessRedContentActions'; I was shocked to find in $links that local language strings have crept into variable names themselves, at the markers @@1@@, and @@3@@, that I put in below: >array(4) { > ["namespaces"]=> > array(2) { > ["分類"]=> @@1@@ > array(3) { > ["class"]=> > string(12) "selected new" > ["text"]=> > string(6) "分類" @@2@@ > ["href"]=> > string(66) "/index.php?title=%E5%88%86%E9%A1%9E:489.0750&action=edit&redlink=1" > } > ["分類_talk"]=> @@3@@ > array(3) { > ["class"]=> > string(3) "new" > ["text"]=> > string(10) "Discussion" @@4@@ > ["href"]=> > string(84) "/index.php?title=%E5%88%86%E9%A1%9E%E8%A8%8E%E8%AB%96:489.0750&action=edit&redlink=1" > } > } I mean how can anybody write a hook now that even the variable names themselves could be in a hundred different languages?! Furthermore, compare @@2@@ and @@4@@, one is English, the other not... I didn't investigate, but I can tell you one thing, using this shell script, >for site in localhost; do > for lang in en zh-tw; do > for skin in monobook vector; do > URL="http://$site/index.php?title=Category:486.3875&uselang=$lang&useskin=$skin" > echo $((++c)). $URL > w3m -no-cookie -no-proxy -dump $URL|egrep '• (分類|Category)' > done; echo ==== > done >done I produced this output: >1. http://localhost/index.php?title=Category:486.3875&uselang=en&useskin=monobook > • Category >2. http://localhost/index.php?title=Category:486.3875&uselang=en&useskin=vector > • 分類 >==== >3. http://localhost/index.php?title=Category:486.3875&uselang=zh-tw&useskin=monobook > • 分類 >4. http://localhost/index.php?title=Category:486.3875&uselang=zh-tw&useskin=vector > • 分類 What it says is is that you have caused the local word for categories here to become so embedded that not even a uselang=en could conquer it! I.e., even though the user changes his Preferences to English, he still must face the 'categories' tab written in in zh-tw. However I couldn't reproduce that when $wgLanguageCode = 'en' and uselang=zh-tw. Only visa-versa. Nor could I reproduce it with this script: >#!/bin/bash >for URL1 in \ > http://en.wikipedia.org/wiki/Category:United_States \ > http://zh.wikipedia.org/wiki/Category:美国 >do > for lang in en zh-tw; do > for skin in monobook vector; do > URL="$URL1?uselang=$lang&useskin=$skin" > echo $((++c)). $URL > w3m -no-cookie -dump $URL|egrep '• (分類|Category)' > done; echo ==== > done >done Now finally returning to the original topic of this bug. If the two skins could use the same hook, that would be great I suppose... OK, each should have its own hook, but users will dare to do $wgHooks['SkinTemplateTabs'][]=$wgHooks['SkinTemplateNavigation'][]='MyFunction'; so there should be some statement about how safe that is.
(In reply to comment #3) > Also, using > >function JidanniLessRedContentActionsVectorSkin(&$a,&$links){var_dump($a,$links);die();return true;} > >$wgHooks['SkinTemplateNavigation'][]='JidanniLessRedContentActions'; > I was shocked to find in $links that local language strings have crept > into variable names themselves, at the markers @@1@@, and @@3@@, that I > put in below: Trevor has fixed this in r52806. > Now finally returning to the original topic of this bug. If the two > skins could use the same hook, that would be great I suppose... > > OK, each should have its own hook, but users will dare to do > $wgHooks['SkinTemplateTabs'][]=$wgHooks['SkinTemplateNavigation'][]='MyFunction'; > so there should be some statement about how safe that is. > The formats are not compatible, so it's not safe to assume they are. Using one function that somehow still differentiates between them is safe as long as you do it right.