php - 通知 : Undefined offset: 2 in wysiwyg's ckeditor. 公司

标签 php drupal drupal-7 ckeditor wysiwyg

我尝试在 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/

相关文章:

javascript - Slideshow_animate 未定义

drupal-7 - 通过 hook_permission() 获取给定模块提供的所有权限

drupal-7 - Drupal 7 View 3 用户 :current filter is missing?

mysql - Drupal 7 手动查询 webforms 数据库表

php - MYSQL全文索引存在但显示错误1191

php - 在另一个模块中创建一个额外的主菜单

php - 简单的搜索功能总是返回 0 个结果

drupal - 使用自定义条件搜索

drupal - 用户注册时两种内容类型的内容配置文件 Drupal

php - Codeigniter 和 Gallery 的 Rest