/usr/share/mediawiki-extensions/base/Poem/Poem.php is in mediawiki-extensions-base 3.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | <?php
# MediaWiki Poem extension v1.0cis
#
# Based on example code from
# http://www.mediawiki.org/wiki/Manual:Extending_wiki_markup
#
# All other code is copyright © 2005 Nikola Smolenski <smolensk@eunet.yu>
# (with modified parser callback and attribute additions)
#
# Anyone is allowed to use this code for any purpose.
#
# To install, copy the extension to your extensions directory and add line
# include("extensions/Poem.php");
# to the bottom of your LocalSettings.php
#
# To use, put some text between <poem></poem> tags
#
# For more information see its page at
# http://www.mediawiki.org/wiki/Extension:Poem
$wgHooks['ParserFirstCallInit'][] = 'wfPoemExtension';
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'Poem',
'author' => array( 'Nikola Smolenski', 'Brion Vibber', 'Steve Sanbeg' ),
'url' => 'https://www.mediawiki.org/wiki/Extension:Poem',
'descriptionmsg' => 'poem-desc',
);
$wgParserTestFiles[] = dirname( __FILE__ ) . "/poemParserTests.txt";
$wgExtensionMessagesFiles['Poem'] = dirname(__FILE__) . '/Poem.i18n.php';
function wfPoemExtension( &$parser ) {
$parser->setHook( 'poem', 'wfRenderPoemTag' );
return true;
}
/**
* @param $in
* @param array $param
* @param $parser Parser
* @param bool $frame
* @return string
*/
function wfRenderPoemTag( $in, $param=array(), $parser=null, $frame=false ) {
/* using newlines in the text will cause the parser to add <p> tags,
* which may not be desired in some cases
*/
$nl = isset( $param['compact'] ) ? '' : "\n";
$tag = $parser->insertStripItem( "<br />", $parser->mStripState );
$text = preg_replace(
array( "/^\n/", "/\n$/D", "/\n/" ),
array( "", "", "$tag\n" ),
$in );
$text = preg_replace_callback( '/^( +)/m', 'wfPoemReplaceSpaces', $text );
$text = $parser->recursiveTagParse( $text, $frame );
$attribs = Sanitizer::validateTagAttributes( $param, 'div' );
// Wrap output in a <div> with "poem" class.
if( isset( $attribs['class'] ) ) {
$attribs['class'] = 'poem ' . $attribs['class'];
} else {
$attribs['class'] = 'poem';
}
return Html::rawElement( 'div', $attribs, $nl . trim( $text ) . $nl );
}
/**
* Callback for preg_replace_callback()
*/
function wfPoemReplaceSpaces( $m ) {
return str_replace( ' ', ' ', $m[1] );
}
|