You are here

function sweaver_init in Sweaver 7

Same name and namespace in other branches
  1. 6 sweaver.module \sweaver_init()

Implements hook_init().

File

./sweaver.module, line 361
Sweaver functions.

Code

function sweaver_init() {

  // We use the drupal_static here instead of a session, because
  // pressflow doesn't allow us to start a session without breaking
  // the page cache.
  $load_style =& drupal_static('load_style', TRUE);
  if (sweaver_show_editor()) {
    $sweaver = Sweaver::get_instance();
    $load_style = FALSE;
    $inline_js_settings = array(
      'sweaver' => array(),
    );
    $skin = variable_get('sweaver_skin', SWEAVER_SKIN);
    drupal_add_js(drupal_get_path('module', 'sweaver') . '/sweaver_plugin.js');
    drupal_add_css(drupal_get_path('module', 'sweaver') . '/skins/' . $skin . '/sweaver-' . $skin . '.css');
    foreach (array_keys($sweaver
      ->get_plugins_registry(TRUE)) as $plugin_name) {
      $sweaver_plugin = $sweaver
        ->get_plugin($plugin_name);

      // Fire init.
      $sweaver_plugin
        ->sweaver_init();

      // CSS and JS.
      $sweaver_plugin
        ->sweaver_form_css_js($inline_js_settings);
    }

    // JS inline settings.
    drupal_add_js($inline_js_settings, 'setting');
  }
}