You are here

function _bueditor_settle in BUEditor 7

Same name and namespace in other branches
  1. 6.2 bueditor.inc \_bueditor_settle()

Include necessary js and css files for editor settlement.

1 call to _bueditor_settle()
bueditor_settle in ./bueditor.module
Include necessary js and css files for editor settlement.

File

./bueditor.inc, line 117
Implements commonly used functions for bueditor.

Code

function _bueditor_settle($editor) {
  static $settled = array();
  if (is_numeric($editor)) {
    $editor = bueditor_editors($editor);
  }
  if ($editor && $editor->eid && !isset($settled[$editor->eid])) {
    $settings = array();
    $path = drupal_get_path('module', 'bueditor');

    // Run once
    if (empty($settled)) {
      drupal_add_css($path . '/bueditor.css');
      drupal_add_js($path . '/bueditor.js');
      if (module_invoke('imce', 'access')) {
        $settings['BUE']['imceURL'] = url('imce');
      }
      module_invoke('ajax_markup', 'on');
    }
    $editor->iconpath = bueditor_path_tr($editor->iconpath);
    bueditor_add_library($editor->librarypath);
    $settings['BUE']['templates']['e' . $editor->eid] = array(
      'iconpath' => base_path() . $editor->iconpath,
      'buttons' => bueditor_processed_buttons($editor->eid),
    );
    if ($editor->spriteon && $editor->spritename) {
      $sprite_path = bueditor_sprites_dir() . '/' . $editor->spritename;
      if (file_exists($sprite_path) && ($info = getimagesize($sprite_path))) {
        $settings['BUE']['templates']['e' . $editor->eid]['sprite'] = array(
          'url' => file_create_url($sprite_path),
          'unit' => $info[1],
          'x1' => base_path() . $path . '/icons/x1.png',
        );
      }
    }
    drupal_add_js($settings, 'setting');
    $settled[$editor->eid] = TRUE;
  }
  return $editor && isset($settled[$editor->eid]);
}