You are here

function ckeditor_update_7003 in CKEditor - WYSIWYG HTML editor 7

Fixes static paths to plugin files.

File

./ckeditor.install, line 515

Code

function ckeditor_update_7003() {
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  module_load_include('module', 'ckeditor');
  _ckeditor_d6_to_d7_migration();
  $render = array();
  $render["%base_path%"] = base_path();
  $render["%editor_path%"] = ckeditor_path('relative') . '/';
  $render["%ckeditor_path%"] = ckeditor_module_path('relative');
  $render["%plugin_dir%"] = $render["%module_path%"] . '/plugins/';
  $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);
    foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
      $settings['loadPlugins'][$i]['path'] = str_replace(array_values($render), array_keys($render), $plugin['path']);
    }
    $settings = serialize($settings);
    $update = db_update('ckeditor_settings')
      ->fields(array(
      'settings' => $settings,
    ))
      ->condition('name', $name, '=')
      ->execute();
  }
}