You are here

function imce_textarea in IMCE 7

Same name and namespace in other branches
  1. 6.2 imce.module \imce_textarea()
  2. 6 imce.module \imce_textarea()

Inline image/link insertion to textareas.

1 string reference to 'imce_textarea'
imce_element_info in ./imce.module
Implements hook_element_info().

File

./imce.module, line 149
Implements the necessary hooks for the file browser to work properly.

Code

function imce_textarea($element) {
  static $regexp;
  if (!isset($regexp)) {
    $regexp = FALSE;
    if (imce_access() && ($regexp = str_replace(' ', '', variable_get('imce_settings_textarea', '')))) {
      $regexp = '@^(' . str_replace(',', '|', implode('.*', array_map('preg_quote', explode('*', $regexp)))) . ')$@';
    }
  }
  if ($regexp && preg_match($regexp, $element['#id'])) {
    drupal_add_js(drupal_get_path('module', 'imce') . '/js/imce_set_inline.js');
    $arrayAtributtes = array(
      '!image' => l(t('image'), 'imce', array(
        'attributes' => array(
          'name' => $element['#id'] . '-IMCE-image',
          'class' => array(
            'imce-inline-image',
          ),
        ),
      )),
      '!link' => l(t('link'), 'imce', array(
        'attributes' => array(
          'name' => $element['#id'] . '-IMCE-link',
          'class' => array(
            'imce-inline-link',
          ),
        ),
      )),
    );
    $element['#description'] = (isset($element['#description']) ? $element['#description'] : '') . '<div class="imce-inline-wrapper" style="display:none">' . t('Insert !image or !link.', $arrayAtributtes) . '</div>';
  }
  return $element;
}