You are here

function ckeditor_skinframe in CKEditor - WYSIWYG HTML editor 6

Same name and namespace in other branches
  1. 7 includes/ckeditor.admin.inc \ckeditor_skinframe()
1 string reference to 'ckeditor_skinframe'
ckeditor_menu in ./ckeditor.module
Implementation of hook_menu().

File

includes/ckeditor.admin.inc, line 2276
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_skinframe() {
  header('Content-Type: text/html; charset=utf-8');
  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'ckeditorSkinframeCall')) {
    exit;
  }
  $editor_path = ckeditor_path();
  $module_drupal_path = base_path() . drupal_get_path('module', 'ckeditor');
  $html = "<!DOCTYPE html>";
  $html .= "<html>";
  $html .= "<head>";
  $html .= '<title>CKEditor UI Color Picker</title>';
  $html .= "<script type=\"text/javascript\" src=\"{$editor_path}/ckeditor.js\"></script>";
  $html .= "</head>";
  $html .= "<body>";
  $html .= "<input type=\"hidden\" name=\"uicolor_user\"/>";
  $html .= "<div id=\"editor\" style=\"height: 200px;\">Click the <strong>UI Color Picker</strong> button to set your color preferences.</div>";
  $html .= "<script type=\"text/javascript\">\nvar skin = window.location.search.match(/skin=([^&]*)/)[1];\nvar uicolor = window.location.search.match(/uicolor=([^&]*)/)[1];\nvar ckeditorUiColorOnChange = function() {\n  var color = CKEDITOR.instances['editor'].getUiColor();\n  if (typeof(color) != 'undefined') {\n    document.getElementsByName('uicolor_user').value = parent.document.getElementsByName('uicolor_user')[0].value = color;\n    var edit_uicolor = parent.document.getElementById('edit-uicolor');\n    for (i=0; i<edit_uicolor.options.length; i++) {\n      if (edit_uicolor[i].value == 'custom') {\n        edit_uicolor.selectedIndex = i;\n        edit_uicolor[i].selected = 'selected';\n        break;\n      }\n    }\n  }\n};\nCKEDITOR.on('dialogDefinition', function( ev ) {\n  var dialogName = ev.data.name;\n  var dialogDefinition = ev.data.definition;\n\n  if (dialogName == 'uicolor') {\n    dialogDefinition.getContents('tab1').get('configBox').style = 'display:none';\n  }\n});\nCKEDITOR.replace('editor', {\n  extraPlugins : 'uicolor',\n  height: 400,\n  uiColor: '#' + uicolor,\n  toolbar : [[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList'],[ 'UIColor' ]],\n  skin: skin,\n  on: {\n    configLoaded: function(ev) {\n      var ckeditor_ver = CKEDITOR.version.split('.')[0];\n      if (ckeditor_ver == 3) {\n        if (skin != 'kama') {\n          ev.editor.config.toolbar = [[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList']];\n        }\n      }\n      else {\n        CKEDITOR.plugins.addExternal('uicolor', '{$module_drupal_path}/includes/uicolor/', 'plugin.js');\n        if (uicolor.length == 0 || uicolor == 'default') {\n          delete ev.editor.config.uiColor;\n        }\n      }\n    },\n    blur: ckeditorUiColorOnChange,\n    focus: ckeditorUiColorOnChange\n  }\n});\n</script>";
  $html .= "</body>";
  $html .= "</html>";
  echo $html;
}