liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.youtube.php

Documentation is available at data.youtube.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7.  
  8. /**
  9.  * definitions
  10.  */
  11.  
  12. global $gLibertySystem;
  13. define( 'PLUGIN_GUID_DATAYOUTUBE', 'datayoutube' );
  14. $pluginParams = array (
  15.     'tag'           => 'YOUTUBE',
  16.     'auto_activate' => FALSE,
  17.     'requires_pair' => FALSE,
  18.     'load_function' => 'data_youtube',
  19.     'title'         => 'Youtube',
  20.     'help_page'     => 'DataPluginYoutube',
  21.     'description'   => tra( "This plugin allows you to simply and safely insert a YouTube video in a page." ),
  22.     'help_function' => 'data_youtube_help',
  23.     'syntax'        => "{youtube id=}",
  24.     'plugin_type'   => DATA_PLUGIN
  25. );
  26. $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAYOUTUBE, $pluginParams );
  27. $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAYOUTUBE );
  28.  
  29. /**
  30.  * data_youtube_help
  31.  * 
  32.  * @access public
  33.  * @return HTML help in a table
  34.  */
  35. function data_youtube_help() {
  36.     return
  37.         '<table class="data help">'
  38.             .'<tr>'
  39.                 .'<th>' . tra( "Key" ) . '</th>'
  40.                 .'<th>' . tra( "Type" ) . '</th>'
  41.                 .'<th>' . tra( "Comments" ) . '</th>'
  42.             .'</tr>'
  43.             .'<tr class="odd">'
  44.                 .'<td>id</td>'
  45.                 .'<td>' . tra( "string" ) . '<br />' . tra("(required)") . '</td>'
  46.                 .'<td>' . tra( "ID nr of the Youtube video. You can get this from the URL of the Youtube video you are watching e.g.: pShf2VuAu_Q" ) . '</td>'
  47.             .'</tr>'
  48.             .'<tr class="even">'
  49.                 .'<td>width</td>'
  50.                 .'<td>' . tra( "numeric" ) . '<br />' . tra( "(optional)" ) . '</td>'
  51.                 .'<td>' . tra( "Alternate width of the youtube box in pixels." ) . '</td>'
  52.             .'</tr>'
  53.             .'<tr class="odd">'
  54.                 .'<td>height</td>'
  55.                 .'<td>' . tra( "numeric" ) . '<br />' . tra("(optional)") . '</td>'
  56.                 .'<td>' . tra( "Alternate height of the youtube box in pixels." ) . '</td>'
  57.             .'</tr>'
  58.             .'<tr class="even">'
  59.                 .'<td>lang</td>'
  60.                 .'<td>' . tra( "string" ) . '<br />' . tra("(optional)") . '</td>'
  61.                 .'<td>' . tra( "Alternate language of the Youtube interface, default is 'en'" ).'</td>'
  62.             .'</tr>'
  63.             .'<tr class="odd">'
  64.                 .'<td>format</td>'
  65.                 .'<td>' . tra( "numeric" ) . '<br />' . tra("(optional)") . '</td>'
  66.                 .'<td>' . tra( "Fetch different video format instead of the default one. Format 6 and Format 18 seem to work quite well for some videos. Please note that this might be buggy and is not available for all videos." ).'</td>'
  67.             .'</tr>'
  68.         .'</table>'
  69.         . tra( "Example: " ) . '{youtube id=XXXXX width=425 height=355 lang=en}';
  70. }
  71.  
  72. /**
  73.  * data_youtube
  74.  * 
  75.  * @param array $pData 
  76.  * @param array $pParams 
  77.  * @access public
  78.  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  79.  */
  80. function data_youtube( $pData, $pParams ) {
  81.     extract( $pParams );
  82.     $width   = ( !empty( $width )  ? $width  : "425" );
  83.     $height  = ( !empty( $height ) ? $height : "355" );
  84.     $lang    = "&amp;hl=".( !empty( $lang ) ? $lang : "en" );
  85.     $format  = ( !empty( $format )  ? "&amp;ap=%2526fmt%3D".$format  : "" );
  86.  
  87.     if( !empty( $id )) {
  88.         return '<!--~np~--><object width="'.$width.'" height="'.$height.'"><param name="movie" value="http://www.youtube.com/v/'.$id.$lang.$format.'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$id.$lang.$format.'" type="application/x-shockwave-flash" wmode="transparent" width="'.$width.'" height="'.$height.'""></embed></object><!--~/np~-->';
  89.     } else {
  90.         return tra( 'No ID given' );
  91.     }
  92. }
  93. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:22 +0000 by phpDocumentor 1.5.0-lsces