]> git.mxchange.org Git - friendica-addons.git/blob - webrtc/webrtc.php
Changes:
[friendica-addons.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
10 use Friendica\App;
11 use Friendica\Core\Hook;
12 use Friendica\Core\Renderer;
13 use Friendica\DI;
14
15 function webrtc_install() {
16         Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
17 }
18
19 function webrtc_app_menu(App $a, array &$b)
20 {
21         $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
22 }
23
24 function webrtc_addon_admin (App $a, &$o)
25 {
26         $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
27         $o = Renderer::replaceMacros( $t, [
28             '$submit' => DI::l10n()->t('Save Settings'),
29             '$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 .')],
30         ]);
31 }
32
33 function webrtc_addon_admin_post (App $a)
34 {
35         $url = trim($_POST['webrtcurl'] ?? '');
36         DI::config()->set('webrtc', 'webrtcurl', $url);
37 }
38
39 /**
40  * This is a statement rather than an actual function definition. The simple
41  * existence of this method is checked to figure out if the addon offers a
42  * module.
43  */
44 function webrtc_module() {}
45
46 function webrtc_content(App $a)
47 {
48         $o = '';
49
50         /* landingpage to create chatrooms */
51         $webrtcurl = DI::config()->get('webrtc','webrtcurl');
52
53         /* embedd the landing page in an iframe */
54         $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
55         $o .= '<p>'.DI::l10n()->t('WebRTC is a video and audio conferencing tool that works in all modern browsers. Just create a new chat room and send the link to someone you want to chat with.').'</p>';
56         if ($webrtcurl == '') {
57                 $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
58         } else {
59                 $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
60         }
61
62         return $o;
63 }