You are here

function sheetnode_plugin_style::render_inject in Sheetnode 7.2

Same name and namespace in other branches
  1. 7 views/sheetnode_plugin_style.inc \sheetnode_plugin_style::render_inject()

Inject plugin style to render.

2 calls to sheetnode_plugin_style::render_inject()
sheetnode_plugin_style::options_form in views/sheetnode_plugin_style.inc
Set plugin style option form.
sheetnode_plugin_style::render in views/sheetnode_plugin_style.inc
Render sheetnode plugin style.

File

views/sheetnode_plugin_style.inc, line 511

Class

sheetnode_plugin_style
Extentions for sheetnode plugin style.

Code

function render_inject($value, $save_element, &$element, $attribute) {
  $library_path = libraries_get_path('socialcalc');
  $module_path = drupal_get_path('module', 'sheetnode');
  $context = array(
    'entity-type' => 'view',
    'oid' => $this->view->name,
  );
  $sheet_id = drupal_clean_css_identifier('sheetview-' . $this->view->name . (empty($this->view->live_preview) ? '' : '-preview'));
  $setting = array(
    'sheetnode' => array(
      $sheet_id => array(
        'aliases' => array(
          $this->view->name,
        ),
        'value' => $value,
        'imagePrefix' => base_path() . $library_path . '/images/sc-',
        'containerElement' => $sheet_id,
        'saveElement' => $save_element,
        'viewMode' => variable_get('sheetnode_view_mode', SHEETNODE_VIEW_FIDDLE),
        'showToolbar' => variable_get('sheetnode_view_toolbar', FALSE),
        'permissions' => array(
          'edit sheetnode settings' => user_access('edit sheetnode settings'),
        ),
        'context' => $context,
      ),
    ),
  );
  $element[$attribute] = '<div class="sheetview" id="' . $sheet_id . '"></div>';
  $element['#attached']['js'] = array(
    $library_path . '/socialcalc.min.js' => array(
      'weight' => 1,
    ),
    $module_path . '/js/sheetnode.js' => array(
      'weight' => 6,
    ),
    array(
      'data' => $setting,
      'type' => 'setting',
    ),
  );
  $element['#attached']['css'] = array(
    $library_path . '/socialcalc..min.css',
    $module_path . '/css/sheetnode.css',
  );
  module_invoke_all('sheetnode_plugins', $value, $save_element, $context);
}