personet
Personalwissen für den Mittelstand – handverlesen
<?php /**
* atroo Robert Krueger */
if ( !defined( 'MEDIAWIKI' ) ) die();
$wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'RKWParser',
'version' => '1.0.0',
'author' => array( 'atroo GbR', ), 'descriptionmsg' => 'rkw-parser-description', 'url' => 'http://www.rkw-kompetenzzentrum.de/kontakt/', );
$wgExtensionMessagesFiles['RKWParser'] = __DIR__ . '/RKWParser.i18n.php';
$wgHooks['ParserFirstCallInit'][] = 'RKWParserClass::wfSampleSetup';
class RKWParserClass {
static function wfSampleSetup( Parser $parser ) { $parser->setHook( 'rkw-container', 'RKWParserClass::wfRkwContainerRender' ); $parser->setHook( 'rkw-box', 'RKWParserClass::wfRkwBoxRender' ); return true; } static function wfRkwContainerRender( $input, array $args, Parser $parser, PPFrame $frame ) { //validate the state of the attributes if(!isset($args['title'])) {
return RKWParserClass::createErr("title attribute in
Autorenempfehlungen
is mandatory");
} if(!isset($args['size'])) { $args['size'] = 'half'; } $title = $args['title']; $size = $args['size']; //parse the elements to pass down the parents size configuration to the childs $input = str_replace("<rkw-box", "<rkw-box parentsize='".$size."' ", $input); //parse the input for further tag elements such as the rkw-box $output = $parser->recursiveTagParse( $input , $frame );
$res = "
". $title ."
";
return array( $res, 'noparse' => false , 'nowiki' => false, 'isHTML' => true); } static function wfRkwBoxRender( $input, array $args, Parser $parser, PPFrame $frame ) { //validate the state of the attributes if(!isset($args['title'])) {
return RKWParserClass::createErr('title attribute in
is mandatory');
} if(!isset($args['wikilink']) && !isset($args['extlink'])) {
return RKWParserClass::createErr('wikilink or extlink attribute in
is mandatory');
} if(!isset($args['parentsize'])) { return RKWParserClass::createErr('<rkw-box> has to be a child of <rkw-container>'); } if(!isset($args['size'])) { $args['size'] = 'small'; } $parentsize = $args['parentsize']; $boxsize = $args['size']; $dimclass = 'col-md-6'; //default class for parent half and box small if($parentsize == 'half' && $boxsize == 'large') { $dimclass = 'col-md-12'; }else if($parentsize == 'full' && $boxsize == 'small') { $dimclass = 'col-md-3'; } $input = $parser->recursivePreProcess($input, $frame); $input = $parser->recursiveTagParse($input, $frame); $content = ; $link = isset($args['wikilink']) ? Skin::makeUrl($args['wikilink']) : $args['extlink']; $img = isset($args['image']) ? '<a href="'.$link.'" class="rkw-image" style="background-image: url('.$args['image'].');"></a>' : ; if($boxsize == 'small') { //smallboxes only have image or text, image takes precedence if(isset($args['image'])) { $imgOrText = $img; }else{
$imgOrText = '
';
}
$content = '
'.$imgOrText;
}else{
$content = '
'.$img.'
';
}
$boxcontent = '
'; $res = '
';
return array( $res, 'noparse' => false , 'nowiki' => false, 'isHTML' => true); //return array( $res, 'noparse' => false , 'nowiki' => false); //return $res; } static function createErr($text) {
return "
";
}
}