我尝试在 Drupal 7 中使用 ckeditor 和 wysiwyg,但我不断收到此错误:
Notice: Undefined offset: 2 in wysiwyg_ckeditor_version() (line 85 of /var/www/sites/all/modules/wysiwyg/editors/ckeditor.inc).
这是第 85 行:
return $version[1] . '.' . $version[2];
它是一个更大函数的一部分:
/**
* Detect editor version.
*
* @param $editor
* An array containing editor properties as returned from hook_editor().
*
* @return
* The installed editor version.
*/
function wysiwyg_ckeditor_version($editor) {
$library = $editor['library path'] . '/ckeditor.js';
if (!file_exists($library)) {
return;
}
$library = fopen($library, 'r');
$max_lines = 8;
while ($max_lines && $line = fgets($library, 500)) {
// version:'CKEditor 3.0 SVN',revision:'3665'
// version:'3.0 RC',revision:'3753'
// version:'3.0.1',revision:'4391'
if (preg_match('@version:[\"|\'](?:CKEditor )?([\d\.]+)(?:.+revision:[\"|\'] ([\d]+))?@', $line, $version)) {
fclose($library);
// Version numbers need to have three parts since 3.0.1.
$version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
return $version[1] . '.' . $version[2];
}
$max_lines--;
}
fclose($library);
}
很抱歉,我无法提供更多详细信息,但我对使用 Drupal 或 php 代码的经验很少。有谁知道我的问题是什么?
可能有关系
if (preg_match('@version:[\"|\'](?:CKEditor )?([\d\.]+)(?:.+revision:[\"|\'] ([\d]+))?@', $line, $version)) {
我必须进入 .inc 文件并将某个字符更改为 [\"|\'] 才能使 ckeditor 兼容。这是我能想到的唯一可能影响该文件的事情。
最佳答案
要解决警告问题,您应该使用以下代码更新第 85 行的return
值:
return $version[1] . ((isset($version[2])) ? '.' . $version[2] : '');
关于php - 通知 : Undefined offset: 2 in wysiwyg's ckeditor. 公司,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19643758/