b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 2.4) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Source for file _videoplug.plugin.php

Documentation is available at _videoplug.plugin.php

  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-2008 by Francois PLANQUE - {@link http://fplanque.net/}
  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.  * @package plugins
  17.  */
  18. class videoplug_plugin extends Plugin
  19. {
  20.     var $code = 'evo_videoplug';
  21.     var $name = 'Video Plug';
  22.     var $priority = 65;
  23.     var $apply_rendering = 'opt-out';
  24.     var $group = 'rendering';
  25.     var $short_desc;
  26.     var $long_desc;
  27.     var $version = '2.2';
  28.     var $number_of_installs = 1;
  29.  
  30.  
  31.     /**
  32.      * Init
  33.      */
  34.     function PluginInit$params )
  35.     {
  36.         $this->short_desc = T_('Video plug for a few popular video sites.');
  37.         $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.');
  38.     }
  39.  
  40.  
  41.     /**
  42.      * Perform rendering
  43.      *
  44.      * @todo add more video sites, anyone...
  45.      *
  46.      * @see Plugin::RenderItemAsHtml()
  47.      */
  48.     function RenderItemAsHtml$params )
  49.     {
  50.         $content $params['data'];
  51.  
  52.         // fp> removed some embeds to make it xhtml compliant, using only object. (Hari style ;)
  53.         // anyone, feel free to clean up the ones that have no object tag at all.
  54.  
  55.         // Youtube:
  56.         $content preg_replace'¤\[video:youtube:(.+?)]¤''<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>'$content );
  57.  
  58.         // Dailymotion:
  59.         $content preg_replace'¤\[video:dailymotion:(.+?)]¤''<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>'$content );
  60.  
  61.         // Google video:
  62.         $content preg_replace'¤\[video:google:(.+?)]¤''<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>'$content );
  63.  
  64.         // LiveVideo
  65.         $content preg_replace'¤\[video:livevideo:(.+?)]¤''<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>'$content );
  66.  
  67.         // iFilm
  68.         $content preg_replace'¤\[video:ifilm:(.+?)]¤''<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>'$content );
  69.  
  70.         return true;
  71.     }
  72.  
  73.  
  74.  
  75.     /**
  76.      * Perform rendering for XML feeds
  77.      *
  78.      * @see Plugin::RenderItemAsXml()
  79.      */
  80.     function RenderItemAsXml$params )
  81.     {
  82.         $this->RenderItemAsHtml$params );
  83.  
  84.         /*
  85.         $content = & $params['data'];
  86.         $Item = & $params['Item'];
  87.  
  88.         $content = preg_replace( '¤\[video:.+?]¤', '<p>'.$Item->get_permanent_link( T_('See video').' &raquo;' ).'</p>', $content );
  89.         */
  90.  
  91.         return true;
  92.     }
  93.  
  94.     /**
  95.      * Display a toolbar in admin
  96.      * dh>> Do the service names, e.g. "YouTube" have to be marked for i18n?
  97.      * fp> nope
  98.      *
  99.      * @param array Associative array of parameters
  100.      * @return boolean did we display a toolbar?
  101.      */
  102.     function AdminDisplayToolbar$params )
  103.     {
  104.         if$params['edit_layout'== 'simple' )
  105.         {    // This is too complex for simple mode, don't display it:
  106.             return false;
  107.         }
  108.  
  109.         echo '<div class="edit_toolbar">';
  110.         echo T_('Video').': ';
  111.         echo '<input type="button" id="video_youtube" title="'.T_('Insert Youtube video').'" class="quicktags" onclick="videotag(\'youtube\');" value="'.T_('YouTube').'" />';
  112.         echo '<input type="button" id="video_google" title="'.T_('Insert Google video').'" class="quicktags" onclick="videotag(\'google\');" value="'.T_('Google video').'" />';
  113.         echo '<input type="button" id="video_dailymotion" title="'.T_('Insert DailyMotion video').'" class="quicktags" onclick="videotag(\'dailymotion\');" value="'.T_('DailyMotion').'" />';
  114.         echo '<input type="button" id="video_livevideo" title="'.T_('Insert LiveVideo video').'" class="quicktags" onclick="videotag(\'livevideo\');" value="'.T_('LiveVideo').'" />';
  115.         echo '<input type="button" id="video_ifilm" title="'.T_('Insert iFilm video').'" class="quicktags" onclick="videotag(\'ifilm\');" value="'.T_('iFilm').'" />';
  116.  
  117.         echo '</div>';
  118.  
  119.         ?>
  120.         <script type="text/javascript">
  121.             //<![CDATA[
  122.             function videotag( tag )
  123.             {
  124.                 var p = '<?php echo TS_('Enter video ID from %s:'?>';
  125.                 var video_ID = prompt( p.replace( /%s/, tag ), '' );
  126.                 if( ! video_ID )
  127.                 {
  128.                     return;
  129.                 }
  130.  
  131.                 tag = '[video:'+tag+':'+video_ID+']';
  132.  
  133.                 textarea_wrap_selection( b2evoCanvas, tag, '', 1 );
  134.             }
  135.             //]]>
  136.         </script>
  137.         <?php
  138.  
  139.         return true;
  140.     }
  141.  
  142. }
  143.  
  144.  
  145. /*
  146.  * $Log: _videoplug.plugin.php,v $
  147.  * Revision 1.11  2008/01/21 09:35:42  fplanque
  148.  * (c) 2008
  149.  *
  150.  * Revision 1.10  2007/11/29 21:52:06  fplanque
  151.  * Hari style embed removal
  152.  *
  153.  * Revision 1.9  2007/09/16 22:16:46  fplanque
  154.  * minor
  155.  *
  156.  * Revision 1.8  2007/09/16 03:04:21  blueyed
  157.  * fixed doc. added question about using i18n for service names
  158.  *
  159.  * Revision 1.7  2007/09/11 20:57:51  fplanque
  160.  * minor fixes
  161.  *
  162.  * Revision 1.6  2007/07/07 22:21:34  fplanque
  163.  * doc
  164.  *
  165.  * Revision 1.5  2007/05/15 21:22:16  blueyed
  166.  * Use+replace %s for dynamic value instead of appending some string!
  167.  *
  168.  * Revision 1.4  2007/05/04 20:43:09  fplanque
  169.  * MFB
  170.  *
  171.  * Revision 1.1.2.5  2007/04/25 22:18:09  fplanque
  172.  * (c) 2007
  173.  *
  174.  * Revision 1.1.2.4  2007/04/24 11:45:13  yabs
  175.  * added a couple more video sources
  176.  *
  177.  * Revision 1.1.2.3  2007/04/20 01:44:24  fplanque
  178.  * added toolbar
  179.  *
  180.  * Revision 1.1.2.2  2007/04/19 01:14:43  fplanque
  181.  * minor
  182.  *
  183.  * Revision 1.1.2.1  2007/04/19 01:03:54  fplanque
  184.  * basic videoplug plugin
  185.  *
  186.  */
  187. ?>

Documentation generated on Sat, 06 Mar 2010 03:42:27 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).