You are here

function ace_editor_install in Ace Code Editor 7

Same name and namespace in other branches
  1. 8 ace_editor.install \ace_editor_install()

Implements hook_install().

File

./ace_editor.install, line 10
Install, update and uninstall functions for the module.

Code

function ace_editor_install() {

  // Create a default text format to use with the editor.
  if (!filter_format_exists('ace_editor')) {
    $html_editor_format = new stdClass();
    $html_editor_format->format = 'ace_editor';
    $html_editor_format->name = 'Ace Editor';
    $html_editor_format->status = 1;
    $html_editor_format->weight = 100;
    filter_format_save($html_editor_format);
  }
  else {

    // Enable ace_editor.
    db_update('filter_format')
      ->fields(array(
      'status' => 1,
    ))
      ->condition('format', 'ace_editor')
      ->execute();
  }

  // Set the newly created text format to use the editor.
  variable_set('ace_editor_filter_formats', array(
    'ace_editor',
  ));

  // Set the defaults to other variables.
  variable_set('ace_editor_autocomplete', TRUE);
  variable_set('ace_editor_autowrap', TRUE);
  variable_set('ace_editor_codefolding', 'markbegin');
  variable_set('ace_editor_default_syntax', 'html');
  variable_set('ace_editor_fontsize', '12pt');
  variable_set('ace_editor_invisibles', FALSE);
  variable_set('ace_editor_linehighlighting', TRUE);
  variable_set('ace_editor_line_numbers', TRUE);
  variable_set('ace_editor_printmargin', FALSE);
  variable_set('ace_editor_tabsize', 2);
  variable_set('ace_editor_theme', 'cobalt');

  // Get modes and themes.
  ace_editor_get_assets();
}