Talk:Policies/Wiki Style
From Mandriva Community Wiki
[edit] Edittools (OLD)
Please could any Sysop click on http://wiki.mandriva.com/en/index.php?title=MediaWiki:Edittools&action=edit and copy and paste from http://en.wikipedia.org/w/index.php?title=MediaWiki:Edittools&action=edit in order to help editing. --Nbrouard 01:07, 6 June 2007 (CEST)
- Thanks for pointing this... I tried to, but the <charinsert> tag is not known by this wiki : is there a special extension required ? yoho 08:57, 6 June 2007 (CEST)
- Yes, it is an extension CharInsert.php, with
require_once( "extensions/CharInsert.php"); in you LocalSettings.php
require_once( "extensions/Expr.php"); require_once( "extensions/ParserFunctions.php");
[edit] extensions/CharInsert.php (OLD)
<?php
# Copyright (C) 2004,2006 Brion Vibber <brion@pobox.com>
# http://www.mediawiki.org/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
/**
* Extension to create new character inserts which can be used on
* the edit page to make it easy to get at special characters and
* such forth.
*
* @author Brion Vibber <brion at pobox.com>
* @package MediaWiki
* @subpackage Extensions
*/
if( !defined( 'MEDIAWIKI' ) ) {
die();
}
$wgExtensionFunctions[] = 'setupSpecialChars';
$wgExtensionCredits['parserhook'][] = array(
'name' => 'CharInsert',
'author' => 'Brion Vibber'
);
function setupSpecialChars() {
global $wgParser;
$wgParser->setHook( 'charinsert', 'charInsert' );
}
function charInsert( $data ) {
return implode( "<br />\n",
array_map( 'charInsertLine',
explode( "\n", trim( $data ) ) ) );
}
function charInsertLine( $data ) {
return implode( "\n",
array_map( 'charInsertItem',
preg_split( '/\\s+/', charInsertArmor( $data ) ) ) );
}
function charInsertArmor( $data ) {
return preg_replace_callback(
'!(.*?)!i',
'charInsertNowiki',
$data );
}
function charInsertNowiki( $matches ) {
return str_replace(
array( '\t', '\r', ' ' ),
array( ' ', '', ' ' ),
$matches[1] );
}
function charInsertItem( $data ) {
$chars = explode( '+', $data );
if( count( $chars ) > 1 ) {
return charInsertChar( $chars[0], $chars[1], 'Click the character while selecting a text' );
} elseif( count( $chars ) == 1 ) {
return charInsertChar( $chars[0] );
} else {
return charInsertChar( '+' );
}
}
function charInsertChar( $start, $end = '', $title = null ) {
$estart = charInsertJsString( $start );
$eend = charInsertJsString( $end );
if( $eend == '' ) {
$inline = charInsertDisplay( $start );
} else {
$inline = charInsertDisplay( $start . $end );
}
if( $title ) {
$extra = ' title="' . htmlspecialchars( $title ) . '"';
} else {
$extra = '';
}
return wfElement( 'a',
array(
'onclick' => "insertTags('$estart','$eend','');return false",
'href' => '#' ),
$inline );
}
function charInsertJsString( $text ) {
return strtr(
charInsertDisplay( $text ),
array(
"\\" => "\\\\",
"\"" => "\\\"",
"'" => "\\'",
"\r\n" => "\\n",
"\r" => "\\n",
"\n" => "\\n",
) );
}
function charInsertDisplay( $text ) {
static $invisibles = array( ' ', ' ' );
static $visibles = array( ' ', ' ' );
return Sanitizer::decodeCharReferences(
str_replace( $invisibles, $visibles, $text ) );
}
?>

