Luis Felipe Schenone has uploaded a new change for review. https://gerrit.wikimedia.org/r/174943
Change subject: Updating all ...................................................................... Updating all Change-Id: I2043fcf0ae022591b4d72759c5bedfe57debc1ea --- M .gitignore A MsLinks.body.php A MsLinks.i18n.php A MsLinks.php D README.TXT A README.md A i18n/de.json A i18n/en.json A i18n/es.json A i18n/qqq.json M images/broken_icon.png D images/code__red_icon.png M images/code_icon.png D images/delete_icon.png M images/doc_icon.png A images/document-access.png A images/document-excel-table.png A images/dwg_icon.gif A images/exe_icon.gif D images/exe_icon.png A images/film_icon.png M images/image_ai_icon.png M images/image_icon.png M images/image_ps_icon.png M images/movie_flash_icon.png M images/movie_icon.png R images/mslink_icon.png A images/mslink_icon_oldschool.gif M images/music_icon.png M images/no_icon.png M images/pdf_icon.png D images/php_icon.png M images/pps_icon.png M images/txt_icon.png M images/xls_icon.png M images/zip_icon.png M mslinks.js D mslinks.php D mslinks_body.php 39 files changed, 341 insertions(+), 290 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MsLinks refs/changes/43/174943/1 diff --git a/.gitignore b/.gitignore index 98b092a..2c8761d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store .svn *~ *.kate-swp diff --git a/MsLinks.body.php b/MsLinks.body.php new file mode 100755 index 0000000..603b6f9 --- /dev/null +++ b/MsLinks.body.php @@ -0,0 +1,73 @@ +<?php + +class MsLinks { + + static function start() { + global $wgOut, $wgJsMimeType, $wgScriptPath; + $wgOut->addModules( 'ext.MsLinks' ); + $path = $wgScriptPath . '/extensions/MsLinks'; + $wgOut->addScript( "<script type=\"$wgJsMimeType\">var msl_icon_path = \"$path\";</script>" ); + return true; + } + + static function setHook( &$parser ) { + $parser->setFunctionHook( 'mslink', 'MsLinks::render' ); + return true; + } + + static function getMagicWord( &$magicWords, $langCode ) { + $magicWords['mslink'] = array( 0, 'l' ); + return true; + } + + static function render( $parser, $type = 'no', $url = '', $description = '', $align = '' ) { + global $wgOut, $wgScriptPath, $wgMSL_FileTypes; + + if ( $type !== 'dlink' and $type !== 'vlink' ) { + $align = $description; + $description = $url; + $url = $type; + } + + try { + $title = Title::newFromText( $url, NS_IMAGE ); + $file = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title ); + $base = ( is_object( $file ) && $file->exists() ) ? ':Image' : 'Media'; + } catch( Exception $exception ) { + $base = 'Media'; + } + + $extension = strtolower( substr( strrchr( $url, '.' ), 1 ) ); + if ( !$description ) { + if ( $extension ) { + $description = substr( $url, 0, ( strlen( $url ) - ( strlen( $extension ) + 1 ) ) ); + } else { + $description = $url; + } + } + + //Defaults + $wikitext = "[[$base:$url|$description]]"; + $image = "<img src=\"$wgScriptPath/extensions/MsLinks/images/" . $wgMSL_FileTypes['no'] . "\">"; + + foreach ( $wgMSL_FileTypes as $key => $value ) { + if ( $key === $extension ) { + $image = "<img title=\"$extension\" src=\"$wgScriptPath/extensions/MsLinks/images/$value\">"; + } + } + $image = $parser->insertStripItem( $image, $parser->mStripState ); + + if ( $type !== 'vlink' and $type !== 'dlink' ) { + $base = 'Media'; + } + + $image = "[[$base:$url|$image]]"; + + if ( $align === 'right' ) { + $wikitext = $wikitext . ' ' . $image; + } else { + $wikitext = $image . ' ' . $wikitext; + } + return $wikitext; + } +} \ No newline at end of file diff --git a/MsLinks.i18n.php b/MsLinks.i18n.php new file mode 100644 index 0000000..4ec7bdb --- /dev/null +++ b/MsLinks.i18n.php @@ -0,0 +1,35 @@ +<?php +/** + * This is a backwards-compatibility shim, generated by: + * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php + * + * Beginning with MediaWiki 1.23, translation strings are stored in json files, + * and the EXTENSION.i18n.php file only exists to provide compatibility with + * older releases of MediaWiki. For more information about this migration, see: + * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format + * + * This shim maintains compatibility back to MediaWiki 1.17. + */ +$messages = array(); +if ( !function_exists( 'wfJsonI18nShim9bfcb6d3a88a9ce0' ) ) { + function wfJsonI18nShim9bfcb6d3a88a9ce0( $cache, $code, &$cachedData ) { + $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); + foreach ( $codeSequence as $csCode ) { + $fileName = dirname( __FILE__ ) . "/extensions/MsLinks/i18n/$csCode.json"; + if ( is_readable( $fileName ) ) { + $data = FormatJson::decode( file_get_contents( $fileName ), true ); + foreach ( array_keys( $data ) as $key ) { + if ( $key === '' || $key[0] === '@' ) { + unset( $data[$key] ); + } + } + $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); + } + + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; + } + + $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShim9bfcb6d3a88a9ce0'; +} \ No newline at end of file diff --git a/MsLinks.php b/MsLinks.php new file mode 100755 index 0000000..79ec9bf --- /dev/null +++ b/MsLinks.php @@ -0,0 +1,71 @@ +<?php + +$wgExtensionCredits['parserhook'][] = array( + 'name' => 'MsLinks', + 'url' => 'https://www.mediawiki.org/wiki/Extension:MsLinks', + 'version' => '3.0', + 'descriptionmsg' => 'msl-desc', + 'license-name' => 'GPLv2+', + 'author' => array( '[mailto:w...@ratin.de Martin Schwindl]', '[mailto:w...@keyler-consult.de Martin Keyler]', '[https://www.mediawiki.org/wiki/User:Luis_Felipe_Schenone Luis Felipe Schenone]' ), +); + +$wgResourceModules['ext.MsLinks'] = array( + 'scripts' => 'MsLinks.js', + 'messages' => array( + 'msl-tooltip', + 'msl-example-filename', + ), + 'localBasePath' => __DIR__, + 'remoteExtPath' => 'MsLinks', +); + +$wgAutoloadClasses['MsLinks'] = __DIR__ . '/MsLinks.body.php'; + +$wgExtensionMessagesFiles['MsLinks'] = __DIR__ . '/MsLinks.i18n.php'; +$wgMessagesDirs['MsLinks'] = __DIR__ . '/i18n'; + +$wgHooks['ParserFirstCallInit'][] = 'MsLinks::setHook'; +$wgHooks['EditPage::showEditForm:initial'][] = 'MsLinks::start'; +$wgHooks['LanguageGetMagic'][] = 'MsLinks::getMagicWord'; + +// Default configuration +$wgMSL_FileTypes = array( + 'no' => 'no_icon.png', + 'jpg' => 'image_icon.png', + 'gif' => 'image_icon.png', + 'bmp' => 'image_icon.png', + 'png' => 'image_icon.png', + 'tiff' => 'image_icon.png', + 'tif' => 'image_icon.png', + 'ai' => 'image_ai_icon.png', + 'psd' => 'image_ps_icon.png', + 'pdf' => 'pdf_icon.png', + 'pps' => 'pps_icon.png', + 'ppt' => 'pps_icon.png', + 'pptx' => 'pps_icon.png', + 'xls' => 'xls_icon.png', + 'xlsx' => 'xls_icon.png', + 'doc' => 'doc_icon.png', + 'docx' => 'doc_icon.png', + 'dot' => 'doc_icon.png', + 'dotx' => 'doc_icon.png', + 'rtf' => 'doc_icon.png', + 'txt' => 'txt_icon.png', + 'html' => 'code_icon.png', + 'php' => 'code_icon.png', + 'exe' => 'exe_icon.gif', + 'asc' => 'txt_icon.png', + 'dwg' => 'dwg_icon.gif', + 'zip' => 'zip_icon.png', + 'mov' => 'movie_icon.png', + 'mpeg' => 'movie_icon.png', + 'mpg' => 'movie_icon.png', + 'wmv' => 'movie_icon.png', + 'avi' => 'movie_icon.png', + 'mp4' => 'movie_icon.png', + 'flv' => 'movie_flash_icon.png', + 'wma' => 'music_icon.png', + 'mp3' => 'music_icon.png', + 'wav' => 'music_icon.png', + 'mid' => 'music_icon.png', +); \ No newline at end of file diff --git a/README.TXT b/README.TXT deleted file mode 100644 index b019254..0000000 --- a/README.TXT +++ /dev/null @@ -1,54 +0,0 @@ -############################################################ -# Author: -#Martin Schwindl, i...@ratin.de -# -# Icons: -#Silk icon set -#famfamfam.com, Mark James, a web developer from Birmingham, UK. -# -# Usage: -#{{#l:dlink|Testfile.zip|Description|right}} -#{{#l:Testfile.zip}} -# -# LocalSettings.php: -#require_once("$IP/extensions/MsLinks/mslinks.php"); -#$wgMSL_FileTypes = array( -# "no" => "no_icon.png", -# "jpg" => "image_icon.png", -# "gif" => "image_icon.png", -# "bmp" => "image_icon.png", -# "png" => "image_icon.png", -# "tiff" => "image_icon.png", -# "tif" => "image_icon.png", -# "ai" => "image_ai_icon.png", -# "psd" => "image_ps_icon.png", -# "pdf" => "pdf_icon.png", -# "pps" => "pps_icon.png", -# "ppt" => "pps_icon.png", -# "pptx" => "pps_icon.png", -# "xls" => "xls_icon.png", -# "xlsx" => "xls_icon.png", -# "doc" => "doc_icon.png", -# "docx" => "doc_icon.png", -# "dot" => "doc_icon.png", -# "dotx" => "doc_icon.png", -# "rtf" => "doc_icon.png", -# "txt" => "txt_icon.png", -# "html" => "code_icon.png", -# "php" => "php_icon.png", -# "exe" => "exe_icon.gif", -# "asc" => "txt_icon.png", -# "zip" => "zip_icon.png", -# "mov" => "movie_icon.png", -# "mpeg" => "movie_icon.png", -# "mpg" => "movie_icon.png", -# "wmv" => "movie_icon.png", -# "avi" => "movie_icon.png", -# "mp4" => "movie_icon.png", -# "flv" => "movie_flash_icon.png", -# "wma" => "music_icon.png", -# "mp3" => "music_icon.png", -# "wav" => "music_icon.png", -# "mid" => "music_icon.png" -# ); -############################################################ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..173b250 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +MsLinks +======= + +The MsLinks extension adds a button to the editor that creates links to view or download files using icons appropriate to the file type. + +Installation +------------ +To install MsLinks, add the following to your LocalSettings.php: + +require_once "$IP/extensions/MsLinks/MsLinks.php"; + +Usage +----- +To insert a basic link to view a file: +{{#l:Example.zip}} + +To insert a link to download a file, with "Download this file" as text and with the icon aligned to the right: +{{#l:dlink|Example.zip|Download this file|right}} + +Configuration +------------- +If you want to change the icons for the different types of links, you may set the following BELOW the require_once line: + +$wgMSL_FileTypes = array( + 'jpg' => 'your_icon_for_jpgs.png', + 'gif' => 'your_icon_for_gifs.png', + 'doc' => 'your_icon_for_docs.png', +); + +The icons should be in the MsLinks/images directory. The defaults are the following: + +$wgMSL_FileTypes = array( + 'no' => 'no_icon.png', + 'jpg' => 'image_icon.png', + 'gif' => 'image_icon.png', + 'bmp' => 'image_icon.png', + 'png' => 'image_icon.png', + 'tiff' => 'image_icon.png', + 'tif' => 'image_icon.png', + 'ai' => 'image_ai_icon.png', + 'psd' => 'image_ps_icon.png', + 'pdf' => 'pdf_icon.png', + 'pps' => 'pps_icon.png', + 'ppt' => 'pps_icon.png', + 'pptx' => 'pps_icon.png', + 'xls' => 'xls_icon.png', + 'xlsx' => 'xls_icon.png', + 'doc' => 'doc_icon.png', + 'docx' => 'doc_icon.png', + 'dot' => 'doc_icon.png', + 'dotx' => 'doc_icon.png', + 'rtf' => 'doc_icon.png', + 'txt' => 'txt_icon.png', + 'html' => 'code_icon.png', + 'php' => 'code_icon.png', + 'exe' => 'exe_icon.gif', + 'asc' => 'txt_icon.png', + 'dwg' => 'dwg_icon.gif', + 'zip' => 'zip_icon.png', + 'mov' => 'movie_icon.png', + 'mpeg' => 'movie_icon.png', + 'mpg' => 'movie_icon.png', + 'wmv' => 'movie_icon.png', + 'avi' => 'movie_icon.png', + 'mp4' => 'movie_icon.png', + 'flv' => 'movie_flash_icon.png', + 'wma' => 'music_icon.png', + 'mp3' => 'music_icon.png', + 'wav' => 'music_icon.png', + 'mid' => 'music_icon.png' +); + +Credits +------- +* Developed and coded by Martin Schwindl (w...@ratin.de) +* Idea, project management and bug fixing by Martin Keyler (w...@keyler-consult.de) +* Updated, debugged and enhanced by Luis Felipe Schenone (scheno...@gmail.com) \ No newline at end of file diff --git a/i18n/de.json b/i18n/de.json new file mode 100644 index 0000000..10fe7c8 --- /dev/null +++ b/i18n/de.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Luis Felipe Schenone" + ] + }, + "msl-desc": "Erzeugt einem Link mit dem passenden Icon sowie einen Direkt- und Versionslink", + "msl-tooltip": "Direktlink", + "msl-example-filename": "Dateiname.ext" +} \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..19d417d --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Luis Felipe Schenone" + ] + }, + "msl-desc": "Creates links to view or download files using icons appropriate to the file type", + "msl-tooltip": "Direct link", + "msl-example-filename": "Filename.ext" +} diff --git a/i18n/es.json b/i18n/es.json new file mode 100644 index 0000000..0cf586e --- /dev/null +++ b/i18n/es.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Luis Felipe Schenone" + ] + }, + "msl-desc": "Crea enlaces para ver o descargar archivos, usando íconos apropiados al tipo de archivo", + "msl-tooltip": "Enlace directo", + "msl-example-filename": "Nombre del archivo.ext" +} diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 0000000..8d6d15e --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Luis Felipe Schenone" + ] + }, + "msl-desc": "{{desc|name=MsLinks|url=https://www.mediawiki.org/wiki/Extension:MsLinks}}", + "msl-tooltip": "Tooltip to the button for inserting links", + "msl-example-filename": "Name of the example file" +} diff --git a/images/broken_icon.png b/images/broken_icon.png old mode 100644 new mode 100755 index 9fc5a0a..3fa6cc7 --- a/images/broken_icon.png +++ b/images/broken_icon.png Binary files differ diff --git a/images/code__red_icon.png b/images/code__red_icon.png deleted file mode 100644 index 87a6914..0000000 --- a/images/code__red_icon.png +++ /dev/null Binary files differ diff --git a/images/code_icon.png b/images/code_icon.png old mode 100644 new mode 100755 index 0c76bd1..4ca303f --- a/images/code_icon.png +++ b/images/code_icon.png Binary files differ diff --git a/images/delete_icon.png b/images/delete_icon.png deleted file mode 100644 index af1ecaf..0000000 --- a/images/delete_icon.png +++ /dev/null Binary files differ diff --git a/images/doc_icon.png b/images/doc_icon.png old mode 100644 new mode 100755 index 834cdfa..0b153c2 --- a/images/doc_icon.png +++ b/images/doc_icon.png Binary files differ diff --git a/images/document-access.png b/images/document-access.png new file mode 100755 index 0000000..7949ae5 --- /dev/null +++ b/images/document-access.png Binary files differ diff --git a/images/document-excel-table.png b/images/document-excel-table.png new file mode 100755 index 0000000..aca8702 --- /dev/null +++ b/images/document-excel-table.png Binary files differ diff --git a/images/dwg_icon.gif b/images/dwg_icon.gif new file mode 100755 index 0000000..17df67c --- /dev/null +++ b/images/dwg_icon.gif Binary files differ diff --git a/images/exe_icon.gif b/images/exe_icon.gif new file mode 100755 index 0000000..bb58db6 --- /dev/null +++ b/images/exe_icon.gif Binary files differ diff --git a/images/exe_icon.png b/images/exe_icon.png deleted file mode 100644 index 106f5aa..0000000 --- a/images/exe_icon.png +++ /dev/null Binary files differ diff --git a/images/film_icon.png b/images/film_icon.png new file mode 100755 index 0000000..b8056c9 --- /dev/null +++ b/images/film_icon.png Binary files differ diff --git a/images/image_ai_icon.png b/images/image_ai_icon.png old mode 100644 new mode 100755 index 23a37b8..23b2307 --- a/images/image_ai_icon.png +++ b/images/image_ai_icon.png Binary files differ diff --git a/images/image_icon.png b/images/image_icon.png old mode 100644 new mode 100755 index 4a158fe..607c25d --- a/images/image_icon.png +++ b/images/image_icon.png Binary files differ diff --git a/images/image_ps_icon.png b/images/image_ps_icon.png old mode 100644 new mode 100755 index 23a37b8..90288b6 --- a/images/image_ps_icon.png +++ b/images/image_ps_icon.png Binary files differ diff --git a/images/movie_flash_icon.png b/images/movie_flash_icon.png old mode 100644 new mode 100755 index 5769120..db7cf80 --- a/images/movie_flash_icon.png +++ b/images/movie_flash_icon.png Binary files differ diff --git a/images/movie_icon.png b/images/movie_icon.png old mode 100644 new mode 100755 index b0ce7bb..4e0924d --- a/images/movie_icon.png +++ b/images/movie_icon.png Binary files differ diff --git a/images/Wiki-Editor-Buttons_Li.png b/images/mslink_icon.png similarity index 100% rename from images/Wiki-Editor-Buttons_Li.png rename to images/mslink_icon.png old mode 100644 new mode 100755 Binary files differ diff --git a/images/mslink_icon_oldschool.gif b/images/mslink_icon_oldschool.gif new file mode 100755 index 0000000..ee3131b --- /dev/null +++ b/images/mslink_icon_oldschool.gif Binary files differ diff --git a/images/music_icon.png b/images/music_icon.png old mode 100644 new mode 100755 index a8b3ede..e6dc2de --- a/images/music_icon.png +++ b/images/music_icon.png Binary files differ diff --git a/images/no_icon.png b/images/no_icon.png old mode 100644 new mode 100755 index 8b8b1ca..0847f09 --- a/images/no_icon.png +++ b/images/no_icon.png Binary files differ diff --git a/images/pdf_icon.png b/images/pdf_icon.png old mode 100644 new mode 100755 index 8f8095e..ca704c2 --- a/images/pdf_icon.png +++ b/images/pdf_icon.png Binary files differ diff --git a/images/php_icon.png b/images/php_icon.png deleted file mode 100644 index 7868a25..0000000 --- a/images/php_icon.png +++ /dev/null Binary files differ diff --git a/images/pps_icon.png b/images/pps_icon.png old mode 100644 new mode 100755 index c4eff03..584cc5c --- a/images/pps_icon.png +++ b/images/pps_icon.png Binary files differ diff --git a/images/txt_icon.png b/images/txt_icon.png old mode 100644 new mode 100755 index 813f712..8c1184d --- a/images/txt_icon.png +++ b/images/txt_icon.png Binary files differ diff --git a/images/xls_icon.png b/images/xls_icon.png old mode 100644 new mode 100755 index b977d7e..2011384 --- a/images/xls_icon.png +++ b/images/xls_icon.png Binary files differ diff --git a/images/zip_icon.png b/images/zip_icon.png old mode 100644 new mode 100755 index fd4bbcc..b887de0 --- a/images/zip_icon.png +++ b/images/zip_icon.png Binary files differ diff --git a/mslinks.js b/mslinks.js old mode 100644 new mode 100755 index c63404b..5813d77 --- a/mslinks.js +++ b/mslinks.js @@ -1,70 +1,47 @@ -if(typeof(add_buttons) != 'undefined'){ - add_buttons.push("msl"); -} - -$(document).ready(function () { //jquery - - var img_msl = "extensions/MsLinks/images/Wiki-Editor-Buttons_Li.png"; - var img_msl2 = path_button_msl +"/images/Wiki-Editor-Buttons_Li.png"; - var nam_msl = "Direktlink"; - var pre_msl = "{{#l:"; - var peri_msl = "Filename.ext"; - var post_msl = "\}\}"; - - if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { - mw.loader.using( 'user.options', function () { - if ( mw.user.options.get('usebetatoolbar') ) { - mw.loader.using( 'ext.wikiEditor.toolbar', function () { - - if(typeof(addThisButton) == 'undefined'){ - addGroup_msl(); - addButton_msl(nam_msl,pre_msl,peri_msl,post_msl,img_msl2); - } - return true; - } ); - } - } ); - - mw.toolbar.addButton({ - "imageFile": img_msl, - "speedTip": nam_msl, - "tagOpen": pre_msl, - "tagClose": post_msl, - "sampleText": peri_msl - }); - } -}); +var msl_icon = msl_icon_path + "/images/mslink_icon.png"; +var msl_pre = "{{#l:"; +var msl_peri = mw.msg( 'msl-example-filename' ); +var msl_post = "}}"; -function addGroup_msl(){ - // To add a group to an existing toolbar section: - $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { - 'section': 'main', - 'groups': { - 'MsLinks': {} - } - }); -} - -function addButton_msl(nam,prex,perix,postx,img){ - - // To add a button to an existing toolbar group: - $('#wpTextbox1' ).wikiEditor( 'addToToolbar', { - 'section': 'main', - 'group': 'MsLinks', - 'tools': { - nam: { - label: nam, // or use labelMsg for a localized label, see above - type: 'button', - icon: img, - action: { - type: 'encapsulate', - options: { - pre: prex, - peri: perix, - post: postx, - } - } - } - } +if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { + mw.loader.using( 'user.options', function () { + if ( mw.user.options.get( 'usebetatoolbar' ) && mw.user.options.get( 'showtoolbar' ) ) { + mw.loader.using( 'ext.wikiEditor.toolbar', msl_addButton1 ); + } else { + mw.loader.using( 'mediawiki.action.edit', msl_addButton2 ); + } }); } + +function msl_addButton1() { + $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { + 'section': 'main', + 'group': 'insert', + 'tools': { + 'MsLink': { + 'label': mw.msg( 'msl-tooltip' ), + 'type': 'button', + 'icon': msl_icon, + 'action': { + 'type': 'encapsulate', + 'options': { + 'pre': msl_pre, + 'peri': msl_peri, + 'post': msl_post, + } + } + } + } + }); +} + +function msl_addButton2() { + mw.toolbar.addButton({ + imageFile: msl_icon, + speedTip: mw.msg( 'msl-tooltip' ), + tagOpen: msl_pre, + tagClose: msl_post, + sampleText: msl_peri, + imageId: 'mslink' + }); +} \ No newline at end of file diff --git a/mslinks.php b/mslinks.php deleted file mode 100644 index 88b44f9..0000000 --- a/mslinks.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -############################################################ -# Author: -#Martin Schwindl, i...@ratin.de -# -# Icons: -#Silk icon set -#famfamfam.com, Mark James, a web developer from Birmingham, UK. -# -# Usage: -#{{#l:dlink|Testfile.zip|Description|right}} -#{{#l:Testfile.zip}} -# -# LocalSettings.php: -#require_once("$IP/extensions/MsLinks/mslinks.php"); -#$wgMSL_FileTypes = array( -# "no" => "no_icon.png", -# "jpg" => "image_icon.png", -# "gif" => "image_icon.png", -# "bmp" => "image_icon.png", -# "png" => "image_icon.png", -# "tiff" => "image_icon.png", -# "tif" => "image_icon.png", -# "ai" => "image_ai_icon.png", -# "psd" => "image_ps_icon.png", -# "pdf" => "pdf_icon.png", -# "pps" => "pps_icon.png", -# "ppt" => "pps_icon.png", -# "pptx" => "pps_icon.png", -# "xls" => "xls_icon.png", -# "xlsx" => "xls_icon.png", -# "doc" => "doc_icon.png", -# "docx" => "doc_icon.png", -# "dot" => "doc_icon.png", -# "dotx" => "doc_icon.png", -# "rtf" => "doc_icon.png", -# "txt" => "txt_icon.png", -# "html" => "code_icon.png", -# "php" => "php_icon.png", -# "exe" => "exe_icon.gif", -# "asc" => "txt_icon.png", -# "zip" => "zip_icon.png", -# "mov" => "movie_icon.png", -# "mpeg" => "movie_icon.png", -# "mpg" => "movie_icon.png", -# "wmv" => "movie_icon.png", -# "avi" => "movie_icon.png", -# "mp4" => "movie_icon.png", -# "flv" => "movie_flash_icon.png", -# "wma" => "music_icon.png", -# "mp3" => "music_icon.png", -# "wav" => "music_icon.png", -# "mid" => "music_icon.png" -# ); -############################################################ - -if(! defined('MEDIAWIKI')) { - die("This is a MediaWiki extension and can not be used standalone.\n"); -} - -$wgExtensionCredits['parserhook'][] = array( - 'name' => 'MsLinks', - 'url' => 'http://www.ratin.de/mslinks.html', - 'description' => 'Erzeugt einem Link mit dem passenden Icon sowie einen Direkt- und Versionslink', - 'version' => '3.1', - 'author' => '[mailto:i...@ratin.de i...@ratin.de] | Ratin' -); - -$dir = dirname(__FILE__).'/'; -require_once('mslinks_body.php'); - -#$wgExtensionFunctions[] = "wfMsLinksSetup"; -$wgHooks['EditPageBeforeEditButtons'][]='MsLinksAddButton'; -$wgHooks['LanguageGetMagic'][] = 'wfMsLinksMagic'; -$wgHooks['ParserFirstCallInit'][] = 'MsLinksRegisterHook'; - - -// Tell MediaWiki that the parser function exists. -function MsLinksRegisterHook(&$parser) { - $parser->setFunctionHook('mslink', 'wfMsLinksRender'); - return true; -} - -function wfMsLinksMagic( &$magicWords, $langCode ) { - $magicWords['mslink'] = array(0,'l'); - return true; -} - -function MsLinksAddButton(){ - global $wgOut,$wgScriptPath,$wgJsMimeType; - $path = $wgScriptPath.'/extensions/MsLinks'; - $wgOut->addScript( "<script type=\"{$wgJsMimeType}\">var path_button_msl='$path'; </script>\n" ); - $wgOut->addScriptFile( $path.'/mslinks.js' ); - - return true; -} - diff --git a/mslinks_body.php b/mslinks_body.php deleted file mode 100644 index fc91375..0000000 --- a/mslinks_body.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -function wfMsLinksRender($parser, $typ = '', $url = '', $beschreibung = '', $align = '') { - - global $wgOut,$wgScriptPath,$wgMSL_FileTypes; - - - if (empty($typ)) { - return 'kein typ angegeben'; - } - - if($typ != "dlink" && $typ != "vlink") { - - $align = $beschreibung; - $beschreibung = $url; - $url = $typ; - - } //if - - try { - $title = Title::newFromText($url,NS_IMAGE); - $file = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title ); - $base = (is_object( $file ) && $file->exists()) ? ":Image" : "Media"; - } catch(Exception $e) { - #return $e->getMessage(); - $base = "Media"; - } - - $extension = strtolower(substr(strrchr ($url, "."), 1)); - - if($beschreibung == "") { - if(strlen($extension)!=0){ - $beschreibung = substr($url,0,(strlen($url)-(strlen($extension)+1))); // damit umlaute auch angezeigt werden - } else { //ist garkeine extension angegeben z.b. {{#l:fehlt noch}} - $beschreibung = $url; - } - } - - - $bild = "<img src='$wgScriptPath/extensions/MsLinks/images/".$wgMSL_FileTypes['no']."'>"; - - - if (isset($wgMSL_FileTypes)){ - foreach($wgMSL_FileTypes as $key => $value) - { - if($key==$extension){ - $bild = "<img title='$extension' src='$wgScriptPath/extensions/MsLinks/images/$value'>"; - } - - } //foreach - } //if - - $bild = $parser->insertStripItem($bild, $parser->mStripState); - - - if ($typ == "dlink"){ - $html = "[[Media:$url|$beschreibung]]"; - $bild = "[[$base:$url|".$bild."]]"; - } else { - $html = "[[$base:$url|$beschreibung]]"; - $bild = "[[Media:$url|".$bild."]]"; - } - - - if ($align == "right") { - $html = $html." ".$bild; - } else { #standardausrichtung - $html = $bild." ".$html; - } - - return $html; -} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/174943 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2043fcf0ae022591b4d72759c5bedfe57debc1ea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MsLinks Gerrit-Branch: master Gerrit-Owner: Luis Felipe Schenone <scheno...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits