(Änderung 6866 von 33.33.33.1 (Diskussion) rückgängig gemacht.)
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
'''MediaWiki wurde erfolgreich installiert.'''
<?php
/**
* atroo Robert Krueger
*/
if ( !defined( 'MEDIAWIKI' ) ) die();


Hilfe zur Benutzung und Konfiguration der Wiki-Software findest du im [//meta.wikimedia.org/wiki/Help:Contents Benutzerhandbuch].
$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/',
);


== Starthilfen ==
$wgExtensionMessagesFiles['RKWParser'] = __DIR__ . '/RKWParser.i18n.php';


* [//www.mediawiki.org/wiki/Manual:Configuration_settings Liste der Konfigurationsvariablen]
$wgHooks['ParserFirstCallInit'][] = 'RKWParserClass::wfSampleSetup';
* [//www.mediawiki.org/wiki/Manual:FAQ MediaWiki-FAQ]
 
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce Mailingliste neuer MediaWiki-Versionen]
class RKWParserClass {
* [//www.mediawiki.org/wiki/Localisation#Translation_resources Lokalisiere MediaWiki für deine Sprache]
    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

</rkw-box>

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 ."

" . $output . "

";

       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

title attribute in <rkw-box /> is mandatory

is mandatory');

       }
       if(!isset($args['wikilink']) && !isset($args['extlink'])) {

return RKWParserClass::createErr('wikilink or extlink attribute in

title attribute in <rkw-box /> is mandatory

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 = '

'.$input.'

';

           }

$content = '

<a href="'.$link.'">'.$args['title'].'</a>

'.$imgOrText;

       }else{

$content = '

<a href="'.$link.'">'.$args['title'].'</a>

'.$img.'

'.$input.'

';

       }

$boxcontent = '

'.$content.'

'; $res = '

'.$boxcontent.'

';

       return array( $res, 'noparse' => false , 'nowiki' => false, 'isHTML' => true);
       //return array( $res, 'noparse' => false , 'nowiki' => false);
       //return $res;
   }
   
   static function createErr($text) {

return "

".htmlspecialchars($text)."

";

   }

}

Veranstaltungen

Herausgeber

Partner