Page MenuHomePhabricator

Allow additional icons in the footer
Closed, ResolvedPublic

Description

Author: shardsofmetal

Description:
While not too important, it would be nice if MediaWiki one day had built-in
support for adding icons to the footer, without modifying the skin. This could
by used by many things, most notably to display a small icon advertising your
webhost (like what Wikia does). A new function, getHostedBy(), could be added to
the Skin class, and the options $wgHostedPage, $wgHostedUrl, $wgHostedIcon, and
$wgHostedText added to LocalSettings.php. Then, the skins distributed with
MediaWiki could display it the same way it does the Rights and Powered-by icons.
There could also be support for displaying multiple additional icons when, say
$wgAdditionalIcons, is given a multi-dimensional array (each array inside
defining the 4 values needed for each icon).


Version: unspecified
Severity: enhancement

Details

Reference
bz8680

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:32 PM
bzimport set Reference to bz8680.
bzimport added a subscriber: Unknown Object (MLST).

shardsofmetal wrote:

The changes necessary to implement a hosted-by icon at the footer

I wrote the functions needed to implement this. Just fill the variables
$wgHostedIcon, $wgHostedText, and $wgHostedUrl, and this works fine. The id of
the div it outputs is "f-hostedbyico". I am currently using this on my wiki,
and it seems to work just fine. If this doesn't break anything, maybe it could
be committed to svn.

attachment addicons.txt ignored as obsolete

robert wrote:

Is this not what $wgCopyrightIcon was originally intended for - I don't see the sense in adding more configuration settings and global variables when this can already be achived.

shardsofmetal wrote:

No, what I'm talking about is adding an additional icon, or additional icons at the bottom. What if you want to have an icon to display the license, powered by mediawiki, and say, a link to an affiliate. To the best of my knowledge, this currently requires modification to the skin. If you use any of the provided skins, and only modify it for the icon or icons, then the changes have to be reapplied every time you update MediaWiki. I thought it would be a good addition, and not to hard to apply, if the skin template was modified to allow adding additional icons to the footer. I created an attachment that gave instructions to one icon to the monobook skin, to show how easy that would be. Of course, that was to the current revision of the time, which was 6 months ago. I'd imagine that the only difference to apply the changes to the current revision would be the line numbers at which to add the lines of code.

ayg wrote:

If this is done it should probably be through some kind of hook, not a hardcoded ability to add a single extra icon.

shardsofmetal wrote:

Modification to my earlier changes, this one allowing multiple icons to be added to the footer

I uploaded an attachment which gives directions to modify Skin.php, SkinTemplate.php, and MonoBook.php to allow the addition of icons in the footer. To add icons, create an array variable $wgAdditionalFooterIcons in LocalSettings.php. Here is an example of the syntax:

$wgAdditionalFooterIcons = array(

'icon1' => array(
  'url' => 'http://example.com',
  'img' => 'http://example.com/example.png',
  'text' => 'Hover text',
),
'icon2' => array(
  'url' => 'http://example.com',
  'img' => 'http://example.com/example.png',
  'text' => 'Hover text',
),

);

The id of the <div> for these icons will be "f-icon1" and "f-icon2" respectively.

If using the modified files, $wgAdditionalFooterIcons needs to be initialized as an array. Even if not adding icons to the footer, the variable needs to be an empty array to prevent php warnings.

attachment attachment.txt ignored as obsolete

ayg wrote:

It's preferable for patches to be in Unix diff format to the latest version of the software in our [[Subversion]] repository at http://svn.wikimedia.org/svnroot/mediawiki/phase3/, generated with the command "svn diff" from a terminal. That way we can apply them with ten seconds' typing or clicking instead of having to manually follow instructions.

As for the content of the patch: people might not want to add just icons to the footer. If this is done, as I said, it should probably be through a hook, not just a global variable, so any content that might be desired can be added. (Also, in your implementation, you should use standard attributes like href, src, title instead of url, img, text, plus you should allow attributes like alt - which by the way you break XHTML validity by not using.)

shardsofmetal wrote:

The code transforms url to href, img to src, and title to alt. I don't know if you just didn't see that, or if I still lack something that breaks XHTML validity. If this does break XHTML validity, I would like to know, even if this code won't be used, so that in the future I don't use invalid code. Thanks

ayg wrote:

(In reply to comment #7)

The code transforms url to href, img to src, and title to alt. I don't know if
you just didn't see that, or if I still lack something that breaks XHTML
validity. If this does break XHTML validity, I would like to know, even if this
code won't be used, so that in the future I don't use invalid code. Thanks

I realize the code transforms the attributes. I was just suggesting that you use the actual HTML attributes rather than possibly more ambiguous values.

As for the XHTML validity, it does seem to be valid, since you set alt="$text". I missed that because I had assumed you were using title for hover text, which you should. alt is what's supposed to appear in place of the image if the image is unavailable (e.g. not loaded yet) or unsupported, title is to be used for hover text.

Anyway, as I said, the proposed patch is too narrow to be good enough to put in core, in my opinion.

shardsofmetal wrote:

Well thank you for your input. I didn't actually think that the code would be put into core when I uploaded it, but I thought it might help a developer implement the change. However, if it is to be done with a hook (if at all), as you suggest, then my code probably won't be of any use to anyone else. Oh, and for using alt and not title, I actually based the code off the Skin::getPoweredBy() function, which does it the same way. I just figured that I'd model that code after some existing code. Thanks again for your reply, I really appreciate it.

I note there is now [[Manual:$wgFooterIcons]].