Remove unneeded Config namespace usages
[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_uninstall() {
19         Hook::unregister('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
20
21 }
22
23 function webrtc_app_menu($a,&$b) {
24         $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
25 }
26
27 function webrtc_addon_admin (&$a, &$o) {
28         $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
29         $o = Renderer::replaceMacros( $t, [
30             '$submit' => DI::l10n()->t('Save Settings'),
31             '$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 .')],
32         ]);
33 }
34 function webrtc_addon_admin_post (&$a) {
35         $url = (!empty($_POST['webrtcurl']) ? Strings::escapeTags(trim($_POST['webrtcurl'])) : '');
36             DI::config()->set('webrtc', 'webrtcurl', $url);
37             info(DI::l10n()->t('Settings updated.'). EOL);
38 }
39
40 function webrtc_module() {
41         return;
42 }
43
44 function webrtc_content(&$a) {
45         $o = '';
46
47         /* landingpage to create chatrooms */
48         $webrtcurl = DI::config()->get('webrtc','webrtcurl');
49
50         /* embedd the landing page in an iframe */
51         $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
52         $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>';
53         if ($webrtcurl == '') {
54             $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
55         } else {
56             $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
57         }
58
59
60         return $o;
61 }
62 ?>