b2evolution PHP Cross Reference Blogging Systems

Source: /plugins/videoplug_plugin/_videoplug.plugin.php - 197 lines - 7500 bytes - Summary - Text - Print

Description: This file implements the Video Plug 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 Video Plug 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   * @package plugins
  10   */
  11  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  12  
  13  /**
  14   * Replaces Video Plug markup in HTML (not XML).
  15   *
  16   * @todo dh> Hook into AdminBeforeItemEditUpdate and validate provided video IDs
  17   *
  18   * @package plugins
  19   */
  20  class videoplug_plugin extends Plugin
  21  {
  22      var $code = 'evo_videoplug';
  23      var $name = 'Video Plug';
  24      var $priority = 65;
  25      var $group = 'rendering';
  26      var $short_desc;
  27      var $long_desc;
  28      var $version = '5.0.0';
  29      var $number_of_installs = 1;
  30  
  31  
  32      /**
  33       * Init
  34       */
  35  	function PluginInit( & $params )
  36      {
  37          $this->short_desc = T_('Video plug for a few popular video sites.');
  38          $this->long_desc = T_('This is a basic video plug pluigin. Use it by entering [video:youtube:123xyz] or [video:dailymotion:123xyz] into your post, where 123xyz is the ID of the video.');
  39      }
  40  
  41  
  42      /**
  43       * Perform rendering
  44       *
  45       * @todo add more video sites, anyone...
  46       *
  47       * @see Plugin::RenderItemAsHtml()
  48       */
  49  	function RenderItemAsHtml( & $params )
  50      {
  51          $content = & $params['data'];
  52  
  53          // fp> removed some embeds to make it xhtml compliant, using only object. (Hari style ;)
  54          // anyone, feel free to clean up the ones that have no object tag at all.
  55  
  56          $search_list = array(
  57                  '#\[video:youtube:(.+?)]#',     // Youtube
  58                  '#\[video:dailymotion:(.+?)]#', // Dailymotion
  59                  '#\[video:google:(.+?)]#',      // Google video
  60                  '#\[video:livevideo:(.+?)]#',   // LiveVideo
  61                  '#\[video:ifilm:(.+?)]#',       // iFilm
  62                  '#\[video:vimeo:(.+?)]#',       // vimeo // blueyed> TODO: might want to use oEmbed (to get title etc separately and display it below video): http://vimeo.com/api/docs/oembed
  63              );
  64          $replace_list = array(
  65                  '<div class="videoblock"><object data="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\\1"></param><param name="wmode" value="transparent"></param></object></div>',
  66                  '<div class="videoblock"><object data="http://www.dailymotion.com/swf/\\1" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"><param name="movie" value="http://www.dailymotion.com/swf/\\1"></param><param name="allowfullscreen" value="true"></param></object></div>',
  67                  '<div class="videoblock"><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=\\1&hl=en" flashvars=""></embed></div>',
  68                  '<div class="videoblock"><object src="http://www.livevideo.com/flvplayer/embed/\\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"><param name="movie" value="http://www.livevideo.com/flvplayer/embed/\\1"></param><param name="wmode" value="transparent"></param></object></div>',
  69                  '<div class="videoblock"><embed width="425" height="350" src="http://www.ifilm.com/efp" quality="high" bgcolor="000000" name="efp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="flvbaseclip=\\1"> </embed></div>',
  70                  '<div class="videoblock"><object data="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" width="400" height="225" type="application/x-shockwave-flash">    <param name="allowfullscreen" value="true" />    <param name="allowscriptaccess" value="always" />    <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /></object></div>',
  71              );
  72  
  73          $content = replace_content_outcode( $search_list, $replace_list, $content );
  74  
  75          return true;
  76      }
  77  
  78  
  79  
  80      /**
  81       * Perform rendering for XML feeds
  82       *
  83       * @see Plugin::RenderItemAsXml()
  84       */
  85  	function RenderItemAsXml( & $params )
  86      {
  87          return $this->RenderItemAsHtml( $params );
  88      }
  89  
  90      /**
  91       * Display a toolbar in admin.
  92       *
  93       * @param array Associative array of parameters
  94       * @return boolean did we display a toolbar?
  95       */
  96  	function AdminDisplayToolbar( & $params )
  97      {
  98          if( !empty( $params['Item'] ) )
  99          {    // Item is set, get Blog from post
 100              $edited_Item = & $params['Item'];
 101              $Blog = & $edited_Item->get_Blog();
 102          }
 103  
 104          if( empty( $Blog ) )
 105          {    // Item is not set, try global Blog
 106              global $Blog;
 107              if( empty( $Blog ) )
 108              {    // We can't get a Blog, this way "apply_rendering" plugin collection setting is not available
 109                  return false;
 110              }
 111          }
 112  
 113          $coll_setting_name = ( $params['target_type'] == 'Comment' ) ? 'coll_apply_comment_rendering' : 'coll_apply_rendering';
 114          $apply_rendering = $this->get_coll_setting( $coll_setting_name, $Blog );
 115          if( empty( $apply_rendering ) || $apply_rendering == 'never' ||
 116              $params['edit_layout'] == 'simple' || $params['edit_layout'] == 'inskin' )
 117          {    // This is too complex for simple mode, don't display it:
 118              return false;
 119          }
 120  
 121          echo '<div class="edit_toolbar" id="video_toolbar">';
 122          echo T_('Video').': ';
 123          echo '<input type="button" id="video_youtube" title="'.T_('Insert Youtube video').'" class="quicktags" onclick="videotag(\'youtube\');" value="YouTube" />';
 124          echo '<input type="button" id="video_google" title="'.T_('Insert Google video').'" class="quicktags" onclick="videotag(\'google\');" value="Google video" />';
 125          echo '<input type="button" id="video_dailymotion" title="'.T_('Insert DailyMotion video').'" class="quicktags" onclick="videotag(\'dailymotion\');" value="DailyMotion" />';
 126          echo '<input type="button" id="video_livevideo" title="'.T_('Insert LiveVideo video').'" class="quicktags" onclick="videotag(\'livevideo\');" value="LiveVideo" />';
 127          echo '<input type="button" id="video_ifilm" title="'.T_('Insert iFilm video').'" class="quicktags" onclick="videotag(\'ifilm\');" value="iFilm" />';
 128          echo '<input type="button" id="video_vimeo" title="'.T_('Insert vimeo video').'" class="quicktags" onclick="videotag(\'vimeo\');" value="vimeo" />';
 129  
 130          echo '</div>';
 131  
 132          ?>
 133          <script type="text/javascript">
 134              //<![CDATA[
 135  			function videotag( tag )
 136              {
 137                  while( 1 )
 138                  {
 139                      var valid_video_ID = false;
 140                      var p = '<?php echo TS_('Enter video ID from %s:') ?>';
 141                      var video_ID = prompt( p.replace( /%s/, tag ), '' );
 142                      if( ! video_ID )
 143                      {
 144                          return;
 145                      }
 146  
 147                      // Validate Video ID:
 148                      // TODO: verify validation / add for others..
 149                      switch( tag )
 150                      {
 151                          case 'google':
 152                              if( video_ID.match( /^[0-9-]+$/ ) )
 153                              { // valid
 154                                  valid_video_ID = true;
 155                              }
 156                              break;
 157  
 158                          case 'youtube':
 159                              // Allow HD video code with ?hd=1 at the end
 160                              if( video_ID.match( /^[a-z0-9_?=-]+$/i ) )
 161                              { // valid
 162                                  valid_video_ID = true;
 163                              }
 164                              break;
 165  
 166                          case 'vimeo':
 167                              if( video_ID.match( /^\d+$/ ) )
 168                              { // valid
 169                                  valid_video_ID = true;
 170                              }
 171                              break;
 172  
 173                          default:
 174                              valid_video_ID = true;
 175                              break;
 176                      }
 177  
 178                      if( valid_video_ID )
 179                      {
 180                          break;
 181                      }
 182                      alert( '<?php echo TS_('The video ID is invalid.'); ?>' );
 183                  }
 184  
 185                  tag = '[video:'+tag+':'+video_ID+']';
 186  
 187                  textarea_wrap_selection( b2evoCanvas, tag, '', 1 );
 188              }
 189              //]]>
 190          </script>
 191          <?php
 192  
 193          return true;
 194      }
 195  }
 196  
 197  ?>

title

Description

title

Description

title

Description

title

title

Body