updated core to 7.58 (right after the site was hacked)

This commit is contained in:
2018-04-20 23:48:40 +02:00
parent 18f4aba146
commit 9344a61b61
711 changed files with 99690 additions and 480 deletions

View File

@@ -0,0 +1,4 @@
.mce-container.mce-toolbar > .mce-container-body > .mce-btn-group > div {
/* Hack to make buttons wrap. */
white-space: normal !important;
}

View File

@@ -0,0 +1,6 @@
.wym_skin_compact .wym_dropdown ul {
margin-top: 0;
}
.wym_skin_compact .wym_iframe iframe {
height: 400px !important;
}

View File

@@ -0,0 +1,245 @@
(function ($) {
/**
* Initialize editor instances.
*
* @see Drupal.wysiwyg.editor.init.ckeditor()
*/
Drupal.wysiwyg.editor.init.tinymce = function (settings, pluginInfo) {
// Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
var $drupalToolbars = $('#toolbar, #admin-menu', Drupal.overlayChild ? window.parent.document : document);
tinymce.on('AddEditor', function (e) {
e.editor.on('FullscreenStateChanged', function (e) {
if (e.state) {
$drupalToolbars.hide();
}
else {
$drupalToolbars.show();
}
});
});
// Register new plugins.
Drupal.wysiwyg.editor.update.tinymce(settings, pluginInfo);
};
/**
* Update the editor library when new settings are available.
*
* @see Drupal.wysiwyg.editor.update.ckeditor()
*/
Drupal.wysiwyg.editor.update.tinymce = function (settings, pluginInfo) {
// Load native external plugins.
// Array syntax required; 'native' is a predefined token in JavaScript.
var plugin;
for (plugin in pluginInfo['native']) {
if (!(plugin in tinymce.PluginManager.lookup || plugin in tinymce.PluginManager.urls)) {
tinymce.PluginManager.load(plugin, pluginInfo['native'][plugin]);
}
}
// Load Drupal plugins.
for (plugin in pluginInfo.drupal) {
if (!(plugin in tinymce.PluginManager.lookup)) {
Drupal.wysiwyg.editor.instance.tinymce.addPlugin(plugin, pluginInfo.drupal[plugin]);
}
}
};
/**
* Attach this editor to a target element.
*
* See Drupal.wysiwyg.editor.attach.none() for a full description of this hook.
*/
Drupal.wysiwyg.editor.attach.tinymce = function (context, params, settings) {
// Remove TinyMCE's internal mceItem class, which was incorrectly added to
// submitted content by Wysiwyg <2.1. TinyMCE only temporarily adds the class
// for placeholder elements. If preemptively set, the class prevents (native)
// editor plugins from gaining an active state, so we have to manually remove
// it prior to attaching the editor. This is done on the client-side instead
// of the server-side, as Wysiwyg has no way to figure out where content is
// stored, and the class only affects editing.
var $field = $('#' + params.field);
$field.val($field.val().replace(/(<.+?\s+class=['"][\w\s]*?)\bmceItem\b([\w\s]*?['"].*?>)/ig, '$1$2'));
// Attach editor.
settings.selector = '#' + params.field;
var oldSetup = settings.setup;
settings.setup = function (editor) {
editor.on('focus', function (e) {
Drupal.wysiwyg.activeId = this.id;
});
if (oldSetup) {
oldSetup(editor);
}
};
tinymce.init(settings);
};
/**
* Detach a single or all editors.
*
* See Drupal.wysiwyg.editor.detach.none() for a full description of this hook.
*/
Drupal.wysiwyg.editor.detach.tinymce = function (context, params, trigger) {
var instance;
if (typeof params !== 'undefined') {
instance = tinymce.get(params.field);
if (instance) {
instance.save();
if (trigger !== 'serialize') {
instance.remove();
}
}
}
else {
// Save contents of all editors back into textareas.
tinymce.triggerSave();
if (trigger !== 'serialize') {
// Remove all editor instances.
for (instance in tinymce.editors) {
if (!tinymce.editors.hasOwnProperty(instance)) {
continue;
}
tinymce.editors[instance].remove();
}
}
}
};
Drupal.wysiwyg.editor.instance.tinymce = {
addPlugin: function (plugin, pluginSettings) {
if (typeof Drupal.wysiwyg.plugins[plugin] !== 'object') {
return;
}
// Register plugin.
tinymce.PluginManager.add('drupal_' + plugin, function (editor) {
var button = {
title: pluginSettings.title,
image: pluginSettings.icon,
onPostRender: function () {
var self = this;
editor.on('nodeChange', function (e) {
// isNode: Return whether the plugin button should be enabled for
// the current selection.
if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
self.active(Drupal.wysiwyg.plugins[plugin].isNode(e.element));
}
});
}
};
if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') {
button.onclick = function () {
var data = {format: 'html', node: editor.selection.getNode(), content: editor.selection.getContent()};
// TinyMCE creates a completely new instance for fullscreen mode.
Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, editor.id);
};
}
// Register the plugin button.
editor.addButton('drupal_' + plugin, button);
/**
* Initialize the plugin, executed after the plugin has been created.
*
* @param ed
* The tinymce.Editor instance the plugin is initialized in.
* @param url
* The absolute URL of the plugin location.
*/
editor.on('init', function (e) {
// Load custom CSS for editor contents on startup.
if (pluginSettings.css) {
editor.dom.loadCSS(pluginSettings.css);
}
});
// Attach: Replace plain text with HTML representations.
editor.on('beforeSetContent', function (e) {
if (typeof Drupal.wysiwyg.plugins[plugin].attach === 'function') {
e.content = Drupal.wysiwyg.plugins[plugin].attach(e.content, pluginSettings, e.target.id);
e.content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(e.content);
}
});
// Detach: Replace HTML representations with plain text.
editor.on('getContent', function (e) {
var editorId = (e.target.id === 'mce_fullscreen' ? e.target.getParam('fullscreen_editor_id') : e.target.id);
if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
e.content = Drupal.wysiwyg.plugins[plugin].detach(e.content, pluginSettings, editorId);
}
});
});
},
openDialog: function (dialog, params) {
var instanceId = this.getInstanceId();
var editor = tinymce.get(instanceId);
editor.windowManager.open({
file: dialog.url + '/' + instanceId,
width: dialog.width,
height: dialog.height,
inline: 1
}, params);
},
closeDialog: function (dialog) {
var editor = tinymce.get(this.getInstanceId());
editor.windowManager.close(dialog);
},
prepareContent: function (content) {
// Certain content elements need to have additional DOM properties applied
// to prevent this editor from highlighting an internal button in addition
// to the button of a Drupal plugin.
var specialProperties = {
img: {class: 'mceItem'}
};
// No .outerHTML() in jQuery :(
var $content = $('<div>' + content + '</div>');
// Find all placeholder/replacement content of Drupal plugins.
$content.find('.drupal-content').each(function () {
// Recursively process DOM elements below this element to apply special
// properties.
var $drupalContent = $(this);
$.each(specialProperties, function (element, properties) {
$drupalContent.find(element).andSelf().each(function () {
for (var property in properties) {
if (property === 'class') {
$(this).addClass(properties[property]);
}
else {
$(this).attr(property, properties[property]);
}
}
});
});
});
return $content.html();
},
insert: function (content) {
content = this.prepareContent(content);
tinymce.get(this.field).insertContent(content);
},
setContent: function (content) {
content = this.prepareContent(content);
tinymce.get(this.field).setContent(content);
},
getContent: function () {
return tinymce.get(this.getInstanceId()).getContent();
},
isFullscreen: function () {
var editor = tinymce.get(this.field);
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
},
getInstanceId: function () {
return this.field;
}
};
})(jQuery);

View File

@@ -0,0 +1,63 @@
(function($) {
/**
* Attach this editor to a target element.
*/
Drupal.wysiwyg.editor.attach.wymeditor = function (context, params, settings) {
// Prepend basePath to wymPath.
settings.wymPath = settings.basePath + settings.wymPath;
settings.postInit = function (instance) {
var $doc = $(instance._doc);
// Inject stylesheet for backwards compatibility.
if (settings.stylesheet) {
$doc.find('head').append('<link rel="stylesheet" type="text/css" media="screen" href="' + settings.stylesheet + '">');
}
// Update activeId on focus.
$doc.find('body').focus(function () {
Drupal.wysiwyg.activeId = params.field;
});
};
// Attach editor.
$('#' + params.field).wymeditor(settings);
};
/**
* Detach a single editor instance.
*/
Drupal.wysiwyg.editor.detach.wymeditor = function (context, params, trigger) {
var $field = $('#' + params.field, context);
var index = $field.data(WYMeditor.WYM_INDEX);
if (typeof index == 'undefined' || !WYMeditor.INSTANCES[index]) {
return;
}
var instance = WYMeditor.INSTANCES[index];
instance.update();
if (trigger != 'serialize') {
instance.vanish();
}
};
Drupal.wysiwyg.editor.instance.wymeditor = {
insert: function (content) {
this.getInstance().insert(content);
},
setContent: function (content) {
this.getInstance().html(content);
},
getContent: function () {
return this.getInstance().html();
},
getInstance: function () {
var $field = $('#' + this.field);
var index = $field.data(WYMeditor.WYM_INDEX);
if (typeof index != 'undefined') {
return WYMeditor.INSTANCES[index];
}
return null;
}
};
})(jQuery);

View File

@@ -0,0 +1,130 @@
<?php
/**
* @file
* Handles adding theme stylesheets into WYSIWYG editors.
*/
/**
* A simple page callback for a checking if a theme is active.
*
* A theme the user does not have permission to use can not be set active.
*
* @see _wysiwyg_theme_callback()
* @see _wysiwyg_delivery_dummy()
*/
function _wysiwyg_theme_check_active($theme) {
global $theme_key;
return $theme === $theme_key;
}
/**
* A simple page delivery dummy implementation.
*
* Acts like a normal HTML delivery mechanism but only "renders" a dummy string
* and prints a short string telling if the page callback result was "true".
*
* Useful for returning the results of an access check, performed by the page
* callback. The actual page callback return value is never printed.
*
* Success:
* - Status header: "200 OK"
* - Content: "OK"
*
* Failure:
* - Status header: "403 Forbidden"
* - Content: "Forbidden"
*
* @see _wysiwyg_theme_check_active()
*/
function _wysiwyg_delivery_dummy($page_callback_result) {
global $theme_key;
drupal_add_http_header('Content-Language', 'en');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
if ($page_callback_result) {
drupal_add_http_header('Status', '200 OK');
}
else {
drupal_add_http_header('Status', '403 Forbidden');
}
// Make sure the theme is always initialized.
drupal_theme_initialize();
// Render a completely themed empty page to catch as many stylesheets as
// possible, but don't actually return anything to speed up the response.
$rendered = drupal_render_page('Dummy');
// In case headers aren't enough, put the status in the response body.
print ($page_callback_result ? 'OK' : 'Forbidden');
// Cleanup and session handling.
drupal_page_footer();
}
/**
* Theme callback to simply suggest a theme based on the page argument.
*/
function _wysiwyg_theme_callback($theme) {
return $theme;
}
/**
* A filtering pre render callback for style elements.
*
* Invokes hook_wysiwyg_editor_stules_alter() to allow other code to filter the
* list of stylesheets which will be used inside the editors in WYSIWYG mode.
*
* Intended to run before Core sorts/groups/aggregates stylesheets.
*/
function _wysiwyg_filter_editor_styles(&$elements) {
global $theme_key;
if (strpos(current_path(), 'wysiwyg_theme/') !== 0) {
return $elements;
}
$context = array('theme' => $theme_key);
drupal_alter('wysiwyg_editor_styles', $elements, $context); $css = array();
return $elements;
}
/**
* Creates a cache of the stylesheets used by the currently set theme.
*
* Since this is a pre render callback for the styles element, it should run
* late enough to catch all the stylesheets added just before the actual markup
* for them is rendered.
*
* The first time this runs for a theme it's too late for a module to have any
* use of the cache, so wysiwyg_get_css() uses drupal_http_request() to fetch a
* dummy page, filling the cache before the original response is sent.
*
* Intended to run after Core has sorted/grouped/aggregated stylesheets.
*/
function _wysiwyg_pre_render_styles($elements) {
global $theme_key;
if (strpos(current_path(), 'wysiwyg_theme/') !== 0) {
return $elements;
}
$cached = cache_get('wysiwyg_css');
foreach (element_children($elements) as $child) {
if (isset($elements['#groups'][$child]['group']) && $elements['#groups'][$child]['group'] != CSS_THEME) {
continue;
}
switch ($elements[$child]['#tag']) {
case 'link':
$css[] = $elements[$child]['#attributes']['href'];
break;
case 'style':
if (!empty($elements[$child]['#attributes']['href'])) {
$css[] = $elements[$child]['#attributes']['href'];
}
elseif (!empty($elements[$child]['#value'])){
preg_match_all('/\@import url\("([^"]+)"\);/', $elements[$child]['#value'], $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$css[] = $val[1];
}
}
break;
}
$all = empty($cached->data) ? array() : $cached->data;
$all[$theme_key] = array('files' => $css, 'aggregated' => variable_get('preprocess_css', FALSE));
}
$all['_css_js_query_string'] = variable_get('css_js_query_string');
cache_set('wysiwyg_css', $all);
return $elements;
}