View source
<?php
use Drupal\Core\Routing\RouteMatchInterface;
function skype_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.skype':
$output = file_get_contents(drupal_get_path('module', 'skype') . '/README.md');
return '<pre>' . $output . '</pre>';
}
}
function skype_theme() {
return [
'skype_button' => [
'variables' => [
'skype_id' => NULL,
'settings' => [],
],
'template' => 'skype-button',
],
'skype_uri' => [
'variables' => [
'skype_id' => NULL,
'settings' => [],
],
'template' => 'skype-uri',
],
'skype_chat_canvas' => [
'variables' => [
'message_recipient' => NULL,
'chat_id' => NULL,
'attributes' => [],
],
'template' => 'skype-chat-canvas',
],
];
}
function skype_page_attachments(array &$attachments) {
$manager = Drupal::service('skype.manager');
if ($manager
->loadSkypeChatCanvas()) {
$attachments['#attached']['library'][] = 'skype/skype.chat.canvas';
}
}
function skype_page_bottom(array &$page_bottom) {
$manager = Drupal::service('skype.manager');
if ($manager
->loadSkypeChatCanvas()) {
$page_bottom['skype'] = [
'#theme' => 'skype_chat_canvas',
'#message_recipient' => $manager
->getMessageRecipient(),
'#chat_id' => $manager
->getChatId(),
'#attributes' => $manager
->getAttributes(),
];
}
}
function skype_preprocess_skype_button(&$variables) {
$settings = $variables['settings'];
$actions = array_filter($settings['actions']);
$variables['skype_name'] = count($actions) > 1 ? 'dropdown' : array_shift($actions);
$variables['unique_id'] = uniqid();
$variables['image_color'] = $settings['image_color'];
$variables['image_size'] = $settings['image_size'];
}
function skype_preprocess_skype_uri(&$variables) {
$settings = $variables['settings'];
$variables['link_text'] = str_replace('[skype:id]', $variables['skype_id'], $settings['link_text']);
$variables['action'] = $settings['action'] == 'video' ? 'call&video=true' : $settings['action'];
}