Révision 6fd71452
Ajouté par Julien Enselme il y a environ 10 ans
drupal7/sites/all/modules/ckeditor/includes/ckeditor.lib.inc | ||
---|---|---|
115 | 115 |
$editor_local_path = ckeditor_path('local'); |
116 | 116 |
$ckconfig_js = $editor_local_path . '/config.js'; |
117 | 117 |
$ckeditor_config_js = $module_drupal_path . '/ckeditor.config.js'; |
118 |
if (file_exists($ckconfig_js) && is_readable($ckconfig_js)) { |
|
118 |
if ($editor_local_path != '<URL>' && file_exists($ckconfig_js) && is_readable($ckconfig_js)) {
|
|
119 | 119 |
$fp = @fopen($ckconfig_js, "r"); |
120 | 120 |
if ($fp) { |
121 | 121 |
while (!feof($fp)) { |
... | ... | |
163 | 163 |
$arr = array(); |
164 | 164 |
$editor_local_path = ckeditor_path('local'); |
165 | 165 |
$skin_dir = $editor_local_path . '/skins'; |
166 |
if (is_dir($skin_dir)) { |
|
166 |
if ($editor_local_path != '<URL>' && is_dir($skin_dir)) {
|
|
167 | 167 |
$dh = @opendir($skin_dir); |
168 | 168 |
if (FALSE !== $dh) { |
169 | 169 |
while (($file = readdir($dh)) !== FALSE) { |
... | ... | |
177 | 177 |
closedir($dh); |
178 | 178 |
} |
179 | 179 |
} |
180 |
|
|
181 | 180 |
//oops, we have no information about skins, let's use only default |
182 | 181 |
if (empty($arr)) { |
183 | 182 |
$arr = array( |
184 |
'kama' => 'Kama', |
|
183 |
'moono' => 'Moono', |
|
184 |
'kama' => 'Kama' |
|
185 | 185 |
); |
186 | 186 |
} |
187 | 187 |
asort($arr); |
... | ... | |
202 | 202 |
if (array_key_exists('kama', $skin_options)) { |
203 | 203 |
return 'kama'; |
204 | 204 |
} |
205 |
reset($skin_options); |
|
205 | 206 |
//if any default theme not exists select first from the list |
206 |
return key(reset($skin_options));
|
|
207 |
return key($skin_options);
|
|
207 | 208 |
} |
208 | 209 |
|
209 | 210 |
/** |
... | ... | |
215 | 216 |
$arr = array(); |
216 | 217 |
$editor_local_path = ckeditor_path('local'); |
217 | 218 |
$lang_file = $editor_local_path . '/lang/_languages.js'; |
218 |
if (file_exists($lang_file)) { |
|
219 |
if ($editor_local_path != '<URL>' && file_exists($lang_file)) {
|
|
219 | 220 |
$f = fopen($lang_file, 'r'); |
220 | 221 |
$file = fread($f, filesize($lang_file)); |
221 | 222 |
$tmp = explode('{', $file); |
... | ... | |
332 | 333 |
$arr = array(); |
333 | 334 |
$base_path = '%base_path%'; |
334 | 335 |
$editor_path = '%editor_path%'; |
335 |
$ckeditor_path = '%module_path%'; |
|
336 | 336 |
$plugin_dir = '%plugin_dir%'; |
337 | 337 |
$plugin_dir_additional = '%plugin_dir_extra%'; |
338 | 338 |
$pattern = '#\.addButton\([\s]*[\'"](.*?)[\'"][\s]*\,[\s]*\{[\s]*(.*?)[\s]*\}#s'; |
... | ... | |
378 | 378 |
/* |
379 | 379 |
* CKEditor build-in plugins |
380 | 380 |
*/ |
381 |
$_editor_path = ckeditor_path('local') . '/'; |
|
382 |
if (file_exists($_editor_path . 'plugins/tableresize/plugin.js')) { |
|
383 |
$arr['tableresize'] = array( |
|
384 |
'name' => 'tableresize', |
|
385 |
'desc' => t('Table Resize plugin'), |
|
386 |
'path' => $editor_path . 'plugins/tableresize/', |
|
387 |
'buttons' => FALSE, |
|
388 |
'default' => 't' |
|
389 |
); |
|
390 |
} |
|
381 |
$_editor_path = ckeditor_path('local'); |
|
382 |
//die($editor_path); |
|
383 |
if ($_editor_path != '<URL>') { |
|
384 |
if (file_exists($_editor_path . '/plugins/tableresize/plugin.js')) { |
|
385 |
$arr['tableresize'] = array( |
|
386 |
'name' => 'tableresize', |
|
387 |
'desc' => t('Table Resize plugin'), |
|
388 |
'path' => $editor_path . '/plugins/tableresize/', |
|
389 |
'buttons' => FALSE, |
|
390 |
'default' => 't' |
|
391 |
); |
|
392 |
} |
|
391 | 393 |
|
392 |
if (file_exists($_editor_path . 'plugins/autogrow/plugin.js')) {
|
|
393 |
$arr['autogrow'] = array( |
|
394 |
'name' => 'autogrow', |
|
395 |
'desc' => t('Auto Grow plugin'), |
|
396 |
'path' => $editor_path . 'plugins/autogrow/',
|
|
397 |
'buttons' => FALSE, |
|
398 |
'default' => 'f' |
|
399 |
); |
|
400 |
} |
|
394 |
if (file_exists($_editor_path . '/plugins/autogrow/plugin.js')) {
|
|
395 |
$arr['autogrow'] = array(
|
|
396 |
'name' => 'autogrow',
|
|
397 |
'desc' => t('Auto Grow plugin'),
|
|
398 |
'path' => $editor_path . '/plugins/autogrow/',
|
|
399 |
'buttons' => FALSE,
|
|
400 |
'default' => 'f'
|
|
401 |
);
|
|
402 |
}
|
|
401 | 403 |
|
402 |
if (file_exists($_editor_path . 'plugins/stylesheetparser/plugin.js')) { |
|
403 |
$arr['stylesheetparser'] = array( |
|
404 |
'name' => 'stylesheetparser', |
|
405 |
'desc' => t('Stylesheet Parser plugin'), |
|
406 |
'path' => $editor_path . 'plugins/stylesheetparser/', |
|
407 |
'buttons' => FALSE, |
|
408 |
'default' => 'f' |
|
409 |
); |
|
404 |
if (file_exists($_editor_path . '/plugins/stylesheetparser/plugin.js')) { |
|
405 |
$arr['stylesheetparser'] = array( |
|
406 |
'name' => 'stylesheetparser', |
|
407 |
'desc' => t('Stylesheet Parser plugin'), |
|
408 |
'path' => $editor_path . '/plugins/stylesheetparser/', |
|
409 |
'buttons' => FALSE, |
|
410 |
'default' => 'f' |
|
411 |
); |
|
412 |
} |
|
413 |
} |
|
414 |
else { |
|
415 |
$_editor_url = ckeditor_path('url'); |
|
416 |
if (preg_match("/\/(standard|full)-all/", $_editor_url)) { |
|
417 |
$arr['tableresize'] = array( |
|
418 |
'name' => 'tableresize', |
|
419 |
'desc' => t('Table Resize plugin. See !link for more details.', array( |
|
420 |
'!link' => l(t('addon page'), 'http://ckeditor.com/addon/tableresize') |
|
421 |
)), |
|
422 |
'path' => $_editor_url . '/plugins/tableresize/', |
|
423 |
'buttons' => FALSE, |
|
424 |
'default' => 't' |
|
425 |
); |
|
426 |
$arr['autogrow'] = array( |
|
427 |
'name' => 'autogrow', |
|
428 |
'desc' => t('Auto Grow plugin. See !link for more details.', array( |
|
429 |
'!link' => l(t('addon page'), 'http://ckeditor.com/addon/autogrow') |
|
430 |
)), |
|
431 |
'path' => $_editor_url . '/plugins/autogrow/', |
|
432 |
'buttons' => FALSE, |
|
433 |
'default' => 'f' |
|
434 |
); |
|
435 |
$arr['stylesheetparser'] = array( |
|
436 |
'name' => 'stylesheetparser', |
|
437 |
'desc' => t('Stylesheet Parser plugin. See !link for more details.', array( |
|
438 |
'!link' => l(t('addon page'), 'http://ckeditor.com/addon/stylesheetparser') |
|
439 |
)), |
|
440 |
'path' => $_editor_url . '/plugins/stylesheetparser/', |
|
441 |
'buttons' => FALSE, |
|
442 |
'default' => 'f' |
|
443 |
); |
|
444 |
$arr['codesnippet'] = array( |
|
445 |
'name' => 'codesnippet', |
|
446 |
'desc' => t('Plugin for inserting Code Snippets. See !link for more details. See !help for additional instructions.', array( |
|
447 |
'!link' => l(t('addon page'), 'http://ckeditor.com/addon/codesnippet'), |
|
448 |
'!help' => l(t('help'), 'admin/help/ckeditor', array('fragment' => 'codesnippet')) |
|
449 |
)), |
|
450 |
'path' => $_editor_url . '/plugins/codesnippet/', |
|
451 |
'buttons' => array( |
|
452 |
'CodeSnippet' => array( |
|
453 |
'icon' => 'icons/codesnippet.png', |
|
454 |
'label' => 'Insert Code Snippet', |
|
455 |
) |
|
456 |
), |
|
457 |
'default' => 'f' |
|
458 |
); |
|
459 |
$arr['mathjax'] = array( |
|
460 |
'name' => 'mathjax', |
|
461 |
'desc' => t('Plugin for inserting Mathematical Formula (MathJax). See !link for more details. See !help for additional instructions.', array( |
|
462 |
'!link' => l(t('addon page'), 'http://ckeditor.com/addon/mathjax'), |
|
463 |
'!help' => l(t('help'), 'admin/help/ckeditor', array('fragment' => 'mathjax')) |
|
464 |
)), |
|
465 |
'path' => $_editor_url . '/plugins/mathjax/', |
|
466 |
'buttons' => array( |
|
467 |
'Mathjax' => array( |
|
468 |
'icon' => 'icons/mathjax.png', |
|
469 |
'label' => 'Insert Mathematical Formulas', |
|
470 |
) |
|
471 |
), |
|
472 |
'default' => 'f' |
|
473 |
); |
|
474 |
} |
|
410 | 475 |
} |
411 | 476 |
|
412 | 477 |
/* |
... | ... | |
532 | 597 |
unset($arr['imce']); |
533 | 598 |
} |
534 | 599 |
//remove page break button if there is no module to do this |
535 |
if (isset($arr['drupalbreaks']['buttons']['DrupalPageBreak']) && !module_exists('paging') && !module_exists('pagebreak')) { |
|
600 |
if (isset($arr['drupalbreaks']['buttons']['DrupalPageBreak']) && !module_exists('paging') && !module_exists('pagebreak') && !module_exists('smart_paging')) {
|
|
536 | 601 |
unset($arr['drupalbreaks']['buttons']['DrupalPageBreak']); |
537 | 602 |
} |
538 | 603 |
|
... | ... | |
579 | 644 |
'auto_lang' => 't', |
580 | 645 |
); |
581 | 646 |
|
647 |
// Allow other modules to alter the default settings. |
|
648 |
drupal_alter('ckeditor_default_settings', $default); |
|
649 |
|
|
582 | 650 |
return $default; |
583 | 651 |
} |
584 | 652 |
|
... | ... | |
646 | 714 |
* @return string |
647 | 715 |
*/ |
648 | 716 |
function _ckeditor_script_path() { |
649 |
$jspath = FALSE;
|
|
717 |
$jspath = '';
|
|
650 | 718 |
$module_path = drupal_get_path('module', 'ckeditor'); |
651 | 719 |
|
652 | 720 |
if (file_exists($module_path . '/ckeditor/ckeditor.js')) { |
... | ... | |
672 | 740 |
*/ |
673 | 741 |
function _ckeditor_requirements_isinstalled() { |
674 | 742 |
$editor_path = ckeditor_path('local'); |
743 |
if ($editor_path == '<URL>') |
|
744 |
return TRUE; |
|
675 | 745 |
$jspath = $editor_path . '/ckeditor.js'; |
676 | 746 |
|
677 | 747 |
$jsp = file_exists($jspath); |
... | ... | |
758 | 828 |
$host = base_path(); |
759 | 829 |
|
760 | 830 |
// setting some variables |
761 |
$base_path = ckeditor_base_path('relative'); |
|
762 | 831 |
$module_drupal_path = ckeditor_module_path('relative'); |
763 | 832 |
$module_drupal_local_path = ckeditor_module_path('local'); |
764 | 833 |
$editor_path = ckeditor_path('relative'); |
765 | 834 |
$editor_local_path = ckeditor_path('local'); |
766 | 835 |
|
767 |
// get the default drupal files path |
|
768 |
$files_path = $host . variable_get('file_private_path', conf_path() . '/files'); |
|
769 |
|
|
770 | 836 |
$toolbar = $conf['toolbar']; |
771 | 837 |
|
772 | 838 |
if (!empty($conf['theme_config_js']) && $conf['theme_config_js'] == 't' && file_exists($themepath . 'ckeditor.config.js')) { |
... | ... | |
782 | 848 |
$settings['enterMode'] = constant("CKEDITOR_ENTERMODE_" . strtoupper($conf['enter_mode'])); |
783 | 849 |
$settings['shiftEnterMode'] = constant("CKEDITOR_ENTERMODE_" . strtoupper($conf['shift_enter_mode'])); |
784 | 850 |
$settings['toolbarStartupExpanded'] = ( $conf['expand'] == 't' ); |
851 |
if ($conf['expand'] == 'f') { |
|
852 |
$settings['toolbarCanCollapse'] = true; |
|
853 |
} |
|
785 | 854 |
$settings['width'] = $conf['width']; |
786 | 855 |
//check if skin exists, if not select default one |
787 | 856 |
if (isset($global_profile->settings['skin']) && file_exists($editor_local_path . '/skins/' . $global_profile->settings['skin'])) { |
... | ... | |
792 | 861 |
} |
793 | 862 |
$settings['format_tags'] = $conf['font_format']; |
794 | 863 |
$settings['show_toggle'] = $conf['show_toggle']; |
864 |
if (!empty($conf['allowed_content']) && $conf['allowed_content'] === 'f') { |
|
865 |
$settings['allowedContent'] = true; |
|
866 |
} |
|
867 |
elseif (!empty($conf['extraAllowedContent'])) { |
|
868 |
$settings['extraAllowedContent'] = $conf['extraAllowedContent']; |
|
869 |
} |
|
795 | 870 |
$settings['ss'] = $conf['ss']; |
796 | 871 |
|
797 | 872 |
if (isset($conf['language_direction'])) { |
... | ... | |
830 | 905 |
} |
831 | 906 |
|
832 | 907 |
//add support for divarea plugin from CKE4 |
833 |
if (isset($conf['use_divarea']) && $conf['use_divarea'] == 't' && file_exists($editor_local_path . '/plugins/divarea/plugin.js')) { |
|
908 |
if (isset($conf['use_divarea']) && $conf['use_divarea'] == 't' && $editor_local_path != '<URL>' && file_exists($editor_local_path . '/plugins/divarea/plugin.js')) {
|
|
834 | 909 |
$settings['loadPlugins']['divarea'] = array('name' => 'divarea', 'path' => $editor_path . '/plugins/divarea/', 'buttons' => FALSE, 'default' => 'f'); |
835 | 910 |
} |
836 | 911 |
|
... | ... | |
1206 | 1281 |
$css_files[] = $host . $themepath . 'style.css' . $query_string; |
1207 | 1282 |
} |
1208 | 1283 |
} |
1209 |
if (file_exists($module_drupal_local_path . '/ckeditor.css')) { |
|
1210 |
$css_files[] = $module_drupal_path . '/ckeditor.css' . $query_string; |
|
1284 |
if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) {
|
|
1285 |
$css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string;
|
|
1211 | 1286 |
} |
1212 | 1287 |
if (file_exists($themepath . 'ckeditor.css')) { |
1213 | 1288 |
$css_files[] = $host . $themepath . 'ckeditor.css' . $query_string; |
... | ... | |
1215 | 1290 |
break; |
1216 | 1291 |
|
1217 | 1292 |
case 'self': |
1218 |
if (file_exists($module_drupal_local_path . '/ckeditor.css')) { |
|
1219 |
$css_files[] = $module_drupal_path . '/ckeditor.css' . $query_string; |
|
1293 |
if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) {
|
|
1294 |
$css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string;
|
|
1220 | 1295 |
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { |
1221 |
if (file_exists($module_drupal_local_path . '/ckeditor-rtl.css')) { |
|
1222 |
$css_files[] = $module_drupal_path . '/ckeditor-rtl.css' . $query_string; |
|
1296 |
if (file_exists($module_drupal_local_path . '/css/ckeditor-rtl.css')) {
|
|
1297 |
$css_files[] = $module_drupal_path . '/css/ckeditor-rtl.css' . $query_string;
|
|
1223 | 1298 |
} |
1224 | 1299 |
} |
1225 | 1300 |
} |
... | ... | |
1230 | 1305 |
break; |
1231 | 1306 |
|
1232 | 1307 |
case 'none': |
1233 |
if (file_exists($module_drupal_local_path . '/ckeditor.css')) { |
|
1234 |
$css_files[] = $module_drupal_path . '/ckeditor.css' . $query_string; |
|
1308 |
if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) {
|
|
1309 |
$css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string;
|
|
1235 | 1310 |
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { |
1236 |
if (file_exists($module_drupal_local_path . '/ckeditor-rtl.css')) { |
|
1237 |
$css_files[] = $module_drupal_path . '/ckeditor-rtl.css' . $query_string; |
|
1311 |
if (file_exists($module_drupal_local_path . '/css/ckeditor-rtl.css')) {
|
|
1312 |
$css_files[] = $module_drupal_path . '/css/ckeditor-rtl.css' . $query_string;
|
|
1238 | 1313 |
} |
1239 | 1314 |
} |
1240 | 1315 |
} |
1241 |
if (file_exists($editor_local_path . '/contents.css')) { |
|
1242 |
$css_files[] = $editor_path . '/contents.css' . $query_string; |
|
1316 |
if ($editor_local_path != '<URL>') { |
|
1317 |
if (file_exists($editor_local_path . '/contents.css')) { |
|
1318 |
$css_files[] = $editor_path . '/contents.css' . $query_string; |
|
1319 |
} |
|
1320 |
} |
|
1321 |
else { |
|
1322 |
$editor_url_path = ckeditor_path('url'); |
|
1323 |
$css_files[] = $editor_url_path . '/contents.css' . $query_string; |
|
1243 | 1324 |
} |
1244 | 1325 |
break; |
1245 | 1326 |
} |
... | ... | |
1266 | 1347 |
} |
1267 | 1348 |
} |
1268 | 1349 |
|
1350 |
// Allow modules to modify the settings. |
|
1351 |
drupal_alter('ckeditor_settings', $settings, $conf); |
|
1352 |
|
|
1269 | 1353 |
return $settings; |
1270 | 1354 |
} |
1271 | 1355 |
|
... | ... | |
1354 | 1438 |
return $field; |
1355 | 1439 |
} |
1356 | 1440 |
|
1441 |
// Attach the editor css. |
|
1442 |
$field['#attached']['css'][] = drupal_get_path('module', 'ckeditor') . '/css/ckeditor.editor.css'; |
|
1443 |
|
|
1357 | 1444 |
if ($settings) { |
1358 | 1445 |
$textarea_id = $field['#id']; |
1359 | 1446 |
$class[] = 'ckeditor-mod'; |
... | ... | |
1385 | 1472 |
|
1386 | 1473 |
$editor_local_path = ckeditor_path('local'); |
1387 | 1474 |
$editor_url_path = ckeditor_path('url'); |
1388 |
// get the default drupal files path |
|
1389 |
$files_path = $host . variable_get('file_private_path', conf_path() . '/files'); |
|
1390 | 1475 |
|
1391 | 1476 |
if (!$is_running) { |
1392 | 1477 |
if (!$ckeditor_in_default_format) { |
... | ... | |
1397 | 1482 |
$load_method = $profile->settings['ckeditor_load_method']; |
1398 | 1483 |
$load_time_out = $profile->settings['ckeditor_load_time_out']; |
1399 | 1484 |
} |
1400 |
drupal_add_js('window.CKEDITOR_BASEPATH = "' . ckeditor_path('relative') . '/"', array('type' => 'inline', 'weight' => -100)); |
|
1485 |
if ($editor_local_path != '<URL>') { |
|
1486 |
drupal_add_js('window.CKEDITOR_BASEPATH = "' . ckeditor_path('relative') . '/"', array('type' => 'inline', 'weight' => -100)); |
|
1487 |
} |
|
1401 | 1488 |
drupal_add_js(ckeditor_module_path('url') . '/includes/ckeditor.utils.js', array('type' => 'file', 'scope' => 'footer')); |
1402 | 1489 |
|
1403 | 1490 |
$preprocess = FALSE; |
... | ... | |
1405 | 1492 |
$preprocess = TRUE; |
1406 | 1493 |
} |
1407 | 1494 |
|
1408 |
if (isset($load_method) && file_exists($editor_local_path . '/' . $load_method)) { |
|
1495 |
if ($editor_local_path == '<URL>') { |
|
1496 |
drupal_add_js($editor_url_path . '/ckeditor.js', array('type' => 'external', 'scope' => 'footer')); |
|
1497 |
} |
|
1498 |
else if (isset($load_method) && file_exists($editor_local_path . '/' . $load_method)) { |
|
1409 | 1499 |
drupal_add_js($editor_url_path . '/' . $load_method, array('type' => 'file', 'scope' => 'footer', 'preprocess' => $preprocess)); |
1410 | 1500 |
if ($load_method == 'ckeditor_basic.js') { |
1411 | 1501 |
drupal_add_js('CKEDITOR.loadFullCoreTimeout = ' . $load_time_out . ';', array('type' => 'inline', 'scope' => 'footer')); |
... | ... | |
1415 | 1505 |
else { |
1416 | 1506 |
drupal_add_js($editor_url_path . '/ckeditor.js', array('type' => 'file', 'scope' => 'footer', 'preprocess' => $preprocess)); |
1417 | 1507 |
} |
1418 |
drupal_add_js(array('ckeditor' => array('module_path' => ckeditor_module_path('relative'), 'editor_path' => ckeditor_path('relative') . '/')), 'setting'); |
|
1508 |
$ckeditor_url = ckeditor_path('relative'); |
|
1509 |
if ($ckeditor_url == '<URL>') { |
|
1510 |
$ckeditor_url = ckeditor_path('url'); |
|
1511 |
} |
|
1512 |
$ckeditor_url .= '/'; |
|
1513 |
drupal_add_js(array('ckeditor' => array('module_path' => ckeditor_module_path('relative'), 'editor_path' => $ckeditor_url)), 'setting'); |
|
1419 | 1514 |
if (module_exists('paging')) { |
1420 | 1515 |
drupal_add_js(array('ckeditor' => array('pagebreak' => TRUE)), 'setting'); |
1421 | 1516 |
} |
... | ... | |
1428 | 1523 |
if (module_exists('pagebreak')) { |
1429 | 1524 |
drupal_add_js(array('ckeditor' => array('pagebreak' => TRUE)), 'setting'); |
1430 | 1525 |
} |
1526 |
if (module_exists('smart_paging')) { |
|
1527 |
drupal_add_js(array('ckeditor' => array('pagebreak' => TRUE)), 'setting'); |
|
1528 |
} |
|
1431 | 1529 |
drupal_add_js(array('ckeditor' => array('ajaxToken' => drupal_get_token('ckeditorAjaxCall'), 'xss_url' => url('ckeditor/xss'))), 'setting'); |
1432 | 1530 |
$is_running = TRUE; |
1433 | 1531 |
} |
... | ... | |
1549 | 1647 |
$security_filters['filters'][$module_filter_name] = TRUE; |
1550 | 1648 |
} |
1551 | 1649 |
} |
1650 |
drupal_alter('ckeditor_security_filter', $security_filters); |
|
1552 | 1651 |
|
1553 | 1652 |
return $security_filters; |
1554 | 1653 |
} |
Formats disponibles : Unified diff
Update CKEditor