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