Here is tiny extension I very quickly put together the other day from some
examples that allows me to say {{#filename:C:\Path to\some file.txt}} and it
creates a proper file:// URL. You may need to modify it. You would use it by
placing this in a file, say extensions/Filename.php and inserting this into
LocalSettings.php
require_once( "$IP/extensions/Filename.php" );
Here is Filename.php:
<?php
# Define a setup function
$wgExtensionFunctions[] = 'wfFilenameParserFunction_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][] = 'wfFilenameParserFunction_Magic';
function wfFilenameParserFunction_Setup() {
global $wgParser;
# Set a function hook associating the "example" magic word with our
function
$wgParser->setFunctionHook( 'example',
'wfFilenameParserFunction_Render' );
}
function wfFilenameParserFunction_Magic( &$magicWords, $langCode ) {
# Add the magic word
# The first array element is case sensitive, in this case it is not
case sensitive
# All remaining elements are synonyms for our parser function
$magicWords['example'] = array( 0, 'filename' );
# unless we return true, other parser functions extensions won't get
loaded.
return true;
}
function wfFilenameParserFunction_Render( &$parser, $filename = '', $title =
'' ) {
# The parser function itself
# The input parameters are wikitext with templates expanded
# The output should be wikitext too
$url = str_replace('/', '\\', $filename);
//$url = str_replace('%20' , ' ' , $url);
$html_out = '<a href="file:///'.$url.'"
rel="nofollow"
class="link-document">'.htmlspecialchars($title == '' ? $filename
:
$title).'</a>';
// $html_out .= '<a href="/Help:How to link to
files">[?]</a>';
// return array( $html_out, noparse => true, isHTML => true );
return $parser->insertStripItem( $html_out, $parser->mStripState
).'[[Help:Linking to files|[?]]]';
}
?>
On Nov 8, 2007 12:44 PM, Victor Onate Aranguren <vonate(a)edelca.com.ve>
wrote:
Hi please sorry my Inglish
How i can create a link from my wiki to file
like at
smb://file
gracias...
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l