You are here

function ueditor_global_settings in UEditor - 百度编辑器 7.2

Same name and namespace in other branches
  1. 7.3 ueditor.module \ueditor_global_settings()

Config options for ueditor global settings.

1 string reference to 'ueditor_global_settings'
ueditor_menu in ./ueditor.module
Implements hook_menu().

File

./ueditor.module, line 227
Integration ueditor for wysiwyg.

Code

function ueditor_global_settings($form, &$form_state) {
  global $base_url;
  $enable_paging = variable_get('ueditor_enable_paging', 0);
  if ($enable_paging == 1) {
    if (!module_exists('paging')) {
      drupal_set_message(t('Please install the <a href="@url">Paging</a> module at first.', array(
        '@url' => url("https://www.drupal.org/project/paging"),
      )), 'error');
    }
  }
  if (file_exists('sites/all/libraries/ueditor/kityformula-plugin/kityformula/js/kityformula-editor.all.min.js') || file_exists('profiles/' . drupal_get_profile() . '/libraries/ueditor/kityformula-plugin/kityformula/js/kityformula-editor.all.min.js')) {
    $kityformula_installed = TRUE;
  }
  else {
    $kityformula_installed = FALSE;
  }
  $enable_formula_editor = variable_get('ueditor_enable_formula_editor', 0);
  if ($enable_formula_editor == 1) {
    if (!$kityformula_installed) {
      drupal_set_message(t('Please install the <a href="@url">kityformula</a> library at first, and the place should be like this: <i>sites/all/libraries/ueditor/kityformula-plugin/kityformula/js/kityformula-editor.all.min.js</i>', array(
        '@url' => url("http://ueditor.baidu.com/download/kityformula-plugin.zip"),
      )), 'error');
      variable_set('ueditor_enable_formula_editor', 0);
    }
  }
  $enable_colorbox = variable_get('ueditor_enable_colorbox', 0);
  if ($enable_colorbox == 1) {
    if (!module_exists('colorbox')) {
      drupal_set_message(t('Please install the <a href="@url">Colorbox</a> module at first.', array(
        '@url' => url("https://www.drupal.org/project/colorbox"),
      )), 'error');
    }
  }
  $form['global']['highlighting_format'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Highlighting Code Format'),
    '#default_value' => variable_get('ueditor_highlighting_format', 1),
    '#description' => t('If enabled, when you insert code, the code will highlighting.'),
  );
  $form['global']['inject_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Ueditor highlighting js/css code inject settings'),
    '#states' => array(
      'invisible' => array(
        'input[name="highlighting_format"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $options = array(
    UEDITOR_INJECT_EXCEPT_LISTED => t('Inject on all pages except those listed'),
    UEDITOR_INJECT_IF_LISTED => t('Inject on only the listed pages'),
  );
  $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
    '%blog' => 'blog',
    '%blog-wildcard' => 'blog/*',
    '%front' => '<front>',
  ));
  $form['global']['inject_settings']['inject'] = array(
    '#type' => 'radios',
    '#title' => t('Inject js/css code on specific pages'),
    '#options' => $options,
    '#default_value' => variable_get('ueditor_inject', UEDITOR_INJECT_EXCEPT_LISTED),
  );
  $form['global']['inject_settings']['pages'] = array(
    '#type' => 'textarea',
    '#title' => '<span class="element-invisible">Pages</span>',
    '#default_value' => variable_get('ueditor_pages', "admin\nadmin/*\nuser\nuser/*\nimce\nimce/*\nueditor/controller\nueditor/controller/*\n"),
    '#description' => $description,
  );
  $form['global']['enable_paging'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Conent paging in ueditor'),
    '#default_value' => variable_get('ueditor_enable_paging', 0),
    '#description' => t('If you want to use content paging in the ueditor, you must enable the <a href="@url">Paging</a> module at first.', array(
      '@url' => url("https://www.drupal.org/project/paging"),
    )),
  );
  $form['global']['enable_formula_editor'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Formula in ueditor'),
    '#default_value' => variable_get('ueditor_enable_formula_editor', 0),
    '#description' => t('If you want to use KityFormula in the ueditor, you must install the <a href="@url">KityFormula</a> library at first. and the place should be like this: <i>sites/all/libraries/ueditor/kityformula-plugin/kityformula/js/kityformula-editor.all.min.js</i>', array(
      '@url' => url("http://ueditor.baidu.com/download/kityformula-plugin.zip"),
    )),
  );

  //ueditor colorbox support
  $form['global']['enable_colorbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Colorbox for ueditor image'),
    '#default_value' => variable_get('ueditor_enable_colorbox', 0),
    '#description' => t('If you want to use colorbox for ueditor image, you must enable the <a href="@url">Colorbox</a> module at first.', array(
      '@url' => url("https://www.drupal.org/project/colorbox"),
    )),
  );
  $form['global']['colorbox_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Colorbox Settings'),
    '#collapsible' => TRUE,
    '#states' => array(
      'invisible' => array(
        'input[name="enable_colorbox"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['global']['colorbox_settings']['wrapper'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'inner',
      ),
    ),
  );
  $form['global']['colorbox_settings']['wrapper']['colorbox_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Colorbox Width'),
    '#description' => t('The width of colorbox.'),
    '#default_value' => variable_get('ueditor_colorbox_width', 500),
  );
  $form['global']['colorbox_settings']['wrapper']['colorbox_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Colorbox Height'),
    '#description' => t('The height of colorbox.'),
    '#default_value' => variable_get('ueditor_colorbox_height', 500),
  );

  //ueditor watermark support
  $form['global']['watermark'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use watermark when upload'),
    '#default_value' => variable_get('ueditor_watermark', 0),
    '#tree' => FALSE,
    '#description' => t('Check here if you want use watermark when upload.'),
  );
  $form['global']['watermark_settings'] = array(
    '#type' => 'container',
    '#states' => array(
      'invisible' => array(
        'input[name="watermark"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['global']['watermark_settings']['watermark_type'] = array(
    '#type' => 'select',
    '#title' => 'The type of watermark',
    '#options' => array(
      'image' => 'Image',
      'text' => 'Text',
    ),
    '#default_value' => variable_get('ueditor_watermark_type', 'image'),
  );
  $form['global']['watermark_settings']['watermark_image'] = array(
    '#type' => 'container',
    '#states' => array(
      'invisible' => array(
        '#edit-watermark-type' => array(
          'value' => 'text',
        ),
      ),
    ),
  );
  $form['global']['watermark_settings']['watermark_image']['watermark_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to custom watermark'),
    '#description' => t('The path to the file you would like to use as watermark image.'),
    '#default_value' => variable_get('ueditor_watermark_path', ''),
  );
  $form['global']['watermark_settings']['watermark_image']['watermark_upload'] = array(
    '#type' => 'file',
    '#title' => t('Upload watermark image'),
    '#maxlength' => 40,
    '#description' => t("If you don't have direct file access to the server, use this field to upload watermark image."),
  );
  $form['global']['watermark_settings']['watermark_image']['watermark_alpha'] = array(
    '#type' => 'select',
    '#title' => t('Watermark Alpha'),
    '#options' => drupal_map_assoc(array(
      30,
      50,
      80,
      100,
    )),
    '#default_value' => variable_get('ueditor_watermark_alpha', 50),
  );
  $form['global']['watermark_settings']['watermark_text'] = array(
    '#type' => 'container',
    '#states' => array(
      'invisible' => array(
        '#edit-watermark-type' => array(
          'value' => 'image',
        ),
      ),
    ),
  );
  $form['global']['watermark_settings']['watermark_text']['textcontent'] = array(
    '#type' => 'textfield',
    '#title' => t('Watermark Text'),
    '#description' => t('The path to the file you would like to use as watermark image.'),
    '#default_value' => variable_get('ueditor_textcontent', $base_url),
  );
  $form['global']['watermark_settings']['watermark_text']['textfontsize'] = array(
    '#type' => 'select',
    '#title' => t('Watermark Text Font Size'),
    '#options' => drupal_map_assoc(array(
      12,
      16,
      18,
      24,
      36,
      48,
      60,
    )),
    '#default_value' => variable_get('ueditor_textfontsize', 16),
  );
  $form['global']['watermark_settings']['watermark_text']['textcolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Watermark Text Color'),
    '#description' => t('The path to the file you would like to use as watermark image.'),
    '#default_value' => variable_get('ueditor_textcolor', '#FF0000'),
  );
  $form['global']['watermark_settings']['watermark_place'] = array(
    '#type' => 'select',
    '#title' => t('Watermark Place'),
    '#options' => array(
      '0' => 'Random',
      '1' => 'Top Left',
      '2' => 'Top Center',
      '3' => 'Top Right',
      '4' => 'Middle Left',
      '5' => 'Middle Center',
      '6' => 'Middle Right',
      '7' => 'Bottom Left',
      '8' => 'Bottom Center',
      '9' => 'Bottom Right',
    ),
    '#default_value' => variable_get('ueditor_watermark_place', 9),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}