-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyoutube.php
38 lines (28 loc) · 1.11 KB
/
youtube.php
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
<?php
defined('_JEXEC') or die;
class PlgButtonYoutube extends JPlugin {
const IMG_ID = "system-youtube";
protected $autoloadLanguage = true;
function PlgButtonYoutube( &$subject, $params ) {
parent::__construct( $subject, $params );
}
public function onDisplay($name, $asset, $author) {
$doc = JFactory::getDocument();
$js = "
function insertYoutube(editor, defaultCode) {
var code = prompt('" . JText::_('PLG_YOUTUBE_XTD_PROMPT') . "', defaultCode);
var src = 'http://i1.ytimg.com/vi/' + code + '/sddefault.jpg';
jInsertEditorText('<img id=\"". self::IMG_ID . "\" src=\"' + src +'\" />', editor);
}
";
$doc->addScriptDeclaration($js);
$button = new JObject;
$button->modal = false;
$button->class = 'btn';
$button->onclick = 'insertYoutube(\'' . $name . '\', \'\');return false;';
$button->text = JText::_('PLG_YOUTUBE_XTD_BUTTON');
$button->name = 'video';
$button->link = '#';
return $button;
}
}