uppdated modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-01-22 16:19:36 +01:00
parent 03be8f82aa
commit 8416e3eea1
748 changed files with 32317 additions and 20900 deletions
@@ -24,6 +24,9 @@
cursor: default;
background: white;
border-bottom: 1px solid #bfbfbf;
z-index: 10;
max-height: 330px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); /* Visually indicate that results are in the topmost layer */
}
/* Groups */
@@ -82,3 +85,13 @@
.better-autocomplete > .result.highlight > p {
color: white;
}
/* ARIA */
.better-autocomplete-aria {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
height: 1px;
}
@@ -172,6 +172,8 @@
.better-autocomplete {
background-color: transparent;
border-bottom: none;
box-shadow: none;
z-index: inherit;
}
.better-autocomplete > .result.status-ok {
background: #397928;
@@ -219,4 +221,8 @@
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-bottom: 1px solid #BFBFBF;
}
}
.ui-dialog.ui-front.linkit-wrapper {
z-index: 2000;
}
@@ -17,7 +17,7 @@ Drupal.linkit.registerDialogHelper('ckeditor', {
*/
afterInit : function () {
var editor = Drupal.settings.linkit.currentInstance.editor;
var element = CKEDITOR.plugins.link.getSelectedLink( editor );
var element = CKEDITOR.plugins.link.getSelectedLink(editor);
// If we have selected a link element, lets populate the fields in the
// modal with the values from that link element.
@@ -41,8 +41,20 @@
// Set the editor object.
Drupal.settings.linkit.currentInstance.editor = editor;
// Set profile.
Drupal.settings.linkit.currentInstance.profile = Drupal.settings.linkit.fields[editor.name].profile;
// Find the current input format of the field we're looking at.
var format = '';
if (Drupal.wysiwyg) { // If using the WYSIWYG module with CKEditor as the editor
// Note that WYSIWYG prepends "profile" to the profile name, so we use .substring() to remove the "format".
format = Drupal.wysiwyg.instances[editor.name].format.substring(6);
}
else if (Drupal.settings.ckeditor) { // If using the CKEditor module
format = Drupal.settings.ckeditor.elements[editor.name];
} else {
alert(Drupal.t('Could not find the Linkit profile.'));
return;
}
// Set profile based on the current text format of this field.
Drupal.settings.linkit.currentInstance.profile = Drupal.settings.linkit.formats[format].profile;
// Set the name of the source field.
Drupal.settings.linkit.currentInstance.source = editor.name;
// Set the source type.
@@ -108,18 +120,22 @@
// Add a shortcut. Only CKeditor version 4 has this function.
if (version >= 4) {
editor.setKeystroke( CKEDITOR.CTRL + 76 /*L*/, 'linkit' );
editor.setKeystroke(CKEDITOR.CTRL + 76 /*L*/, 'linkit');
}
// Add event listener.
editor.on( 'doubleclick', function( evt ) {
editor.on('doubleclick', function(evt) {
if (evt.data.dialog !== 'link') {
return;
}
// Delete the default link dialog.
delete evt.data.dialog;
var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element;
if ( !element.isReadOnly() ) {
if ( element.is( 'a' ) ) {
editor.getSelection().selectElement( element );
var element = CKEDITOR.plugins.link.getSelectedLink(editor) || evt.data.element;
if (!element.isReadOnly()) {
if (element.is( 'a' )) {
editor.getSelection().selectElement(element);
if (version >= 4) {
editor.commands.linkit.exec();
}
@@ -131,7 +147,7 @@
});
// Register an extra fucntion, this will be used in the modal.
editor._.linkitFnNum = CKEDITOR.tools.addFunction( insertLink, editor );
editor._.linkitFnNum = CKEDITOR.tools.addFunction(insertLink, editor);
}
});
@@ -150,7 +166,7 @@
var range = selection.getRanges(1)[0];
if (range.collapsed) {
var content = (Drupal.settings.linkit.currentInstance.linkContent) ? Drupal.settings.linkit.currentInstance.linkContent : data.path;
var text = new CKEDITOR.dom.text(content , editor.document );
var text = new CKEDITOR.dom.text(content , editor.document);
range.insertNode(text);
range.selectNodeContents(text);
}
@@ -17,8 +17,18 @@
// Set the editor object.
Drupal.settings.linkit.currentInstance.editor = editor;
// Set profile.
Drupal.settings.linkit.currentInstance.profile = Drupal.settings.linkit.fields[editor.id].profile;
// Find the current input format of the field we're looking at. Note that we get it in the form
// "format<formatname" instead of just "<formatname>" so we use .substring() to remove the "format".
if (Drupal.wysiwyg && Drupal.wysiwyg.instances[editor.id].format) {
var format = Drupal.wysiwyg.instances[editor.id].format.substring(6);
} else {
alert(Drupal.t('Could not find the Linkit profile.'));
return;
}
// Set profile based on the current text format of this field.
Drupal.settings.linkit.currentInstance.profile = Drupal.settings.linkit.formats[format].profile;
// Set the name of the source field..
Drupal.settings.linkit.currentInstance.source = editor.id;
@@ -9,13 +9,13 @@ Drupal.behaviors.linkitDashboard = {
attach: function (context, settings) {
// Bind the insert link button.
$('.linkit-insert', context).once('linkit-insert', function() {
$('.linkit-insert', context).click(function() {
$('.linkit-insert', context).click(function(event) {
event.preventDefault();
// Call the insertLink() function.
Drupal.linkit.getDialogHelper(Drupal.settings.linkit.currentInstance.helper).insertLink(Drupal.linkit.getLink());
// Close the dialog.
Drupal.linkit.modalClose();
return false;
});
});
@@ -232,12 +232,11 @@ Drupal.behaviors.linkitSearch = {
$('.linkit-path-element', context).focus();
}
}
};
searchElement.betterAutocomplete('init', Drupal.settings.linkit.currentInstance.autocompletePathParsed, Drupal.settings.linkit.currentInstance.autocomplete, callbacks);
});
}
};
})(jQuery);
})(jQuery);
@@ -2,134 +2,149 @@
* @file
* Linkit field ui functions
*/
(function($, behavior) {
'use strict';
(function ($) {
Drupal.behaviors[behavior] = {
attach: function(context, settings) {
// If there is no fields, just stop here.
if (undefined === settings.linkit || null === settings.linkit.fields) {
return false;
}
Drupal.behaviors.linkit_field = {
attach : function(context, settings) {
// If there is no fields, just stop here.
$.each(settings.linkit.fields, function(i, instance) {
$('#' + instance.source, context).once(behavior, function() {
var element = this;
if (settings.linkit == undefined || settings.linkit.fields == null) {
return false;
}
$('.linkit-field-' + instance.source).click(function(event) {
event.preventDefault();
$.each(settings.linkit.fields, function(field_name, field) {
$('#' + field_name, context).once('linkit_field', function() {
$('.linkit-field-' + field_name).click(function() {
// Set profile.
Drupal.settings.linkit.currentInstance.profile = Drupal.settings.linkit.fields[field_name].profile;
// Only care about selection if the element is a textarea.
if ('textarea' === element.nodeName.toLowerCase()) {
instance.selection = Drupal.linkit.getDialogHelper('field').getSelection(element);
}
// Set the name of the source field..
Drupal.settings.linkit.currentInstance.source = field_name;
// Set the source type.
Drupal.settings.linkit.currentInstance.helper = 'field';
// Only care about selection if the element is a textarea.
if ($('textarea#' + field_name).length) {
var selection = Drupal.linkit.getDialogHelper('field').getSelection($('#' + field_name).get(0));
// Save the selection.
Drupal.settings.linkit.currentInstance.selection = selection;
}
// Suppress profile changer.
Drupal.settings.linkit.currentInstance.suppressProfileChanger = true;
// Create the modal.
Drupal.linkit.createModal();
return false;
Drupal.settings.linkit.currentInstance = instance;
Drupal.linkit.createModal();
});
});
});
});
}
};
/**
* Linkit field dialog helper.
*/
Drupal.linkit.registerDialogHelper('field', {
init : function() {},
afterInit : function () {},
}
};
/**
* Insert the link into the field.
*
* @param {Object} link
* The link object.
* Linkit field dialog helper.
*/
insertLink : function(data) {
var source = $('#' + Drupal.settings.linkit.currentInstance.source),
field_settings = Drupal.settings.linkit.fields[Drupal.settings.linkit.currentInstance.source],
Drupal.linkit.registerDialogHelper('field', {
afterInit: function() {},
// Call the insert plugin.
link = Drupal.linkit.getInsertPlugin(field_settings.insert_plugin).insert(data, field_settings);
/**
* Insert the link into the field.
*
* @param {Object} data
* The link object.
*/
insertLink: function(data) {
var instance = Drupal.settings.linkit.currentInstance,
// Call the insert plugin.
link = Drupal.linkit.getInsertPlugin(instance.insertPlugin).insert(data, instance);
if (typeof Drupal.settings.linkit.currentInstance.selection != 'undefined') {
// Replace the selection and insert the link there.
this.replaceSelection(source.get(0), Drupal.settings.linkit.currentInstance.selection, link);
}
else {
// Replace the field value.
this.replaceFieldValue(source.get(0), link);
}
if (instance.hasOwnProperty('selection')) {
// Replace the selection and insert the link there.
this.replaceSelection(instance.source, instance.selection, link);
}
else if (instance.hasOwnProperty('titleField')) {
// The "linkContent" property will always be present when AJAX used.
// Otherwise, if you use simple insert without autocomplete, then this
// property will be undefined and title field should not be filled in.
//
// @see Drupal.behaviors.linkitSearch.attach
if (instance.hasOwnProperty('linkContent')) {
this.replaceFieldValue(instance.titleField, instance.linkContent);
}
// Link field can have a title field. If they have, we populate the title
// field with the search result title if any.
if (typeof field_settings.title_field != 'undefined' && typeof Drupal.settings.linkit.currentInstance.linkContent != 'undefined') {
this.replaceFieldValue($('#' + field_settings.title_field).get(0), Drupal.settings.linkit.currentInstance.linkContent);
}
},
// The "path" property will always be present after dialog was
// opened and contain raw URL.
//
// @see Drupal.behaviors.linkitDashboard.attach
this.replaceFieldValue(instance.source, data.path);
}
else {
// Replace the field value.
this.replaceFieldValue(instance.source, link);
}
},
/**
* Get field selection.
*/
getSelection : function(e) {
// Mozilla and DOM 3.0.
if ('selectionStart' in e) {
var l = e.selectionEnd - e.selectionStart;
return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) };
}
// IE.
else if(document.selection) {
e.focus();
var r = document.selection.createRange(),
tr = e.createTextRange(),
tr2 = tr.duplicate();
tr2.moveToBookmark(r.getBookmark());
tr.setEndPoint('EndToStart',tr2);
/**
* Get field selection.
*/
getSelection: function(element) {
var object = {
start: element.value.length,
end: element.value.length,
length: 0,
text: ''
};
if (r == null || tr == null) {
return { start: e.value.length, end: e.value.length, length: 0, text: '' };
// Mozilla and DOM 3.0.
if ('selectionStart' in element) {
var length = element.selectionEnd - element.selectionStart;
object = {
start: element.selectionStart,
end: element.selectionEnd,
length: length,
text: element.value.substr(element.selectionStart, length)
};
}
// IE.
else if (document.selection) {
element.focus();
var range = document.selection.createRange(),
textRange = element.createTextRange(),
textRangeDuplicate = textRange.duplicate();
textRangeDuplicate.moveToBookmark(range.getBookmark());
textRange.setEndPoint('EndToStart', textRangeDuplicate);
if (!(range || textRange)) {
return object;
}
// For some reason IE doesn't always count the \n and \r in the length.
var text_part = r.text.replace(/[\r\n]/g,'.'),
text_whole = e.value.replace(/[\r\n]/g,'.'),
the_start = text_whole.indexOf(text_part, tr.text.length);
return { start: the_start, end: the_start + text_part.length, length: text_part.length, text: r.text };
var text_part = range.text.replace(/[\r\n]/g, '.'),
text_whole = element.value.replace(/[\r\n]/g, '.'),
the_start = text_whole.indexOf(text_part, textRange.text.length);
object = {
start: the_start,
end: the_start + text_part.length,
length: text_part.length,
text: range.text
};
}
return object;
},
/**
* Replace the field selection.
*/
replaceSelection: function(id, selection, text) {
var field = this.getField(id);
field.value = field.value.substr(0, selection.start) + text + field.value.substr(selection.end, field.value.length);
},
/**
* Replace the field value.
*/
replaceFieldValue: function(id, text) {
this.getField(id).value = text;
},
getField: function(id) {
return document.getElementById(id);
}
// Browser not supported.
else {
return { start: e.value.length, end: e.value.length, length: 0, text: '' };
}
},
/**
* Replace the field selection.
*/
replaceSelection : function (e, selection, text) {
var start_pos = selection.start;
var end_pos = start_pos + text.length;
e.value = e.value.substr(0, start_pos) + text + e.value.substr(selection.end, e.value.length);
},
/**
* Replace the field value.
*/
replaceFieldValue : function (e, text) {
e.value = text;
}
});
})(jQuery);
});
})(jQuery, 'linkitField');
@@ -6,11 +6,15 @@
(function ($) {
// Create the Linkit namespaces.
Drupal.linkit = Drupal.linkit || {};
Drupal.linkit = Drupal.linkit || { 'excludeIdSelectors': {} };
Drupal.linkit.currentInstance = Drupal.linkit.currentInstance || {};
Drupal.linkit.dialogHelper = Drupal.linkit.dialogHelper || {};
Drupal.linkit.insertPlugins = Drupal.linkit.insertPlugins || {};
// Exclude ids from ajax_html_ids during AJAX requests.
Drupal.linkit.excludeIdSelectors.ckeditor = ['[id^="cke_"]'];
Drupal.linkit.excludeIdSelectors.tokens = ['[id^="token-"]'];
/**
* Create the modal dialog.
*/
@@ -140,6 +144,12 @@ Drupal.linkit.registerDialogHelper = function(name, helper) {
/**
* Get a dialog helper.
*
* @param {String} name
* The name of helper.
*
* @return {Object}
* Dialog helper object.
*/
Drupal.linkit.getDialogHelper = function(name) {
return Drupal.linkit.dialogHelper[name];
@@ -159,4 +169,30 @@ Drupal.linkit.getInsertPlugin = function(name) {
return Drupal.linkit.insertPlugins[name];
};
var oldBeforeSerialize = (Drupal.ajax ? Drupal.ajax.prototype.beforeSerialize : false);
if (oldBeforeSerialize) {
/**
* Filter the ajax_html_ids list sent in AJAX requests.
*
* This avoids hitting like max_input_vars, which defaults to 1000,
* even with just a few active editor instances.
*/
Drupal.ajax.prototype.beforeSerialize = function (element, options) {
var ret = oldBeforeSerialize.call(this, element, options);
var excludeSelectors = [];
$.each(Drupal.linkit.excludeIdSelectors, function () {
if ($.isArray(this)) {
excludeSelectors = excludeSelectors.concat(this);
}
});
if (excludeSelectors.length > 0) {
options.data['ajax_html_ids[]'] = [];
$('[id]:not(' + excludeSelectors.join(',') + ')').each(function () {
options.data['ajax_html_ids[]'].push(this.id);
});
}
return ret;
}
}
})(jQuery);
@@ -29,4 +29,23 @@ function hook_linkit_search_plugin_entities_alter(&$plugins) {
);
$plugins['my_custom_plugin']['handler'] = $handler;
}
}
}
/**
* Implements hook_linkit_local_hosts_alter().
*
* The default behavior is that only the current host is considered "local",
* when deciding how to classify a URL. For example, if the user is on
* http://www.example.com, then all URLs to other hosts will not be considered
* for local URLs. This means that if your users edit content on a different host
* from the actual public-facing site, such as https://staging.example.com,
* then if they paste in URLs from the public site (www), none of those
* URLs will be considered local.
*
* Implementing this hook will allow you to alter the list (indexed array) of
* hosts that will be considered for internal links. Include the protocol
* (eg, http or https).
*/
function hook_linkit_local_hosts_alter(&$local_hosts) {
$local_hosts[] = 'http://www.example.com';
}
@@ -170,72 +170,80 @@ function linkit_field_profile_validate($element, &$form_state, $form) {
}
/**
* Process callback.
* After build callback.
*
* @param array $element
* Form API element.
* @param array $form_state
* State of form the element belongs to.
*
* @return array
* Form API element with attached Linkit functionality.
*/
function linkit_process_field_element($element, &$form_state, &$complete_form) {
function linkit_field_element_after_build(array $element, array &$form_state) {
// Only proceed if the field is attached to an entity.
if (!isset($element['#entity_type'])) {
return $element;
}
$field = field_info_field($element['#field_name']);
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
if (isset($instance['settings']['linkit']['enable']) && $instance['settings']['linkit']['enable']) {
// Load the profile.
$profile = linkit_profile_load($instance['settings']['linkit']['profile']);
if (!$profile) {
return $element;
}
// Load the insert plugin for the profile.
$insert_plugin = linkit_insert_plugin_load($profile->data['insert_plugin']['plugin']);
if ($insert_plugin === NULL) {
return $element;
}
// Set the field ID.
$field_id = $element['#id'];
// Special treatment for link fields.
if ($element['#type'] == 'link_field') {
$field_id = $element['#id'] . '-url';
}
$field_js = array(
'data' => array(
'linkit' => array(
'fields' => array(
$field_id => array(
'profile' => $instance['settings']['linkit']['profile'],
'insert_plugin' => $profile->data['insert_plugin']['plugin'],
'url_method' => $profile->data['insert_plugin']['url_method'],
// @TODO: Add autocomplete settings.
),
),
),
),
'type' => 'setting',
);
// Link fields can have a title field.
if ($element['#type'] == 'link_field') {
if (isset($instance['settings']['title']) && in_array($instance['settings']['title'], array('optional', 'required'))) {
$field_js['data']['linkit']['fields'][$field_id]['title_field'] = $element['#id'] . '-title';
}
}
// Attach js files and settings Linkit needs.
$element['#attached']['library'][] = array('linkit', 'base');
$element['#attached']['library'][] = array('linkit', 'field');
$element['#attached']['js'][] = $insert_plugin['javascript'];
$element['#attached']['js'][] = $field_js;
$button_text = !empty($instance['settings']['linkit']['button_text']) ? $instance['settings']['linkit']['button_text'] : t('Search');
// Add Linkit dialog button to the element suffix.
$element['#field_suffix'] = '<a class="button linkit-field-button linkit-field-' . $field_id . '" href="#">' . $button_text . '</a>';
if (empty($instance['settings']['linkit']['enable'])) {
return $element;
}
// Load the profile.
/* @var \LinkitProfile $profile */
$profile = linkit_profile_load($instance['settings']['linkit']['profile']);
if (!$profile || !isset($profile->data['insert_plugin']['plugin'])) {
return $element;
}
// Load the insert plugin for the profile.
$insert_plugin = linkit_insert_plugin_load($profile->data['insert_plugin']['plugin']);
$js_settings = array(
'helper' => 'field',
'source' => $element['#id'],
'profile' => $instance['settings']['linkit']['profile'],
'insertPlugin' => $profile->data['insert_plugin']['plugin'],
);
// Special treatment for link fields.
if ('link_field' == $element['#type']) {
$js_settings['source'] = $element['url']['#id'];
// @see link_field_info()
// @see link_field_instance_settings_form()
//
// Link fields have a title field, but value could
// be changed only for those options.
if (in_array($instance['settings']['title'], array('optional', 'required'))) {
$js_settings['titleField'] = $element['title']['#id'];
}
}
// Add Linkit dialog button to the element suffix.
$element['#field_suffix'] = l(empty($instance['settings']['linkit']['button_text']) ? t('Search') : $instance['settings']['linkit']['button_text'], '', array(
'attributes' => array(
'class' => array(
"button",
"linkit-field-button",
"linkit-field-{$js_settings['source']}",
),
),
));
// Attach js files and settings Linkit needs.
$element['#attached']['library'][] = array('linkit', 'base');
$element['#attached']['library'][] = array('linkit', 'field');
$element['#attached']['js'][] = $insert_plugin['javascript'];
$element['#attached']['js'][] = array(
'type' => 'setting',
'data' => array(
'linkit' => array('fields' => array($js_settings)),
),
);
return $element;
}
}
@@ -21,11 +21,10 @@ files[] = test/linkit_search_plugin.test
files[] = test/linkit_search_plugin_node.test
files[] = test/linkit_search_plugin_user.test
files[] = test/linkit_search_plugin_taxonomy_term.test
files[] = test/linkit_field.test
; Information added by Drupal.org packaging script on 2015-01-06
version = "7.x-3.3"
; Information added by Drupal.org packaging script on 2016-01-10
version = "7.x-3.5"
core = "7.x"
project = "linkit"
datestamp = "1420580858"
datestamp = "1452407341"
@@ -111,6 +111,9 @@ function linkit_update_7300() {
)
);
// Make sure our schema changes are reflected in the cached schema or
// subsequent update hooks making use of it might fail.
drupal_get_schema('linkit_profiles', TRUE);
foreach ($old_profiles as $profile) {
$data = unserialize($profile->data);
@@ -209,15 +212,50 @@ function linkit_update_7301() {
}
/**
* Set URL type to "Entity view page" to preserve current behavior.
* Reverted.
*/
function linkit_update_7302() {
// This is the broken verison of 7304
}
/**
* Fixed 7302. Set URL type to "Entity view page" to preserve current behavior.
*/
function linkit_update_7303() {
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'linkit') . '/plugins/linkit_search/file.class.php';
$profiles = linkit_profile_load_all();
$show_notice = FALSE;
foreach ($profiles as $profile) {
if (isset($profile->data['entity:file'])) {
$profile->data['entity:file'] = LINKIT_FILE_URL_TYPE_ENTITY;
// If the broken 7302 has been applied, and no other changes has been made, there is not way to get the data back.
// Lets add the default settings instead.
if (isset($profile->data['entity:file']) && $profile->data['entity:file'] == LINKIT_FILE_URL_TYPE_ENTITY) {
$profile->data['entity:file'] = array(
'result_description' => '',
'bundles' => array(
'image' => 0,
'video' => 0,
'audio' => 0,
'document' => 0,
),
'group_by_bundle' => 0,
'show_scheme' => 0,
'group_by_scheme' => 0,
'url_type' => 'entity',
'image_extra_info' => array(
'thumbnail' => 'thumbnail',
'dimensions' => 'dimensions',
),
);
ctools_export_crud_save('linkit_profiles', $profile);
$show_notice = TRUE;
}
else if (isset($profile->data['entity:file']) && !isset($profile->data['entity:file']['url_type'])) {
$profile->data['entity:file']['url_type'] = LINKIT_FILE_URL_TYPE_ENTITY;
ctools_export_crud_save('linkit_profiles', $profile);
}
if ($show_notice) {
return t('A previous update may have changed the settings for the "managed file" search plugin in all your linkit profiles.');
}
}
}
@@ -326,10 +326,10 @@ function linkit_module_implements_alter(&$implementations, $hook) {
* Implements hook_element_info_alter().
*/
function linkit_element_info_alter(&$types) {
// Append a process function for the field integration.
// Append a after_build function for the field integration.
foreach (linkit_get_allowed_field_elements() as $element) {
if (isset($types[$element])) {
$types[$element]['#process'][] = 'linkit_process_field_element';
$types[$element]['#after_build'][] = 'linkit_field_element_after_build';
}
}
@@ -338,7 +338,7 @@ function linkit_element_info_alter(&$types) {
if (in_array('ckeditor_pre_render_text_format', $types['text_format']['#pre_render'])) {
$types['text_format']['#pre_render'][] = 'linkit_pre_render_editor_element';
// Add the linkit library for the editor.
drupal_add_library('linkit', 'ckeditor');
$types['text_format']['#attached']['library'][] = array('linkit', 'ckeditor');
}
}
@@ -556,7 +556,7 @@ function linkit_dashboard_form($form, &$form_state) {
'#options' => $_profiles,
'#ajax' => array(
'callback' => 'linkit_change_profile',
'wrapper' => 'linkit-dashbaord-ajax-wrapper',
'wrapper' => 'linkit-dashboard-ajax-wrapper',
'method' => 'replaceWith',
'effect' => 'fade',
'event' => 'click',
@@ -577,7 +577,7 @@ function linkit_dashboard_form($form, &$form_state) {
$form['linkit_container'] = array(
'#type' => 'container',
'#weight' => 100,
'#prefix' => '<div id="linkit-dashbaord-ajax-wrapper">',
'#prefix' => '<div id="linkit-dashboard-ajax-wrapper">',
'#suffix' => '</div>',
'#attached' => array(
'js' => array(
@@ -687,12 +687,12 @@ function linkit_autocomplete(LinkitProfile $profile) {
// Special for link to frontpage.
if (strpos($search_string, 'front') !== FALSE) {
$results = array_merge($results, array(
$results[] = array(
'title' => t('Frontpage'),
'description' => 'The frontpage for this site.',
'path' => url('<front>'),
'group' => t('System'),
));
);
}
// Let the Linkit search plugins do their job.
@@ -823,7 +823,10 @@ function linkit_parse_url($url, $parts) {
// Internal URL.
// We can not use the url_is_external() as it treats all absolute links as
// external and treats all stream wrappers as internal.
$local_url = trim($path_info['scheme'] . '://' . $path_info['host'] . base_path(), '/') == $base_url;
$local_hosts = array($base_url);
// Give other modules a chance to add/remove/alter the local hosts.
drupal_alter('linkit_local_hosts', $local_hosts);
$local_url = in_array(trim($path_info['scheme'] . '://' . $path_info['host'] . base_path(), '/'), $local_hosts);
$local_stream_wrapper = isset($local_stream_wrappers[$path_info['scheme']]);
//@TODO: maybe file_valid_uri() ?
@@ -1041,49 +1044,53 @@ function linkit_pre_render_editor_element($element) {
static $processed = array();
if (!isset($processed[$element['#id']])) {
// Load the first profile that is assign to this text format.
$profile = linkit_profile_load_by_format($element['#format']);
global $user;
$all_formats = array_keys(filter_formats($user));
// If we dont have any profile, lets just return the element.
if (!$profile) {
return $element;
}
// Set the field ID.
if (isset($element['value']['#id'])) {
$field_id = $element['value']['#id'];
}
else {
$field_id = $element['#id'] . '-value';
$profiles_formats = array();
$use_imce = FALSE;
// First we need to figure out which formats that the current user can access have active Linkit profiles for them.
foreach ($all_formats as $format) {
// Load the first profile that is assigned to this text format.
$profile = linkit_profile_load_by_format($format);
if ($profile) {
if (isset($profile->data['imce']) && $profile->data['imce'] == 1) {
$use_imce = TRUE;
}
$profiles_formats[$format] = array('profile' => $profile->name);
}
}
$field_js = array(
'data' => array(
'linkit' => array(
'fields' => array(
$field_id => array(
'profile' => $profile->name,
),
if (!empty($profiles_formats)) {
$field_js = array(
'data' => array(
'linkit' => array(
'formats' => $profiles_formats,
),
),
),
'type' => 'setting',
);
'type' => 'setting',
);
// Configure Linkit to have an IMCE selector.
if (module_invoke('imce', 'access') && isset($profile->data['imce']) && $profile->data['imce'] == 1) {
$field_js['data']['linkit']['IMCEurl'] = url('imce', array('query' => array(
'app' => 'Linkit|sendto@Drupal.linkit.IMCECallback',
'absolute' => TRUE,
)));
// We will only serv public files with IMCE.
$field_js['data']['linkit']['publicFilesDirectory'] = variable_get('file_public_path', conf_path() . '/files');
// Configure Linkit to have an IMCE selector.
if (module_invoke('imce', 'access') && $use_imce) {
$field_js['data']['linkit']['IMCEurl'] = url('imce', array('query' => array(
'app' => 'Linkit|sendto@Drupal.linkit.IMCECallback',
'absolute' => TRUE,
)));
// We will only serv public files with IMCE.
$field_js['data']['linkit']['publicFilesDirectory'] = variable_get('file_public_path', conf_path() . '/files');
}
// Attach the linkit_base librar
$element['#attached']['library'][] = array('linkit', 'base');
$element['#attached']['js'][] = $field_js;
$processed[$element['#id']] = TRUE;
}
// Attach the linkit_base librar
$element['#attached']['library'][] = array('linkit', 'base');
$element['#attached']['js'][] = $field_js;
$processed[$element['#id']] = TRUE;
}
return $element;
@@ -1139,14 +1146,14 @@ function linkit_get_insert_plugin_processed_path(LinkitProfile $profile, $uri, $
switch ($profile->data['insert_plugin']['url_method']) {
case LINKIT_URL_METHOD_RAW:
$path = $uri;
break;
case LINKIT_URL_METHOD_RAW_SLASH:
$options['alias'] = TRUE;
$path = url($uri, $options);
break;
case LINKIT_URL_METHOD_ALIAS:
$path = url($uri, $options);
break;
break;
case LINKIT_URL_METHOD_RAW_SLASH:
$options['alias'] = TRUE;
$path = url($uri, $options);
break;
case LINKIT_URL_METHOD_ALIAS:
$path = url($uri, $options);
break;
}
return $path;
@@ -106,7 +106,6 @@ function _linkit_build_profile_type_form_fields(&$form, LinkitProfile $profile)
$form['data']['profile_type'] = array(
'#type' => 'fieldset',
'#title' => t('Profile type'),
'#description' => t(''),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => FALSE,
@@ -143,7 +142,6 @@ function _linkit_build_profile_type_form_fields(&$form, LinkitProfile $profile)
'#empty_option' => t('- Select one or more text format- '),
'#default_value' => isset($profile->data['text_formats'])
? $profile->data['text_formats'] : array(),
'#description' => t('.'),
'#states' => array(
'visible' => array(
// While waiting for https://drupal.org/node/879580 to be commited, we
@@ -294,7 +292,7 @@ function _linkit_build_insert_plugin_form_fields(&$form, LinkitProfile $profile)
),
LINKIT_URL_METHOD_RAW_SLASH => array(
'#description' => t('This is the default behavior, it will insert paths
like %example_link.<br/>These will work <strong>without the need for a input filter</strong>,
like %example_link.<br/>These will work <strong>without the need for an input filter</strong>,
but might fail after moving a site, or on multilingual sites.',
array('%example_link' => '/node/123')),
),
@@ -307,7 +305,7 @@ function _linkit_build_insert_plugin_form_fields(&$form, LinkitProfile $profile)
$form['data']['insert_plugin']['url_method']['#options'][LINKIT_URL_METHOD_ALIAS] = t('Alias paths');
$form['data']['insert_plugin']['url_method'][LINKIT_URL_METHOD_ALIAS] = array(
'#description' => t('This will insert the alias for the result item.
<br/>The paths will be runned thru the <em>url()</em> function.', array('%example_link' => 'node/123')),
<br/>The paths will be run through the <em>url()</em> function.', array('%example_link' => 'node/123')),
);
}
}
@@ -327,7 +325,7 @@ function _linkit_build_attribute_plugin_form_fields(&$form, LinkitProfile $profi
$form['data']['attribute_plugins_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Attributes'),
'#description' => t('Attributes is HTML attributes that will be attached to
'#description' => t('Attributes are HTML attributes that will be attached to
the insert plugin.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
@@ -417,7 +415,7 @@ function _linkit_build_autocomplete_form_fields(&$form, LinkitProfile $profile)
$form['data']['autocomplete'] = array(
'#type' => 'fieldset',
'#title' => t('Autocomplete options'),
'#description' => t('Linkit uses !bac which may be configured with focus on
'#description' => t('Linkit uses !bac which may be configured with a focus on
performance.', array('!bac' => l(t('Better Autocomplete'),
'https://github.com/betamos/Better-Autocomplete'))),
'#collapsible' => TRUE,
@@ -2,34 +2,32 @@
* @file
* HTML Link insert plugin for Linkit.
*/
(function ($) {
(function($) {
Drupal.linkit.registerInsertPlugin('html_link', {
insert: function(data) {
var linkitInstance = Drupal.settings.linkit.currentInstance,
selection = linkitInstance.selection,
text = linkitInstance.linkContent || data.path;
Drupal.linkit.registerInsertPlugin('html_link', {
insert : function(data) {
var text,
selection = Drupal.settings.linkit.currentInstance.selection;
// Delete all attributes that are empty.
for (var attr in data.attributes) {
if (data.attributes.hasOwnProperty(attr)) {
delete data.attributes[attr];
}
}
// Delete all attributes that are empty.
for (name in data.attributes) {
(data.attributes[name]) ? null : delete data.attributes[name];
if (selection && selection.text.length >= 1) {
text = selection.text;
}
// Use document.createElement as it is mush fasten then $('<a/>).
return $(document.createElement('a'))
.attr(data.attributes)
.attr('href', data.path)
.html(text)
// Convert the element to a string.
.get(0)
.outerHTML;
}
if (typeof selection != 'undefined' &&
selection.text.length >= 1) {
text = selection.text;
}
else {
text = Drupal.settings.linkit.currentInstance.linkContent;
}
// Use document.createElement as it is mush fasten then $('<a/>).
return $(document.createElement('a'))
.attr(data.attributes)
.attr('href', data.path)
.html(text)
// Convert the element to a string.
.get(0).outerHTML;
}
});
})(jQuery);
});
})(jQuery);
@@ -5,7 +5,7 @@
*/
/**
* Reprecents a Linkit entity search plugin.
* Represents a Linkit entity search plugin.
*/
class LinkitSearchPluginEntity extends LinkitSearchPlugin {
@@ -97,13 +97,13 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
* The entity label, or FALSE if not found.
*/
function createLabel($entity) {
return check_plain(entity_label($this->plugin['entity_type'], $entity));
return filter_xss(entity_label($this->plugin['entity_type'], $entity));
}
/**
* Create a search row description.
*
* If there is a "result_description", run it thro token_replace.
* If there is a "result_description", run it through token_replace.
*
* @param object $data
* An entity object that will be used in the token_place function.
@@ -145,7 +145,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
$options['language'] = $languages[$entity->language];
}
}
// Process the uri with the insert pluing.
// Process the uri with the insert plugin.
$path = linkit_get_insert_plugin_processed_path($this->profile, $uri['path'], $options);
return $path;
}
@@ -175,7 +175,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
}
/**
* Create a row class to appaned to the search result row.
* Create a row class to append to the search result row.
*
* @param $entity
* The entity object.
@@ -194,7 +194,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
$this->query = new EntityFieldQuery();
$this->query->entityCondition('entity_type', $this->plugin['entity_type']);
// Add the default sort on the enity label.
// Add the default sort on the entity label.
$this->query->propertyOrderBy($this->entity_field_label, 'ASC');
}
@@ -240,7 +240,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
$entities = entity_load($this->plugin['entity_type'], $ids);
foreach ($entities AS $entity) {
// Check the access againt the definded entity access callback.
// Check the access against the defined entity access callback.
if (entity_access('view', $this->plugin['entity_type'], $entity) === FALSE) {
continue;
}
@@ -276,7 +276,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
// Get supported tokens for the entity type.
$tokens = linkit_extract_tokens($this->plugin['entity_type']);
// A short description in within the search result for each row.
// A short description within the search result for each row.
$form[$this->plugin['name']]['result_description'] = array(
'#title' => t('Result description'),
'#type' => 'textfield',
@@ -286,7 +286,7 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
'#description' => t('Available tokens: %tokens.', array('%tokens' => implode(', ', $tokens))),
);
// If the token module is installed, lets make some fancy stuff with the
// If the token module is installed, lets do some fancy stuff with the
// token chooser.
if (module_exists('token')) {
// Unset the regular description if token module is enabled.
@@ -295,17 +295,15 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
// Display the user documentation of placeholders.
$form[$this->plugin['name']]['token_help'] = array(
'#title' => t('Replacement patterns'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#type' => 'markup',
);
$form[$this->plugin['name']]['token_help']['help'] = array(
'#theme' => 'token_tree',
'#theme' => 'token_tree_link',
'#token_types' => array($this->plugin['entity_type']),
);
}
// If there is bundles, add some default settings features.
// If there are bundles, add some default settings features.
if (count($this->entity_info['bundles']) > 1) {
$bundles = array();
// Extract the bundle data.
@@ -331,4 +329,4 @@ class LinkitSearchPluginEntity extends LinkitSearchPlugin {
}
return $form;
}
}
}
@@ -43,7 +43,7 @@ class LinkitSearchPluginNode extends LinkitSearchPluginEntity {
'#title' => t('Include unpublished nodes'),
'#type' => 'checkbox',
'#default_value' => isset($this->conf['include_unpublished']) ? $this->conf['include_unpublished'] : 0,
'#description' => t('In order to see unpublished nodes, the user most also have permissions to do so. '),
'#description' => t('In order to see unpublished nodes, the user must also have permissions to do so. '),
);
return $form;
@@ -16,7 +16,6 @@ class LinkitProfileUICRUDTestCase extends LinkitTestCase {
'name' => 'test_profile',
'admin_title' => 'Test Profile',
'admin_description' => 'This is a description for the Test Profile.',
'profile_type' => LINKIT_PROFILE_TYPE_EDITOR,
);
/**
@@ -32,6 +31,7 @@ class LinkitProfileUICRUDTestCase extends LinkitTestCase {
function setUp($extra_modules = array()) {
parent::setUp($extra_modules);
$this->profile_defaults['profile_type'] = LINKIT_PROFILE_TYPE_EDITOR;
}
/**