Hi all,
I've added a couple of buttons to the toolbar by adding some javascript to Mediawiki:Common.js, but is it possible to remove some of the default buttons? Thanks.
Claus
You can use CSS. Eg put this line in MediaWiki:Common.css #ca-talk { display: none; }
The talk button will be hidden.
Rob
On 13/08/2009, at 6:56 PM, Claus Juhl Knudsen wrote:
Hi all,
I've added a couple of buttons to the toolbar by adding some javascript to Mediawiki:Common.js, but is it possible to remove some of the default buttons? Thanks.
Claus _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
I think he was referring to the buttons in the editing toolbar, which can not be hidden by CSS afaik.
Here is what I did quite some time ago (so I don't remember how I did it and if anything else apart from this is neccessary): http://wiki.rockinchina.com/index.php?title=MediaWiki:Common.js
Actually, removing buttons 6,7 does not seem to work (file link and math are still there). But maybe it will get you started. Tell me if you sorted out how to remove those two though... ;-)
Best, matsch
Am Fri, 14 Aug 2009 08:13:45 +1200 schrieb Robert Carter r.carter@cs.auckland.ac.nz:
You can use CSS. Eg put this line in MediaWiki:Common.css #ca-talk { display: none; }
The talk button will be hidden.
Rob
On 13/08/2009, at 6:56 PM, Claus Juhl Knudsen wrote:
Hi all,
I've added a couple of buttons to the toolbar by adding some javascript to Mediawiki:Common.js, but is it possible to remove some of the default buttons? Thanks.
Claus _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
"MK" == Matthias Korn matsch@rockinchina.com writes:
MK> Actually, removing buttons 6,7 does not seem to work (file link and MK> math are still there). But maybe it will get you started. Tell me if MK> you sorted out how to remove those two though... ;-)
Hmmm, see also Bug #19848 not all editing icons always applicable https://bugzilla.wikimedia.org/show_bug.cgi?id=19848
I think you can go directly to SkinTemplate.php in the include folder to delete it but then again, I understand that one should not meddle with any files in the include folder. PM Poon
On Sun, Aug 16, 2009 at 1:14 AM, jidanni@jidanni.org wrote:
"MK" == Matthias Korn matsch@rockinchina.com writes:
MK> Actually, removing buttons 6,7 does not seem to work (file link and MK> math are still there). But maybe it will get you started. Tell me if MK> you sorted out how to remove those two though... ;-)
Hmmm, see also Bug #19848 not all editing icons always applicable https://bugzilla.wikimedia.org/show_bug.cgi?id=19848
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Matthias Korn wrote:
I think he was referring to the buttons in the editing toolbar, which can not be hidden by CSS afaik.
Here is what I did quite some time ago (so I don't remember how I did it and if anything else apart from this is neccessary): http://wiki.rockinchina.com/index.php?title=MediaWiki:Common.js
Actually, removing buttons 6,7 does not seem to work (file link and math are still there). But maybe it will get you started. Tell me if you sorted out how to remove those two though... ;-)
Best, matsch
It doesn't work because the removing code is run before the button are added.
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { if ((imageId=="mw-editbutton-image") || (imageId=="mw-editbutton-media")) return; mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText}; }
Hi, I change the codes directly in SkinTemplate.php and it was a breeze. Can common.css override SkinTemplate, ie. instead of changing the codes in SkinTemplate.php, I paste those codes in Common.css like what we would do if we were to change any of the css files? Looks like it cannot be done because SkinTemplate is a php file. Alternatively, how about having a second copy of SkinTemplate.php in the relevant skin folder and then redirecting the reference to point to the correct SkinTemplate?
PM Poon
On Sun, Aug 16, 2009 at 6:34 AM, Platonides Platonides@gmail.com wrote:
Matthias Korn wrote:
I think he was referring to the buttons in the editing toolbar, which can not be hidden by CSS afaik.
Here is what I did quite some time ago (so I don't remember how I did it and if anything else apart from this is neccessary): http://wiki.rockinchina.com/index.php?title=MediaWiki:Common.js
Actually, removing buttons 6,7 does not seem to work (file link and math are still there). But maybe it will get you started. Tell me if you sorted out how to remove those two though... ;-)
Best, matsch
It doesn't work because the removing code is run before the button are added.
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText,
imageId) {
if ((imageId=="mw-editbutton-image") ||
(imageId=="mw-editbutton-media")) return;
mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText};
}
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Ekompute .info wrote:
Alternatively, how about having a second copy of SkinTemplate.php in the relevant skin folder and then redirecting the reference to point to the correct SkinTemplate?
I don't know what code changes you're referring to, however, you can probably take advantage of the fact that PHP is object oriented. Since functions are inherited and can be overridden in derived classes, you should be able to use a subclass to override the function in SkinTemplate.php. Conveniently, skins are subclasses of SkinTemplate. Since your skin need not be core code (you can easily copy an existing skin and rename it so it becomes your own skin), change it at will.
Mike
Hi Mike, I amended the following parts: if( $this->iscontent ) { $subjpage = $this->mTitle->getSubjectPage(); $talkpage = $this->mTitle->getTalkPage();
$nskey = $this->mTitle->getNamespaceKey(); // $content_actions[$nskey] = $this->tabAction( // $subjpage, // $nskey, // !$this->mTitle->isTalkPage() && !$prevent_active_tabs, // '', true);
if ( $this->mTitle->getNamespace() == 102 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 103 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 104 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 105) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 106 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 107 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 108 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 109 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 110 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 111 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 112 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
elseif ( $this->mTitle->getNamespace() == 113 ) { //then build a link to the main namespace $content_actions['nstab-main'] = $this->tabAction( Title::makeTitle( NS_MAIN, $this->mTitle->getText() ),'nstab-main',!$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
else { $content_actions[$nskey] = $this->tabAction( $subjpage, $nskey, !$this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true); }
$content_actions['talk'] = $this->tabAction( $talkpage, 'talk', $this->mTitle->isTalkPage() && !$prevent_active_tabs, '', true);
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 102) { $content_actions['blog'] = $this->tabAction( Title::makeTitle ( 102, $this->mTitle->getText() ), 'blog', $this->mTitle->getNamespace() == 102 && !$prevent_active_tabs,'', true); }
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 110) { $content_actions['chrono'] = $this->tabAction( Title::makeTitle ( 110, $this->mTitle->getText() ), 'chrono', $this->mTitle->getNamespace() == 110 && !$prevent_active_tabs,'', true); }
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 104) { $content_actions['how-to'] = $this->tabAction( Title::makeTitle ( 104, $this->mTitle->getText() ), 'how-to', $this->mTitle->getNamespace() == 104 && !$prevent_active_tabs,'', true); }
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 106) { $content_actions['video'] = $this->tabAction( Title::makeTitle ( 106, $this->mTitle->getText() ), 'video', $this->mTitle->getNamespace() == 106 && !$prevent_active_tabs,'', true); }
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 108) { $content_actions['gallery'] = $this->tabAction( Title::makeTitle ( 108, $this->mTitle->getText() ), 'gallery', $this->mTitle->getNamespace() == 108 && !$prevent_active_tabs,'', true); }
if ( $ns == NS_MAIN || $ns == NS_TALK || $ns == 112) { $content_actions['useful_links'] = $this->tabAction( Title::makeTitle ( 112, $this->mTitle->getText() ), 'useful_links', $this->mTitle->getNamespace() == 112 && !$prevent_active_tabs,'', true); }
PM Poon
On Mon, Aug 17, 2009 at 12:56 AM, Michael Daly michael.daly@kayakwiki.orgwrote:
Ekompute .info wrote:
Alternatively, how about having a second copy of SkinTemplate.php in the relevant skin folder and then redirecting the reference to point to the correct SkinTemplate?
I don't know what code changes you're referring to, however, you can probably take advantage of the fact that PHP is object oriented. Since functions are inherited and can be overridden in derived classes, you should be able to use a subclass to override the function in SkinTemplate.php. Conveniently, skins are subclasses of SkinTemplate. Since your skin need not be core code (you can easily copy an existing skin and rename it so it becomes your own skin), change it at will.
Mike
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Ekompute .info wrote:
Hi Mike, I amended the following parts: if( $this->iscontent ) { $subjpage = $this->mTitle->getSubjectPage(); $talkpage = $this->mTitle->getTalkPage(); [...] 'useful_links', $this->mTitle->getNamespace() == 112 && !$prevent_active_tabs,'', true); }
So it would appear that you should override:
function buildContentActionUrls() {...}
in skinname.php (where skinname is whatever skin you're using - e.g. monobook.php). Of course, if you're using a standard skin, then copy and rename it to your own skin first otherwise you'll risk losing the changes if you upgrade to a newer version and the skin gets overwritten.
Note that this is a private function in SkinTemplate.php according to the comments but not explicitly using the PHP visibility keyword. If someone decides in the future to enforce this in the class by putting the keyword into the class definition, your code will no longer be able to inherit. Since this is not enforced, you'll probably be ok.
Mike
Hi Mike, thank you very much for your comment, especially that part that says: "If someone decides in the future to enforce this in the class by putting the keyword into the class definition, your code will no longer be able to inherit." If it ever happens, at least I am forewarned. PM Poon
On Mon, Aug 17, 2009 at 6:44 AM, Michael Daly michael.daly@kayakwiki.orgwrote:
Ekompute .info wrote:
Hi Mike, I amended the following parts: if( $this->iscontent ) { $subjpage = $this->mTitle->getSubjectPage(); $talkpage = $this->mTitle->getTalkPage(); [...] 'useful_links', $this->mTitle->getNamespace() == 112 && !$prevent_active_tabs,'', true); }
So it would appear that you should override:
function buildContentActionUrls() {...}
in skinname.php (where skinname is whatever skin you're using - e.g. monobook.php). Of course, if you're using a standard skin, then copy and rename it to your own skin first otherwise you'll risk losing the changes if you upgrade to a newer version and the skin gets overwritten.
Note that this is a private function in SkinTemplate.php according to the comments but not explicitly using the PHP visibility keyword. If someone decides in the future to enforce this in the class by putting the keyword into the class definition, your code will no longer be able to inherit. Since this is not enforced, you'll probably be ok.
Mike
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Ekompute .info wrote:
If it ever happens, at least I am forewarned.
It happened to me with a function in either the 12 to 13 or the 13 to 14 upgrade. I simply put into bugzilla a request to undo the restriction and it was reversed. In my case it was an obvious (to me) example of a function that should be generally accessible and not private. The developers agreed. You'd have to make a case for having the function you need kept at least protected and not private; I don't know how reasonable that would be since I didn't look at that function in any detail.
Mike
Hi Platonides,
Am Sun, 16 Aug 2009 00:34:31 +0200 schrieb Platonides Platonides@gmail.com:
[ Removing buttons from the editing toolbar, code at http://wiki.rockinchina.com/index.php?title=MediaWiki:Common.js ]
It doesn't work because the removing code is run before the button are added.
Ok, this sound reasonable.. ;-)
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { if ((imageId=="mw-editbutton-image") || (imageId=="mw-editbutton-media")) return; mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText}; }
I don't quite understand what you suggest with this function. How would I use it to *remove* some of the default buttons? Adding custom buttons works fine...
Best, matsch
Matthias Korn schrieb:
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { if ((imageId=="mw-editbutton-image") || (imageId=="mw-editbutton-media")) return; mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText}; }
I don't quite understand what you suggest with this function. How would I use it to *remove* some of the default buttons? Adding custom buttons works fine...
Best, matsch
You add that function to eg. Mediawiki:monobook.js That function will be called *by mediawiki* to add the toolbar images.
And when it tries to add the image or media buttons:
if ((imageId=="mw-editbutton-image")||(imageId=="mw-editbutton-media"))
it returns without adding them to mwEditButtons.
Ok, that's great to remove some of the default buttons. Neat little hack!
Thanks, matsch
Am Mon, 17 Aug 2009 00:35:36 +0200 schrieb Platonides Platonides@gmail.com:
Matthias Korn schrieb:
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { if ((imageId=="mw-editbutton-image") || (imageId=="mw-editbutton-media")) return; mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText}; }
I don't quite understand what you suggest with this function. How would I use it to *remove* some of the default buttons? Adding custom buttons works fine...
Best, matsch
You add that function to eg. Mediawiki:monobook.js That function will be called *by mediawiki* to add the toolbar images.
And when it tries to add the image or media buttons:
if ((imageId=="mw-editbutton-image")||(imageId=="mw-editbutton-media"))
it returns without adding them to mwEditButtons.
Thank a bunch guys. I'll go with the solution Matthias outlined.
Claus
2009/8/17 Matthias Korn matsch@rockinchina.com
Ok, that's great to remove some of the default buttons. Neat little hack!
Thanks, matsch
Am Mon, 17 Aug 2009 00:35:36 +0200 schrieb Platonides Platonides@gmail.com:
Matthias Korn schrieb:
Try this instead:
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { if ((imageId=="mw-editbutton-image") || (imageId=="mw-editbutton-media")) return; mwEditButtons[mwEditButtons.length] = {"imageId": imageId, "imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText}; }
I don't quite understand what you suggest with this function. How would I use it to *remove* some of the default buttons? Adding custom buttons works fine...
Best, matsch
You add that function to eg. Mediawiki:monobook.js That function will be called *by mediawiki* to add the toolbar images.
And when it tries to add the image or media buttons:
if ((imageId=="mw-editbutton-image")||(imageId=="mw-editbutton-media"))
it returns without adding them to mwEditButtons.
-- Rock in China http://wiki.rockinchina.com/ http://www.rockinchina.com/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org