2

我正在尝试在 Drupal 7 中使用 ckeditor 和所见即所得,但我一直收到此错误:

注意:未定义的偏移量:wysiwyg_ckeditor_version() 中的 2(/var/www/sites/all/modules/wysiwyg/editors/ckeditor.inc 的第 85 行)。

这是第 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 兼容。这是我能想到的唯一可能会影响文件的事情。

4

1 回答 1

4

要解决警告问题,您应该return使用以下代码更新第 85 行的值:

return $version[1] . ((isset($version[2])) ? '.' . $version[2] : '');
于 2013-10-28T23:02:52.417 回答