Header

From Lost

(Difference between revisions)
 
(11 intermediate revisions not shown)
Line 1: Line 1:
-
<script type="text/javascript">
 
-
  //Your Javascript Here
 
-
</script>
 
  <style type="text/css">
  <style type="text/css">
-
+
  /*
-
  #column-content {
+
  * EmbedVideo.php - Adds a parser function aembedding video from popular sources.
-
    width: 100%;
+
* @author Jim R. Wilson
-
    float: right;
+
* @version 0.1.2
-
    margin: 0 0 0.6em -12.2em;
+
* @copyright Copyright (C) 2007 Jim R. Wilson
-
    padding:0;
+
* @license The MIT License - http://www.opensource.org/licenses/mit-license.php
-
  }
+
* -----------------------------------------------------------------------
-
  #content {
+
* Description:
-
    margin: 2.8em 0 0 12.2em;
+
  *    This is a MediaWiki extension which adds a parser function for embedding
-
    padding: 0em 1em 1.5em 1em;
+
  *    video from popular sources (configurable).
-
    background: White;
+
* Requirements:
-
    border: 1px solid #aaaaaa;
+
*    MediaWiki 1.6.x, 1.9.x, 1.10.x or higher
-
    border-right: none;
+
*    PHP 4.x, 5.x or higher.
-
    line-height: 1.5em;
+
* Installation:
-
    position: relative;
+
*    1. Drop this script (EmbedVideo.php) in $IP/extensions
-
    z-index: 2;
+
*        Note: $IP is your MediaWiki install dir.
-
  }
+
*    2. Enable the extension by adding this line to your LocalSettings.php:
-
  #column-one { padding-top: 160px; }
+
*        require_once('extensions/EmbedVideo.php');
-
  /* the left column width is specified in class .portlet */
+
* Version Notes:
-
   
+
*    version 0.1.2:
-
  /* Font size:
+
*        Bug fix - now can be inserted in lists without breakage (from newlines)
-
  ** We take advantage of keyword scaling- browsers won't go below 9px
+
*        Code cleanup - would previously give 'Notice' messages in PHP strict.
-
  ** More at http://www.w3.org/2003/07/30-font-size
+
*    version 0.1.1:
-
  ** http://style.cleverchimp.com/font_size_intervals/altintervals.html
+
*        Code cleanup - no functional difference.
 +
*    version 0.1:
 +
  *        Initial release.
 +
  * -----------------------------------------------------------------------
 +
  * Copyright (c) 2007 Jim R. Wilson
 +
*
 +
* Permission is hereby granted, free of charge, to any person obtaining a copy
 +
* of this software and associated documentation files (the "Software"), to deal
 +
* in the Software without restriction, including without limitation the rights to
 +
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 +
  * the Software, and to permit persons to whom the Software is furnished to do
 +
  * so, subject to the following conditions:
 +
  *  
 +
* The above copyright notice and this permission notice shall be included in all
 +
* copies or substantial portions of the Software.
 +
  *  
 +
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 +
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 +
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 +
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 +
  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 +
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 +
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 +
* OTHER DEALINGS IN THE SOFTWARE.  
 +
* -----------------------------------------------------------------------
  */
  */
   
   
-
body {
+
# Confirm MW environment
-
    font: x-small sans-serif;
+
if (defined('MEDIAWIKI')) {
-
    background: #f9f9f9 url("headbg.jpg") 0px 0px no-repeat;
+
-
    color: Black;
+
-
    margin: 0;
+
-
    padding: 0;
+
-
}
+
   
   
-
/* scale back up to a sane default */
+
# Credits
-
#globalWrapper {
+
$wgExtensionCredits['parserhook'][] = array(
-
    font-size:127%;
+
    'name'=>'EmbedVideo',
-
    width: 100%;
+
    'author'=>'Jim R. Wilson - wilson.jim.r&lt;at&gt;gmail.com',
-
    margin: 0;
+
    'url'=>'http://jimbojw.com/wiki/index.php?title=EmbedVideo',
-
    padding: 0;
+
    'description'=>'Adds a parser function aembedding video from popular sources.',
-
}
+
    'version'=>'0.1.2'
-
.visualClear { clear: both; }
+
);
   
   
-
/* general styles */
+
/**
-
   
+
  * Wrapper class for encapsulating EmbedVideo related parser methods
-
table {
+
-
    font-size: 100%;
+
-
    background: White;
+
-
}
+
-
a {
+
-
    text-decoration: none;
+
-
    color: #002bb8;
+
-
    background: none;
+
-
}
+
-
a:visited { color: #5a3696; }
+
-
a:active { color: #ffa500; }
+
-
a:hover { text-decoration: underline; }
+
-
a.stub { color: #772233; }
+
-
a.new,
+
-
#p-personal a.new { color:#ba0000; }
+
-
a.new:visited,
+
-
#p-personal a.new:visited { color:#a55858; }
+
-
+
-
img {
+
-
    border: none;
+
-
    vertical-align: middle;
+
-
}
+
-
p {
+
-
    margin: 0.4em 0em 0.5em 0em;
+
-
    line-height: 1.5em;
+
-
}
+
-
+
-
p img { margin: 0; }
+
-
+
-
hr {
+
-
    height: 1px;
+
-
    color: #aaaaaa;
+
-
    background-color: #aaaaaa;
+
-
    border: 0;
+
-
    margin: 0.2em 0 0.2em 0;
+
-
}
+
-
+
-
h1, h2, h3, h4, h5, h6 {
+
-
    color: Black;
+
-
    background: none;
+
-
    font-weight: normal;
+
-
    margin: 0;
+
-
    padding-top: 0.5em;
+
-
    padding-bottom: 0.17em;
+
-
    border-bottom: 1px solid #aaaaaa;
+
-
}
+
-
h1 { font-size: 188%; }
+
-
h2 { font-size: 150%; }
+
-
h3, h4, h5, h6 {
+
-
    border-bottom: none;
+
-
    font-weight: bold;
+
-
}
+
-
h3 { font-size: 132%; }
+
-
h4 { font-size: 116%; }
+
-
h5 { font-size: 100%; }
+
-
h6 { font-size: 80%;  }
+
-
+
-
ul {
+
-
    line-height: 1.5em;
+
-
    list-style-type: square;
+
-
    margin: 0.3em 0 0 1.5em;
+
-
    padding:0;
+
-
    list-style-image: url("bullet.gif");
+
-
}
+
-
ol {
+
-
    line-height: 1.5em;
+
-
    margin: 0.3em 0 0 3.2em;
+
-
    padding:0;
+
-
    list-style-image: none;
+
-
}
+
-
li { margin-bottom: 0.1em; }
+
-
dt {
+
-
    font-weight: bold;
+
-
    margin-bottom: 0.1em;
+
-
}
+
-
dl{
+
-
    margin-top: 0.2em;
+
-
    margin-bottom: 0.5em;
+
-
}
+
-
dd {
+
-
    line-height: 1.5em;
+
-
    margin-left: 2em;
+
-
    margin-bottom: 0.1em;
+
-
}
+
-
+
-
fieldset {
+
-
    border: 1px solid #2f6fab;
+
-
    margin: 1em 0em 1em 0em;
+
-
    padding: 0em 1em 1em 1em;
+
-
    line-height: 1.5em;
+
-
}
+
-
legend {
+
-
    background: White;
+
-
    padding: 0.5em;
+
-
    font-size: 95%;
+
-
}
+
-
form {
+
-
    border: none;
+
-
    margin: 0;
+
-
}
+
-
+
-
textarea {
+
-
    width: 100%;
+
-
    padding: 0.1em;
+
-
}
+
-
+
-
+
-
input.historysubmit {
+
-
    padding: 0 0.3em 0.3em 0.3em !important;
+
-
    font-size: 94%;
+
-
    cursor: pointer;
+
-
    height: 1.7em !important;
+
-
    margin-left: 1.6em;
+
-
}
+
-
select {
+
-
vertical-align: top;
+
-
}
+
-
abbr, acronym, .explain {
+
-
    border-bottom: 1px dotted Black;
+
-
    color: Black;
+
-
    background: none;
+
-
    cursor: help;
+
-
}
+
-
q {
+
-
    font-family: Times, "Times New Roman", serif;
+
-
    font-style: italic;
+
-
}
+
-
/* disabled for now
+
-
blockquote {
+
-
    font-family: Times, "Times New Roman", serif;
+
-
    font-style: italic;
+
-
}*/
+
-
code { background-color: #f9f9f9; }
+
-
pre {
+
-
    padding: 1em;
+
-
    border: 1px dashed #2f6fab;
+
-
    color: Black;
+
-
    background-color: #f9f9f9;
+
-
    line-height: 1.1em;
+
-
}
+
-
+
-
+
-
/*
+
-
** the main content area
+
  */
  */
 +
class EmbedVideo {
   
   
-
#siteSub { display: none; }
+
    /**
-
#contentSub {
+
    * Sets up parser functions.
-
    font-size: 84%;
+
    */
-
    line-height: 1.2em;
+
    function setup( ) {
-
    margin: 0 0 1.4em 1em;
+
   
-
    color: #7d7d7d;
+
        # Setup parser hook
-
    width: auto;
+
    global $wgParser, $wgVersion;
-
}
+
    $hook = (version_compare($wgVersion, '1.7', '<')?'#ev':'ev');
-
span.subpages { display: block; }
+
    $wgParser->setFunctionHook( $hook, array($this, 'parserFunction') );
 +
   
 +
    # Add system messages
 +
    global $wgMessageCache;
 +
        $wgMessageCache->addMessage('embedvideo-missing-params', 'EmbedVideo is missing a required parameter.');
 +
        $wgMessageCache->addMessage('embedvideo-bad-params', 'EmbedVideo received a bad parameter.');
 +
        $wgMessageCache->addMessage('embedvideo-unparsable-param-string', 'EmbedVideo received the unparsable parameter string "<tt>$1</tt>".');
 +
        $wgMessageCache->addMessage('embedvideo-unrecognized-service', 'EmbedVideo does not recognize the video service "<tt>$1</tt>".');
 +
        $wgMessageCache->addMessage('embedvideo-bad-id', 'EmbedVideo received the bad id "$1" for the service "$2".');
 +
        $wgMessageCache->addMessage('embedvideo-illegal-width', 'EmbedVideo received the illegal width parameter "$1".');
 +
        $wgMessageCache->addMessage('embedvideo-embed-clause',
 +
            '<object width="$2" height="$3">'.
 +
            '<param name="movie" value="$1"></param>'.
 +
            '<param name="wmode" value="transparent"></param>'.
 +
            '<embed src="$1" type="application/x-shockwave-flash" '.
 +
            'wmode="transparent" width="$2" height="$3">'.
 +
            '</embed></object>'
 +
        );
 +
    }
 +
   
 +
    /**
 +
    * Adds magic words for parser functions.
 +
    * @param Array $magicWords
 +
    * @param $langCode
 +
    * @return Boolean Always true
 +
    */
 +
    function parserFunctionMagic( &$magicWords, $langCode='en' ) {
 +
        $magicWords['ev'] = array( 0, 'ev' );
 +
        return true;
 +
    }
 +
   
 +
    /**
 +
    * Embeds video of the chosen service
 +
    * @param Parser $parser Instance of running Parser.
 +
    * @param String $service Which online service has the video.
 +
    * @param String $id Identifier of the chosen service
 +
    * @param String $width Width of video (optional)
 +
    * @return String Encoded representation of input params (to be processed later)
 +
    */
 +
    function parserFunction( $parser, $service=null, $id=null, $width=null ) {
 +
        if ($service===null || $id===null) return '<div class="errorbox">'.wfMsg('embedvideo-missing-params').'</div>';
   
   
-
/* Some space under the headers in the content area */
+
        $params = array(
-
#bodyContent h1, #bodyContent h2 { margin-bottom:0.6em; }
+
            'service' => trim($service),
-
#bodyContent h3,
+
            'id' => trim($id),
-
#bodyContent h4,
+
            'width' => ($width===null?null:trim($width)),
-
#bodyContent h5 {
+
        );
-
    margin-bottom: 0.3em;
+
-
}
+
-
.firstHeading { margin-bottom:0.1em; }
+
   
   
-
/* user notification thing */
+
        global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
-
.usermessage {
+
        if (!is_numeric($wgEmbedVideoMinWidth) || $wgEmbedVideoMinWidth<100) $wgEmbedVideoMinWidth = 100;
-
    background-color: #ffce7b;
+
        if (!is_numeric($wgEmbedVideoMaxWidth) || $wgEmbedVideoMaxWidth>1024) $wgEmbedVideoMaxWidth = 1024;
-
    border: 1px solid #ffa500;
+
       
-
    color: Black;
+
        global $wgEmbedVideoServiceList;
-
    font-weight: bold;
+
        $service = $wgEmbedVideoServiceList[$params['service']];
-
    margin: 2em 0em 1em 0em;
+
        if (!$service) return '<div class="errorbox">'.wfMsg('embedvideo-unrecognized-service', @htmlspecialchars($params['service'])).'</div>';
-
    padding: 0.5em 1em;
+
       
-
    vertical-align: middle;
+
        $id = htmlspecialchars($params['id']);
-
}
+
        $idpattern = ( isset($service['id_pattern']) ? $service['id_pattern'] : '%[^A-Za-z0-9_\\-]%' );
-
#siteNotice {
+
        if ($id==null || preg_match($idpattern,$id)) {
-
    text-align: center;
+
            return '<div class="errorbox">'.wfMsgForContent('embedvideo-bad-id', $id, @htmlspecialchars($params['service'])).'</div>';
-
    font-size: 95%;
+
        }
-
    padding: 0 0.9em 0 0.9em;
+
   
-
}
+
        # Build URL and output embedded flash object
-
#siteNotice p {
+
        $ratio = 425 / 350;
-
    margin: 0;
+
        $width = 425;
-
    padding: 0;
+
       
-
}
+
        if ($params['width']!==null) {
-
.error {
+
            if (
-
    color: red;
+
                !is_numeric($params['width']) ||
-
    font-size: larger;
+
                $params['width'] < $wgEmbedVideoMinWidth ||
-
}
+
                $params['width'] > $wgEmbedVideoMaxWidth
-
#catlinks {
+
            ) return
-
    border:1px solid #aaaaaa;
+
                '<div class="errorbox">'.
-
    background-color:#f9f9f9;
+
                wfMsgForContent('embedvideo-illegal-width', @htmlspecialchars($params['width'])).
-
    padding:5px;
+
                '</div>';
-
    margin-top: 1em;
+
            $width = $params['width'];
-
    clear: both;
+
        }
-
}
+
        $height = round($width / $ratio);
-
/* currently unused, intended to be used by a metadata box
+
        $url = wfMsgReplaceArgs($service['url'], array($id, $width, $height));
-
in the bottom-right corner of the content area */
+
       
-
.documentDescription {
+
        return $parser->insertStripItem(
-
    /* The summary text describing the document */
+
            wfMsgForContent('embedvideo-embed-clause', $url, $width, $height),
-
    font-weight: bold;
+
            $parser->mStripState
-
    display: block;
+
        );
-
    margin: 1em 0em;
+
    }
-
    line-height: 1.5em;
+
-
}
+
-
.documentByLine {
+
-
    text-align: right;
+
-
    font-size: 90%;
+
-
    clear: both;
+
-
    font-weight: normal;
+
-
    color: #76797c;
+
-
}
+
   
   
-
/* emulate center */
+
}
-
.center {
+
-
    width: 100%;
+
-
    text-align: center;
+
-
}
+
-
*.center * {
+
-
    margin-left: auto;
+
-
    margin-right: auto;
+
-
}
+
-
/* small for tables and similar */
+
-
.small, .small * { font-size: 94%; }
+
-
table.small { font-size: 100% }
+
   
   
-
/*
+
/**
-
  ** content styles
+
  * Wrapper function for language magic call (hack for 1.6
  */
  */
   
   
-
#toc {
+
# Create global instance and wire it up!
-
    /*border:1px solid #2f6fab;*/
+
$wgEmbedVideo = new EmbedVideo();
-
    border:1px solid #aaaaaa;
+
$wgExtensionFunctions[] = array($wgEmbedVideo, 'setup');
-
    background-color:#f9f9f9;
+
if (version_compare($wgVersion, '1.7', '<')) {
-
    padding:5px;
+
    # Hack solution to resolve 1.6 array parameter nullification for hook args
-
    font-size: 95%;
+
    function wfEmbedVideoLanguageGetMagic( &$magicWords ) {
-
}
+
        global $wgEmbedVideo;
-
#toc .tocindent { margin-left: 2em; }
+
        $wgEmbedVideo->parserFunctionMagic( $magicWords );
-
#toc .tocline { margin-bottom: 0px; }
+
        return true;
-
#toc p { margin: 0 }
+
    }
-
#toc .toctoggle { font-size: 94%; }
+
    $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic';
-
#toc .editsection {
+
} else {
-
    margin-top: 0.7em;
+
    $wgHooks['LanguageGetMagic'][] = array($wgEmbedVideo, 'parserFunctionMagic');
-
    font-size: 94%;
+
}
-
}
+
   
   
-
/* images */
+
# Build services list (may be augmented in LocalSettings.php)
-
div.floatright, table.floatright {
+
$wgEmbedVideoServiceList = array(
-
    clear: right;
+
    'dailymotion' => array(
-
    float: right;
+
        'url' => 'http://www.dailymotion.com/swf/$1'
-
    position: relative;
+
    ),
-
    margin: 0 0 0.5em 0.5em;
+
    'funnyordie' => array(
-
    border: 0
+
        'url' =>
-
/*
+
            'http://www.funnyordie.com/v1/flvideo/fodplayer.swf?file='.
-
    border: 0.5em solid White;
+
            'http://funnyordie.vo.llnwd.net/o16/$1.flv&autoStart=false'
-
    border-width: 0.5em 0 0.8em 1.4em;
+
    ),
-
*/
+
    'googlevideo' => array(
-
}
+
        'id_pattern'=>'%[^0-9\\-]%',
-
div.floatright p { font-style: italic; }
+
        'url' => 'http://video.google.com/googleplayer.swf?docId=$1'
-
div.floatleft, table.floatleft {
+
    ),
-
    float: left;
+
    'sevenload' => array(
-
    position: relative;
+
        'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1'
-
    margin: 0 0.5em 0.5em 0;
+
    ),
-
    border: 0
+
    'revver' => array(
-
/*
+
        'url' => 'http://flash.revver.com/player/1.0/player.swf?mediaId=$1'
-
    margin: 0.3em 0.5em 0.5em 0;
+
    ),
-
    border: 0.5em solid White;
+
    'youtube' => array(
-
    border-width: 0.5em 1.4em 0.8em 0;
+
        'url'=>'http://www.youtube.com/v/$1'
-
*/
+
    )
-
}
+
);
-
div.floatleft p { font-style: italic; }
+
-
/* thumbnails */
+
-
div.thumb {
+
-
    margin-bottom: 0.5em;
+
-
    border-style: solid; border-color: White;
+
-
    width: auto;
+
-
}
+
-
div.thumb div {
+
-
    border:1px solid #cccccc;
+
-
    padding: 3px !important;
+
-
    background-color:#f9f9f9;
+
-
    font-size: 94%;
+
-
    text-align: center;
+
-
    overflow: hidden;
+
-
}
+
-
div.thumb div a img {
+
-
    border:1px solid #cccccc;
+
-
}
+
-
div.thumb div div.thumbcaption {
+
-
    border: none;
+
-
    text-align: left;
+
-
    line-height: 1.4em;
+
-
    padding: 0.3em 0 0.1em 0;
+
-
}
+
-
div.magnify {
+
-
    float: right;
+
-
    border: none !important;
+
-
    background: none !important;
+
-
}
+
-
div.magnify a, div.magnify img {
+
-
    display: block;
+
-
    border: none !important;
+
-
    background: none !important;
+
-
}
+
-
div.tright {
+
-
    clear: right;
+
-
    float: right;
+
-
    border-width: 0.5em 0 0.8em 1.4em;
+
-
}
+
-
div.tleft {
+
-
    float: left;
+
-
    margin-right:0.5em;
+
-
    border-width: 0.5em 1.4em 0.8em 0;
+
-
}
+
-
.urlexpansion,
+
-
.hiddenStructure {
+
-
    display: none;
+
-
}
+
-
img.tex { vertical-align: middle; }
+
-
span.texhtml { font-family: serif; }
+
-
+
-
/*
+
-
** classes for special content elements like town boxes
+
-
** intended to be referenced directly from the wiki src
+
-
*/
+
-
+
-
/*
+
-
** User styles
+
-
*/
+
-
/* table standards */
+
-
table.rimage {
+
-
    float:right;
+
-
    position:relative;
+
-
    margin-left:1em;
+
-
    margin-bottom:1em;
+
-
    text-align:center;
+
-
}
+
-
.toccolours {
+
-
    border:1px solid #aaaaaa;
+
-
    background-color:#f9f9f9;
+
-
    padding:5px;
+
-
    font-size: 95%;
+
-
}
+
-
div.townBox {
+
-
    position:relative;
+
-
    float:right;
+
-
    background:White;
+
-
    margin-left:1em;
+
-
    border: 1px solid gray;
+
-
    padding:0.3em;
+
-
    width: 200px;
+
-
    overflow: hidden;
+
-
    clear: right;
+
-
}
+
-
div.townBox dl {
+
-
    padding: 0;
+
-
    margin: 0 0 0.3em 0;
+
-
    font-size: 96%;
+
-
}
+
-
div.townBox dl dt {
+
-
    background: none;
+
-
    margin: 0.4em 0 0 0;
+
-
}
+
-
div.townBox dl dd {
+
-
    margin: 0.1em 0 0 1.1em;
+
-
    background-color: #f3f3f3;
+
-
}
+
-
+
-
/*
+
-
** edit views etc
+
-
*/
+
-
.special li {
+
-
    line-height: 1.4em;
+
-
    margin: 0;
+
-
    padding: 0;
+
-
}
+
-
+
-
/* Page history styling */
+
-
/* the auto-generated edit comments */
+
-
.autocomment { color: gray; }
+
-
#pagehistory span.user {
+
-
    margin-left: 1.4em;
+
-
    margin-right: 0.4em;
+
-
}
+
-
#pagehistory span.minor { font-weight: bold; }
+
-
#pagehistory li { border: 1px solid White; }
+
-
#pagehistory li.selected {
+
-
    background-color:#f9f9f9;
+
-
    border:1px dashed #aaaaaa;
+
-
}
+
-
/*
+
-
** Diff rendering
+
-
*/
+
-
table.diff { background:white; }
+
-
td.diff-otitle { background:#ffffff; }
+
-
td.diff-ntitle { background:#ffffff; }
+
-
td.diff-addedline {
+
-
    background:#ccffcc;
+
-
    font-size: smaller;
+
-
}
+
-
td.diff-deletedline {
+
-
    background:#ffffaa;
+
-
    font-size: smaller;
+
-
}
+
-
td.diff-context {
+
-
    background:#eeeeee;
+
-
    font-size: smaller;
+
-
}
+
-
span.diffchange { color: red; font-weight: bold; }
+
-
+
-
/*
+
-
** keep the whitespace in front of the ^=, hides rule from konqueror
+
-
** this is css3, the validator doesn't like it when validating as css2
+
-
*/
+
-
#bodyContent a[href ^="http://"],
+
-
#bodyContent a[href ^="gopher://"] {
+
-
    background: url(external.png) center right no-repeat;
+
-
    padding-right: 13px;
+
-
}
+
-
#bodyContent a[href ^="https://"],
+
-
.link-https {
+
-
    background: url("lock_icon.gif") center right no-repeat;
+
-
    padding-right: 16px;
+
-
}
+
-
#bodyContent a[href ^="mailto:"],
+
-
.link-mailto {
+
-
    background: url("mail_icon.gif") center right no-repeat;
+
-
    padding-right: 18px;
+
-
}
+
-
#bodyContent a[href ^="news://"] {
+
-
    background: url("news_icon.png") center right no-repeat;
+
-
    padding-right: 18px;
+
-
}
+
-
#bodyContent a[href ^="ftp://"],
+
-
.link-ftp {
+
-
    background: url("file_icon.gif") center right no-repeat;
+
-
    padding-right: 18px;
+
-
}
+
-
#bodyContent a[href ^="irc://"],
+
-
.link-irc {
+
-
    background: url("discussionitem_icon.gif") center right no-repeat;
+
-
    padding-right: 18px;
+
-
}
+
-
/* disable interwiki styling */
+
-
#bodyContent a.extiw,
+
-
#bodyContent a.extiw:active {
+
-
    color: #3366bb;
+
-
    background: none;
+
-
    padding: 0;
+
-
}
+
-
#bodyContent a.external { color: #3366bb; }
+
-
/* this can be used in the content area to switch off
+
-
special external link styling */
+
-
#bodyContent .plainlinks a {
+
-
    background: none !important;
+
-
    padding: 0;
+
-
}
+
-
/*
+
-
** Structural Elements
+
-
*/
+
-
+
-
/*
+
-
** general portlet styles (elements in the quickbar)
+
-
*/
+
-
.portlet {
+
-
    border: none;
+
-
    margin: 0 0 0.5em 0em;
+
-
    float: none;
+
-
    padding: 0;
+
-
    width: 11.6em;
+
-
    overflow: hidden;
+
-
}
+
-
.portlet h4 {
+
-
    font-size: 95%;
+
-
    font-weight: normal;
+
-
    white-space: nowrap;
+
-
}
+
-
.portlet h5 {
+
-
    background: transparent;
+
-
    padding: 0em 1em 0em 0.5em;
+
-
    text-transform: lowercase;
+
-
    display: inline;
+
-
    font-size: 91%;
+
-
    height: 1em;
+
-
    font-weight: normal;
+
-
    white-space: nowrap;
+
-
}
+
-
.portlet h6 {
+
-
    background: #ffae2e;
+
-
    border: 1px solid #2f6fab;
+
-
    border-style: solid solid none solid;
+
-
    padding: 0em 1em 0em 1em;
+
-
    text-transform: lowercase;
+
-
    display: block;
+
-
    font-size: 1em;
+
-
    height: 1.2em;
+
-
    font-weight: normal;
+
-
    white-space: nowrap;
+
-
}
+
-
.pBody {
+
-
    font-size: 95%;
+
-
    background: White;
+
-
    border-collapse: collapse;
+
-
    border: 1px solid #aaaaaa;
+
-
    padding: 0 0.8em 0.3em 0.5em;
+
-
}
+
-
.portlet h1,
+
-
.portlet h2,
+
-
.portlet h3,
+
-
.portlet h4 {
+
-
    margin: 0;
+
-
    padding: 0;
+
-
}
+
-
.portlet ul {
+
-
    line-height: 1.5em;
+
-
    list-style-type: square;
+
-
    list-style-image: url("bullet.gif");
+
-
    font-size:95%;
+
-
}
+
-
.portlet li {
+
-
    padding: 0;
+
-
    margin: 0;
+
-
}
+
-
+
-
/*
+
-
** Logo properties
+
-
*/
+
-
+
-
#p-logo {
+
-
    z-index: 3;
+
-
    position:absolute; /*needed to use z-index */
+
-
    top: 0;
+
-
    left: 0;
+
-
    height: 155px;
+
-
    width: 12em;
+
-
    overflow: visible;
+
-
}
+
-
#p-logo h5 { display: none; }
+
-
#p-logo a,
+
-
#p-logo a:hover {
+
-
    display: block;
+
-
    height: 155px;
+
-
    width: 12.2em;
+
-
    background-repeat: no-repeat;
+
-
    background-position: 35% 50% !important;
+
-
    text-decoration: none;
+
-
}
+
-
+
-
/*
+
-
** the navigation portlet
+
-
*/
+
-
+
-
#p-nav {
+
-
    position:relative;
+
-
    z-index:3;
+
-
}
+
-
+
-
/*
+
-
** Search portlet
+
-
*/
+
-
#p-search {
+
-
    position:relative;
+
-
    z-index:3;
+
-
}
+
-
#p-search .pBody {
+
-
    text-align: center;
+
-
}
+
-
input.searchButton {
+
-
    margin-top:1px;
+
-
    font-size: 95%;
+
-
}
+
-
#searchGoButton {
+
-
    padding-left: .5em;
+
-
    padding-right: .5em;
+
-
    font-weight: bold;
+
-
}
+
-
#searchInput {
+
-
    width:10.9em;
+
-
    margin: 0;
+
-
    font-size: 95%;
+
-
}
+
-
#p-search .pBody {
+
-
    padding: 0.5em 0.4em 0.4em 0.4em;
+
-
}
+
-
+
-
/*
+
-
** the personal toolbar
+
-
*/
+
-
+
-
#p-personal {
+
-
    width:100%;
+
-
    white-space:nowrap;
+
-
    padding: 0;
+
-
    margin: 0;
+
-
    position:absolute;
+
-
    left:0px;
+
-
    top:0px;
+
-
    z-index: 0;
+
-
    border: none;
+
-
    background: none;
+
-
    overflow: visible;
+
-
    line-height: 1.2em;
+
-
}
+
-
+
-
#p-personal h5 {
+
-
    display:none;
+
-
}
+
-
#p-personal .portlet,
+
-
#p-personal .pBody {
+
-
    padding:0;
+
-
    margin:0;
+
-
    border: none;
+
-
    z-index:0;
+
-
    overflow: visible;
+
-
    background: none;
+
-
}
+
-
/* this is the ul contained in the portlet */
+
-
#p-personal ul {
+
-
    border: none;
+
-
    line-height: 1.4em;
+
-
    color: #2f6fab;
+
-
    padding: 0em 2em 0 3em;
+
-
    margin: 0;
+
-
    text-align: right;
+
-
    text-transform: lowercase;
+
-
    list-style: none;
+
-
    z-index:0;
+
-
    background: none;
+
-
}
+
-
#p-personal li {
+
-
    z-index:0;
+
-
    border:none;
+
-
    padding:0;
+
-
    display: inline;
+
-
    color: #2f6fab;
+
-
    margin-left: 1em;
+
-
    line-height: 1.2em;
+
-
    background: none;
+
-
}
+
-
#p-personal li a {
+
-
    text-decoration: none;
+
-
    color: #005896;
+
-
    padding-bottom: 0.2em;
+
-
    background: none;
+
-
}
+
-
#p-personal li a:hover {
+
-
    background-color: White;
+
-
    padding-bottom: 0.2em;
+
-
    text-decoration: none;
+
-
}
+
-
+
-
/* the icon in front of the user name, single quotes
+
-
in bg url to hide it from iemac */
+
-
li#pt-userpage,
+
-
li#pt-anonuserpage,
+
-
li#pt-login {
+
-
    background: url('user.gif') top left no-repeat;
+
-
    padding-left: 20px;
+
-
    text-transform: none;
+
-
}
+
-
+
-
/*
+
-
** the page-related actions- page/talk, edit etc
+
-
*/
+
-
#p-cactions {
+
-
    position:absolute;
+
-
    top: 1.3em;
+
-
    left: 11.5em;
+
-
    margin: 0;
+
-
    white-space:nowrap;
+
-
    width: 76%;
+
-
    line-height: 1.1em;
+
-
    overflow: visible;
+
-
    background: none;
+
-
    border-collapse: collapse;
+
-
    padding-left: 1em;
+
-
    list-style: none;
+
-
    font-size: 95%;
+
-
}
+
-
#p-cactions .hiddenStructure { display: none; }
+
-
#p-cactions ul {
+
-
    list-style: none;
+
-
}
+
-
#p-cactions li {
+
-
    display: inline;
+
-
    border: 1px solid #aaaaaa;
+
-
    border-bottom: none;
+
-
    padding: 0 0 0.1em 0;
+
-
    margin: 0 0.3em 0 0;
+
-
    overflow: visible;
+
-
    background: White;
+
-
}
+
-
#p-cactions li.selected {
+
-
    border-color: #fabd23;
+
-
    padding: 0 0 0.2em 0;
+
-
}
+
-
#p-cactions li a {
+
-
    background-color: White;
+
-
    color: #002bb8;
+
-
    border: none;
+
-
    padding: 0 0.8em 0.3em 0.8em;
+
-
    text-decoration: none;
+
-
    text-transform: lowercase;
+
-
    position: relative;
+
-
    z-index: 0;
+
-
    margin: 0;
+
-
}
+
-
#p-cactions .selected a { z-index: 3; }
+
-
#p-cactions .new a { color:#ba0000; }
+
-
#p-cactions li a:hover {
+
-
    z-index: 3;
+
-
    text-decoration: none;
+
-
}
+
-
#p-cactions h5 { display: none; }
+
-
#p-cactions li.istalk { margin-right: 0; }
+
-
#p-cactions li.istalk a { padding-right: 0.5em; }
+
-
#p-cactions #ca-addsection a {
+
-
    padding-left: 0.4em;
+
-
    padding-right: 0.4em;
+
-
}
+
-
/* offsets to distinguish the tab groups */
+
-
li#ca-talk { margin-right: 1.6em; }
+
-
li#ca-watch, li#ca-unwatch, li#ca-varlang-0 { margin-left: 1.6em; }
+
-
+
-
+
-
/*
+
-
** the remaining portlets
+
-
*/
+
-
#p-tbx,
+
-
#p-lang {
+
-
    position:relative;
+
-
    z-index:3;
+
-
}
+
-
+
-
/*
+
-
** footer
+
-
*/
+
-
#footer {
+
-
    background-color: White;
+
-
    border-top: 1px solid #fabd23;
+
-
    border-bottom: 1px solid #fabd23;
+
-
    margin: 0.6em 0em 1em 0em;
+
-
    padding: 0.4em 0em 1.2em 0em;
+
-
    text-align: center;
+
-
    font-size: 90%;
+
-
}
+
-
#footer li {
+
-
    display: inline;
+
-
    margin: 0 1.3em;
+
-
}
+
-
/* hide from incapable browsers */
+
-
head:first-child+body #footer li { white-space: nowrap; }
+
-
#f-poweredbyico, #f-copyrightico {
+
-
    margin: 0 8px;
+
-
    position: relative;
+
-
    top: -2px; /* Bump it up just a tad */
+
-
}
+
-
#f-poweredbyico {
+
-
    float: right;
+
-
    height: 1%;
+
-
}
+
-
#f-copyrightico {
+
-
    float: left;
+
-
    height: 1%;
+
-
}
+
-
+
-
/* js pref toc */
+
-
#preftoc {
+
-
    float: left;
+
-
    margin: 1em 1em 1em 1em;
+
-
    width: 13em;
+
-
}
+
-
#preftoc li { border: 1px solid White; }
+
-
#preftoc li.selected {
+
-
    background-color:#f9f9f9;
+
-
    border:1px dashed #aaaaaa;
+
-
}
+
-
#preftoc a,
+
-
#preftoc a:active {
+
-
    display: block;
+
-
    color: #0014a6;
+
-
}
+
-
#prefcontrol {
+
-
    clear: both;
+
-
    float: left;
+
-
    margin-top: 1em;
+
-
}
+
-
div.prefsectiontip {
+
-
    font-size: 95%;
+
-
    margin-top: 1em;
+
-
}
+
-
fieldset.operaprefsection { margin-left: 15em }
+
-
+
-
/*
+
-
** IE/Mac fixes, hope to find a validating way to move this
+
-
** to a separate stylesheet. This would work but doesn't validate:
+
-
** @import("IEMacFixes.css");
+
-
*/
+
-
/* tabs: border on the a, not the div */
+
-
* > html #p-cactions li { border:none; }
+
-
* > html #p-cactions li a {
+
-
    border: 1px solid #aaaaaa;
+
-
    border-bottom: none;
+
-
}
+
-
* > html #p-cactions li.selected a { border-color: #fabd23; }
+
-
/* footer icons need a fixed width */
+
-
* > html #f-poweredbyico,
+
-
* > html #f-copyrightico { width: 88px; }
+
-
* > html #bodyContent,
+
-
* > html #bodyContent pre {
+
-
    overflow-x: auto;
+
-
    width: 100%;
+
-
    padding-bottom: 25px;
+
-
}
+
-
+
-
/* more IE fixes */
+
-
/* float/negative margin brokenness */
+
-
* html #footer {margin-top: 0;}
+
-
* html #column-content {
+
-
    display: inline;
+
-
    margin-bottom: 0;
+
-
}
+
-
* html div.editsection { font-size: smaller; }
+
-
#pagehistory li.selected { position: relative; }
+
-
+
-
/* Mac IE 5.0 fix; floated content turns invisible */
+
-
* > html #column-content {
+
-
    float: none;
+
-
}
+
-
* > html #column-one {
+
-
    position: absolute;
+
-
    left: 0;
+
-
    top: 0;
+
-
}
+
-
* > html #footer {
+
-
    margin-left: 13.2em;
+
-
}
+
-
.redirectText {
+
-
font-size:150%;
+
-
margin:5px;
+
-
}
+
-
+
-
.printfooter {
+
-
        display: none;
+
-
}
+
-
+
-
.not_patrolled {
+
-
background-color: #ffa;
+
-
}
+
-
div.patrollink {
+
-
font-size: 75%;
+
-
text-align: right;
+
-
}
+
-
span.newpage, span.minor, span.searchmatch {
+
-
font-weight: bold;
+
-
}
+
-
span.unpatrolled {
+
-
font-weight:bold;
+
-
color:red;
+
-
}
+
-
+
-
span.searchmatch {
+
-
color: red;
+
-
}
+
-
.sharedUploadNotice {
+
-
        font-style: italic;
+
-
}
+
-
+
-
span.updatedmarker {
+
-
color:black;
+
-
background-color:#00FF00;
+
-
}
+
-
span.newpageletter {
+
-
font-weight:bold;
+
-
color:black;
+
-
background-color:yellow;
+
-
}
+
-
span.minoreditletter {
+
-
color:black;
+
-
background-color:#C5FFE6;
+
-
}
+
-
+
-
table.gallery {
+
-
border:  1px solid #cccccc;
+
-
margin:  2px;
+
-
padding: 2px;
+
-
background-color:#ffffff;
+
-
}
+
-
+
-
table.gallery tr {
+
-
vertical-align:top;
+
-
}
+
-
+
-
table.gallery td {
+
-
vertical-align:top;
+
-
background-color:#f9f9f9;
+
-
border: solid 2px white;
+
-
}
+
-
+
-
div.gallerybox {
+
-
margin: 2px;
+
-
width:  150px;
+
-
}
+
-
+
-
div.gallerybox div.thumb {
+
-
text-align: center;
+
-
border: 1px solid #cccccc;
+
-
margin: 2px;
+
-
}
+
-
+
-
div.gallerytext {
+
-
font-size: 94%;
+
-
padding: 2px 4px;
+
-
}
+
   
   
-
#fundraising {
+
} # End MW Environment wrapper
-
  text-align: center;
+
//
-
  border: 1px solid gray;
+
     
-
  padding: 5px;
+
-
  margin-top: 5px;
+
-
}
+
  </style>
  </style>
 +
 +
<script type="text/javascript">
 +
  //Feel free to add your javascript code here.
 +
</script>

Current revision as of 01:56, 27 July 2008

<style type="text/css">
  /*
* EmbedVideo.php - Adds a parser function aembedding video from popular sources.
* @author Jim R. Wilson
* @version 0.1.2
* @copyright Copyright (C) 2007 Jim R. Wilson
* @license The MIT License - http://www.opensource.org/licenses/mit-license.php 
* -----------------------------------------------------------------------
* Description:
*     This is a MediaWiki extension which adds a parser function for embedding 
*     video from popular sources (configurable).
* Requirements:
*     MediaWiki 1.6.x, 1.9.x, 1.10.x or higher
*     PHP 4.x, 5.x or higher.
* Installation:
*     1. Drop this script (EmbedVideo.php) in $IP/extensions
*         Note: $IP is your MediaWiki install dir.
*     2. Enable the extension by adding this line to your LocalSettings.php:
*         require_once('extensions/EmbedVideo.php');
* Version Notes:
*     version 0.1.2:
*         Bug fix - now can be inserted in lists without breakage (from newlines)
*         Code cleanup - would previously give 'Notice' messages in PHP strict.
*     version 0.1.1:
*         Code cleanup - no functional difference.
*     version 0.1:
*         Initial release.
* -----------------------------------------------------------------------
* Copyright (c) 2007 Jim R. Wilson
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights to 
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 
* the Software, and to permit persons to whom the Software is furnished to do 
* so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in all 
* copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
* OTHER DEALINGS IN THE SOFTWARE. 
* -----------------------------------------------------------------------
*/

  1. Confirm MW environment

if (defined('MEDIAWIKI')) {

  1. Credits

$wgExtensionCredits['parserhook'][] = array(

   'name'=>'EmbedVideo',
   'author'=>'Jim R. Wilson - wilson.jim.r<at>gmail.com',
   'url'=>'http://jimbojw.com/wiki/index.php?title=EmbedVideo',
   'description'=>'Adds a parser function aembedding video from popular sources.',
   'version'=>'0.1.2'

);

/**

* Wrapper class for encapsulating EmbedVideo related parser methods
*/

class EmbedVideo {

   /**
    * Sets up parser functions.
    */
   function setup( ) {
   
       # Setup parser hook
   	global $wgParser, $wgVersion;
   	$hook = (version_compare($wgVersion, '1.7', '<')?'#ev':'ev');
   	$wgParser->setFunctionHook( $hook, array($this, 'parserFunction') );
   	
   	# Add system messages
   	global $wgMessageCache;
       $wgMessageCache->addMessage('embedvideo-missing-params', 'EmbedVideo is missing a required parameter.');
       $wgMessageCache->addMessage('embedvideo-bad-params', 'EmbedVideo received a bad parameter.');
       $wgMessageCache->addMessage('embedvideo-unparsable-param-string', 'EmbedVideo received the unparsable parameter string "$1".');
       $wgMessageCache->addMessage('embedvideo-unrecognized-service', 'EmbedVideo does not recognize the video service "$1".');
       $wgMessageCache->addMessage('embedvideo-bad-id', 'EmbedVideo received the bad id "$1" for the service "$2".');
       $wgMessageCache->addMessage('embedvideo-illegal-width', 'EmbedVideo received the illegal width parameter "$1".');
       $wgMessageCache->addMessage('embedvideo-embed-clause', 
           '<object width="$2" height="$3">'.
           '<param name="movie" value="$1"></param>'.
           '<param name="wmode" value="transparent"></param>'.
           '<embed src="$1" type="application/x-shockwave-flash" '.
           'wmode="transparent" width="$2" height="$3">'.
           '</embed></object>'
       );
   }
   
   /**
    * Adds magic words for parser functions.
    * @param Array $magicWords
    * @param $langCode
    * @return Boolean Always true
    */
   function parserFunctionMagic( &$magicWords, $langCode='en' ) {
       $magicWords['ev'] = array( 0, 'ev' );
       return true;
   }
   
   /**
    * Embeds video of the chosen service
    * @param Parser $parser Instance of running Parser.
    * @param String $service Which online service has the video.
    * @param String $id Identifier of the chosen service
    * @param String $width Width of video (optional)
    * @return String Encoded representation of input params (to be processed later)
    */
   function parserFunction( $parser, $service=null, $id=null, $width=null ) {
if ($service===null || $id===null) return '
'.wfMsg('embedvideo-missing-params').'
';
       $params = array(
           'service' => trim($service),
           'id' => trim($id),
           'width' => ($width===null?null:trim($width)),
       );

       global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
       if (!is_numeric($wgEmbedVideoMinWidth) || $wgEmbedVideoMinWidth<100) $wgEmbedVideoMinWidth = 100;
       if (!is_numeric($wgEmbedVideoMaxWidth) || $wgEmbedVideoMaxWidth>1024) $wgEmbedVideoMaxWidth = 1024;
       
       global $wgEmbedVideoServiceList;
       $service = $wgEmbedVideoServiceList[$params['service']];
if (!$service) return '
'.wfMsg('embedvideo-unrecognized-service', @htmlspecialchars($params['service'])).'
';
       $id = htmlspecialchars($params['id']);
       $idpattern = ( isset($service['id_pattern']) ? $service['id_pattern'] : '%[^A-Za-z0-9_\\-]%' );
       if ($id==null || preg_match($idpattern,$id)) {
return '
'.wfMsgForContent('embedvideo-bad-id', $id, @htmlspecialchars($params['service'])).'
';
       }
    
       # Build URL and output embedded flash object
       $ratio = 425 / 350;
       $width = 425;
       
       if ($params['width']!==null) {
           if (
               !is_numeric($params['width']) || 
               $params['width'] < $wgEmbedVideoMinWidth ||
               $params['width'] > $wgEmbedVideoMaxWidth
           ) return 
'
'.
               wfMsgForContent('embedvideo-illegal-width', @htmlspecialchars($params['width'])).
'
';
           $width = $params['width'];
       }
       $height = round($width / $ratio);
       $url = wfMsgReplaceArgs($service['url'], array($id, $width, $height));
       
       return $parser->insertStripItem(
           wfMsgForContent('embedvideo-embed-clause', $url, $width, $height),
           $parser->mStripState
       );
   }

}

/**

* Wrapper function for language magic call (hack for 1.6 
*/

  1. Create global instance and wire it up!

$wgEmbedVideo = new EmbedVideo(); $wgExtensionFunctions[] = array($wgEmbedVideo, 'setup'); if (version_compare($wgVersion, '1.7', '<')) {

   # Hack solution to resolve 1.6 array parameter nullification for hook args
   function wfEmbedVideoLanguageGetMagic( &$magicWords ) {
       global $wgEmbedVideo;
       $wgEmbedVideo->parserFunctionMagic( $magicWords );
       return true;
   }
   $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic';

} else {

   $wgHooks['LanguageGetMagic'][] = array($wgEmbedVideo, 'parserFunctionMagic');

}

  1. Build services list (may be augmented in LocalSettings.php)

$wgEmbedVideoServiceList = array(

   'dailymotion' => array(
       'url' => 'http://www.dailymotion.com/swf/$1'
   ),
   'funnyordie' => array(
       'url' => 
           'http://www.funnyordie.com/v1/flvideo/fodplayer.swf?file='.
           'http://funnyordie.vo.llnwd.net/o16/$1.flv&autoStart=false'
   ),
   'googlevideo' => array(
       'id_pattern'=>'%[^0-9\\-]%',
       'url' => 'http://video.google.com/googleplayer.swf?docId=$1'
   ),
   'sevenload' => array(
       'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1'
   ),
   'revver' => array(
       'url' => 'http://flash.revver.com/player/1.0/player.swf?mediaId=$1'
   ),
   'youtube' => array(
       'url'=>'http://www.youtube.com/v/$1'
   )

);

} # End MW Environment wrapper //

</style>
<script type="text/javascript">
  //Feel free to add your javascript code here.
</script>
Personal tools