GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing www.mediawiki.org — Extension:Document UNCified - MediaWiki
What can this extension do?This extension has this purposes:
The link can be for documents of type:
The very useful if your wiki is housed internally and used for as an intranet for your company. UsageSyntaxThis extension get us a new tag, with it,we can insert links (on URI or UNC format) to documents not incorporated at your wiki. <document_unc></document_unc> Syntax: <document_unc
width=['100%'|'300px']
height=['20%'|'300px']
type=['embedded'|'image'|'link']
link='unc|uri'
margin='units'
>
[unc|uri]|label]
</document_unc>
Where:
On tag value exists two options:
Like image
Download instructionsPlease cut and paste the code found below and place it in InstallationTo install this extension, add the following to LocalSettings.php: #add configuration parameters here require_once("$IP/extensions/DocumentUNCified/document_uncified.php"); Code<?php /** * MediaWiki. This code is released under the GNU General Public License. * * @author Secundino Garcia Jimenez <[email protected]> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package MediaWikiExtensions * @version 0.3 */ if( !defined( 'MEDIAWIKI' ) ) { echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); die( -1 ); } $wgHooks['ParserFirstCallInit'][] = 'DocumentUNCfied_Setup'; function DocumentUNCfied_Setup( &$parser ) { $parser->setHook( 'document_unc', 'DocumentUNCfied_Render' ); return true; } function DocumentUNCfied_Render( $input, $args, $parser, $frame ) { /* The following lines can be used to get the variable values directly: $to = $args['to'] ; $email = $args['email'] ; */ //---------------[ Initialization ]------------------------------------------ $ah = "center"; $type = "link"; $link = ""; $linktext = "[1]"; $margin = "0"; foreach( $args as $name => $value ) { if ($name == 'width') $w = $value; if ($name == 'height') $h = $value; if ($name == 'type') $type =$value; if ($name == 'link') $link =$value; if ($name == 'margin') $margin =$value; } if (strpos( $margin, ";") > 0){ $margin = substr( $margin, 0, strpos( $margin, ";") ); } //---------------[ exploding ]------------------------------------------ $exploded = explode('|', $input); if (!(!isset($exploded[0]) || empty($exploded[0]))) { $uri = htmlentities($exploded[0], ENT_QUOTES, "UTF-8"); $uri_old = $uri; $uri = getMagic( $parser, $uri, $uri_old, $type ); } if (!(!isset($link) || empty($link))) { $link = htmlentities($link, ENT_QUOTES, "UTF-8"); $link_old = $link; $link = getMagic( $parser, $link, $link_old, $type ); } //---------------[ getting the path ]------------------------------------------ $result = ""; if ($type == 'link'){ $result = getInstructionForLink($w, $h, $type, $link, $margin, $uri, $exploded, $parser); } if ($type == 'embedded') { $result = getInstructionForEmbed($w, $h, $type, $link, $margin, $uri, $exploded, $parser); } if ($type == 'image') { $result = getInstructionForImage($w, $h, $type, $link, $margin, $uri, $exploded, $parser); } //---------------[ returning results ]------------------------------------------ return $result; //return $w . "|" . $h . "|" . $type . "|" . $margin . "|" . $link . "|" . $uri; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function getMagic( $parser, $uri, $uri_old, $type ) { $result = $uri; if (preg_match_all("/(\{){2}(.*)(\}){2}/", $uri, $matchfounded)) { foreach ($matchfounded[0] as $match) { $matched = $parser->recursiveTagParse( $match ); $matched = preg_replace("/((<)(.*)(rel=\"nofollow\">))|(<\/a>)/", "", $matched); $regexp_match = preg_replace("/\{/", "\{", $match); $regexp_match = preg_replace("/\}/", "\}", $regexp_match); $result = preg_replace( "/" . $regexp_match . "/", $matched, $uri); } } //Deleting bad commands.... if (preg_match_all("/(?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit)))|(?i:((<|<)[\/]?script(>|>)))/", $result, $matchfounded)){ $result = "[ Here was detected & eliminated a possible hijack attack instruction ]"; } else { $result = getNewURI($result, $uri_old, $type); } return $result; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function getNewURI($uri, $uri_old, $type){ $result = $uri; if (strpos($uri, "/") === false) { $uri = str_replace(" ", "%20", $uri); $uri = str_replace("\\", "/", $uri); if ( $type == 'link'){ if (strpos($uri_old, "{{") === false) { $uri = "file:///" . $uri; } else { $uri = "file:////" . $uri; } } if ( $type == 'embedded'){ if (strpos($uri_old, "{{") === false) { $uri = "file:///" . $uri; } else { $uri = "file:////" . $uri; } } if ( $type == 'image'){ if (strpos($uri_old, "{{") === false) { $uri = "file:///" . $uri; } else { $uri = "file:////" . $uri; } } } return $uri; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function getInstructionForLink($w, $h, $type, $link, $margin, $uri, $exploded, $parser){ $result = ""; if ( !isset($link) || empty($link) ){ if ( !isset($exploded[0]) || empty($exploded[0]) ){ return $result; } if ( !isset($exploded[1]) || empty($exploded[1]) ){ $linktext = $uri; } else { $linktext = htmlentities($exploded[1], ENT_QUOTES, "UTF-8"); } $link = $uri; } else { if ( !isset($exploded[0]) || empty($exploded[0]) ){ $uri = $link; $linktext = $link; } else { if ( !isset($exploded[1]) || empty($exploded[1]) ){ $linktext = htmlentities($exploded[0], ENT_QUOTES, "UTF-8"); $uri = $link; } else { $linktext = htmlentities($exploded[1], ENT_QUOTES, "UTF-8"); } } } $result = "<a href=\"" . $uri . "\" class=\"external autonumber\" style=\"margin:" . $margin . ";\" rel=\"nofollow\" title=\"" . $uri . "\" target=\"_blank\">" . $linktext . "</a>"; return $result; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function getInstructionForEmbed($w, $h, $type, $link, $margin, $uri, $exploded, $parser){ $result = ""; if (!isset($w) || empty($w)) { $w = '100%'; } if (!isset($h) || empty($h)) { $h = '560px'; } if ( !isset($link) || empty($link) ){ if ( !isset($exploded[0]) || empty($exploded[0]) ){ return $result; } $link = $uri; } else { if ( !isset($exploded[0]) || empty($exploded[0]) ){ $uri = htmlentities($link, ENT_QUOTES, "UTF-8"); } } $result = "<div style=\"width:" . $w . "; height:" . $h . ";margin:" . $margin . ";\"><iframe style=\"background-color:none; padding: 0; margin: " . $margin . ";\" width=" . $w . " height=" . $h . " src=\"" . $uri . "\" frameborder=0 framebordercolor=#00000></iframe></div>"; return $result; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function getInstructionForImage($w, $h, $type, $link, $margin, $uri, $exploded, $parser){ $result = ""; if (!isset($w) || empty($w)) { $w = 'auto'; } if (!isset($h) || empty($h)) { } if ( !isset($link) || empty($link) ){ if ( !isset($exploded[0]) || empty($exploded[0]) ){ return $result; } $link = $uri; if ( !isset($exploded[1]) || empty($exploded[1]) ){ $linktext = $uri; } } else { $linktext = $link; if ( !isset($exploded[0]) || empty($exploded[0]) ){ $uri = $link; } } $result = "<a href=\"" . $link . "\" title=\"" . $linktext . "\" target=\"_blank\"><img src=\"" . $uri . "\" alt=\"" . $linktext . "\" width=\"" . $w . "\" height=\"" . $h . "\" style=\"margin:" . $margin . "\";/></a>"; // return $result; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $wgExtensionCredits['parserhook'][] = array( 'name' => 'DocumentUNCified', 'author' => '[[User:CQ|Secundino Garcia Jimenez]]', 'description' => 'Embed documents PDF, Sounds and images in your pages, link another documents on easy way; use URL or UNC format for path!.', 'url' => 'http://www.mediawiki.org/wiki/Extension:Document_UNCified'); ?> | ||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||||||||||