Extension:Navigation path

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
Navigation Path
Release status: beta
Description Used as a memory list.
Author(s) KOSELLEK Francktalk
Latest version 0.1
License No license specified
Download No link
Translate the Navigation path extension if it is available at translatewiki.net
Check usage and version matrix.

What can this extension do?[edit]

This extension add a navigation bar into your page.

It take the url and parse using ":" char.

Usage[edit]

<npath border=border_color background=background_color name=name />


Parameters :

    • border : OPTIONAL, to precise the border-color, Default is black.
    • background : OPTIONAL. to precise the background color. Default is white;
    • name : OPTIONAL . To precise the name before the Nav Bar. Default is "Path : "


Download instructions[edit]

Please cut and paste the code found below and place it in $IP/extensions/npath/navigation_path.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation[edit]

To install this extension, add the following to LocalSettings.php:

#add configuration parameters here
#setup user rights here
require_once("$IP/extensions/npath/navigation_path.php");

Configuration parameters[edit]

User rights[edit]

Code[edit]

<?php
/******************
http://aiantis.net
Author : Fricky
Version : 0.1 Beta

DESCRIPTION
-------------
Navigation Path is a Navigation bar respecting the tree structure of your location,
It use the url and parse automatically with ":" char.

USAGE
------
<npath border=border_color background=background_color name=name />


Parameters : 
** border : OPTIONAL, to precise the border-color, Default is black.
** background : OPTIONAL. to precise the background color. Default is white;
** name : OPTIONAL . To precise the name before the Nav Bar. Default is "Path : "

EXAMPLE
--------
<npath border=red background=green />

*********************************************************/

$wgExtensionFunctions[] = "npath";

function npath() {
        global $wgParser;
        $wgParser->setHook( "npath", "build_ts" );
        $wgParser->disableCache();
}

function build_ts ( $input, $argv=array() )
{
if ($argv["border"])
	$border = $argv["border"];
else
	$border= 'black';
	
if ($argv["background"])
	$background = $argv["background"];
else
	$background = "white";
	
if ($argv["name"])
	$name = $argv["name"];
else
	$name = "Path : ";
	
$url = '<div id="path" style="border:1px solid ' . $border . '; background:' . $background . '; padding:4px;">-</div>
<script>
var url = document.location.href;
var begining = "";
var temp = "";
var str = "";
if (url.indexOf("title=")!= -1)
	{
		temp = url.split("title=");
		begining = temp[0] + "title=";
		str = temp[1];
	}
else
	{
		temp = url.split(".php/");
		begining = temp[0] + ".php/";
		str = temp[1];
	}
temp = str.split(":");
var count = 0;
var path = begining;
str = "";
while (temp[count])
	{
		path += temp[count];
		if (temp[count + 1])
			{
				str += "<a href=\'" + path + "\'>" + temp[count] + "</a>";
				path += ":";
				str += "&nbsp;<b>></b>&nbsp;";
			}
		else if (temp[count].indexOf("action=")== -1)
			str += "<b>" + temp[count] + "</b>";
		else
			{
				meuh = escape(temp[count]);
				plop = meuh.split("%26action%3D");
				str += "<b>" + plop[0] + " </b><i>(action)</i>";
			}
		count++;
	}
	str = decodeURI(str);
document.getElementById("path").innerHTML = "<b>' . $name . '</b>  " + str;
</script>
';

	return $url;
}
?>

See also[edit]