Extension:SlideShare2012
From MediaWiki.org
SlideShare2012 Release status: beta |
|
---|---|
Implementation | Parser function |
Description | Parser function for embedding SlideShare presentations |
Author(s) | MgXtalk |
Latest version | 0.2 (February 2012) |
License | No license specified |
Download | See below |
Example | Example of presentation |
Translate the SlideShare2012 extension if it is available at translatewiki.net |
|
Check usage and version matrix; code metrics |
N.B.: The original extension (by Sergey Chernyshev) was replaced with SlideShare Widget which is using Widgets extension to render the player. But I modified the original code because the Widget doesn't work on my MediaWiki 1.18+.
Usage[edit | edit source]
{{#slideshare:slideshare_document_id|width|height}} @slideshare_document_id - slideshare document id (id parameter in the URL) @width - (optional) width parameter, default is 425 pixels @height - (optional) height parameter, default is 348 pixels
Where's the ID of the slide?[edit | edit source]
Click on 'Embed' in the top of the slide which you want to insert in your webpage, and then click on 'Copy'. You'll have this (is an example):
<div style="width:425px" id="__ss_306252"> <strong style="display:block;margin:12px 0 4px"> <a href="http://www.slideshare.net/SergeyChernyshev/semantic-media-wiki-semantic-forms" title="Semantic Media Wiki & Semantic Forms" target="_blank">Semantic Media Wiki & Semantic Forms</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/306252" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> <div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/" target="_blank">presentations</a> from <a href="http://www.slideshare.net/SergeyChernyshev" target="_blank">Sergey Chernyshev</a> </div> </div>
Copy the number (*only* the number) near the string "id="__ss_" and paste it replacing the string "slideshare_document_id". It's quick and simple, isn't it? :)
Configuration[edit | edit source]
Add the following line at the bottom of your LocalSettings.php
require_once( "$IP/extensions/SlideShare.php" );
Code[edit | edit source]
<?php <?php /******************************************************************************* * $Id$ * * This extension allow adding SlideShare slideshows to wiki pages * * {{#slideshare:slideshare_document_id|width|height}} * *@slideshare_document_id - slideshare document id (id parameter in the URL) *@width - (optional) width parameter, default is 425 pixels *@height - (optional) height parameter, default is 348 pixels * * For more tricks, see http://www.mediawiki.org/wiki/Extension:SlideShare2012 ******************************************************************************** * Original version > Copyright (C) 2007 Sergey Chernyshev * * Modified by MgX > 27 February 2012 * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ********************************************************************************/ $wgExtensionFunctions[] = 'wfSlideShare'; $wgHooks['LanguageGetMagic'][] = 'wfSlideShare_Magic'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'SlideShare2012', 'description' => 'Extension to add SlideShare slideshows to wiki pages.', 'author' => '[http://www.mediawiki.org/wiki/User:MgX MgX]', 'url' => 'http://www.mediawiki.org/wiki/Extension:SlideShare2012', 'version' => '0.2', 'type' => 'parserhook' ); function wfSlideShare() { global $wgParser; $wgParser->setFunctionHook('slideshare', 'renderSlideShare'); } function wfSlideShare_Magic( &$magicWords, $langCode ) { $magicWords['slideshare'] = array( 0, 'slideshare' ); return true; } function renderSlideShare(&$parser, $id, $width=425, $height=348) { $id = filter_var($id, FILTER_SANITIZE_ENCODED); $width = filter_var($width, FILTER_VALIDATE_INT, array("options" => array("min_range"=>1)) ); $height = filter_var($height, FILTER_VALIDATE_INT, array("options" => array("min_range"=>1)) ); $output = ''; if ($id) { $output = '<div style="width:425px" id="'.$id.'"><iframe src="http://www.slideshare.net/ slideshow/embed_code/'.$id.'" width="'.$width.'" height="'.$height.'" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>'; } return array($output, 'noparse' => true, 'isHTML' => true, 'noargs' => true); }
Nice note[edit | edit source]
It's my first extension! ;)