You are here

function ckeditor_update_6101 in CKEditor - WYSIWYG HTML editor 6

Implementation of hook_update_N().

Fixes static paths to plugin files.

File

./ckeditor.install, line 506

Code

function ckeditor_update_6101() {
  module_load_include('module', 'ckeditor');
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  $render = array();
  $render["%base_path%"] = base_path();
  $render["%editor_path%"] = ckeditor_path(TRUE) . '/';
  $render["%ckeditor_path%"] = drupal_get_path('module', 'ckeditor') . '/';
  $render["%plugin_dir%"] = $render["%ckeditor_path%"] . 'plugins/';
  $render["%plugin_dir_extra%"] = ckeditor_plugins_path(TRUE) . '/';
  if ($render["%plugin_dir%"] == $render["%plugin_dir_extra%"]) {
    unset($render["%plugin_dir_extra%"]);
  }
  $ret = array();
  $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> 'CKEditor Global Profile'");
  while ($profile = db_fetch_object($result)) {
    $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);
    $return = db_query("UPDATE {ckeditor_settings} SET settings = '%s' WHERE name = '%s'", $settings, $name);
    $ret[] = array(
      'success' => $return !== FALSE,
      'query' => "UPDATE PROFILE - {$name}",
    );
  }
  return $ret;
}