Last modified: 2012-09-27 01:10:40 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 19304 - Vector Skin needs hook similar to SkinTemplateContentActions
Vector Skin needs hook similar to SkinTemplateContentActions
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.16.x
All All
: Normal normal (vote)
: ---
Assigned To: Trevor Parscal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-20 09:13 UTC by Thomas Bleher
Modified: 2012-09-27 01:10 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Thomas Bleher 2009-06-20 09:13:45 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()?
Comment 1 Thomas Bleher 2009-07-04 07:56:50 UTC
Fixed in r52718 with the introduction of the SkinTemplateNavigation hook.

Thanks for fixing this so fast!
Comment 2 Dan Jacobson 2009-07-06 00:56:34 UTC
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?

		
Comment 3 Dan Jacobson 2009-07-06 01:48:54 UTC
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.
Comment 4 Roan Kattouw 2009-07-06 21:26:49 UTC
(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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links