Extension:Hierarchy/Link.php

From MediaWiki.org
Jump to: navigation, search
<?php
// Link MediaWiki extension.
// Creates a link to a network location.
 
// Copyright (C) 2007, Aretai Systems.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
$wgExtensionFunctions[] = "linkExtension";
 
function linkExtension() {
    global $wgParser;
    $wgParser->setHook( "link", "renderlink" );
}
 
# The callback function for converting the input text to HTML output
function renderlink($loc="",$argv=array()) {
    global $wgOut, $wgTitle, $wgParser;
 
    $args=array();
    $args['TARGET']="";
 
    switch (strtoupper($args['TARGET'])) {
       case "SELF":
       $out = "<a href=\"{$loc}\" target=\"_self\">$loc</a>";
       break;
       case "TOP":
       $out = "<a href=\"{$loc}\" target=\"_top\">$loc</a>";
       case "PARENT":
       $out = "<a href=\"{$loc}\" target=\"_parent\">$loc</a>";
       break;
       default:
       $out = "<a href=\"{$loc}\" target=\"_blank\">$loc</a>";
    }
 
    return $out;
 
}
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox