You are here

function xbbcode_list_autocomplete in Extensible BBCode 7

Same name and namespace in other branches
  1. 8 xbbcode_list/xbbcode_list.module \xbbcode_list_autocomplete()
  2. 5 xbbcode_list/xbbcode_list.module \xbbcode_list_autocomplete()
  3. 6 xbbcode_list/xbbcode_list.module \xbbcode_list_autocomplete()
1 string reference to 'xbbcode_list_autocomplete'
xbbcode_list_menu in xbbcode_list/xbbcode_list.module

File

xbbcode_list/xbbcode_list.module, line 180

Code

function xbbcode_list_autocomplete($string) {
  $styles = array(
    'upper-alpha',
    'lower-alpha',
    'upper-roman',
    'lower-roman',
    'numeric',
  );
  $results = array();
  if (preg_match('/^(.*,\\s*)?(.*)$/', check_plain($string), $match)) {
    list($first, $last) = array(
      $match[1],
      $match[2],
    );
    $length = drupal_strlen($last);
    foreach ($styles as $style) {
      if (drupal_substr($style, 0, $length) == $last) {
        $results[$first . $style] = $style;
      }
    }
  }
  drupal_json_output($results);
}