updated etxlink, ctools, colorbox, computed_field

This commit is contained in:
2019-05-13 17:51:14 +02:00
parent 33210e10f2
commit 2ffad14939
309 changed files with 4930 additions and 2655 deletions

View File

@@ -2,7 +2,7 @@
/**
* @file
* Ctools access plugin to provide access/visiblity if two user contexts are equal.
* CTools access plugin to provide access/visiblity if two user contexts are equal.
*/
/**
@@ -20,12 +20,12 @@ $plugin = array(
'summary' => 'ctools_compare_users_ctools_access_summary',
'required context' => array(
new ctools_context_required(t('First User'), 'user'),
new ctools_context_required(t("Second User"), 'user')
new ctools_context_required(t("Second User"), 'user'),
),
);
/**
* Settings form for the 'by perm' access plugin
* Settings form for the 'by perm' access plugin.
*/
function ctools_compare_users_settings($form, &$form_state, $conf) {

View File

@@ -2,7 +2,7 @@
/**
* @file
* Plugin to provide access control/visibility based on existence of a specified context
* Plugin to provide access control/visibility based on existence of a specified context.
*/
$plugin = array(
@@ -16,7 +16,7 @@ $plugin = array(
);
/**
* Settings form
* Settings form.
*/
function ctools_context_exists_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['exists'] = array(
@@ -29,17 +29,17 @@ function ctools_context_exists_ctools_access_settings($form, &$form_state, $conf
}
/**
* Check for access
* Check for access.
*/
function ctools_context_exists_ctools_access_check($conf, $context) {
// xor returns false if the two bools are the same, and true if they are not.
// Xor returns false if the two bools are the same, and true if they are not.
// i.e, if we asked for context_exists and it does, return true.
// If we asked for context does not exist and it does, return false.
return (empty($context->data) xor !empty($conf['exists']));
}
/**
* Provide a summary description based upon the specified context
* Provide a summary description based upon the specified context.
*/
function ctools_context_exists_ctools_access_summary($conf, $context) {
if (!empty($conf['exists'])) {

View File

@@ -43,7 +43,7 @@ function ctools_entity_bundle_ctools_access_get_children($plugin, $parent) {
}
/**
* Settings form for the 'by entity_bundle' access plugin
* Settings form for the 'by entity_bundle' access plugin.
*/
function ctools_entity_bundle_ctools_access_settings($form, &$form_state, $conf) {
$plugin = $form_state['plugin'];
@@ -133,4 +133,3 @@ function ctools_entity_bundle_ctools_access_summary($conf, $context, $plugin) {
return format_plural(count($names), '@identifier is bundle "@types"', '@identifier bundle is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier));
}

View File

@@ -48,7 +48,7 @@ function ctools_entity_field_value_ctools_access_get_children($plugin, $parent)
}
function _ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $entity_type, $bundle_type, $field_name, $entity = NULL, $bundle = NULL, $field = NULL) {
// check that the entity, bundle and field arrays have a value.
// Check that the entity, bundle and field arrays have a value.
// If not, load theme using machine names.
if (empty($entity)) {
$entity = entity_get_info($entity_type);
@@ -68,14 +68,14 @@ function _ctools_entity_field_value_ctools_access_get_child($plugin, $parent, $e
$plugin['description'] = t('Control access by @entity entity bundle.', array('@entity' => $entity_type));
$plugin['name'] = $parent . ':' . $entity_type . ':' . $bundle_type . ':' . $field_name;
$plugin['required context'] = new ctools_context_required(t(ucfirst($entity_type)), $entity_type, array(
'type' => $bundle_type,
));
'type' => $bundle_type,
));
return $plugin;
}
/**
* Settings form for the 'by entity_bundle' access plugin
* Settings form for the 'by entity_bundle' access plugin.
*/
function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $conf) {
$plugin = $form_state['plugin'];
@@ -88,7 +88,7 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
$columns[$column] = _field_sql_storage_columnname($field_name, $column);
}
ctools_include('fields');
$entity = (object)array(
$entity = (object) array(
$entity_info['entity keys']['bundle'] => $bundle_type,
);
@@ -115,7 +115,7 @@ function ctools_entity_field_value_ctools_access_settings($form, &$form_state, $
$form['#parents'] = array('settings');
$langcode = field_valid_language(NULL);
$form['settings'] += (array) ctools_field_invoke_field($instance, 'form', $entity_type, $entity, $form, $form_state, array('default' => TRUE, 'language' => $langcode));
// weight is really not important once this is populated and will only interfere with the form layout.
// Weight is really not important once this is populated and will only interfere with the form layout.
foreach (element_children($form['settings']) as $element) {
unset($form['settings'][$element]['#weight']);
}
@@ -145,7 +145,8 @@ function ctools_entity_field_value_ctools_access_settings_submit($form, &$form_s
function _ctools_entity_field_value_get_proper_form_items($field, $form_items, $columns) {
$items = array();
if (!is_array($form_items)) { // Single value item.
// Single value item.
if (!is_array($form_items)) {
foreach ($columns as $column) {
$items[0][$column] = $form_items;
}
@@ -175,7 +176,7 @@ function _ctools_entity_field_value_get_proper_form_items($field, $form_items, $
foreach ($columns as $column) {
if (isset($form_items[$column])) {
$has_columns = TRUE;
$item[$column] = $form_items[$column];
$item[$column] = $form_items[$column];
}
else {
$item[$column] = '';
@@ -353,7 +354,7 @@ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugi
$display['type'] = 'entityreference_label';
break;
default :
default:
// Use field instance formatter setting.
break;
}
@@ -381,7 +382,7 @@ function ctools_entity_field_value_ctools_access_summary($conf, $context, $plugi
if (is_array($elements)) {
foreach ($elements as $element_key => $element) {
if (is_numeric($element_key)) {
$value_str= strip_tags(drupal_render($element));
$value_str = strip_tags(drupal_render($element));
if (strlen($value_str) > 0) {
$output[] = $value_str;
}

View File

@@ -19,7 +19,7 @@ $plugin = array(
);
/**
* Settings form for the 'by parent term' access plugin
* Settings form for the 'by parent term' access plugin.
*/
function ctools_front_ctools_access_settings($form, &$form_state, $conf) {
// No additional configuration necessary.

View File

@@ -24,7 +24,7 @@ $plugin = array(
);
/**
* Settings form for the 'by node_access' access plugin
* Settings form for the 'by node_access' access plugin.
*/
function ctools_node_access_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['type'] = array(
@@ -86,4 +86,3 @@ function ctools_node_access_ctools_access_summary($conf, $context) {
return t('@user can create nodes of the same type as @node.', $replacement);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* @file
* Plugin to provide access control based upon node comment status.

View File

@@ -23,7 +23,7 @@ if (module_exists('locale')) {
}
/**
* Settings form for the 'by node_language' access plugin
* Settings form for the 'by node_language' access plugin.
*/
function ctools_node_language_ctools_access_settings($form, &$form_state, $conf) {
$options = array(
@@ -111,4 +111,3 @@ function ctools_node_language_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier language is "@languages"', '@identifier language is one of "@languages"', array('@languages' => implode(', ', $names), '@identifier' => $context->identifier));
}

View File

@@ -30,4 +30,3 @@ function ctools_node_status_ctools_access_check($conf, $context) {
function ctools_node_status_ctools_access_summary($conf, $context) {
return t('Returns true if the nodes status is "published".');
}

View File

@@ -22,7 +22,7 @@ $plugin = array(
);
/**
* Settings form for the 'by node_type' access plugin
* Settings form for the 'by node_type' access plugin.
*/
function ctools_node_type_ctools_access_settings($form, &$form_state, $conf) {
$types = node_type_get_types();
@@ -114,4 +114,3 @@ function ctools_node_type_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier is type "@types"', '@identifier type is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier));
}

View File

@@ -11,12 +11,12 @@ $plugin = array(
'callback' => 'ctools_path_visibility_ctools_access_check',
'settings form' => 'ctools_path_visibility_ctools_access_settings',
'summary' => 'ctools_path_visibility_ctools_access_summary',
'required context' => new ctools_context_optional(t('Path'), 'string'),
'required context' => new ctools_context_optional(t('Path'), 'string'),
'default' => array('visibility_setting' => 1, 'paths' => ''),
);
/**
* Settings form
* Settings form.
*/
function ctools_path_visibility_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['note'] = array(

View File

@@ -20,11 +20,11 @@ $plugin = array(
);
/**
* Settings form for the 'by perm' access plugin
* Settings form for the 'by perm' access plugin.
*/
function ctools_perm_ctools_access_settings($form, &$form_state, $conf) {
$perms = array();
// Get list of permissions
// Get list of permissions.
foreach (module_list(FALSE, FALSE, TRUE) as $module) {
// By keeping them keyed by module we can use optgroups with the
// 'select' type.
@@ -70,4 +70,3 @@ function ctools_perm_ctools_access_summary($conf, $context) {
$permissions = module_invoke_all('permission');
return t('@identifier has "@perm"', array('@identifier' => $context->identifier, '@perm' => $permissions[$conf['perm']]['title']));
}

View File

@@ -20,7 +20,7 @@ $plugin = array(
);
/**
* Settings form for the 'by perm' access plugin
* Settings form for the 'by perm' access plugin.
*
* @todo Need a way to provide a list of all available contexts to be used by
* the eval-ed PHP.
@@ -38,7 +38,7 @@ function ctools_php_ctools_access_settings($form, &$form_state, $conf) {
'#type' => 'textarea',
'#title' => t('PHP Code'),
'#default_value' => $conf['php'],
'#description' => t('Access will be granted if the following PHP code returns <code>TRUE</code>. Do not include &lt;?php ?&gt;. Note that executing incorrect PHP-code can break your Drupal site. All contexts will be available in the <em>$contexts</em> variable.'),
'#description' => t('Access will be granted if the following PHP code returns <code>TRUE</code>. Do not include &lt;?php ?&gt;. Note that executing incorrect PHP-code can break your Drupal site. All contexts will be available in the <em>$contexts</em> variable.'),
);
if (!user_access('use PHP for settings')) {
$form['settings']['php']['#disabled'] = TRUE;

View File

@@ -23,7 +23,7 @@ function ctools_query_string_exists_ctools_access_settings($form, &$form_state,
'#description' => t('Enter the key of the query string.'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => $config['key']
'#default_value' => $config['key'],
);
return $form;

View File

@@ -21,7 +21,7 @@ $plugin = array(
);
/**
* Settings form for the 'by role' access plugin
* Settings form for the 'by role' access plugin.
*/
function ctools_role_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['rids'] = array(
@@ -76,4 +76,3 @@ function ctools_role_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier has role "@roles"', '@identifier has one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier));
}

View File

@@ -22,7 +22,7 @@ if (module_exists('locale')) {
}
/**
* Settings form for the 'by site_language' access plugin
* Settings form for the 'by site_language' access plugin.
*/
function ctools_site_language_ctools_access_settings($form, &$form_state, $conf) {
$options = array(
@@ -84,4 +84,3 @@ function ctools_site_language_ctools_access_summary($conf, $context) {
return format_plural(count($names), 'Site language is "@languages"', 'Site language is one of "@languages"', array('@languages' => implode(', ', $names)));
}

View File

@@ -2,7 +2,7 @@
/**
* @file
* Plugin to provide access control/visibility based on specified context string matching user-specified string
* Plugin to provide access control/visibility based on specified context string matching user-specified string.
*/
$plugin = array(
@@ -16,7 +16,7 @@ $plugin = array(
);
/**
* Settings form
* Settings form.
*/
function ctools_string_equal_ctools_access_settings($form, &$form_state, $conf) {
$form['settings']['operator'] = array(
@@ -47,7 +47,7 @@ function ctools_string_equal_ctools_access_settings($form, &$form_state, $conf)
}
/**
* Check for access
* Check for access.
*/
function ctools_string_equal_ctools_access_check($conf, $context) {
if (empty($context) || empty($context->data)) {
@@ -66,29 +66,34 @@ function ctools_string_equal_ctools_access_check($conf, $context) {
switch ($conf['operator']) {
case '=':
return $string === $value;
case '!=':
return $string !== $value;
case 'regex':
return preg_match($value, $string);
case '!regex':
return !preg_match($value, $string);
}
}
/**
* Provide a summary description based upon the specified context
* Provide a summary description based upon the specified context.
*/
function ctools_string_equal_ctools_access_summary($conf, $context) {
$values = array('@identifier' => $context->identifier, '@value' => $conf['value']);
switch ($conf['operator']) {
case '=':
return t('@identifier is "@value"', $values);
case '!=':
return t('@identifier is not "@value"', $values);
case 'regex':
return t('@identifier matches "@value"', $values);
case '!regex':
return t('@identifier does not match "@value"', $values);
}
}

View File

@@ -57,14 +57,19 @@ function ctools_string_length_ctools_access_check($conf, $context) {
switch ($conf['operator']) {
case '<':
return $length < $conf['length'];
case '<=':
return $length <= $conf['length'];
case '=':
return $length == $conf['length'];
case '!=':
return $length != $conf['length'];
case '>':
return $length > $conf['length'];
case '>=':
return $length >= $conf['length'];
}

View File

@@ -22,7 +22,7 @@ $plugin = array(
);
/**
* Settings form for the 'by term' access plugin
* Settings form for the 'by term' access plugin.
*/
function ctools_term_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
@@ -51,7 +51,6 @@ function ctools_term_ctools_access_settings($form, &$form_state, $conf) {
// A note: Dependency works strangely on these forms as they have never been
// updated to a more modern system so they are not individual forms of their
// own like the content types.
$form['settings']['#tree'] = TRUE;
// Loop over each of the configured vocabularies.
@@ -124,6 +123,8 @@ function ctools_term_ctools_access_summary($conf, $context) {
return format_plural(count($terms),
'@term can be the term "@terms"',
'@term can be one of these terms: @terms',
array('@terms' => implode(', ', $terms),
'@term' => $context->identifier));
array(
'@terms' => implode(', ', $terms),
'@term' => $context->identifier,
));
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* @file
* Plugin to provide access control based upon a parent term.
@@ -20,7 +21,7 @@ $plugin = array(
);
/**
* Settings form for the 'by parent term' access plugin
* Settings form for the 'by parent term' access plugin.
*/
function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
@@ -49,7 +50,6 @@ function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $con
// A note: Dependency works strangely on these forms as they have never been
// updated to a more modern system so they are not individual forms of their
// own like the content types.
$form['settings']['#tree'] = TRUE;
// Loop over each of the configured vocabularies.
@@ -62,7 +62,7 @@ function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $con
'#default_value' => !empty($conf['vid_' . $vid]) ? $conf['vid_' . $vid] : '',
'#size' => 10,
'#multiple' => TRUE,
//@todo: Remove the following workaround when the following patch is in core. {@see:http://drupal.org/node/1117526}
// @todo: Remove the following workaround when the following patch is in core. {@see:http://drupal.org/node/1117526}
'#name' => sprintf("settings[%u][]", $vid),
'#attributes' => array('multiple' => 'multiple'),
);
@@ -71,7 +71,6 @@ function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $con
foreach (taxonomy_get_tree($vocabulary->vid) as $term) {
$terms[$term->tid] = str_repeat('-', $term->depth) . ($term->depth ? ' ' : '') . $term->name;
}
//$form['settings']['vid_' . $vid]['#type'] = 'select';
$form['settings']['vid_' . $vid]['#type'] = 'checkboxes';
$form['settings']['vid_' . $vid]['#options'] = $terms;
unset($terms);
@@ -116,37 +115,36 @@ function ctools_term_has_parent_ctools_access_check($conf, $context) {
// we'll start looking up the hierarchy from our context term id.
$current_term = $context->data->tid;
$term='';
$term = '';
// scan up the tree.
while (true) {
// select parent as term_parent to avoid PHP5 complications with the parent keyword
//@todo: Find a way to reduce the number of queries required for really deep hierarchies.
$term = db_query("SELECT parent AS term_parent, tid AS tid FROM {taxonomy_term_hierarchy} th WHERE th.tid = :tid", array(':tid'=>$current_term))->fetchObject();
// Scan up the tree.
while (TRUE) {
// Select parent as term_parent to avoid PHP5 complications with the parent keyword.
// @todo: Find a way to reduce the number of queries required for really deep hierarchies.
$term = db_query("SELECT parent AS term_parent, tid AS tid FROM {taxonomy_term_hierarchy} th WHERE th.tid = :tid", array(':tid' => $current_term))->fetchObject();
// if no term is found, get out of the loop
// If no term is found, get out of the loop.
if (!$term || empty($term->tid)) {
break;
}
// check the term selected, if the user asked it to.
// Check the term selected, if the user asked it to.
if (!empty($conf['include_self']) && isset($conf['vid_' . $vid][$term->tid])) {
return TRUE;
}
// did we find the parent TID we were looking for?
// Did we find the parent TID we were looking for?
if (isset($conf['vid_' . $vid][$term->tid])) {
// YES, we're done!
return TRUE;
}
// Nope, we didn't find it.
// If this is the top of the hierarchy, stop scanning.
if ($term->term_parent==0) {
if ($term->term_parent == 0) {
break;
}
// update the parent, and keep scanning.
// Update the parent, and keep scanning.
$current_term = $term->term_parent;
}
@@ -157,7 +155,7 @@ function ctools_term_has_parent_ctools_access_check($conf, $context) {
* Provide a summary description based upon the checked terms.
*/
function ctools_term_has_parent_ctools_access_summary($conf, $context) {
$vid = (int)$conf['vid'];
$vid = (int) $conf['vid'];
$terms = array();
foreach ($conf['vid_' . $vid] as $tid) {
$term = taxonomy_term_load($tid);
@@ -167,6 +165,8 @@ function ctools_term_has_parent_ctools_access_summary($conf, $context) {
return format_plural(count($terms),
'@term can have the parent "@terms"',
'@term can have one of these parents: @terms',
array('@terms' => implode(', ', $terms),
'@term' => $context->identifier));
array(
'@terms' => implode(', ', $terms),
'@term' => $context->identifier,
));
}

View File

@@ -22,7 +22,7 @@ $plugin = array(
);
/**
* Settings form for the 'by parent term' access plugin
* Settings form for the 'by parent term' access plugin.
*/
function ctools_term_parent_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.

View File

@@ -2,7 +2,7 @@
/**
* @file
* Plugin to provide access control based upon term vocabulary
* Plugin to provide access control based upon term vocabulary.
*/
/**
@@ -20,12 +20,12 @@ $plugin = array(
'required context' => new ctools_context_required(t('Vocabulary'), array(
'taxonomy_term',
'terms',
'taxonomy_vocabulary'
'taxonomy_vocabulary',
)),
);
/**
* Settings form for the 'by term_vocabulary' access plugin
* Settings form for the 'by term_vocabulary' access plugin.
*/
function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $conf) {
$options = array();
@@ -101,7 +101,7 @@ function ctools_term_vocabulary_ctools_access_summary($conf, $context) {
return format_plural(count($names), '@identifier vocabulary is "@machine_names"', '@identifier vocabulary is one of "@machine_names"', array(
'@machine_names' => implode(', ', $names),
'@identifier' => $context->identifier
'@identifier' => $context->identifier,
));
}
@@ -123,5 +123,3 @@ function _ctools_term_vocabulary_ctools_access_map_vids(&$conf) {
}
}
}

View File

@@ -19,7 +19,7 @@ $plugin = array(
);
/**
* Settings form for the 'by theme' access plugin
* Settings form for the 'by theme' access plugin.
*/
function ctools_theme_ctools_access_settings($form, &$form_state, $conf) {
$themes = array();
@@ -44,10 +44,10 @@ function ctools_theme_ctools_access_check($conf, $context) {
if (!empty($GLOBALS['theme'])) {
$theme = $GLOBALS['theme'];
}
else if (!empty($GLOBALS['custom_theme'])) {
elseif (!empty($GLOBALS['custom_theme'])) {
$theme = $GLOBALS['custom_theme'];
}
else if (!empty($GLOBALS['user']->theme)) {
elseif (!empty($GLOBALS['user']->theme)) {
$theme = $GLOBALS['user']->theme;
}
else {