You are here

public static function RocketChat::hookPageAlter in Rocket.Chat 7.2

Same name and namespace in other branches
  1. 7 RocketChat.class.inc \RocketChat\RocketChat::hookPageAlter()

Implements hook_page_alter().

Parameters

$page: Current Render array for this Page.

1 call to RocketChat::hookPageAlter()
rocket_chat_page_alter in ./rocket_chat.module
Implements hook_page_alter().

File

src/RocketChat.class.inc, line 50

Class

RocketChat
Class RocketChat.

Namespace

RocketChat

Code

public static function hookPageAlter(&$page) {
  $path = request_path();
  $paths_raw = variable_get('rocket_chat_route', "");
  $paths = explode("\r\n", $paths_raw);
  foreach ($paths as $key => $value) {
    if (empty($value)) {
      unset($paths[$key]);
    }
  }
  if (RocketChat::checkIfTargetIsRocketChatPath($paths, $path)) {
    $version = variable_get('rocket_chat_livechat_version', "1.0.0");
    $url = variable_get('rocket_chat_url', "http://localhost");
    $javascript = LiveChat::getLivechatJavascript($url, $version);
    drupal_add_js($javascript, array(
      'type' => 'inline',
      'scope' => 'footer',
      'weight' => 0,
    ));
  }
  return $page;
}