jitsi-8.x-1.0-beta1/ek_jitsi.module
ek_jitsi.module
<?php
/**
* @file
* Contains ek_jitsi.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function ek_jitsi_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the ek_jitsi module.
case 'help.page.ek_jitsi':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Integration of Jitsi video.') . '</p>';
$output .= '<p>' . t('Go to <a href="@c">structure -> block layout</a> to enable jitsi block on your site.', ['@c' => '/admin/structure/block']) . '</p>';
$output .= '<p>' . t('Go to <a href="@c">configuration</a> to set signal server and other settings.', ['@c' => '/admin/ek_jitsi']) . '</p>';
$output .= '<p>' . t('To start meeting with random room name, click on "Start New Meeting". The meeting name can be change after start.') . '</p>';
$output .= '<p>' . t('To jooin a meeting or start with custom name, enter a room name and click "Join".') . '</p>';
$output .= '<p>' . t('You can also add a video field to any node / page.') . '</p>';
$output .= '<p>' . t('Go to <a href="@c">structure</a> to add a field (i.e basic page).', ['@c' => '/admin/structure/types/manage/page/fields/add-field']) . '</p>';
$output .= '<p>' . t('There are 2 types of fields:') . '</p>';
$output .= '<ul><li>' . t('conference which is same as the block UI;') . '</li>';
$output .= '<li>' . t('embed which create an autostart video with room name based on page Alias or Title.') . '</li></ul>';
$output .= '<p>' . t('When installing the module, a new content type <b>Video</b> is created for embed video in page.') . '</p>';
$output .= '<p>' . t('Go to <a href="@c">manage form</a> to enable field in form.', ['@c' => '/admin/structure/types/manage/video/form-display']) . '</p>';
$output .= '<p>' . t('Go to <a href="@c">manage display</a> to enable field display on page.', ['@c' => '/admin/structure/types/manage/video/display']) . '</p>';
$output .= '<p>' . t('Then go to <a href="@c">add content</a> to edit a custom <a href="@v">video page</a>.', ['@c' => '/node/add','@v' => '/node/add/video']) . '</p>';
$output .= '<p>' . t('There is an option to display a countdown with embed video field.') ;
$output .= t('To do that, add a new field of type "timestamp". The field label must be set to <b>"timestamp"</b> in order to be recognized by the module.') ;
$output .= t('When you create a video page content, you can then set the time for the video to start (i.e 1 hour later) and the module will set countdown until video launches.') . '</p>' ;
$output .= '<p>' . t('More info about Jitsi at <a href="@c">jitsi.org</a>.', ['@c' => 'https://jitsi.org/']) . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function ek_jitsi_theme() {
return [
'jitsi_video' => [
'template' => 'jitsivideoblock',
'variables' => ['items' => []],
],
'jitsi_video_page' => [
'template' => 'jitsivideopage',
'variables' => [
'room' => 0,
'user' => '',
'link_external' => NULL,
],
],
'jitsi_video_page_join' => [
'template' => 'jitsivideopagejoin',
'variables' => [
'room' => 0,
'user' => '',
'link_external' => NULL,
],
],
'jitsi_video_field_join' => [
'template' => 'jitsivideofieldjoin',
'variables' => [
'room' => 0,
'user' => '',
'link_external' => NULL,
],
],
'jitsi_video_field_embed' => [
'template' => 'jitsivideofieldembed',
'variables' => [
'room' => 0,
'user' => '',
'link_external' => NULL,
],
],
];
}
/**
* Implements hook_library_info_alter().
*/
function ek_jitsi_library_info_alter(&$libraries, $extension) {
if ('ek_jitsi' == $extension && isset($libraries['video'])) {
// Change the domain so that it fetches external_api.js from the configured
// domain. @see ek_jitsi.libraries.yml for more information.
$default_api = '//meet.jit.si/external_api.js';
if (isset($libraries['video']['js'][$default_api])) {
if (Drupal::config('ek_jitsi.settings')->get('ek_jitsi_library') == 'other') {
$new_external_api = '//'
. Drupal::config('ek_jitsi.settings')->get('ek_jitsi_library_url')
. '/external_api.js';
$new_js = [
$new_external_api => $libraries['video']['js'][$default_api],
];
unset($libraries['video']['js'][$default_api]);
$libraries['video']['js'] = $new_js + $libraries['video']['js'];
}
}
}
}
