b2evolution PHP Cross Reference Blogging Systems

Source: /plugins/flowplayer_plugin/_flowplayer.plugin.php - 165 lines - 4231 bytes - Summary - Text - Print

Description: This file implements the Flow Player plugin for b2evolution b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * This file implements the Flow Player plugin for b2evolution
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   8   *
   9   * @author fplanque: Francois PLANQUE.
  10   * @author gorgeb: Bertrand GORGE / EPISTEMA
  11   *
  12   * @package plugins
  13   * @version $Id: _flowplayer.plugin.php 198 2011-11-05 21:34:08Z fplanque $
  14   */
  15  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  16  
  17  
  18  /**
  19   * @package plugins
  20   */
  21  class flowplayer_plugin extends Plugin
  22  {
  23      var $code = 'b2evFlp';
  24      var $name = 'Flowplayer';
  25      var $priority = 80;
  26      var $version = '5.0.0';
  27      var $group = 'files';
  28      var $number_of_installs = 1;
  29      var $allow_ext = array( 'flv', 'swf', 'm4v', 'f4v', 'mov', 'mp4' );
  30  
  31  
  32  	function PluginInit( & $params )
  33      {
  34          $this->short_desc = sprintf( T_('Media player for the these file formats: %s.'), implode( ', ', $this->allow_ext ) );
  35          $this->long_desc = $this->short_desc;
  36      }
  37  
  38  
  39      /**
  40       * @see Plugin::SkinBeginHtmlHead()
  41       */
  42  	function SkinBeginHtmlHead( & $params )
  43      {
  44          require_js( $this->get_plugin_url( true ).'flowplayer.min.js', 'relative' );
  45          require_js( $this->get_plugin_url( true ).'flowplayer_init.js', 'relative' );
  46          add_js_headline( 'flowplayer_url = "'.$this->get_plugin_url( true ).'";' );
  47      }
  48  
  49  
  50      /**
  51       * @see Plugin::AdminEndHtmlHead()
  52       */
  53  	function AdminEndHtmlHead( & $params )
  54      {
  55          $this->SkinBeginHtmlHead( $params );
  56      }
  57  
  58  
  59      /**
  60       * Get the settings that the plugin can use.
  61       *
  62       * Those settings are transfered into a Settings member object of the plugin
  63       * and can be edited in the backoffice (Settings / Plugins).
  64       *
  65       * @see Plugin::GetDefaultSettings()
  66       * @see PluginSettings
  67       * @see Plugin::PluginSettingsValidateSet()
  68       * @return array
  69       */
  70  	function GetDefaultSettings( & $params )
  71      {
  72          return array(
  73              'width' => array(
  74                  'label' => T_('Video width (px)'),
  75                  'note' => T_('100% width if left empty or 0'),
  76                  ),
  77              'height' => array(
  78                  'label' => T_('Video height (px)'),
  79                  'type' => 'integer',
  80                  'defaultvalue' => 300,
  81                  'note' => '',
  82                  'valid_range' => array( 'min' => 1 ),
  83                  ),
  84              'allow_download' => array(
  85                  'label' => T_('Allow downloading of the video file'),
  86                  'type' => 'checkbox',
  87                  'defaultvalue' => 0,
  88                  ),
  89              );
  90      }
  91  
  92  
  93      /**
  94       * Check a file for correct extension
  95       *
  96       * @param File
  97       * @return boolean true if extension of file supported by plugin
  98       */
  99  	function is_flp_video( $File )
 100      {
 101          return in_array( strtolower( $File->get_ext() ), $this->allow_ext );
 102      }
 103  
 104  
 105      /**
 106       * Event handler: Called when displaying item attachment.
 107       *
 108       * @param array Associative array of parameters. $params['File'] - attachment, $params['data'] - output
 109       * @param boolean TRUE - when render in comments
 110       * @return boolean true if plugin rendered this attachment
 111       */
 112  	function RenderItemAttachment( & $params, $in_comments = false )
 113      {
 114          $File = $params['File'];
 115  
 116          if( ! $this->is_flp_video( $File ) )
 117          {
 118              return false;
 119          }
 120  
 121          $width = (int) $this->Settings->get( 'width' );
 122          if( empty( $width ) )
 123          {    // Set default width
 124              $width = 'width:100%';
 125          }
 126          else
 127          {
 128              $width = 'width:'.$width.'px';
 129          }
 130  
 131          $height = (int) $this->Settings->get( 'height' );
 132          $height = 'height:'.$height.'px';
 133  
 134          if( $File->exists() )
 135          {
 136              if( $in_comments )
 137              {
 138                  $params['data'] .= '<div style="clear: both; height: 0px; font-size: 0px"></div>';
 139              }
 140              $params['data'] .= '<br /><a class="flowplayer" style="display: block; '.$width.';'.$height.';" href="'.$File->get_url().'"></a>';
 141  
 142              if( $this->Settings->get( 'allow_download' ) )
 143              {    // Allow to download the video files
 144                  $params['data'] .= '<div class="small center"><a href="'.$File->get_url().'">'.T_('Download this video').'</a></div>';
 145              }
 146  
 147              return true;
 148          }
 149          return false;
 150      }
 151  
 152  
 153      /**
 154       * Event handler: Called when displaying comment attachment.
 155       *
 156       * @param array Associative array of parameters. $params['File'] - attachment, $params['data'] - output
 157       * @return boolean true if plugin rendered this attachment
 158       */
 159  	function RenderCommentAttachment( & $params )
 160      {
 161          return $this->RenderItemAttachment( $params, true );
 162      }
 163  
 164  }
 165  ?>

title

Description

title

Description

title

Description

title

title

Body