curweather addon ES translation updated THX Senex Petrovic
[friendica-addons.git/.git] / webrtc / webrtc.php
1 <?php
2 /*
3  * Name: WebRTC Application
4  * Description: add a webrtc instance for video/audio
5  * Version: 1.0
6  * Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
7  * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
8  */
9 use Friendica\Core\Hook;
10 use Friendica\Core\Renderer;
11 use Friendica\DI;
12 use Friendica\Util\Strings;
13
14 function webrtc_install() {
15         Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
16 }
17
18 function webrtc_app_menu($a,&$b) {
19         $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
20 }
21
22 function webrtc_addon_admin (&$a, &$o) {
23         $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
24         $o = Renderer::replaceMacros( $t, [
25             '$submit' => DI::l10n()->t('Save Settings'),
26             '$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
27         ]);
28 }
29 function webrtc_addon_admin_post (&$a) {
30         $url = (!empty($_POST['webrtcurl']) ? Strings::escapeTags(trim($_POST['webrtcurl'])) : '');
31             DI::config()->set('webrtc', 'webrtcurl', $url);
32 }
33
34 function webrtc_module() {
35         return;
36 }
37
38 function webrtc_content(&$a) {
39         $o = '';
40
41         /* landingpage to create chatrooms */
42         $webrtcurl = DI::config()->get('webrtc','webrtcurl');
43
44         /* embedd the landing page in an iframe */
45         $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
46         $o .= '<p>'.DI::l10n()->t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
47         if ($webrtcurl == '') {
48             $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
49         } else {
50             $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
51         }
52
53
54         return $o;
55 }
56 ?>