Extension:EnableAbbrTags
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
![]() Release status: unmaintained |
|
---|---|
Implementation | Tag |
Description | Adds <xabbr></xabbr> tags and parses them to <a class(es) href=''></a> tags. |
Author(s) | Jeff McNeill (Jeffmcneilltalk) |
Latest version | 0.2 (2007-10-31) |
MediaWiki | 1.7.3, 1.9.3, 1.11 |
Database changes | No |
License | GNU General Public License 3.0 |
Download | see here |
What can this extension do?Edit
The purpose is to allow abbr tag to be handled to support POSH and microformats. Builds on the AllowAnchorTags extension. Adds support for <xabbr></xabbr>
tags and parses them to <abbr></abbr>
tags.
UsageEdit
The URL must be specified in the following format: <xabbr class='some class(es)' title='some title(s)'>Some Text</xabbr>
.
- Both class and title are optional, but including one or the other is sort of the point of this extension.
InstallationEdit
- Download and place the file(s) in a directory called
EnableAbbrTags
in yourextensions/
folder. - Add the following code at the bottom of your
LocalSettings.php
:require_once "$IP/extensions/EnableAbbrTags/EnableAbbrTags.php";
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
CodeEdit
<?php
/**
* EnableAbbrTags.php
* v.0.2 added return codes to run under 1.11
* This extension enables <abbr></abbr>
* written by Jeff McNeill http://jeffmcneill.com/
* building on the work of AllowAnchorTags https://www.mediawiki.org/wiki/Extension:AllowAnchorTags
* To activate the functionality of this extension include the following in LocalSettings.php file:
* require_once('extensions/EnableAbbrTags.php');
*/
#Defines the main function to be executed for this extension.
$wgExtensionFunctions[] = 'EnableAbbrTag';
# Sets the hook to be executed once the parser has stripped HTML tags.
$wgHooks['ParserAfterStrip'][] = 'EnableAbbrTag';
# This function initiates the hook for the parser to convert <xabbr></xabbr>
# tags to <abbr></abbr> tags.
function EnableAbbrTag() {
// Declaring the global parser..
global $wgParser;
// Setting the hook to parse <xabbr></xabbr> tags from the parser output..
$wgParser->setHook( 'xabbr', 'startEnableAbbr' );
return(true);
}
# This function extracts the parameters from the <xabbr></xabbr> tags and
# the text between the <xabbr> and </xabbr> tags and formats them as "<abbr></abbr>"
# tags and writes them in the document.
function startEnableAbbr( $input, $argv ) {
// Fetching the 'class' parameter..
if(isset($argv['class'])) {
$class = $argv['class'];
} else {
$class = '';
}
// Fetching the 'input' parameter..
$body = $input;
// Fetching the 'title' parameter..
if(isset($argv['title'])) {
$title = $argv['title'];
} else {
$title = '';
}
if ($body != '' && $class != '' && $title != '' ) {
// all three
return "<abbr" . " class=\"" . $class . "\"" . " title=\"" . $title . "\">" . $body . "</abbr>";
} else if ($body != '' && $class != '' ) {
// body and class
return "<abbr" . " class=\"" . $class . "\">" . $body . "</abbr>";
} else if ($body != '' && $title != '' ) {
// body and title
return "<abbr" . " title=\"" . $title . "\">" . $body . "</abbr>";
} else if ($body != '' ) {
// body
return "<abbr>" . $body . "</abbr>";
} else {
// none
return "<abbr" . " class=\"" . $class . "\"" . " title=\"" . $title . "\">" . $body . "</abbr>";
}
}