You are here

function _img_assist_textarea_match in Image Assist 5.3

Same name and namespace in other branches
  1. 5 img_assist.module \_img_assist_textarea_match()
  2. 5.2 img_assist.module \_img_assist_textarea_match()
  3. 6.2 img_assist.module \_img_assist_textarea_match()
  4. 6 img_assist.module \_img_assist_textarea_match()

Determine if img_assist can render the current textarea.

Return value

TRUE if can render, FALSE if not allowed.

See also

block_list().

Related topics

1 call to _img_assist_textarea_match()
img_assist_textarea in ./img_assist.module
Add JavaScript settings for generating the image link underneath textareas.

File

./img_assist.module, line 1689
Image Assist module

Code

function _img_assist_textarea_match($formid) {
  $must_match = variable_get('img_assist_textareas_type', 2);
  if ($must_match == 2) {
    return TRUE;
  }
  else {
    $formids = variable_get('img_assist_textareas', "edit-body\nedit-comment");
    $regexp = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
    ), array(
      '|',
      '.*',
    ), preg_quote($formids, '/')) . ')$/';

    // Compare with the form id.
    $page_match = preg_match($regexp, $formid);

    // When $must_match has a value of 0, img_assist is displayed on
    // all pages except those listed in img_assist_textareas. When set to 1, it
    // is displayed only on those textareas listed in img_assist_textareas.
    $page_match = !($must_match xor $page_match);
    return $page_match;
  }
}