25 $config = parent::loadConfig( dirname(__FILE__) );
28 function xoopsCodeYoutube(
id, enterFlashPhrase, enterFlashHeightPhrase, enterFlashWidthPhrase)
30 var selection = xoopsGetSelect(
id);
31 if (selection.length > 0) {
34 var text = prompt(enterFlashPhrase,
"");
36 var domobj = xoopsGetElementById(
id);
37 if ( text.length > 0 ) {
38 var text2 = prompt(enterFlashWidthPhrase,
"425");
39 var text3 = prompt(enterFlashHeightPhrase,
"350");
40 var result =
"[youtube="+text2+
","+text3+
"]" + text +
"[/youtube]";
41 xoopsInsertText(domobj, result);
52 $ts->patterns[] =
"/\[youtube=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/youtube\]/esU";
53 $ts->replacements[] = __CLASS__ .
"::decode( '\\4', '\\2', '\\3' )";
58 if (!preg_match(
"/^http:\/\/(www\.)?youtube\.com\/watch\?v=(.*)/i",
$url, $matches)) {
59 trigger_error(
"Not matched: {$url} {$width} {$height}", E_USER_WARNING);
62 $src =
"http://www.youtube.com/v/" . $matches[2];
63 if (empty($width) || empty($height)) {
64 if (!$dimension = @getimagesize($src) ) {
68 $height = $dimension[1] * $width / $dimension[0];
69 }
else if (!empty($height)) {
70 $width = $dimension[0] * $height / $dimension[1];
72 list($width, $height) = array($dimension[0], $dimension[1]);
75 $code =
"<object width='{$width}' height='{$height}'><param name='movie' value='{$src}'></param>" .
76 "<param name='wmode' value='transparent'></param>" .
77 "<embed src='{$src}' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed>" .