Mediawiki/Erweiterung/FileProtocolLinks: Unterschied zwischen den Versionen

Aus Mikiwiki
Wechseln zu: Navigation, Suche
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 3: Zeile 3:
 
Damit diese Erweiterung auch unter [[Mozilla Firefox]] funktioniert, muss das Addon [https://addons.mozilla.org/de/firefox/addon/281 LocalLink] installiert werden.
 
Damit diese Erweiterung auch unter [[Mozilla Firefox]] funktioniert, muss das Addon [https://addons.mozilla.org/de/firefox/addon/281 LocalLink] installiert werden.
  
Ein bisher ungelöstets Problem sind allerdings URLs mit Leerzeichen innerhalb der Padangabe oder des Dateinamens (z. B. "<nowiki>/MUSIC/Pete Townshend/1980 album ''Empty glass''/01 - Rough boys.mp3</nowiki>".
+
<font color=red>Ein bisher ungelöstes Problem sind allerdings URLs mit Leerzeichen innerhalb der Pfadangabe oder des Dateinamens</font>, beispielsweise
 +
 
 +
<pre class=wiki>
 +
/MUSIC/Pete Townshend/1980 album ''Empty glass''/01 - Rough boys.mp3
 +
</pre>
  
 
== Installation ==
 
== Installation ==
Zeile 105: Zeile 109:
 
== Weblinks ==
 
== Weblinks ==
  
* [http://www.mediawiki.org/wiki/Extension:FileProtocolLinks Extension:FileProtocolLinks] (Mediawiki.org)
+
{{Weblinks}}
 +
{{url|US|Mediawiki|eng|http://www.mediawiki.org/wiki/Extension:FileProtocolLinks|Extension:FileProtocolLinks}}
 +
{{Fuss}}
  
  
 
{{cat|Datei}}
 
{{cat|Datei}}
 
{{cat|Mediawiki}}
 
{{cat|Mediawiki}}

Aktuelle Version vom 8. Februar 2010, 19:30 Uhr

Die Mediawiki-Erweiterung FileProtocolLinks ermöglicht die Verlinkung zu Dateien auf dem lokalen rechner.

Damit diese Erweiterung auch unter Mozilla Firefox funktioniert, muss das Addon LocalLink installiert werden.

Ein bisher ungelöstes Problem sind allerdings URLs mit Leerzeichen innerhalb der Pfadangabe oder des Dateinamens, beispielsweise

/MUSIC/Pete Townshend/1980 album ''Empty glass''/01 - Rough boys.mp3

Inhaltsverzeichnis

Installation

1. Herunterladen der aktuellen Software unter http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Description

Anlegen des Verzeichnisses "extensions/Description".

# mkdir extensions/Description
# chown wiki:wiki extensions/Description

2. Anlegen der Datei "extensions/FileProtocolLinks.php" und Einfügen des folgenden PHP-Codes: FileProtocolLinks 0.2 (für Mediawiki 1.14).

# vi extensions/FileProtocolLinks.php
<?php
 
/**
 * This file contains the main include file for the FileProtocolLinks extension of 
 * MediaWiki. This code is released under the GNU General Public License.
 *
 * As I am new to php the code for this plugin was taken from the XFNLinks Plugin. 
 * Thanks to Travis Swicegood for his work.
 
 * @author Edmund Mielach <edmund.mielach@s.roteskreuz.at>
 * @copyright Copyright 2005, Edmund Mielach
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package MediaWikiExtensions
 * @version 0.2
 */
 
/**
 * Register the FileProtocolLinks extension with MediaWiki
 */ 
$wgExtensionFunctions[] = 'registerFileProtocolLinks';
 
/**
 * Sets the tag that this extension looks for and the function by which it
 * operates
 */
function registerFileProtocolLinks()
{
  global $wgParser;
  $wgParser->setHook('file', 'renderFileProtocolLink');
}
 
/**
 * Renders a file protocol link based on the information provided by $input.
 *
 * @param string
 *  The string should be in the following format:
 *      URI[;link text]
 *  One example for a Windows environment would be:
 *      c:/something.txt|some nice text
 * @return string
 *  Returns an anchor tag for the given input. For the example above
 *  the return string would be
 *      <a style="color:green" href="file:///c:/something.txt“>some nice text</a>
 * The links are rendered in green text color to make it easier to recognize 
 * them as local shares.
 */
function renderFileProtocolLink($input)
{
  $exploded = explode('|', $input);
  $uri = htmlentities($exploded[0], ENT_COMPAT, "UTF-8");
 
  if (!isset($exploded[1]) || empty($exploded[1])) {
    // no linktext has been specified ==> use the URI as linktext
    $linktext = $uri;
  }
  else {
    $linktext = htmlentities($exploded[1], ENT_COMPAT, "UTF-8");
  }

  return sprintf('<a style="color:green" href="file:///%s">%s</a>', 
    $uri, $linktext);
}
 
#credits for [[Special:Version]]
$wgExtensionCredits['parserhook'][] = array(
  'name'        => 'FileProtocolLinks',
  'author'      => 'Edmund Mielach',
  'description' => 'highlights links to local filesystem',
  'url'         => 'http://www.mediawiki.org/wiki/Extension:FileProtocolLinks');	
?>

3. Anpassung der Rechte.

# chown wiki:wiki extensions/FileProtocolLinks.php

4. Einfügen der folgenden Zeile in die Datei "LocalSettings.php".

## Extension: FileProtocolLinks
require_once("extensions/FileProtocolLinks.php");

Weblinks

Herausgeber Sprache Webseitentitel Anmerkungen
country US.gif Mediawiki eng Extension:FileProtocolLinkswbm