http://www.mediawiki.org/wiki/Special:Code/MediaWiki/67471

Revision: 67471
Author:   siebrand
Date:     2010-06-06 16:29:09 +0000 (Sun, 06 Jun 2010)

Log Message:
-----------
Update indentation, stylize.php, update messages, headers, svn properties, i18n 
for description message.

Modified Paths:
--------------
    trunk/extensions/EmbedVideo/EmbedVideo.Services.php
    trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
    trunk/extensions/EmbedVideo/EmbedVideo.i18n.php
    trunk/extensions/EmbedVideo/EmbedVideo.php

Property Changed:
----------------
    trunk/extensions/EmbedVideo/CREDITS
    trunk/extensions/EmbedVideo/EmbedVideo.Services.php
    trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
    trunk/extensions/EmbedVideo/EmbedVideo.i18n.php
    trunk/extensions/EmbedVideo/EmbedVideo.php
    trunk/extensions/EmbedVideo/LICENSE
    trunk/extensions/EmbedVideo/README


Property changes on: trunk/extensions/EmbedVideo/CREDITS
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EmbedVideo/EmbedVideo.Services.php
===================================================================
--- trunk/extensions/EmbedVideo/EmbedVideo.Services.php 2010-06-06 15:56:50 UTC 
(rev 67470)
+++ trunk/extensions/EmbedVideo/EmbedVideo.Services.php 2010-06-06 16:29:09 UTC 
(rev 67471)
@@ -1,60 +1,63 @@
 <?php
+if ( !defined( 'MEDIAWIKI' ) ) die();
+/**
+ * @file
+ * @ingroup Extensions
+ */
 
 # Build services list (may be augmented in LocalSettings.php)
 $wgEmbedVideoServiceList = array(
-    'dailymotion' => array(
-        'url' => 'http://www.dailymotion.com/swf/$1'
-    ),
-    'divshare' => array(
-        'url' => 'http://www.divshare.com/flash/video2?myId=$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'
-    ),
-    'interiavideo' => array(
-        'url' => 
'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1',
-    ),
-    'interia' => array(
-        'url' => 
'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1',
-    ),
-    'revver' => array(
-        'url' => 'http://flash.revver.com/player/1.0/player.swf?mediaId=$1'
-    ),
-    'sevenload' => array(
-        'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1'
-    ),
-    'teachertube' => array(
-        'extern' =>
-            '<embed src="http://www.teachertube.com/embed/player.swf"; ' .
-                'width="470" ' .
-                'height="275" ' .
-                'bgcolor="undefined" ' .
-                'allowscriptaccess="always" ' .
-                'allowfullscreen="true" ' .
-                
'flashvars="file=http://www.teachertube.com/embedFLV.php?pg=video_$2' .
-                    '&menu=false' .
-                    '&frontcolor=ffffff&lightcolor=FF0000' .
-                    
'&logo=http://www.teachertube.com/www3/images/greylogo.swf' .
-                    '&skin=http://www.teachertube.com/embed/overlay.swf 
volume=80' .
-                    '&controlbar=over&displayclick=link' .
-                    
'&viral.link=http://www.teachertube.com/viewVideo.php?video_id=$2' .
-                    '&stretching=exactfit&plugins=viral-2' .
-                    '&viral.callout=none&viral.onpause=false' .
-                '"' .
-            '/>',
-    ),
-    'youtube' => array(
-        'url'=>'http://www.youtube.com/v/$1'
-    ),
-    'youtubehd' => array(
-        'url'=>'http://www.youtube.com/v/$1&ap=%2526fmt%3D22',
-        'default_width'=>720,
-        'default_ratio'=>16/9
-    )
+       'dailymotion' => array(
+               'url' => 'http://www.dailymotion.com/swf/$1'
+       ),
+       'divshare' => array(
+               'url' => 'http://www.divshare.com/flash/video2?myId=$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'
+       ),
+       'interiavideo' => array(
+               'url' => 
'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1',
+       ),
+       'interia' => array(
+               'url' => 
'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1',
+       ),
+       'revver' => array(
+               'url' => 
'http://flash.revver.com/player/1.0/player.swf?mediaId=$1'
+       ),
+       'sevenload' => array(
+               'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1'
+       ),
+       'teachertube' => array(
+               'extern' => '<embed 
src="http://www.teachertube.com/embed/player.swf"; ' .
+                       'width="470" ' .
+                       'height="275" ' .
+                       'bgcolor="undefined" ' .
+                       'allowscriptaccess="always" ' .
+                       'allowfullscreen="true" ' .
+                       
'flashvars="file=http://www.teachertube.com/embedFLV.php?pg=video_$2' .
+                       '&menu=false' .
+                       '&frontcolor=ffffff&lightcolor=FF0000' .
+                       
'&logo=http://www.teachertube.com/www3/images/greylogo.swf' .
+                       '&skin=http://www.teachertube.com/embed/overlay.swf 
volume=80' .
+                       '&controlbar=over&displayclick=link' .
+                       
'&viral.link=http://www.teachertube.com/viewVideo.php?video_id=$2' .
+                       '&stretching=exactfit&plugins=viral-2' .
+                       '&viral.callout=none&viral.onpause=false' .
+                       '"' .
+                       '/>',
+       ),
+       'youtube' => array(
+               'url' => 'http://www.youtube.com/v/$1'
+       ),
+       'youtubehd' => array(
+               'url' => 'http://www.youtube.com/v/$1&ap=%2526fmt%3D22',
+               'default_width' => 720,
+               'default_ratio' => 16 / 9
+       )
 );


Property changes on: trunk/extensions/EmbedVideo/EmbedVideo.Services.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
===================================================================
--- trunk/extensions/EmbedVideo/EmbedVideo.hooks.php    2010-06-06 15:56:50 UTC 
(rev 67470)
+++ trunk/extensions/EmbedVideo/EmbedVideo.hooks.php    2010-06-06 16:29:09 UTC 
(rev 67471)
@@ -1,259 +1,274 @@
 <?php
 /**
  * Wrapper class for encapsulating EmbedVideo related parser methods
+ *
+ * @file
+ * @ingroup Extensions
  */
-abstract class EmbedVideo
-{
-    protected static $initialized = false;
 
-    /**
-     * Sets up parser functions.
-     */
-    public static function setup()
-    {
-        # Setup parser hooks. ev is the primary hook, evp is supported for
-        # legacy purposes
-        global $wgVersion;
-        $prefix = version_compare($wgVersion, '1.7', '<') ? '#' : '';
-        EmbedVideo::addMagicWord($prefix, "ev", 
"EmbedVideo::parserFunction_ev");
-        EmbedVideo::addMagicWord($prefix, "evp", 
"EmbedVideo::parserFunction_evp");
-        return true;
-    }
+abstract class EmbedVideo {
+       protected static $initialized = false;
 
-    private static function addMagicWord($prefix, $word, $function)
-    {
-        global $wgParser;
-        $wgParser->setFunctionHook($prefix . $word, $function);
-    }
+       /**
+        * Sets up parser functions.
+        */
+       public static function setup() {
+               # Setup parser hooks. ev is the primary hook, evp is supported 
for
+               # legacy purposes
+               global $wgVersion;
 
-    /**
-     * Adds magic words for parser functions.
-     * @param Array $magicWords
-     * @param $langCode
-     * @return Boolean Always true
-     */
-    public static function parserFunctionMagic(&$magicWords, $langCode='en')
-    {
-        $magicWords['evp'] = array(0, 'evp');
-        $magicWords['ev']  = array(0, 'ev');
-        return true;
-    }
+               $prefix = version_compare( $wgVersion, '1.7', '<' ) ? '#' : '';
+               EmbedVideo::addMagicWord( $prefix, "ev", 
"EmbedVideo::parserFunction_ev" );
+               EmbedVideo::addMagicWord( $prefix, "evp", 
"EmbedVideo::parserFunction_evp" );
 
-    /**
-     * Embeds video of the chosen service, legacy support for 'evp' version of
-     * the tag
-     * @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)
-     */
-    public static function parserFunction_evp($parser, $service = null, $id = 
null, $desc = null,
-        $align = null, $width = null)
-    {
-        return EmbedVideo::parserFunction_ev($parser, $service, $id, $width, 
$align, $desc);
-    }
+               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)
-     * @param String $desc description to show (optional, unused)
-     * @param String $align alignment of the video (optional, unused)
-     * @return String Encoded representation of input params (to be processed 
later)
-     */
-    public static function parserFunction_ev($parser, $service = null, $id = 
null, $width = null,
-        $align = null, $desc = null)
-    {
-        global $wgScriptPath;
+       private static function addMagicWord( $prefix, $word, $function ) {
+               global $wgParser;
+               $wgParser->setFunctionHook( $prefix . $word, $function );
+       }
 
-        # Initialize things once
-        if (!EmbedVideo::$initialized) {
-            EmbedVideo::VerifyWidthMinAndMax();
-            # Add system messages
-            wfLoadExtensionMessages('embedvideo');
-            $parser->disableCache();
-            EmbedVideo::$initialized = true;
-        }
+       /**
+        ** Adds magic words for parser functions.
+        * @param Array $magicWords
+        * @param $langCode
+        * @return Boolean Always true
+        */
+       public static function parserFunctionMagic( &$magicWords, $langCode = 
'en' ) {
+               $magicWords['evp'] = array( 0, 'evp' );
+               $magicWords['ev']  = array( 0, 'ev' );
 
-        # Get the name of the host
-        if ($service === null || $id === null)
-            return EmbedVideo::errMissingParams($service, $id);
+               return true;
+       }
 
-        $service = trim($service);
-        $id = trim($id);
+       /**
+        * Embeds video of the chosen service, legacy support for 'evp' version 
of
+        * the tag
+        * @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)
+        */
+       public static function parserFunction_evp( $parser, $service = null, 
$id = null, $desc = null, $align = null, $width = null ) {
+               return EmbedVideo::parserFunction_ev( $parser, $service, $id, 
$width, $align, $desc );
+       }
 
-        $entry = EmbedVideo::getServiceEntry($service);
-        if (!$entry)
-            return EmbedVideo::errBadService($service);
+       /**
+        * 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)
+        * @param String $desc description to show (optional, unused)
+        * @param String $align alignment of the video (optional, unused)
+        * @return String Encoded representation of input params (to be 
processed later)
+        */
+       public static function parserFunction_ev( $parser, $service = null, $id 
= null, $width = null, $align = null, $desc = null ) {
+               global $wgScriptPath;
 
-        if (!EmbedVideo::sanitizeWidth($entry, $width))
-            return EmbedVideo::errBadWidth($width);
-        $height = EmbedVideo::getHeight($entry, $width);
+               # Initialize things once
+               if ( !EmbedVideo::$initialized ) {
+                       EmbedVideo::VerifyWidthMinAndMax();
+                       # Add system messages
+                       wfLoadExtensionMessages( 'embedvideo' );
+                       $parser->disableCache();
+                       EmbedVideo::$initialized = true;
+               }
 
-        $hasalign = ($align !== null);
-        if ($hasalign)
-            $desc = EmbedVideo::getDescriptionMarkup($desc);
+               # Get the name of the host
+               if ( $service === null || $id === null ) {
+                       return EmbedVideo::errMissingParams( $service, $id );
+               }
 
-        # If the service has an ID pattern specified, verify the id number
-        if (!EmbedVideo::verifyID($entry, $id))
-            return EmbedVideo::errBadID($service, $id);
+               $service = trim( $service );
+               $id = trim( $id );
 
-        # if the service has it's own custom extern declaration, use that 
instead
-        $clause = $entry['extern'];
-        if (isset($clause)) {
-            $clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, 
$width, $height));
-            if ($hasalign)
-                $clause = EmbedVideo::generateAlignExternClause($clause, 
$align, $desc, $width, $height);
-            return array($clause, 'noparse' => true, 'isHTML' => true);
-        }
+               $entry = EmbedVideo::getServiceEntry( $service );
+               if ( !$entry ) {
+                       return EmbedVideo::errBadService( $service );
+               }
 
-        # Build URL and output embedded flash object
-        $url = wfMsgReplaceArgs($entry['url'], array($id, $width, $height));
-        $clause = "";
-        if ($hasalign)
-            $clause = EmbedVideo::generateAlignClause($url, $width, $height, 
$align, $desc);
-        else
-            $clause = EmbedVideo::generateNormalClause($url, $width, $height);
-        return array($clause, 'noparse' => true, 'isHTML' => true);
-    }
+               if ( !EmbedVideo::sanitizeWidth( $entry, $width ) ) {
+                       return EmbedVideo::errBadWidth( $width );
+               }
+               $height = EmbedVideo::getHeight( $entry, $width );
 
-    # Return the HTML necessary to embed the video normally.
-    private static function generateNormalClause($url, $width, $height)
-    {
-        $clause = "<object width=\"{$width}\" height=\"{$height}\">" .
-            "<param name=\"movie\" value=\"{$url}\"></param>" .
-            "<param name=\"wmode\" value=\"transparent\"></param>" .
-            "<embed src=\"{$url}\" type=\"application/x-shockwave-flash\"" .
-            " wmode=\"transparent\" width=\"{$width}\" height=\"{$height}\">" .
-            "</embed></object>";
-        return $clause;
-    }
+               $hasalign = ( $align !== null );
+               if ( $hasalign ) {
+                       $desc = EmbedVideo::getDescriptionMarkup( $desc );
+               }
 
-    # The HTML necessary to embed the video with a custom embedding clause,
-    # specified align and description text
-    private static function generateAlignExternClause($clause, $align, $desc, 
$width, $height)
-    {
-        $clause = "<div class=\"thumb t{$align}\">" .
-            "<div class=\"thumbinner\" style=\"width: {$width}px;\">" .
-            $clause .
-            "<div class=\"thumbcaption\">" .
-            $desc .
-            "</div></div></div>";
-        return $clause;
-    }
+               # If the service has an ID pattern specified, verify the id 
number
+               if ( !EmbedVideo::verifyID( $entry, $id ) ) {
+                       return EmbedVideo::errBadID( $service, $id );
+               }
 
-    # Generate the HTML necessary to embed the video with the given alignment
-    # and text description
-    private static function generateAlignClause($url, $width, $height, $align, 
$desc)
-    {
-        $clause = "<div class=\"thumb t{$align}\">" .
-            "<div class=\"thumbinner\" style=\"width: {$width}px;\">" .
-            "<object width=\"{$width}\" height=\"{$height}\">" .
-            "<param name=\"movie\" value=\"{$url}\"></param>" .
-            "<param name=\"wmode\" value=\"transparent\"></param>" .
-            "<embed src=\"{$url}\" type=\"application/x-shockwave-flash\"" .
-            " wmode=\"transparent\" width=\"{$width}\" 
height=\"{$height}\"></embed>" .
-            "</object>" .
-            "<div class=\"thumbcaption\">" .
-            $desc .
-            "</div></div></div>";
-        return $clause;
-    }
+               # if the service has it's own custom extern declaration, use 
that instead
+               $clause = $entry['extern'];
+               if ( isset( $clause ) ) {
+                       $clause = wfMsgReplaceArgs( $clause, array( 
$wgScriptPath, $id, $width, $height ) );
+                       if ( $hasalign ) {
+                               $clause = 
EmbedVideo::generateAlignExternClause( $clause, $align, $desc, $width, $height 
);
+                       }
 
-    # Get the entry for the specified service, by name
-    private static function getServiceEntry($service)
-    {
-        # Get the entry in the list of services
-        global $wgEmbedVideoServiceList;
-        return $wgEmbedVideoServiceList[$service];
-    }
+                       return array( $clause, 'noparse' => true, 'isHTML' => 
true );
+               }
 
-    # Get the width. If there is no width specified, try to find a default
-    # width value for the service. If that isn't set, default to 425.
-    # If a width value is provided, verify that it is numerical and that it
-    # falls between the specified min and max size values. Return true if
-    # the width is suitable, false otherwise.
-    private static function sanitizeWidth($entry, &$width)
-    {
-        global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
-        if ($width === null) {
-            if (isset($entry['default_width']))
-                $width = $entry['default_width'];
-            else
-                $width = 425;
-            return true;
-        }
-        if (!is_numeric($width))
-            return false;
-        return $width >= $wgEmbedVideoMinWidth && $width <= 
$wgEmbedVideoMaxWidth;
-    }
+               # Build URL and output embedded flash object
+               $url = wfMsgReplaceArgs( $entry['url'], array( $id, $width, 
$height ) );
+               $clause = "";
+               if ( $hasalign ) {
+                       $clause = EmbedVideo::generateAlignClause( $url, 
$width, $height, $align, $desc );
+               } else {
+                       $clause = EmbedVideo::generateNormalClause( $url, 
$width, $height );
+               }
 
-    # Calculate the height from the given width. The default ratio is 450/350,
-    # but that may be overridden for some sites.
-    private static function getHeight($entry, $width)
-    {
-        $ratio = 425 / 350;
-        if (isset($entry['default_ratio']))
-            $ratio = $entry['default_ratio'];
-        return round($width / $ratio);
-    }
+               return array( $clause, 'noparse' => true, 'isHTML' => true );
+       }
 
-    # If we have a textual description, get the markup necessary to display
-    # it on the page.
-    private static function getDescriptionMarkup($desc)
-    {
-        if ($desc !== null)
-            return "<div class=\"thumbcaption\">$desc</div>";
-        return "";
-    }
+       # Return the HTML necessary to embed the video normally.
+       private static function generateNormalClause( $url, $width, $height ) {
+               $clause = "<object width=\"{$width}\" height=\"{$height}\">" .
+                       "<param name=\"movie\" value=\"{$url}\"></param>" .
+                       "<param name=\"wmode\" value=\"transparent\"></param>" .
+                       "<embed src=\"{$url}\" 
type=\"application/x-shockwave-flash\"" .
+                       " wmode=\"transparent\" width=\"{$width}\" 
height=\"{$height}\">" .
+                       "</embed></object>";
 
-    # Verify the id number of the video, if a pattern is provided.
-    private static function verifyID($entry, $id)
-    {
-        $idhtml = htmlspecialchars($id);
-        //$idpattern = (isset($entry['id_pattern']) ? $entry['id_pattern'] : 
'%[^A-Za-z0-9_\\-]%');
-        //if ($idhtml == null || preg_match($idpattern, $idhtml)) {
-        return ($idhtml != null);
-    }
+               return $clause;
+       }
 
-    # Get an error message for the case where the ID value is bad
-    private static function errBadID($service, $id)
-    {
-        $idhtml = htmlspecialchars($id);
-        $msg = wfMsgForContent('embedvideo-bad-id', $idhtml, 
@htmlspecialchars($service));
-        return '<div class="errorbox">' . $msg . '</div>';
-    }
+       # The HTML necessary to embed the video with a custom embedding clause,
+       # specified align and description text
+       private static function generateAlignExternClause( $clause, $align, 
$desc, $width, $height ) {
+               $clause = "<div class=\"thumb t{$align}\">" .
+                       "<div class=\"thumbinner\" style=\"width: 
{$width}px;\">" .
+                       $clause .
+                       "<div class=\"thumbcaption\">" .
+                       $desc .
+                       "</div></div></div>";
 
-    # Get an error message if the width is bad
-    private static function errBadWidth($width)
-    {
-        $msg = wfMsgForContent('embedvideo-illegal-width', 
@htmlspecialchars($width));
-        return '<div class="errorbox">' . $msg . '</div>';
-    }
+               return $clause;
+       }
 
-    # Get an error message if there are missing parameters
-    private static function errMissingParams($service, $id)
-    {
-        return '<div class="errorbox">' . wfMsg('embedvideo-missing-params') . 
'</div>';
-    }
+       # Generate the HTML necessary to embed the video with the given 
alignment
+       # and text description
+       private static function generateAlignClause( $url, $width, $height, 
$align, $desc ) {
+               $clause = "<div class=\"thumb t{$align}\">" .
+                       "<div class=\"thumbinner\" style=\"width: 
{$width}px;\">" .
+                       "<object width=\"{$width}\" height=\"{$height}\">" .
+                       "<param name=\"movie\" value=\"{$url}\"></param>" .
+                       "<param name=\"wmode\" value=\"transparent\"></param>" .
+                       "<embed src=\"{$url}\" 
type=\"application/x-shockwave-flash\"" .
+                       " wmode=\"transparent\" width=\"{$width}\" 
height=\"{$height}\"></embed>" .
+                       "</object>" .
+                       "<div class=\"thumbcaption\">" .
+               $desc .
+                       "</div></div></div>";
 
-    # Get an error message if the service name is bad
-    private static function errBadService($service)
-    {
-        $msg = wfMsg('embedvideo-unrecognized-service', 
@htmlspecialchars($service));
-        return '<div class="errorbox">' . $msg . '</div>';
-    }
+               return $clause;
+       }
 
-    # Verify that the min and max values for width are sane.
-    private static function VerifyWidthMinAndMax()
-    {
-        global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
-        if (!is_numeric($wgEmbedVideoMinWidth) || $wgEmbedVideoMinWidth < 100)
-            $wgEmbedVideoMinWidth = 100;
-        if (!is_numeric($wgEmbedVideoMaxWidth) || $wgEmbedVideoMaxWidth > 1024)
-            $wgEmbedVideoMaxWidth = 1024;
-    }
+       # Get the entry for the specified service, by name
+       private static function getServiceEntry( $service ) {
+               # Get the entry in the list of services
+               global $wgEmbedVideoServiceList;
+
+               return $wgEmbedVideoServiceList[$service];
+       }
+
+       # Get the width. If there is no width specified, try to find a default
+       # width value for the service. If that isn't set, default to 425.
+       # If a width value is provided, verify that it is numerical and that it
+       # falls between the specified min and max size values. Return true if
+       # the width is suitable, false otherwise.
+       private static function sanitizeWidth( $entry, &$width ) {
+               global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
+
+               if ( $width === null ) {
+                       if ( isset( $entry['default_width'] ) ) {
+                               $width = $entry['default_width'];
+                       } else {
+                               $width = 425;
+                       }
+
+                       return true;
+               }
+
+               if ( !is_numeric( $width ) ) {
+                       return false;
+               }
+
+               return $width >= $wgEmbedVideoMinWidth && $width <= 
$wgEmbedVideoMaxWidth;
+       }
+
+       # Calculate the height from the given width. The default ratio is 
450/350,
+       # but that may be overridden for some sites.
+       private static function getHeight( $entry, $width ) {
+               $ratio = 425 / 350;
+               if ( isset( $entry['default_ratio'] ) ) {
+                       $ratio = $entry['default_ratio'];
+               }
+
+               return round( $width / $ratio );
+       }
+
+       # If we have a textual description, get the markup necessary to display
+       # it on the page.
+       private static function getDescriptionMarkup( $desc ) {
+               if ( $desc !== null ) {
+                       return "<div class=\"thumbcaption\">$desc</div>";
+               }
+
+               return "";
+       }
+
+       # Verify the id number of the video, if a pattern is provided.
+       private static function verifyID( $entry, $id ) {
+               $idhtml = htmlspecialchars( $id );
+               // $idpattern = (isset($entry['id_pattern']) ? 
$entry['id_pattern'] : '%[^A-Za-z0-9_\\-]%');
+               // if ($idhtml == null || preg_match($idpattern, $idhtml)) {
+
+               return ( $idhtml != null );
+       }
+
+       # Get an error message for the case where the ID value is bad
+       private static function errBadID( $service, $id ) {
+               $idhtml = htmlspecialchars( $id );
+               $msg = wfMsgForContent( 'embedvideo-bad-id', $idhtml, 
@htmlspecialchars( $service ) );
+
+               return '<div class="errorbox">' . $msg . '</div>';
+       }
+
+       # Get an error message if the width is bad
+       private static function errBadWidth( $width ) {
+               $msg = wfMsgForContent( 'embedvideo-illegal-width', 
@htmlspecialchars( $width ) );
+
+               return '<div class="errorbox">' . $msg . '</div>';
+       }
+
+       # Get an error message if there are missing parameters
+       private static function errMissingParams( $service, $id ) {
+               return '<div class="errorbox">' . wfMsg( 
'embedvideo-missing-params' ) . '</div>';
+       }
+
+       # Get an error message if the service name is bad
+       private static function errBadService( $service ) {
+               $msg = wfMsg( 'embedvideo-unrecognized-service', 
@htmlspecialchars( $service ) );
+               return '<div class="errorbox">' . $msg . '</div>';
+       }
+
+       # Verify that the min and max values for width are sane.
+       private static function VerifyWidthMinAndMax() {
+               global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
+               if ( !is_numeric( $wgEmbedVideoMinWidth ) || 
$wgEmbedVideoMinWidth < 100 ) {
+                       $wgEmbedVideoMinWidth = 100;
+               }
+
+               if ( !is_numeric( $wgEmbedVideoMaxWidth ) || 
$wgEmbedVideoMaxWidth > 1024 ) {
+                       $wgEmbedVideoMaxWidth = 1024;
+               }
+       }
 }


Property changes on: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EmbedVideo/EmbedVideo.i18n.php
===================================================================
--- trunk/extensions/EmbedVideo/EmbedVideo.i18n.php     2010-06-06 15:56:50 UTC 
(rev 67470)
+++ trunk/extensions/EmbedVideo/EmbedVideo.i18n.php     2010-06-06 16:29:09 UTC 
(rev 67471)
@@ -1,11 +1,19 @@
 <?php
+/**
+ * Internationalisation file for extension EmbedVideo.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
 $messages = array();
+
 $messages['en'] = array(
-    'embedvideo-missing-params' => 'EmbedVideo is missing a required 
parameter.',
-    'embedvideo-bad-params' => 'EmbedVideo received a bad parameter.',
-    'embedvideo-unparsable-param-string' => 'EmbedVideo received the 
unparsable parameter string "<tt>$1</tt>".',
-    'embedvideo-unrecognized-service' => 'EmbedVideo does not recognize the 
video service "<tt>$1</tt>".',
-    'embedvideo-bad-id' => 'EmbedVideo received the bad id "$1" for the 
service "$2".',
-    'embedvideo-illegal-width' => 'EmbedVideo received the illegal width 
parameter "$1".',
+       'embedvideo-desc' => 'Adds a parser function for embedding video from 
popular sources',
+       'embedvideo-missing-params' => 'EmbedVideo is missing a required 
parameter.',
+       'embedvideo-bad-params' => 'EmbedVideo received a bad parameter.',
+       'embedvideo-unparsable-param-string' => 'EmbedVideo received the 
unparsable parameter string "<code>$1</code>".',
+       'embedvideo-unrecognized-service' => 'EmbedVideo does not recognize the 
video service "<code>$1</code>".',
+       'embedvideo-bad-id' => 'EmbedVideo received a bad id "$1" for the 
service "$2".',
+       'embedvideo-illegal-width' => 'EmbedVideo received the illegal width 
parameter "$1".',
 );
-?>


Property changes on: trunk/extensions/EmbedVideo/EmbedVideo.i18n.php
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EmbedVideo/EmbedVideo.php
===================================================================
--- trunk/extensions/EmbedVideo/EmbedVideo.php  2010-06-06 15:56:50 UTC (rev 
67470)
+++ trunk/extensions/EmbedVideo/EmbedVideo.php  2010-06-06 16:29:09 UTC (rev 
67471)
@@ -3,40 +3,42 @@
  * EmbedVideo.php - Adds a parser function embedding video from popular 
sources.
  * See README for details. For licensing information, see LICENSE. For a
  * complete list of contributors, see CREDITS
+ *
+ * @file
+ * @ingroup Extensions
  */
 
 # Confirm MW environment
-if (!defined('MEDIAWIKI')) {
-       echo <<<EOT
+if ( !defined( 'MEDIAWIKI' ) ) {
+       echo <<<EOT
 To install EmbedVideo, put the following line in LocalSettings.php:
 require_once( "\$IP/extensions/EmbedVideo/EmbedVido.php" );
 EOT;
-    exit( 1 );
+       exit( 1 );
 }
 
 # Credits
 $wgExtensionCredits['parserhook'][] = array(
-    'name'        => 'EmbedVideo',
-    'author'      => 'Jim R. Wilson and Andrew Whitworth',
-    'url'         => 'http://www.mediawiki.org/wiki/Extension:EmbedVideo',
-    'description' => 'Adds a parser function embedding video from popular 
sources.',
-    'version'     => '1.0'
+       'name'           => 'EmbedVideo',
+       'author'         => 'Jim R. Wilson and Andrew Whitworth',
+       'url'            => 
'http://www.mediawiki.org/wiki/Extension:EmbedVideo',
+       'descriptionmsg' => 'embedvideo-desc',
+       'version'        => '1.0'
 );
 
-$dir = dirname(__FILE__) . '/';
-require_once($dir . "EmbedVideo.hooks.php");
-require_once($dir . "EmbedVideo.Services.php");
+$dir = dirname( __FILE__ ) . '/';
+require_once( $dir . "EmbedVideo.hooks.php" );
+require_once( $dir . "EmbedVideo.Services.php" );
 $wgExtensionMessagesFiles['embedvideo'] = $dir . 'EmbedVideo.i18n.php';
 
-
 $wgHooks['ParserFirstCallInit'][] = "EmbedVideo::setup";
-if (version_compare($wgVersion, '1.7', '<')) {
-    # Hack solution to resolve 1.6 array parameter nullification for hook args
-    function wfEmbedVideoLanguageGetMagic( &$magicWords ) {
-        EmbedVideo::parserFunctionMagic( $magicWords );
-        return true;
-    }
-    $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic';
+if ( version_compare( $wgVersion, '1.7', '<' ) ) {
+       # Hack solution to resolve 1.6 array parameter nullification for hook 
args
+       function wfEmbedVideoLanguageGetMagic( &$magicWords ) {
+               EmbedVideo::parserFunctionMagic( $magicWords );
+               return true;
+       }
+       $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic';
 } else {
-    $wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic';
+       $wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic';
 }


Property changes on: trunk/extensions/EmbedVideo/EmbedVideo.php
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: trunk/extensions/EmbedVideo/LICENSE
___________________________________________________________________
Added: svn:eol-style
   + native


Property changes on: trunk/extensions/EmbedVideo/README
___________________________________________________________________
Added: svn:eol-style
   + native



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to