function _bootstrap_is_simple_string

8.x-3.x deprecated.php _bootstrap_is_simple_string($string, $length = 250, $allowed_tags = NULL, &$html = FALSE)
7.x-3.x common.inc _bootstrap_is_simple_string($string, $length = 250, $allowed_tags = NULL, &$html = FALSE)

Determines if a string of text is considered "simple".

Parameters

string $string: The string of text to check "simple" criteria on.

int|false $length: The length of characters used to determine whether or not $string is considered "simple". Set explicitly to FALSE to disable this criteria.

array|false $allowed_tags: An array of allowed tag elements. Set explicitly to FALSE to disable this criteria.

bool $html: A variable, passed by reference, that indicates whether or not the string contains HTML.

Return value

bool Returns TRUE if the $string is considered "simple", FALSE otherwise.

Related topics

Source includes/common.inc (line 1498)

function _bootstrap_is_simple_string($string, $length = 250, $allowed_tags = NULL, &$html = FALSE) {
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['strings'] = &drupal_static(__FUNCTION__);
  }
  $strings = &$drupal_static_fast['strings'];
  if (!isset($strings[$string])) {
    $plain_string = strip_tags($string);
    $simple = TRUE;
    if ($allowed_tags !== FALSE) {
      $filtered_string = filter_xss($string, $allowed_tags);
      $html = $filtered_string !== $plain_string;
      $simple = $simple && $string === $filtered_string;
    }
    if ($length !== FALSE) {
      $simple = $simple && strlen($plain_string) <= intval($length);
    }
    $strings[$string] = $simple;
  }
  return $strings[$string];
}