You are here

skype.module in Skype 8

Same filename and directory in other branches
  1. 7 skype.module

File

skype.module
View source
<?php

/**
 * Holds hooks and general functionality.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
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>';
  }
}

/**
 * Implements hook_theme().
 */
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',
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 */
function skype_page_attachments(array &$attachments) {

  /** @var \Drupal\skype\Manager\SkypeManager $manager */
  $manager = Drupal::service('skype.manager');
  if ($manager
    ->loadSkypeChatCanvas()) {
    $attachments['#attached']['library'][] = 'skype/skype.chat.canvas';
  }
}

/**
 * Implements hook_page_bottom().
 */
function skype_page_bottom(array &$page_bottom) {

  /** @var \Drupal\skype\Manager\SkypeManager $manager */
  $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(),
    ];
  }
}

/**
 * Implements hook_preprocess_hook().
 */
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'];
}

/**
 * Implements hook_preprocess_hook().
 */
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'];
}

Functions

Namesort descending Description
skype_help Implements hook_help().
skype_page_attachments Implements hook_page_attachments().
skype_page_bottom Implements hook_page_bottom().
skype_preprocess_skype_button Implements hook_preprocess_hook().
skype_preprocess_skype_uri Implements hook_preprocess_hook().
skype_theme Implements hook_theme().