User:SvenB
From MediaWiki.org
About Me [edit]
- Name
- Sven Brinkmann
Currently I am working on Extension:NagiosConfig
Simple Extension to include Soundcloud/Youtube-Links
<?php /* * <youtube>videourl1, videourl2, ..., videourlX</youtube> => * <iframe width="560" height="315" src="videourl1" frameborder="0" allowfullscreen></iframe> * <iframe width="560" height="315" src="videourl2" frameborder="0" allowfullscreen></iframe> * .... * <iframe width="560" height="315" src="videourlX" frameborder="0" allowfullscreen></iframe> * <soundcloud>soundcloudURL</soundcloud> => <iframe width="100%" scrolling="no" frameborder="no" src="####"></iframe> */ $wgExtensionFunctions[] = 'wfmediainclude'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'Mediainclude', 'description' => 'Include specific media urls in pages', 'author' => 'Sven Brinkmann', 'url' => '', 'version' => 0.1 ); function wfmediainclude() { global $wgParser; $wgParser->setHook('youtube', 'incyoutube'); $wgParser->setHook('soundcloud', 'incsoundcloud'); } function incYoutube( $input ) { $links = explode( ',', $input ); $output = ''; if ( !is_array( $links ) ) return $output; foreach( $links as $ytlink ) { preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]\/)[^&\n]+|(?<=v=)[^&\n]+#", htmlspecialchars( $ytlink ), $match); $output .= "<iframe width='560' height='315' src='http://www.youtube.com/embed/" . $match[0] . "?rel=0' frameborder='0' allowfullscreen></iframe>\n"; } return $output; } function incSoundcloud( $input ) { $links = explode( ',', $input ); $output = ''; if ( !is_array( $links ) ) return $output; foreach( $links as $sclink ) { $output .= '<iframe name="soundcloud" width="100%" scrolling="no" frameborder="no" src="' . htmlspecialchars( $sclink ) . '"></iframe>'; } return $output; }