personet
Personalwissen für den Mittelstand – handverlesen
(Änderung 6866 von 33.33.33.1 (Diskussion) rückgängig gemacht.) |
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
'' | <?php | ||
/** | |||
* atroo Robert Krueger | |||
*/ | |||
if ( !defined( 'MEDIAWIKI' ) ) die(); | |||
$wgExtensionCredits['parserhook'][] = array( | |||
'path' => __FILE__, | |||
'name' => 'RKWParser', | |||
'version' => '1.0.0', | |||
'author' => array( | |||
'[http://www.atroo.de 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 <rkw-container /> 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 = "<div class='rkw-container " . ($size == 'half' ? 'col-md-6' : 'col-md-12') . "'><h1 class='rkw-font-sans'>". $title ."</h1><div class='row'>" . $output . "</div></div>"; | |||
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 <rkw-box /> is mandatory'); | |||
} | |||
if(!isset($args['wikilink']) && !isset($args['extlink'])) { | |||
return RKWParserClass::createErr('wikilink or extlink attribute in <rkw-box /> 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 = '<div class="rkw-text rkw-font-sans">'.$input.'</div>'; | |||
} | |||
$content = '<div class="rkw-title rkw-font-sans"><a href="'.$link.'">'.$args['title'].'</a></div>'.$imgOrText; | |||
}else{ | |||
$content = '<div class="rkw-title rkw-font-sans"><a href="'.$link.'">'.$args['title'].'</a></div>'.$img.'<div class="rkw-text rkw-font-sans">'.$input.'</div>'; | |||
} | |||
$boxcontent = '<div class="rkw-content">'.$content.'<div class="rkw-footer-blend"></div></div>'; | |||
$res = '<div class="rkw-box '.$dimclass.' '.$boxsize.'">'.$boxcontent.'</div>'; | |||
return array( $res, 'noparse' => false , 'nowiki' => false, 'isHTML' => true); | |||
//return array( $res, 'noparse' => false , 'nowiki' => false); | |||
//return $res; | |||
} | |||
static function createErr($text) { | |||
return "<div class='rkw-config-error'>".htmlspecialchars($text)."</div>"; | |||
} | |||
} |
Version vom 21. Juli 2015, 15:09 Uhr
<?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 "
";
}
}