Extension:FLVPlayerTwo/FLVPlayerTwo code v1.00

From MediaWiki.org
Jump to: navigation, search
<?php
 
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 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 General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USAw
 *
 * @author Raju Shah
 * @version 1.01
 *
 * Changelog
 * =========
 *
 * 1.00 - Initial release
 * 1.01 - Edited/Fixed by Kenny Holden to refine the extension and support Flowplayer-3.1.0
 *
 */
 
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'FLVPlayerTwo',
        'author' => 'Raju Shah',
        'url' => 'http://www.mediawiki.org/wiki/Extension:FLVPlayerTwo',
        'description' => 'Allows the display of flv movies within a wiki using the FlowPlayer FLV movie player.'
);
 
$wgExtensionFunctions[] = "wfFLVPlayerExtension";
 
 
/*
 * The FlvPlayer class generates code that embeds a flash movie player
 * with reference to the uploaded movie.
 *
 * The flash based flv player used is flowplayer (http://flowplayer.org/)
 *
 */
class Player {
 
  /* Constructor */
  function Player( $input, $argv ) {
 
    $this->file = $input;
 
    /* Assumes the file is the actual location */
 
    if ($argv["width"] == "")
      { $this->width = "320"; }
    else
      { $this->width = $argv["width"]; }
 
    if ($argv["height"] == "")
      { $this->height = "240"; }
    else
      { $this->height = $argv["height"]; }
 
    if ($argv["autoPlay"] == "")
      { $this->autoPlay = "false"; }
    else
      { $this->autoPlay = $argv["autoPlay"]; }
 
    if ($argv["autoBuffering"] == "")
      { $this->autoBuffering = "false"; }
    else
      { $this->autoBuffering = $argv["autoBuffering"]; }
 
    $this->random_number = rand();
 
    global $wgScriptPath;
    $BaseURL = $wgScriptPath . "/extensions/FLVPlayerTwo";
 
    $this->flowswfpath = $BaseURL . "/flowplayer-3.1.0.swf";
    $this->flowjspath  = $BaseURL . "/flowplayer-3.1.0.min.js";
    $this->flowconpath = $BaseURL . "/flowplayer.controls-3.1.0.swf";
 
  }
 
 
 
  /* Generate final code */
  function render() {
 
    $this->code = '<script type="text/javascript" src="' . $this->flowjspath . '"></script> <a href="' . $this->getViewPath($this->file) . '" style="display:
block;width:' . $this->width . 'px;height:' . $this->height . 'px" id="player' . $this->random_number . '"></a> <script>flowplayer("player' . $this->random_n
umber . '", "' . $this->flowswfpath . '", { clip: { autoPlay:' . $this->autoPlay . ', autoBuffering:' . $this->autoBuffering . '} } );</script>';
 
    return $this->code;
  }
 
 
  function getViewPath($file) {
    $title = Title::makeTitleSafe("Image",$file);
 
    $img = new Image($title);
 
    $path = $img->getViewURL(false);
 
    return $path;
  }
}
 
function wfFLVPlayerExtension() {
  global $wgParser;
 
  $wgParser->setHook( "flvplayertwo", "renderPlayer" );
}
 
function renderPlayer( $input, $argv ) {
  // Constructor
  $PlayerFile = new Player( $input, $argv );
 
  $result = $PlayerFile->render();
 
  return $result; // send the final code to the wiki
}
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox