]> 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 function webrtc_addon_admin_post (App $a)
33 {
34         $url = trim($_POST['webrtcurl'] ?? '');
35         DI::config()->set('webrtc', 'webrtcurl', $url);
36 }
37
38 function webrtc_module() {
39         return;
40 }
41
42 function webrtc_content(App $a)
43 {
44         $o = '';
45
46         /* landingpage to create chatrooms */
47         $webrtcurl = DI::config()->get('webrtc','webrtcurl');
48
49         /* embedd the landing page in an iframe */
50         $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
51         $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>';
52         if ($webrtcurl == '') {
53                 $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
54         } else {
55                 $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
56         }
57
58         return $o;
59 }