ckeditor.install 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <?php
  2. /*
  3. * CKEditor - The text editor for the Internet - http://ckeditor.com
  4. * Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  5. *
  6. * == BEGIN LICENSE ==
  7. *
  8. * Licensed under the terms of any of the following licenses of your
  9. * choice:
  10. *
  11. * - GNU General Public License Version 2 or later (the "GPL")
  12. * http://www.gnu.org/licenses/gpl.html
  13. *
  14. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. * http://www.gnu.org/licenses/lgpl.html
  16. *
  17. * - Mozilla Public License Version 1.1 or later (the "MPL")
  18. * http://www.mozilla.org/MPL/MPL-1.1.html
  19. *
  20. * == END LICENSE ==
  21. *
  22. * @file
  23. * CKEditor Module for Drupal 7.x
  24. *
  25. * This module allows Drupal to replace textarea fields with CKEditor.
  26. *
  27. * CKEditor is an online rich text editor that can be embedded inside web pages.
  28. * It is a WYSIWYG (What You See Is What You Get) editor which means that the
  29. * text edited in it looks as similar as possible to the results end users will
  30. * see after the document gets published. It brings to the Web popular editing
  31. * features found in desktop word processors such as Microsoft Word and
  32. * OpenOffice.org Writer. CKEditor is truly lightweight and does not require any
  33. * kind of installation on the client computer.
  34. */
  35. /*
  36. * Implementation of hook_install().
  37. *
  38. * This will automatically install the database tables for the CKEditor module for both MySQL and PostgreSQL databases.
  39. *
  40. * If you are using another database, you will have to install the tables manually, using the queries below as a reference.
  41. *
  42. * Note that the curly braces around table names are a Drupal-specific feature to allow for automatic database table prefixing,
  43. * and will need to be removed.
  44. */
  45. function ckeditor_install() {
  46. module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  47. //searching ckeditor.js
  48. $editor_path = _ckeditor_script_path();
  49. //insert default input formats to profiles
  50. db_insert('ckeditor_input_format')->fields(array("name" => "Advanced", "format" => 'filtered_html'))->execute();
  51. db_insert('ckeditor_input_format')->fields(array("name" => "Full", "format" => 'full_html'))->execute();
  52. //insert settings for default role
  53. $arr = array();
  54. $arr['filebrowser'] = 'none';
  55. $arr['quickupload'] = 'f';
  56. //security
  57. $arr['ss'] = "2";
  58. $arr['filters']['filter_html'] = 1;
  59. //appearance
  60. $arr['default'] = "t";
  61. $arr['show_toggle'] = "t";
  62. $arr['popup'] = variable_get('ckeditor_popup', 0) ? "t" : "f";
  63. $arr['toolbar'] = "
  64. [
  65. ['Source'],
  66. ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
  67. ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
  68. ['Image','Media','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
  69. ['Maximize', 'ShowBlocks'],
  70. '/',
  71. ['Format'],
  72. ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
  73. ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
  74. ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
  75. ['Link','Unlink','Anchor', 'Linkit']
  76. ]
  77. ";
  78. $arr['expand'] = variable_get('ckeditor_toolbar_start_expanded', 1) ? "t" : "f";
  79. $arr['width'] = variable_get("ckeditor_width", "100%");
  80. $arr['lang'] = "en";
  81. $arr['auto_lang'] = "t";
  82. $arr['language_direction'] = "default";
  83. //output
  84. $arr['enter_mode'] = "p";
  85. $arr['shift_enter_mode'] = "br";
  86. $arr['font_format'] = 'p;div;pre;address;h1;h2;h3;h4;h5;h6';
  87. $arr['format_source'] = "t";
  88. $arr['format_output'] = "t";
  89. $arr['custom_formatting'] = "f";
  90. $arr['formatting']['custom_formatting_options'] = array('indent' => 'indent', 'breakBeforeOpen' => 'breakBeforeOpen', 'breakAfterOpen' => 'breakAfterOpen', 'breakAfterClose' => 'breakAfterClose');
  91. //css
  92. $arr['css_mode'] = "none";
  93. $arr['css_path'] = variable_get("ckeditor_stylesheet", "");
  94. //upload
  95. //get permissions here like in _update_role_permissions
  96. $arr['filebrowser'] = "none";
  97. $arr['user_choose'] = "f";
  98. $arr['ckeditor_load_method'] = "ckeditor.js";
  99. $arr['ckeditor_load_time_out'] = 0;
  100. $arr['scayt_autoStartup'] = "f";
  101. //advanced options
  102. $arr['html_entities'] = "f";
  103. db_insert('ckeditor_settings')->fields(array("name" => "Advanced", "settings" => serialize($arr)))->execute();
  104. //insert settings for advanced role
  105. $arr['toolbar'] = "
  106. [
  107. ['Source'],
  108. ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
  109. ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
  110. ['Image','Media','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe'],
  111. '/',
  112. ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
  113. ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
  114. ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
  115. ['Link','Unlink','Anchor', 'Linkit'],
  116. ['DrupalBreak'],
  117. '/',
  118. ['Format','Font','FontSize'],
  119. ['TextColor','BGColor'],
  120. ['Maximize', 'ShowBlocks']
  121. ]
  122. ";
  123. $arr['filters'] = array();
  124. db_insert('ckeditor_settings')->fields(array("name" => "Full", "settings" => serialize($arr)))->execute();
  125. $arr = array();
  126. if ($editor_path) {
  127. $arr['ckeditor_path'] = $editor_path;
  128. }
  129. db_insert('ckeditor_settings')->fields(array("name" => "CKEditor Global Profile", "settings" => serialize($arr)))->execute();
  130. module_load_include('inc', 'ckeditor', 'includes/ckeditor.admin');
  131. }
  132. /**
  133. * Implementation of hook_schema().
  134. */
  135. function ckeditor_schema() {
  136. $schema['ckeditor_settings'] = array(
  137. 'description' => 'Stores CKEditor profile settings',
  138. 'fields' => array(
  139. 'name' => array(
  140. 'type' => 'varchar',
  141. 'not null' => TRUE,
  142. 'default' => '',
  143. 'length' => 128,
  144. 'description' => 'Name of the CKEditor profile',
  145. ),
  146. 'settings' => array(
  147. 'type' => 'text',
  148. 'description' => 'Profile settings',
  149. ),
  150. ),
  151. 'primary key' => array('name')
  152. );
  153. $schema['ckeditor_input_format'] = array(
  154. 'description' => 'Stores CKEditor input format assignments',
  155. 'fields' => array(
  156. 'name' => array(
  157. 'type' => 'varchar',
  158. 'not null' => TRUE,
  159. 'default' => '',
  160. 'length' => 128,
  161. 'description' => 'Name of the CKEditor role',
  162. ),
  163. 'format' => array(
  164. 'type' => 'varchar',
  165. 'not null' => TRUE,
  166. 'default' => '',
  167. 'length' => 128,
  168. 'description' => 'Drupal filter format ID',
  169. )
  170. ),
  171. 'primary key' => array('name', 'format'),
  172. );
  173. return $schema;
  174. }
  175. /**
  176. * Implementation of hook_requirements().
  177. *
  178. * This hook will issue warnings if:
  179. * - The CKEditor source files are not found.
  180. * - The CKEditor source files are out of date.
  181. * - Quick upload and/or the built-in file browser are used and $cookie_domain is not set.
  182. */
  183. function ckeditor_requirements($phase) {
  184. $requirements = array();
  185. if ($phase == 'runtime') {
  186. module_load_include('module', 'ckeditor');
  187. module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  188. $requirements['ckeditor'] = array(
  189. 'title' => t('CKEditor'),
  190. 'value' => t('Unknown'),
  191. );
  192. $requirements['ckeditor']['severity'] = REQUIREMENT_OK;
  193. if (!_ckeditor_requirements_isinstalled()) {
  194. $sourcepath = ckeditor_path('local');
  195. $requirements['ckeditor']['description'] = t('CKEditor was not found in <code>%sourcepath</code>.', array('%sourcepath' => $sourcepath));
  196. $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
  197. }
  198. elseif (($installed_version = _ckeditor_requirements_getinstalledversion()) === NULL) {
  199. $requirements['ckeditor']['description'] = t('CKEditor version could not be determined.');
  200. $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
  201. }
  202. else {
  203. $profile_name = _ckeditor_requirements_ckfinder_filebrowser_enabled();
  204. if ($profile_name !== FALSE) {
  205. if (!_ckeditor_requirements_cookiedomainset()) {
  206. $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
  207. $requirements['ckeditor']['description'] = t('You are using a feature that requires <code>$cookie_domain</code> to be set, but it is not set in your <code>settings.php</code> file (CKFinder is enabled in the !profile profile).', array('!profile' => l($profile_name, 'admin/config/content/ckeditor/edit/' . urlencode($profile_name))));
  208. }
  209. elseif ($error = _ckeditor_requirements_ckfinder_config_check($profile_name)) {
  210. $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
  211. $requirements['ckeditor']['description'] = $error;
  212. }
  213. }
  214. }
  215. if ((($installed_version = _ckeditor_requirements_getinstalledversion()) !== NULL) && (-1 == version_compare($installed_version, '3.1 SVN')) && $installed_version != '%VERSION%') {
  216. $requirements['ckeditor']['description'] = t('Some features are disabled because you are using an older version of CKEditor. Please upgrade to CKEditor 3.1 (or higher).');
  217. $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
  218. }
  219. if (!empty($installed_version)) {
  220. if ($installed_version == '%VERSION%') {
  221. $requirements['ckeditor']['value'] = 'GIT version';
  222. }
  223. else {
  224. $requirements['ckeditor']['value'] = $installed_version;
  225. }
  226. }
  227. else {
  228. $requirements['ckeditor']['value'] = t('Not found');
  229. }
  230. }
  231. return $requirements;
  232. }
  233. /**
  234. * Fetches the version of the installed CKEditor sources.
  235. *
  236. * It tries to locate the version of the CKEditor sources in
  237. * ckeditor.js.
  238. *
  239. * Releases have a version number such as "3.0.1".
  240. * SVN nightly releases have a minor version number with SVN appended: "3.0 SVN".
  241. * SVN checkouts have the string "[Development]".
  242. *
  243. * This function is used by ckeditor_requirements().
  244. *
  245. * @return string Version number (eg. 3.0) of CKEditor. Null if not found in ckeditor_basic.js.
  246. */
  247. function _ckeditor_requirements_getinstalledversion() {
  248. module_load_include('module', 'ckeditor');
  249. $editor_path = ckeditor_path('local', TRUE);
  250. $jspath = $editor_path . '/ckeditor.js';
  251. $configcontents = @file_get_contents($jspath);
  252. if (!$configcontents) {
  253. return NULL;
  254. }
  255. $matches = array();
  256. if (preg_match('#,version:[\'\"]{1}(.*?)[\'\"]{1},#', $configcontents, $matches)) {
  257. return $matches[1];
  258. }
  259. return NULL;
  260. }
  261. /**
  262. * Executed when the built-in file browser is enabled.
  263. * Returns FALSE if no errors are found in the config.php file, otherwise it returns an error message.
  264. *
  265. * @return string|boolean
  266. */
  267. function _ckeditor_requirements_ckfinder_config_check($profile_name) {
  268. global $base_url;
  269. module_load_include('module', 'ckeditor');
  270. $config_path = ckfinder_path('local') . '/config.php';
  271. if (!file_exists($config_path)) {
  272. return t('!ckfinder is not installed correctly: <code>!config</code> not found. Make sure that you uploaded all files and did not accidentally remove the configuration file.', array(
  273. '!config' => $config_path,
  274. '!ckfinder' => '<a href="http://ckfinder.com">CKFinder</a>'
  275. ));
  276. }
  277. if (!is_readable($config_path)) {
  278. return t('CKEditor needs read permission to the <code>!config</code> file.', array('!config' => $config_path));
  279. }
  280. $config_contents = file($config_path);
  281. //not a 100% valid check, but well... let's have at least some error checking
  282. $require_once_found = FALSE;
  283. $require_once_line = 0;
  284. $userfiles_absolute_path_line = 0;
  285. $force_single_extension_line = 0;
  286. if ($config_contents) {
  287. foreach ($config_contents as $line_num => $line) {
  288. //make sure it doesn't start with a comment, unfortunately we're not protected if code is commented with /* */
  289. if (!$require_once_found && strpos($line, "filemanager.config.php") !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
  290. $require_once_found = TRUE;
  291. $require_once_line = $line_num;
  292. }
  293. /**
  294. * @todo Finish this
  295. */
  296. if (!$userfiles_absolute_path_line && strpos($line, '$Config[\'UserFilesAbsolutePath\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
  297. $userfiles_absolute_path_line = $line_num;
  298. }
  299. if (!$force_single_extension_line && strpos($line, '$Config[\'ForceSingleExtension\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
  300. $force_single_extension_line = $line_num;
  301. }
  302. }
  303. }
  304. if (!$require_once_found) {
  305. return t('You are using a feature that requires manual integration in the <code>config.php</code> file. Please read the "Installing CKFinder" section in the <code>!readme</code> file carefully and add a <code>require_once ...</code> statement to the <code>%ckfconfig</code> file.', array('%ckfconfig' => $config_path, '!readme' => l(t('README.txt'), $base_url . '/' . drupal_get_path('module', 'ckeditor') . '/README.txt', array('absolute' => TRUE))));
  306. }
  307. if ($userfiles_absolute_path_line && $force_single_extension_line && (
  308. $require_once_line < $userfiles_absolute_path_line || $require_once_line > $force_single_extension_line)) {
  309. return t('You are using a feature that requires manual integration in the <code>config.php</code> file. You have added a <code>require_once ...</code> statement to the <code>%ckfconfig</code> file, but in the wrong line.', array('%ckfconfig' => $config_path));
  310. }
  311. return FALSE;
  312. }
  313. /**
  314. * Checks if any profile requires an explicit setting of $cookie_domain
  315. * in settings.php.
  316. *
  317. * %cookie_domain is required when the internal file browser or quick upload is used.
  318. *
  319. * This function is used by ckeditor_requirements().
  320. *
  321. * @return boolean True if any profile requires $cookie_domain.
  322. */
  323. function _ckeditor_requirements_ckfinder_filebrowser_enabled() {
  324. module_load_include('module', 'ckeditor');
  325. $profiles = ckeditor_profile_load();
  326. foreach ($profiles as $profile) {
  327. if ((isset($profile->settings['filebrowser']) && $profile->settings['filebrowser'] == 'ckfinder')) {
  328. return $profile->name;
  329. }
  330. }
  331. return FALSE;
  332. }
  333. /**
  334. * Checks if $cookie_domain was set.
  335. *
  336. * It has to include settings.php again because conf_init() sets
  337. * $cookie_domain regardless of its presence in settings.php, so
  338. * simply checking $GLOBALS['cookie_domain'] is not possible.
  339. *
  340. * This function is used by ckeditor_requirements().
  341. *
  342. * @return boolean True if $cookie_domain was set in settings.php.
  343. */
  344. function _ckeditor_requirements_cookiedomainset() {
  345. if (file_exists('./' . conf_path() . '/settings.php')) {
  346. $settings = file_get_contents('./' . conf_path() . '/settings.php');
  347. if (preg_match('#^\s*\$cookie_domain#m', $settings)) {
  348. return TRUE;
  349. }
  350. }
  351. return FALSE;
  352. }
  353. /**
  354. * Updates broken settings for the 'Full' profile. (Resets toolbar to default)
  355. */
  356. function ckeditor_update_7000() {
  357. _ckeditor_d6_to_d7_migration();
  358. $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'Full'))->fetchField();
  359. $settings = unserialize($result);
  360. $settings['toolbar'] = "
  361. [
  362. ['Source'],
  363. ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
  364. ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
  365. ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
  366. '/',
  367. ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
  368. ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
  369. ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
  370. ['Link','Unlink','Anchor'],
  371. ['DrupalBreak'],
  372. '/',
  373. ['Format','Font','FontSize'],
  374. ['TextColor','BGColor'],
  375. ['Maximize', 'ShowBlocks']
  376. ]
  377. ";
  378. $settings = serialize($settings);
  379. $update = db_update('ckeditor_settings')
  380. ->fields(array(
  381. 'settings' => $settings,
  382. ))
  383. ->condition('name', 'Full', '=')
  384. ->execute();
  385. }
  386. /**
  387. * Removes the 'DrupalBreak' button from the 'Advanced' profile. (Resets toolbar to default)
  388. */
  389. function ckeditor_update_7001() {
  390. $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'Advanced'))->fetchField();
  391. $settings = unserialize($result);
  392. $settings['toolbar'] = "
  393. [
  394. ['Source'],
  395. ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
  396. ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
  397. ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
  398. ['Maximize', 'ShowBlocks'],
  399. '/',
  400. ['Format'],
  401. ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
  402. ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
  403. ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
  404. ['Link','Unlink','Anchor']
  405. ]
  406. ";
  407. $settings = serialize($settings);
  408. $update = db_update('ckeditor_settings')
  409. ->fields(array(
  410. 'settings' => $settings,
  411. ))
  412. ->condition('name', 'Advanced', '=')
  413. ->execute();
  414. }
  415. /**
  416. * Rewrites 'Path to CKEditor' to new flags.
  417. */
  418. function ckeditor_update_7002() {
  419. $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'CKEditor Global Profile'))->fetchField();
  420. $settings = unserialize($result);
  421. if ($settings['ckeditor_path'] == '%b/sites/all/libraries/ckeditor') {
  422. $settings['ckeditor_path'] = '%l/ckeditor';
  423. }
  424. else {
  425. $settings['ckeditor_path'] = str_replace('%b/', '', $settings['ckeditor_path']);
  426. $settings['ckeditor_path'] = str_replace('%b', '', $settings['ckeditor_path']);
  427. }
  428. $settings = serialize($settings);
  429. $update = db_update('ckeditor_settings')
  430. ->fields(array(
  431. 'settings' => $settings,
  432. ))
  433. ->condition('name', 'CKEditor Global Profile', '=')
  434. ->execute();
  435. }
  436. /**
  437. * Fixes static paths to plugin files.
  438. */
  439. function ckeditor_update_7003() {
  440. module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  441. module_load_include('module', 'ckeditor');
  442. _ckeditor_d6_to_d7_migration();
  443. $render = array();
  444. $render["%base_path%"] = base_path();
  445. $render["%editor_path%"] = ckeditor_path('relative') . '/';
  446. $render["%ckeditor_path%"] = ckeditor_module_path('relative');
  447. $render["%plugin_dir%"] = $render["%module_path%"] . '/plugins/';
  448. $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> :name", array(':name' => 'CKEditor Global Profile'))->fetchAllAssoc('name');
  449. foreach ((array) $result as $profile) {
  450. $name = $profile->name;
  451. $settings = unserialize($profile->settings);
  452. foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
  453. $settings['loadPlugins'][$i]['path'] = str_replace(array_values($render), array_keys($render), $plugin['path']);
  454. }
  455. $settings = serialize($settings);
  456. $update = db_update('ckeditor_settings')
  457. ->fields(array(
  458. 'settings' => $settings,
  459. ))
  460. ->condition('name', $name, '=')
  461. ->execute();
  462. }
  463. }
  464. /**
  465. * Minor update for those who have run update.php with problems.
  466. * @see http://drupal.org/node/1347682 for a better explanation.
  467. */
  468. function ckeditor_update_7004() {
  469. return _ckeditor_d6_to_d7_migration();
  470. }
  471. /**
  472. * Fixes plugin paths stored in database.
  473. * @see http://drupal.org/node/1864760 for more information
  474. */
  475. function ckeditor_update_7005() {
  476. $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> :name", array(':name' => 'CKEditor Global Profile'))->fetchAllAssoc('name');
  477. foreach ((array) $result as $profile) {
  478. $name = $profile->name;
  479. $settings = unserialize($profile->settings);
  480. $replace = array(
  481. "%base_path%%editor_path%" => "%editor_path%",
  482. "%base_path%%module_path%" => "%module_path%",
  483. "%base_path%%plugin_dir%" => "%plugin_dir%",
  484. "%base_path%%plugin_dir_extra%" => "%plugin_dir_extra%"
  485. );
  486. foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
  487. $settings['loadPlugins'][$i]['path'] = str_replace(array_keys($replace), array_values($replace), $plugin['path']);
  488. }
  489. $settings = serialize($settings);
  490. db_update('ckeditor_settings')
  491. ->fields(array(
  492. 'settings' => $settings,
  493. ))
  494. ->condition('name', $name, '=')
  495. ->execute();
  496. }
  497. }
  498. /**
  499. * Adapts D6 table structure to D7 schema.
  500. */
  501. function _ckeditor_d6_to_d7_migration() {
  502. if (db_table_exists('ckeditor_role')) {
  503. db_drop_table('ckeditor_role');
  504. }
  505. if (!db_table_exists('ckeditor_input_format')) {
  506. $ckeditor_input_format = array(
  507. 'description' => 'Stores CKEditor input format assignments',
  508. 'fields' => array(
  509. 'name' => array(
  510. 'type' => 'varchar',
  511. 'not null' => TRUE,
  512. 'default' => '',
  513. 'length' => 128,
  514. 'description' => 'Name of the CKEditor role',
  515. ),
  516. 'format' => array(
  517. 'type' => 'varchar',
  518. 'not null' => TRUE,
  519. 'default' => '',
  520. 'length' => 128,
  521. 'description' => 'Drupal filter format ID',
  522. )
  523. ),
  524. 'primary key' => array('name', 'format'),
  525. );
  526. db_create_table('ckeditor_input_format', $ckeditor_input_format);
  527. }
  528. }