You are here

function sweaver_init in Sweaver 6

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

Implementation of hook_init().

File

./sweaver.module, line 287
Sweaver functions.

Code

function sweaver_init() {

  // We use the ctools_static here instead of a session, because
  // pressflow doesn't allow us to start a session without breaking
  // the page cache.
  $load_style =& ctools_static('load_style', TRUE);
  if (sweaver_show_editor()) {
    $sweaver = Sweaver::get_instance();
    $load_style = FALSE;
    $inline_js_settings = array(
      'sweaver' => array(
        'invokes' => array(),
      ),
    );
    $skin = variable_get('sweaver_skin', SWEAVER_SKIN);
    drupal_add_js(drupal_get_path('module', 'sweaver') . '/sweaver_plugin.js', 'module');
    drupal_add_css(drupal_get_path('module', 'sweaver') . '/skins/' . $skin . '/sweaver-' . $skin . '.css', 'module');
    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');
  }
}