You are here

function ckeditor_update_7005 in CKEditor - WYSIWYG HTML editor 7

Fixes plugin paths stored in database.

See also

http://drupal.org/node/1864760 for more information

File

./ckeditor.install, line 560

Code

function ckeditor_update_7005() {
  $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> :name", array(
    ':name' => 'CKEditor Global Profile',
  ))
    ->fetchAllAssoc('name');
  foreach ((array) $result as $profile) {
    $name = $profile->name;
    $settings = unserialize($profile->settings);
    $replace = array(
      "%base_path%%editor_path%" => "%editor_path%",
      "%base_path%%module_path%" => "%module_path%",
      "%base_path%%plugin_dir%" => "%plugin_dir%",
      "%base_path%%plugin_dir_extra%" => "%plugin_dir_extra%",
    );
    foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
      $settings['loadPlugins'][$i]['path'] = str_replace(array_keys($replace), array_values($replace), $plugin['path']);
    }
    $settings = serialize($settings);
    db_update('ckeditor_settings')
      ->fields(array(
      'settings' => $settings,
    ))
      ->condition('name', $name, '=')
      ->execute();
  }
}