Browse Source

[up] Ckeditor 7.x-1.18

opi 7 years ago
parent
commit
9039d66f5f

+ 3 - 1
sites/all/modules/ckeditor/ckeditor.api.php

@@ -48,8 +48,10 @@ function hook_ckeditor_plugin() {
       'path' => base_path() . drupal_get_path('module', 'my_module') . '/plugin_dir/',
       'buttons' => array(
         'button_name' => array(
-          // Path to an icon relative to the plugins folder.
+          // Path to the button icon. Relative to the plugin directory 'path' unless 'icon_path' is specified.
           'icon' => 'icon/plugin_name.png',
+          // Optional full path to the directory the icon is located in.
+          'icon_path' => base_path() . drupal_get_path('theme', 'my_theme') . '/icon_dir/',
           'label' => 'Button Label',
         )
       )

+ 16 - 0
sites/all/modules/ckeditor/ckeditor.ckeditor.inc

@@ -141,12 +141,20 @@ function ckeditor_ckeditor_plugin() {
         $buttons = array();
         if (preg_match_all($pattern, $source, $matches)) {
           foreach ($matches[1] as $i => $button_name) {
+            // Check for icon in button definition (legacy method)
             if (preg_match('#(icon)[\s]*\:[\s]*([^\,\n]*)#', $matches[2][$i], $matches2)) {
               $buttons[$button_name] = array();
               $buttons[$button_name]['label'] = $button_name;
               $matches2[2] = str_replace(array('this.path', '+', '\'', '"'), array('', '', '', ''), $matches2[2]);
               $buttons[$button_name]['icon'] = trim($matches2[2]);
             }
+            else {
+              // Otherwise we assume the icon is being stored in the icons
+              // folder using the lowercased button name as the filename.
+              $buttons[$button_name] = array();
+              $buttons[$button_name]['label'] = $button_name;
+              $buttons[$button_name]['icon'] = 'icons/' . strtolower($button_name) . '.png';
+            }
           }
         }
         if (preg_match('#@file ([^\n\r]*)#', $source, $matches)) {
@@ -183,12 +191,20 @@ function ckeditor_ckeditor_plugin() {
         $buttons = array();
         if (preg_match_all($pattern, $source, $matches)) {
           foreach ($matches[1] as $i => $button_name) {
+            // Check for icon in button definition (legacy method)
             if (preg_match('#(icon)[\s]*\:[\s]*([^\,\n]*)#', $matches[2][$i], $matches2)) {
               $buttons[$button_name] = array();
               $buttons[$button_name]['label'] = $button_name;
               $matches2[2] = str_replace(array('this.path', '+', '\'', '"'), array('', '', '', ''), $matches2[2]);
               $buttons[$button_name]['icon'] = trim($matches2[2]);
             }
+            else {
+              // Otherwise we assume the icon is being stored in the icons
+              // folder using the lowercased button name as the filename.
+              $buttons[$button_name] = array();
+              $buttons[$button_name]['label'] = $button_name;
+              $buttons[$button_name]['icon'] = 'icons/' . strtolower($button_name) . '.png';
+            }
           }
         }
         if (preg_match('#@file ([^\n\r]*)#', $source, $matches)) {

+ 4 - 3
sites/all/modules/ckeditor/ckeditor.info

@@ -4,9 +4,10 @@ core        = 7.x
 package     = User interface
 configure   = admin/config/content/ckeditor
 
-; Information added by Drupal.org packaging script on 2015-12-24
-version = "7.x-1.17"
+files[] = tests/ckeditor.test
+; Information added by Drupal.org packaging script on 2017-06-26
+version = "7.x-1.18"
 core = "7.x"
 project = "ckeditor"
-datestamp = "1450969741"
+datestamp = "1498506247"
 

+ 9 - 2
sites/all/modules/ckeditor/includes/ckeditor.admin.inc

@@ -1758,11 +1758,18 @@ function ckeditor_toolbar_buttons_all() {
   );
 
   $plugins = ckeditor_load_plugins(TRUE);
+
   foreach ($plugins as $plugin_name => $plugin) {
-    if (!isset($plugin['buttons']) || $plugin['buttons'] == FALSE)
+    if (empty($plugin['buttons'])) {
       continue;
+    }
     foreach ((array) $plugin['buttons'] as $button_name => $button) {
-      $buttons[$button_name] = array('name' => $button_name, 'icon' => $plugin['path'] . $button['icon'], 'title' => t($button['label']), 'row' => 4);
+      $buttons[$button_name] = array(
+        'name' => $button_name,
+        'icon' => !empty($button['icon_path']) ? $button['icon_path'] . $button['icon'] : $plugin['path'] . $button['icon'],
+        'title' => t($button['label']),
+        'row' => 4,
+      );
     }
   }
 

+ 1 - 1
sites/all/modules/ckeditor/includes/ckeditor.features.inc

@@ -62,7 +62,7 @@ function ckeditor_profile_features_export($data, &$export, $module_name = '') {
       }
     }
   }
-  $export['dependencies'][] = 'ckeditor';
+  $export['dependencies']['ckeditor'] = 'ckeditor';
   return $pipe;
 }
 

+ 95 - 81
sites/all/modules/ckeditor/includes/ckeditor.lib.inc

@@ -937,87 +937,7 @@ function ckeditor_profile_settings_compile($global_profile, $profile) {
   $css_files = array();
   switch ($conf['css_mode']) {
     case 'theme':
-      global $language, $base_theme_info;
-      $themes = list_themes();
-      $theme_info = $themes[$current_theme];
-      if (!empty($theme_info->stylesheets)) {
-        $editorcss = "\"";
-        foreach ($base_theme_info as $base) { // Grab stylesheets from base theme
-          if (!empty($base->stylesheets)) { // may be empty when the base theme reference in the info file is invalid
-            foreach ($base->stylesheets as $type => $stylesheets) {
-              if ($type != "print") {
-                foreach ($stylesheets as $name => $path) {
-                  if (file_exists($path)) {
-                    $css_files[$name] = $host . $path . $query_string;
-                    // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
-                    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") {
-                      $rtl_path = substr($path, 0, -4) . "-rtl.css";
-                      if (file_exists($rtl_path)) {
-                        $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        if (!empty($theme_info->stylesheets)) { // Grab stylesheets from current theme
-          foreach ($theme_info->stylesheets as $type => $stylesheets) {
-            if ($type != "print") {
-              foreach ($stylesheets as $name => $path) {
-                // Checks if less module exists...
-                if (strstr($path, '.less') && module_exists('less')) {
-                  $path = 'sites/default/files/less/' . $path; // append the less file path
-                  $path = str_replace('.less', '', $path); // remove the .less
-                }
-                if (file_exists($path)) {
-                  $css_files[$name] = $host . $path . $query_string;
-                  // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
-                  if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") {
-                    $rtl_path = substr($path, 0, -4) . "-rtl.css";
-                    if (file_exists($rtl_path)) {
-                      $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string;
-                    }
-                  }
-                }
-                elseif (!empty($css_files[$name])) {
-                  unset($css_files[$name]);
-                }
-              }
-            }
-          }
-        }
-        // Grab stylesheets local.css and local-rtl.css if they exist (fusion based themes)
-        if (file_exists($themepath . 'css/local.css')) {
-          $css_files[] = $host . $themepath . 'css/local.css' . $query_string;
-        }
-        if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($themepath . 'css/local-rtl.css')) {
-          $css_files[] = $host . $themepath . 'css/local-rtl.css' . $query_string;
-        }
-
-        // Grab stylesheets from color module
-        $color_paths = variable_get('color_' . $current_theme . '_stylesheets', array());
-        if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
-          if (!empty($color_paths[1])) {
-            $css_files[] = $host . $color_paths[1] . $query_string;
-          }
-        }
-        elseif (!empty($color_paths[0])) {
-          $css_files[] = $host . $color_paths[0] . $query_string;
-        }
-      }
-      else {
-        if (!file_exists($themepath . 'ckeditor.css') && file_exists($themepath . 'style.css')) {
-          $css_files[] = $host . $themepath . 'style.css' . $query_string;
-        }
-      }
-      if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) {
-        $css_files[] = $module_drupal_path . '/css/ckeditor.css' . $query_string;
-      }
-      if (file_exists($themepath . 'ckeditor.css')) {
-        $css_files[] = $host . $themepath . 'ckeditor.css' . $query_string;
-      }
+      _ckeditor_add_css_from_theme($current_theme, $css_files);
       break;
 
     case 'self':
@@ -1090,6 +1010,100 @@ function ckeditor_profile_settings_compile($global_profile, $profile) {
   return $settings;
 }
 
+function _ckeditor_add_css_from_theme($current_theme, &$css_files) {
+  global $language, $base_theme_info;
+
+  $themes = list_themes();
+  $theme_info = $themes[$current_theme];
+  if (!empty($theme_info->base_theme)) {
+    _ckeditor_add_css_from_theme($theme_info->base_theme, $css_files);
+  }
+
+  $query_string = '?' . variable_get('css_js_query_string', '0');
+  $host = base_path();
+  $themepath = drupal_get_path('theme', $current_theme) . '/';
+  $module_drupal_local_path = ckeditor_module_path('local');
+  $module_drupal_path = drupal_get_path('module', 'ckeditor');
+  if (!empty($theme_info->stylesheets)) {
+    $editorcss = "\"";
+    foreach ($base_theme_info as $base) { // Grab stylesheets from base theme
+      if (!empty($base->stylesheets)) { // may be empty when the base theme reference in the info file is invalid
+        foreach ($base->stylesheets as $type => $stylesheets) {
+          if ($type != "print") {
+            foreach ($stylesheets as $name => $path) {
+              if (file_exists($path)) {
+                $css_files[$name] = $host . $path . $query_string;
+                // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
+                if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") {
+                  $rtl_path = substr($path, 0, -4) . "-rtl.css";
+                  if (file_exists($rtl_path)) {
+                    $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string;
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+    if (!empty($theme_info->stylesheets)) { // Grab stylesheets from current theme
+      foreach ($theme_info->stylesheets as $type => $stylesheets) {
+        if ($type != "print") {
+          foreach ($stylesheets as $name => $path) {
+            // Checks if less module exists...
+            if (strstr($path, '.less') && module_exists('less')) {
+              $path = 'sites/default/files/less/' . $path; // append the less file path
+              $path = str_replace('.less', '', $path); // remove the .less
+            }
+            if (file_exists($path)) {
+              $css_files[$name] = $host . $path . $query_string;
+              // Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
+              if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path, 0, -8) != "-rtl.css") {
+                $rtl_path = substr($path, 0, -4) . "-rtl.css";
+                if (file_exists($rtl_path)) {
+                  $css_files[$name . "-rtl"] = $host . $rtl_path . $query_string;
+                }
+              }
+            }
+            elseif (!empty($css_files[$name])) {
+              unset($css_files[$name]);
+            }
+          }
+        }
+      }
+    }
+    // Grab stylesheets local.css and local-rtl.css if they exist (fusion based themes)
+    if (file_exists($themepath . 'css/local.css')) {
+      $css_files[] = $host . $themepath . 'css/local.css' . $query_string;
+    }
+    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($themepath . 'css/local-rtl.css')) {
+      $css_files[] = $host . $themepath . 'css/local-rtl.css' . $query_string;
+    }
+
+    // Grab stylesheets from color module
+    $color_paths = variable_get('color_' . $current_theme . '_stylesheets', array());
+    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
+      if (!empty($color_paths[1])) {
+        $css_files[] = $host . $color_paths[1] . $query_string;
+      }
+    }
+    elseif (!empty($color_paths[0])) {
+      $css_files[] = $host . $color_paths[0] . $query_string;
+    }
+  }
+  else {
+    if (!file_exists($themepath . 'ckeditor.css') && file_exists($themepath . 'style.css')) {
+      $css_files[] = $host . $themepath . 'style.css' . $query_string;
+    }
+  }
+  if (file_exists($module_drupal_local_path . '/css/ckeditor.css')) {
+    $css_files[] = $host . $module_drupal_path . '/css/ckeditor.css' . $query_string;
+  }
+  if (file_exists($themepath . 'ckeditor.css')) {
+    $css_files[] = $host . $themepath . 'ckeditor.css' . $query_string;
+  }
+}
+
 /**
  * Load CKEditor for field ID
  *

+ 3 - 0
sites/all/modules/ckeditor/includes/ckeditor.page.inc

@@ -286,6 +286,9 @@ function ckeditor_filter_xss() {
       }
       continue;
     }
+    if (function_exists($filters[$name]['prepare callback'])) {
+      $text = $filters[$name]['prepare callback']($text, $format_filters[$name], $format, '', TRUE, $cache_id);
+    }
     $text = $filters[$name]['process callback']($text, $format_filters[$name], $format, '', TRUE, $cache_id);
   }
 

+ 1 - 1
sites/all/modules/ckeditor/includes/filemanager.config.php

@@ -99,7 +99,7 @@ else {
   // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
   // Path to user files relative to the document root.
   $baseUrl = strtr(base_path(), array(
-        '/modules/ckeditor/ckfinder/core/connector/php' => '',
+        drupal_get_path('module','ckeditor') . '/ckfinder/core/connector/php' => '',
       )) . variable_get('file_private_path', conf_path() . '/files') . '/';
   $baseDir = resolveUrl($baseUrl);
 }

+ 1 - 1
sites/all/modules/ckeditor/plugins/imce/plugin.js

@@ -25,7 +25,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
           var width = editor.config.filebrowserWindowWidth || '80%',
           height = editor.config.filebrowserWindowHeight || '70%';
 
-          editor.popup(Drupal.settings.basePath + 'index.php?q=imce\x26app=ckeditor|sendto@ckeditor_setFile|&CKEditorFuncNum=' + editor._.filebrowserFnIMCE, width, height);
+          editor.popup(Drupal.settings.basePath + 'index.php?q=' + Drupal.settings.pathPrefix  + 'imce\x26app=ckeditor|sendto@ckeditor_setFile|&CKEditorFuncNum=' + editor._.filebrowserFnIMCE, width, height);
         }
       });
 

+ 43 - 0
sites/all/modules/ckeditor/tests/ckeditor.test

@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * @file
+ * Contains ckeditorTest.
+ */
+
+/**
+ * Base class for ckeditor tests.
+ */
+class CkeditorTest extends DrupalWebTestCase {
+  protected $profile = 'testing';
+
+  /**
+   * Test info.
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Configuration available',
+      'description' => 'Check module is enabled and config available.',
+      'group' => 'ckeditor',
+    );
+  }
+
+  /**
+   * Setup the environment.
+   */
+  public function setUp() {
+    parent::setUp('ckeditor');
+
+    $admin_user = $this->drupalCreateUser(array('administer ckeditor'));
+    $this->drupalLogin($admin_user);
+  }
+
+  /**
+   * Check admin page is available.
+   */
+  public function test() {
+    $this->drupalGet('admin/config/content/ckeditor');
+    $this->assertResponse(200, 'User is allowed to edit the content.');
+  }
+
+}