You are here

function sheetnode_ethercalc_sheetnode_plugins in Sheetnode 7

Same name and namespace in other branches
  1. 6 modules/sheetnode_ethercalc/sheetnode_ethercalc.module \sheetnode_ethercalc_sheetnode_plugins()
  2. 7.2 modules/sheetnode_ethercalc/sheetnode_ethercalc.module \sheetnode_ethercalc_sheetnode_plugins()

Implements hook_sheetnode_plugins().

File

modules/sheetnode_ethercalc/sheetnode_ethercalc.module, line 14
Module file for the sheetnode_ethercalc module. This extends sheetnodes to allow syncronising with Ethercalc.

Code

function sheetnode_ethercalc_sheetnode_plugins($value, $save_element, $context) {

  // Only turn on Ethercalc if we're editing the node.
  if (!empty($save_element) || variable_get('sheetnode_ethercalc_mode', SHEETNODE_ETHERCALC_EDIT_ONLY) == SHEETNODE_ETHERCALC_EDIT_FIDDLE && variable_get('sheetnode_view_mode', SHEETNODE_VIEW_FIDDLE) == SHEETNODE_VIEW_FIDDLE) {
    $ethercalc_host = variable_get('sheetnode_ethercalc_host', '');
    $ethercalc_port = variable_get('sheetnode_ethercalc_port', '8000');
    $ethercalc_path = $GLOBALS['base_url'];
    $ethercalc_path = preg_replace('/(:\\/\\/[^\\/]+).*/', '$1', $ethercalc_path, 1);
    if ($ethercalc_port) {
      $ethercalc_path = preg_replace('/(?:\\:\\d+)?$/', ':' . $ethercalc_port, $ethercalc_path, 1);
    }
    if ($ethercalc_host) {
      $ethercalc_path = preg_replace('/^([^:]*)/', $ethercalc_host, $ethercalc_path, 1);
    }
    drupal_add_js($ethercalc_path . '/socket.io/socket.io.js#', array(
      'weight' => 10,
    ));
    drupal_add_js($ethercalc_path . '/zappa/zappa.js#', array(
      'weight' => 10,
    ));
    drupal_add_js($ethercalc_path . '/static/md5.js#', array(
      'weight' => 10,
    ));
    drupal_add_js($ethercalc_path . '/player/broadcast.js#', array(
      'weight' => 10,
    ));
    drupal_add_js($ethercalc_path . '/player/main.js#', array(
      'weight' => 10,
    ));
  }
}