Skip to content
Snippets Groups Projects
Commit 5c088b60 authored by Chris Gross's avatar Chris Gross
Browse files

daily build 2

parent 577ebf6c
No related merge requests found
The following patches have been applied to this project:
- http://drupal.org/files/issues/linkit-add-to-any-element-2651404-3.patch
- http://drupal.org/files/issues/linkit-private_files_direct_link-2652300-2.patch
- http://drupal.org/files/issues/linkit-menu-links-2514928-2.patch
This file was automatically generated by Drush Make (http://drupal.org/project/drush).
<?php
/**
* @file
* Linkit admin settings.
*/
/**
* Linkit settings form.
*/
function linkit_settings_form($form, &$form_state) {
$menu = variable_get('linkit_menu', array());
// Linkit fieldset.
$form['linkit_menu'] = array(
'#type' => 'fieldset',
'#title' => t('Menu settings'),
'#tree' => TRUE,
);
// Enable Linkit.
$form['linkit_menu']['enable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Linkit for menu links.'),
'#default_value' => isset($menu['enable']) ? $menu['enable'] : FALSE,
);
// Load profile options.
$profiles = linkit_profile_field_load_all();
$options = array();
foreach ($profiles as $profile) {
$options[$profile->name] = $profile->admin_title;
}
natsort($options);
// Linkit profile.
$form['linkit_menu']['profile'] = array(
'#type' => 'select',
'#title' => t('Profile'),
'#options' => $options,
'#empty_option' => t('- Select a profile -'),
'#default_value' => isset($menu['profile']) ? $menu['profile'] : '',
'#states' => array(
'invisible' => array(
'input[name="linkit_menu[enable]"]' => array('checked' => FALSE),
),
'required' => array(
'input[name="linkit_menu[enable]"]' => array('checked' => TRUE),
),
),
'#element_validate' => array('linkit_menu_profile_validate'),
);
// Button text.
$form['linkit_menu']['button_text'] = array(
'#type' => 'textfield',
'#title' => t('Button text that activates Linkit modal'),
'#default_value' => isset($menu['button_text']) ? $menu['button_text'] : t('Search'),
'#states' => array(
'invisible' => array(
'input[name="linkit_menu[enable]"]' => array('checked' => FALSE),
),
),
);
return system_settings_form($form);
}
/**
* Validation callback which validates profile field if linkit is enabled for
* menus.
*
* @see linkit_form_menu_edit_menu_alter()
*/
function linkit_menu_profile_validate($element, &$form_state, $form) {
if (!empty($form_state['values']['menu']['enable']) && empty($element['#value'])) {
form_error($element, t('You must select a Linkit profile.'));
}
}
......@@ -181,20 +181,49 @@ function linkit_field_profile_validate($element, &$form_state, $form) {
* Form API element with attached Linkit functionality.
*/
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;
// Default settings.
$settings = array(
'profile' => NULL,
'enable' => TRUE,
'button_text' => t('Search'),
'js_settings' => array(),
);
// For Field API elements, merge settings from field instance.
if (isset($element['#entity_type'])) {
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
if (isset($instance['settings']['linkit'])) {
$settings = array_merge($settings, $instance['settings']['linkit']);
}
// Special treatment for link fields.
if ($element['#type'] == 'link_field') {
$settings['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'))) {
$settings['js_settings']['titleField'] = $element['title']['#id'];
}
}
}
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
// Allow dynamically adding to any eligible element type.
if (!empty($element['#linkit'])) {
$settings = array_merge($settings, $element['#linkit']);
}
if (empty($instance['settings']['linkit']['enable'])) {
// If profile is empty or disabled, skip the rest.
if (empty($settings['profile']) || empty($settings['enable'])) {
return $element;
}
// Load the profile.
/* @var \LinkitProfile $profile */
$profile = linkit_profile_load($instance['settings']['linkit']['profile']);
$profile = linkit_profile_load($settings['profile']);
if (!$profile || !isset($profile->data['insert_plugin']['plugin'])) {
return $element;
......@@ -202,29 +231,15 @@ function linkit_field_element_after_build(array $element, array &$form_state) {
// Load the insert plugin for the profile.
$insert_plugin = linkit_insert_plugin_load($profile->data['insert_plugin']['plugin']);
$js_settings = array(
$js_settings = $settings['js_settings'] + array(
'helper' => 'field',
'source' => $element['#id'],
'profile' => $instance['settings']['linkit']['profile'],
'profile' => $profile->name,
'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(
$element['#field_suffix'] = l($settings['button_text'], '', array(
'attributes' => array(
'class' => array(
"button",
......
......@@ -471,6 +471,17 @@ function linkit_menu() {
'type' => MENU_CALLBACK,
);
// Settings form.
$items['admin/config/content/linkit/settings'] = array(
'type' => MENU_LOCAL_TASK,
'title' => 'Settings',
'description' => 'Linkit settings.',
'access arguments' => array('administer linkit'),
'page callback' => 'drupal_get_form',
'page arguments' => array('linkit_settings_form'),
'file' => 'linkit.admin.inc',
);
return $items;
};
......@@ -1158,3 +1169,11 @@ function linkit_get_insert_plugin_processed_path(LinkitProfile $profile, $uri, $
return $path;
}
/**
* Implements hook_form_FORM_ID_alter() for "menu_edit_item".
*/
function linkit_form_menu_edit_item_alter(&$form, &$form_state) {
// Add menu settings to link path.
$form['link_path']['#linkit'] = variable_get('linkit_menu', array());
}
......@@ -110,7 +110,7 @@ class LinkitSearchPluginFile extends LinkitSearchPluginEntity {
case LINKIT_FILE_URL_TYPE_DIRECT:
// Check if this is a local file.
$wrapper = file_stream_wrapper_get_instance_by_uri($entity->uri);
if ($wrapper instanceof DrupalLocalStreamWrapper) {
if ($wrapper instanceof DrupalLocalStreamWrapper && strpos($entity->uri, 'private://') === FALSE) {
// Create a relative URL to the local file.
// See https://www.drupal.org/node/837794.
$path = $wrapper->getDirectoryPath() . '/' . file_uri_target($entity->uri);
......
......@@ -17,9 +17,9 @@ projects[fitvids][subdir] = contrib
projects[linkit][version] = 3.5
projects[linkit][subdir] = contrib
projects[ctools][patch][2651404] = http://drupal.org/files/issues/linkit-add-to-any-element-2651404-3.patch
projects[ctools][patch][2652300] = http://drupal.org/files/issues/linkit-private_files_direct_link-2652300-2.patch
projects[ctools][patch][2514928] = http://drupal.org/files/issues/linkit-menu-links-2514928-2.patch
projects[linkit][patch][2651404] = http://drupal.org/files/issues/linkit-add-to-any-element-2651404-3.patch
projects[linkit][patch][2652300] = http://drupal.org/files/issues/linkit-private_files_direct_link-2652300-2.patch
projects[linkit][patch][2514928] = http://drupal.org/files/issues/linkit-menu-links-2514928-2.patch
projects[pasteformat][version] = 1.5
projects[pasteformat][subdir] = contrib
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment