You are here

function ckeditor_rebuild_selectors in CKEditor - WYSIWYG HTML editor 6

Rebuilds the regular expression that is used to match the inclusion/exclusion rules and the simplified toolbar rules

Parameters

string $name Name of the profile to process. If omitted, all profiles are rebuilt:

4 calls to ckeditor_rebuild_selectors()
ckeditor_admin_global_profile_form_submit in includes/ckeditor.admin.inc
ckeditor_admin_profile_clone_form_submit in includes/ckeditor.admin.inc
ckeditor_admin_profile_form_submit in includes/ckeditor.admin.inc
ckeditor_install in ./ckeditor.install

File

includes/ckeditor.admin.inc, line 2035
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_rebuild_selectors($name = NULL) {
  if ($name == NULL) {
    $result = db_query("SELECT * FROM {ckeditor_settings}");
  }
  else {
    $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name = '%s'", $name);
  }
  while ($data = db_fetch_object($result)) {
    if ($data->settings) {
      $settings = unserialize($data->settings);
      $vars = array(
        'excl',
        'simple_incl',
        'default_state_exception',
      );
      foreach ($vars as $var) {
        if (!isset($settings[$var])) {
          $settings[$var] = '';
        }
        $settings[$var . '_regex'] = '';
        $rules = preg_split('/[\\s,]+/', $settings[$var]);
        $regex = array();
        if (!empty($rules)) {
          foreach ($rules as $rule) {
            if (!empty($rule)) {
              $rule = ckeditor_parse_rule($rule);
              $regex[] = '(?:' . ckeditor_rule_to_regex($rule) . ')';
            }
          }
          if (!empty($regex)) {
            $settings[$var . '_regex'] = '#' . implode('|', $regex) . '#';
          }
        }
      }
      db_query("UPDATE {ckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
    }
  }
}