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
@@ -6,9 +6,9 @@ package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -19,6 +19,7 @@
.ctools-button-processed .ctools-content ul {
list-style-image: none;
list-style-type: none;
margin-left: 0;
}
.ctools-button-processed li {
@@ -0,0 +1,60 @@
div.ctools-modal-content {
text-align: right;
}
div.ctools-modal-content .modal-header {
background-color: #2385c2;
padding: 0 1em 0 .25em;
}
div.ctools-modal-content a.close {
color: white;
float: left;
}
/** modal forms CSS **/
div.ctools-modal-content .form-item label {
float: right;
}
div.ctools-modal-content .form-item .description {
clear: right;
}
div.ctools-modal-content .form-item .description .tips {
margin-left: 0;
margin-right: 2em;
}
div.ctools-modal-content fieldset,
div.ctools-modal-content .form-radios,
div.ctools-modal-content .form-checkboxes {
clear: right;
}
div.ctools-modal-content .resizable-textarea {
margin-left: 5em;
margin-right: 15em;
}
div.ctools-modal-content .container-inline .form-item {
margin-right: 0;
margin-left: 2em;
}
div.ctools-modal-content label.hidden-options {
background-position: left;
padding-right: 0;
padding-left: 12px;
}
div.ctools-modal-content label.expanded-options {
background-position: left;
padding-right: 0;
padding-left: 16px;
}
div.ctools-modal-content .dependent-options {
padding-left: 0;
padding-right: 30px;
}
@@ -199,7 +199,10 @@ function hook_ctools_render_alter(&$info, &$page, &$context) {
* or categories or to rename content on specific sites.
*/
function hook_ctools_content_subtype_alter($subtype, $plugin) {
$subtype['render last'] = TRUE;
// Force a particular subtype of a particular plugin to render last.
if ($plugin['module'] == 'some_plugin_module' && $plugin['name'] == 'some_plugin_name' && $subtype['subtype_id'] == 'my_subtype_id') {
$subtype['render last'] = TRUE;
}
}
/**
@@ -2,16 +2,23 @@ name = Chaos tools
description = A library of helpful tools by Merlin of Chaos.
core = 7.x
package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
files[] = includes/context.inc
files[] = includes/css-cache.inc
files[] = includes/math-expr.inc
files[] = includes/stylizer.inc
files[] = tests/css_cache.test
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Tests.
files[] = tests/context.test
files[] = tests/css.test
files[] = tests/css_cache.test
files[] = tests/ctools.plugins.test
files[] = tests/math_expression.test
files[] = tests/math_expression_stack.test
files[] = tests/object_cache.test
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -9,7 +9,7 @@
* must be implemented in the module file.
*/
define('CTOOLS_API_VERSION', '2.0.8');
define('CTOOLS_API_VERSION', '2.0.9');
/**
* The current working ctools version.
@@ -23,7 +23,7 @@ define('CTOOLS_API_VERSION', '2.0.8');
* ; Requires CTools v7.x-1.4 or newer.
* dependencies[] = ctools (>=1.4)
*/
define('CTOOLS_MODULE_VERSION', '7.x-1.6');
define('CTOOLS_MODULE_VERSION', '7.x-1.11');
/**
* Test the CTools API version.
@@ -617,6 +617,27 @@ function ctools_registry_files_alter(&$files, $indexed_modules) {
return _ctools_registry_files_alter($files, $indexed_modules);
}
// -----------------------------------------------------------------------
// FAPI hooks that must be in the .module file.
/**
* Alter the comment form to get a little more control over it.
*/
function ctools_form_comment_form_alter(&$form, &$form_state) {
if (!empty($form_state['ctools comment alter'])) {
// Force the form to post back to wherever we are.
$form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
if (empty($form['#submit'])) {
$form['#submit'] = array('comment_form_submit');
}
$form['#submit'][] = 'ctools_node_comment_form_submit';
}
}
function ctools_node_comment_form_submit(&$form, &$form_state) {
$form_state['redirect'][0] = $_GET['q'];
}
// -----------------------------------------------------------------------
// CTools hook implementations.
@@ -737,6 +758,12 @@ function ctools_process(&$variables, $hook) {
$variables['classes_array'] = array_diff($variables['classes_array'], $remove_classes);
}
// Update the classes within the attributes array to match the classes array
if (isset($variables['attributes_array']['class'])) {
$variables['attributes_array']['class'] = array_unique(array_merge($variables['classes_array'], $variables['attributes_array']['class']));
$variables['attributes'] = $variables['attributes_array'] ? drupal_attributes($variables['attributes_array']) : '';
}
// Since this runs after template_process(), we need to re-implode the
// classes array.
$variables['classes'] = implode(' ', $variables['classes_array']);
@@ -1018,3 +1045,50 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
}
}
}
/**
* Implements hook_field_create_field().
*/
function ctools_field_create_field($field) {
ctools_flush_field_caches();
}
/**
* Implements hook_field_create_instance().
*/
function ctools_field_create_instance($instance) {
ctools_flush_field_caches();
}
/**
* Implements hook_field_delete_field().
*/
function ctools_field_delete_field($field) {
ctools_flush_field_caches();
}
/**
* Implements hook_field_delete_instance().
*/
function ctools_field_delete_instance($instance) {
ctools_flush_field_caches();
}
/**
* Implements hook_field_update_field().
*/
function ctools_field_update_field($field, $prior_field, $has_data) {
ctools_flush_field_caches();
}
/**
* Implements hook_field_update_instance().
*/
function ctools_field_update_instance($instance, $prior_instance) {
ctools_flush_field_caches();
}
/**
* Clear field related caches.
*/
function ctools_flush_field_caches() {
// Clear caches of 'Entity field' content type plugin.
cache_clear_all('ctools_entity_field_content_type_content_types', 'cache');
}
@@ -5,9 +5,9 @@ package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -5,9 +5,9 @@ version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
core = 7.x
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -524,7 +524,7 @@ function ctools_ajax_sample_wizard_next(&$form_state) {
}
/**
* Handle the 'finish' click on teh add/edit pane form wizard.
* Handle the 'finish' click on the add/edit pane form wizard.
*
* All we need to do is set a flag so the return can handle adding
* the pane.
@@ -5,9 +5,9 @@ package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -23,6 +23,22 @@ class ctools_custom_content_ui extends ctools_export_ui {
'#title' => t('Title'),
);
$form['title_heading'] = array(
'#title' => t('Title heading'),
'#type' => 'select',
'#default_value' => isset($form_state['item']->settings['title_heading']) ? $form_state['item']->settings['title_heading'] : 'h2',
'#options' => array(
'h1' => t('h1'),
'h2' => t('h2'),
'h3' => t('h3'),
'h4' => t('h4'),
'h5' => t('h5'),
'h6' => t('h6'),
'div' => t('div'),
'span' => t('span'),
),
);
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Body'),
@@ -43,6 +59,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
// Since items in our settings are not in the schema, we have to do these manually:
$form_state['item']->settings['title'] = $form_state['values']['title'];
$form_state['item']->settings['title_heading'] = $form_state['values']['title_heading'];
$form_state['item']->settings['body'] = $form_state['values']['body']['value'];
$form_state['item']->settings['format'] = $form_state['values']['body']['format'];
$form_state['item']->settings['substitute'] = $form_state['values']['substitute'];
@@ -8,9 +8,9 @@ dependencies[] = page_manager
dependencies[] = advanced_help
core = 7.x
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -64,7 +64,7 @@ function ctools_drush_command() {
'machine names' => 'Space separated list of exportables you want to view.',
),
'options' => array(
'indent' => 'The string to use for indentation when dispalying the exportable export code. Defaults to \'\'.',
'indent' => 'The string to use for indentation when displaying the exportable export code. Defaults to \'\'.',
'no-colour' => 'Remove any colour formatting from export string output. Ideal if you are sending the output of this command to a file.',
'module' => $module_text,
'all' => $all_text,
@@ -155,6 +155,11 @@ function ctools_content_get_subtypes($type) {
// Walk through the subtypes and ensure minimal settings are
// retained.
foreach ($subtypes as $id => $subtype) {
// Ensure that the 'subtype_id' value exists.
if (!isset($subtype['subtype_id'])) {
$subtype['subtype_id'] = $id;
}
// Use exact name since this is a modify by reference.
ctools_content_prepare_subtype($subtypes[$id], $plugin);
}
@@ -217,6 +222,7 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
}
}
// Trigger hook_ctools_content_subtype_alter().
drupal_alter('ctools_content_subtype', $subtype, $plugin);
}
@@ -241,8 +247,8 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
* Any incoming content, if this display is a wrapper.
*
* @return
* The content as rendered by the plugin. This content should be an array
* with the following possible keys:
* The content as rendered by the plugin, or NULL.
* This content should be an object with the following possible properties:
* - title: The safe to render title of the content.
* - title_heading: The title heading.
* - content: The safe to render HTML content.
@@ -341,7 +347,16 @@ function ctools_content_editable($type, $subtype, $conf) {
return FALSE;
}
if ($function = ctools_plugin_get_function($subtype, 'check editable')) {
$function = FALSE;
if (!empty($subtype['check editable'])) {
$function = ctools_plugin_get_function($subtype, 'check editable');
}
elseif (!empty($type['check editable'])) {
$function = ctools_plugin_get_function($type, 'check editable');
}
if ($function) {
return $function($type, $subtype, $conf);
}
@@ -23,12 +23,13 @@ function ctools_content_menu(&$items) {
/**
* Helper function for autocompletion of entity titles.
*/
function ctools_content_autocomplete_entity($type, $string = '') {
function ctools_content_autocomplete_entity($entity_type, $string = '') {
if ($string != '') {
global $user;
$entity_info = entity_get_info($type);
if ($type == 'node') {
$entity_info['entity keys']['bundle field'] = 'type';
$entity_info = entity_get_info($entity_type);
if (!module_exists('entity')) {
module_load_include('inc', 'ctools', 'includes/entity-access');
_ctools_entity_access($entity_info, $entity_type);
}
// We must query all ids, because if every one of the 10 don't have access
@@ -42,25 +43,19 @@ function ctools_content_autocomplete_entity($type, $string = '') {
// If an ID match was found, use that ID rather than the whole string.
if ($match) {
$entity_id = $preg_matches[1];
$entity = entity_load($type, array($entity_id));
// Format results in an array so later we could add attributes to the
// autocomplete text that is returned.
$results = array($entity_id => array(
'label' => $entity[$entity_id]->$entity_info['entity keys']['label'],
));
$results = _ctools_getReferencableEntities($entity_type, $entity_info, $entity_id, '=', 1);
}
else {
$results = _ctools_getReferencableEntities($type, $entity_info, $string, 'LIKE', 10);
// We cannot find results if the entity doesn't have a label to search.
if (!isset($entity_info['entity keys']['label'])) {
drupal_json_output(array("[id: NULL]" => '<span class="autocomplete_title">' . t('Entity Type !entity_type does not support autocomplete search.', array('!entity_type' => $entity_type)) . '</span>'));
return;
}
$results = _ctools_getReferencableEntities($entity_type, $entity_info, $string, 'LIKE', 10);
}
foreach($results as $entity_id => $result) {
if (!$entity_info['entity keys']['label']) {
$matches["[id: $entity_id]"] = '<span class="autocomplete_title">' . $entity_id . '</span>';
}
else {
$matches[$result['label'] . " [id: $entity_id]"] = '<span class="autocomplete_title">' . check_plain($result['label']) . '</span>';
$matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle field']) ? ' <span class="autocomplete_bundle">(' . check_plain($result['bundle field']) . ')</span>' : '';
}
foreach ($results as $entity_id => $result) {
$matches[$result['label'] . " [id: $entity_id]"] = '<span class="autocomplete_title">' . check_plain($result['label']) . '</span>';
$matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle']) ? ' <span class="autocomplete_bundle">(' . check_plain($result['bundle']) . ')</span>' : '';
}
drupal_json_output($matches);
@@ -73,53 +68,53 @@ function ctools_content_autocomplete_entity($type, $string = '') {
*/
function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_operator = 'CONTAINS') {
$base_table = $entity_info['base table'];
$query = db_select($base_table)
->fields($base_table, array($entity_info['entity keys']['id']));
$label_key = $entity_info['entity keys']['label'];
$query = db_select($base_table)
->fields($base_table, array($entity_info['entity keys']['id']));
if (isset($match)) {
if (isset($entity_info['entity keys']['label'])) {
$query->condition($base_table .'.'. $entity_info['entity keys']['label'], '%' . $match . '%' , $match_operator);
}
}
// Add a label to the query, if the label exists
if (isset($entity_info['entity keys']['label'])) {
$query->fields($base_table, array($entity_info['entity keys']['label']));
}
// Add bundle field to the query, if it exists.
if (isset($entity_info['entity keys']['bundle field'])) {
$query->fields($base_table, array($entity_info['entity keys']['bundle field']));
}
// Add a generic entity access tag to the query.
$query->addTag('ctools');
if($entity_type == 'comment') {
// Adding the 'comment_access' tag is sadly insufficient for comments: core
// requires us to also know about the concept of 'published' and
// 'unpublished'.
if (!user_access('administer comments')) {
$query->condition('comment.status', COMMENT_PUBLISHED);
}
// Join to a node if the user does not have node access bypass permissions
// to obey node published permissions
if (!user_access('bypass node access') && !count(module_implements('node_grants'))) {
$node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
$query->condition($node_alias . '.status', NODE_PUBLISHED);
}
$query->addTag('node_access');
if (isset($match)) {
if (isset($label_key)) {
$query->condition($base_table . '.' . $label_key, '%' . $match . '%', $match_operator);
}
// This should never happen, but double check just in case.
else {
$query->addTag($entity_type . '_access');
return array();
}
}
// Add a generic entity access tag to the query.
$query->addTag('ctools');
// We have to perform two checks. First check is a query alter (with tags)
// in an attempt to only return results that have access. However, this is
// not full-proof since entities many not implement hook_access query tag.
// This is why we have a second check after entity load, before we display
// the label of an entity.
if ($entity_type == 'comment') {
// Adding the 'comment_access' tag is sadly insufficient for comments: core
// requires us to also know about the concept of 'published' and
// 'unpublished'.
if (!user_access('administer comments')) {
$query->condition('comment.status', COMMENT_PUBLISHED);
}
// Add the sort option.
if(isset($entity_info['entity keys']['label'])) {
$query->orderBy($base_table .'.'. $entity_info['entity keys']['label'], 'ASC');
// Join to a node if the user does not have node access bypass permissions
// to obey node published permissions
if (!user_access('bypass node access')) {
$node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
$query->condition($node_alias . '.status', NODE_PUBLISHED);
}
$query->addTag('node_access');
}
else {
$query->addTag($entity_type . '_access');
}
return $query;
// Add the sort option.
if (isset($label_key)) {
$query->orderBy($base_table . '.' . $label_key, 'ASC');
}
return $query;
}
/**
@@ -127,23 +122,58 @@ function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_op
* Entity Reference module.
*/
function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NULL, $match_operator = 'LIKE', $limit = 0) {
global $user;
$account = $user;
$options = array();
$query = _ctools_buildQuery($entity_type, $entity_info, $match, $match_operator);
if ($limit > 0) {
$query->range(0, $limit);
}
$results = $query->execute();
if (!empty($results)) {
foreach ($results as $record) {
$options[$record->{$entity_info['entity keys']['id']}] = array(
'label' => isset($entity_info['entity keys']['label']) ? check_plain($record->{$entity_info['entity keys']['label']}) : $record->{$entity_info['entity keys']['id']},
'bundle field' => isset($entity_info['entity keys']['bundle field']) ? check_plain($record->{$entity_info['entity keys']['bundle field']}) : '',
);
// We're an entity ID, return the id
if (is_numeric($match) && $match_operator == '=') {
if ($entity = array_shift(entity_load($entity_type, array($match)))) {
if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
$label = entity_label($entity_type, $entity);
return array(
$match => array(
'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
),
);
}
}
}
// If you don't have access, or an access callback or a valid entity, just
// Return back the Entity ID.
return array(
$match => array(
'label' => $match,
'bundle' => NULL,
),
);
}
return $options;
}
// We have matches, build a query to fetch the result.
if ($query = _ctools_buildQuery($entity_type, $entity_info, $match, $match_operator)) {
if ($limit > 0) {
$query->range(0, $limit);
}
$results = $query->execute();
if (!empty($results)) {
foreach ($results as $record) {
$entities = entity_load($entity_type, array($record->{$entity_info['entity keys']['id']}));
$entity = array_shift($entities);
if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
$label = entity_label($entity_type, $entity);
$options[$record->{$entity_info['entity keys']['id']}] = array(
'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
);
}
}
}
}
return $options;
}
return array();
}
@@ -367,7 +367,6 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
'contexts' => $contexts,
'title' => t('Edit criteria'),
'ajax' => TRUE,
'ajax' => TRUE,
'modal' => TRUE,
'modal return' => TRUE,
);
@@ -376,11 +376,11 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
'path' => "ctools/context/ajax/add/$mechanism/$type/$cache_key/$name/%step",
'show cancel' => TRUE,
'default form' => 'ctools_edit_context_form_defaults',
'auto caching' => TRUE,
'auto cache' => TRUE,
'cache mechanism' => $mechanism,
'cache key' => $cache_key,
// This is stating what the cache will be referred to in $form_state
'cache storage' => 'object',
'cache location' => 'object',
);
if ($type == 'requiredcontext') {
@@ -561,11 +561,11 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
'path' => "ctools/context/ajax/configure/$mechanism/$type/$cache_key/$position/%step",
'show cancel' => TRUE,
'default form' => 'ctools_edit_context_form_defaults',
'auto caching' => TRUE,
'auto cache' => TRUE,
'cache mechanism' => $mechanism,
'cache key' => $cache_key,
// This is stating what the cache will be referred to in $form_state
'cache storage' => 'object',
'cache location' => 'object',
);
if ($type == 'requiredcontext') {
@@ -736,6 +736,15 @@ function ctools_edit_context_form_defaults($form, &$form_state) {
'#default_value' => $conf['keyword'],
);
if ($type_info['key'] == 'requiredcontexts') {
$form['optional'] = array(
'#type' => 'checkbox',
'#title' => t('Context is optional'),
'#default_value' => !empty($form_state['conf']['optional']),
'#description' => t('This context need not be present for the component to function.'),
);
}
$form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
return $form;
@@ -752,6 +761,9 @@ function ctools_edit_context_form_defaults_submit(&$form, &$form_state) {
$form_state['conf']['default'] = $form_state['values']['default'];
$form_state['conf']['title'] = $form_state['values']['title'];
}
if ($form_state['type info']['key'] == 'requiredcontexts') {
$form_state['conf']['optional'] = $form_state['values']['optional'];
}
$form_state['conf']['identifier'] = $form_state['values']['identifier'];
$form_state['conf']['keyword'] = $form_state['values']['keyword'];
@@ -42,7 +42,7 @@ class ctools_context {
var $restrictions = array();
var $empty = FALSE;
function ctools_context($type = 'none', $data = NULL) {
function __construct($type = 'none', $data = NULL) {
$this->type = $type;
$this->data = $data;
$this->title = t('Unknown context');
@@ -119,7 +119,7 @@ class ctools_context_required {
* @param ...
* One or more keywords to use for matching which contexts are allowed.
*/
function ctools_context_required($title) {
function __construct($title) {
$args = func_get_args();
$this->title = array_shift($args);
@@ -204,10 +204,6 @@ class ctools_context_required {
*/
class ctools_context_optional extends ctools_context_required {
var $required = FALSE;
function ctools_context_optional() {
$args = func_get_args();
call_user_func_array(array($this, 'ctools_context_required'), $args);
}
/**
* Add the 'empty' context which is possible for optional
@@ -216,7 +212,7 @@ class ctools_context_optional extends ctools_context_required {
$context = new ctools_context('any');
$context->title = t('No context');
$context->identifier = t('No context');
$contexts = array_merge(array('empty' => $context), $contexts);
$contexts['empty'] = $context;
}
function filter($contexts) {
@@ -680,14 +676,19 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
}
}
if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
$keywords['%' . $keyword] = '';
}
else if (!empty($converter)) {
$keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
if (!isset($context_keywords[$context])) {
$keywords['%' . $keyword] = '%' . $keyword;
}
else {
$keywords['%' . $keyword] = $context_keywords[$keyword]->title;
if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
$keywords['%' . $keyword] = '';
}
else if (!empty($converter)) {
$keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
}
else {
$keywords['%' . $keyword] = $context_keywords[$keyword]->title;
}
}
}
}
@@ -1163,7 +1164,7 @@ function ctools_context_match_required_contexts($required, $contexts) {
}
foreach ($required as $r) {
$context = clone(array_shift($contexts));
$context = clone array_shift($contexts);
$context->identifier = $r['identifier'];
$context->page_title = isset($r['title']) ? $r['title'] : '';
$context->keyword = $r['keyword'];
@@ -1505,7 +1506,7 @@ function ctools_access($settings, $contexts = array()) {
return TRUE;
}
else if (!$pass && $settings['logic'] == 'and') {
// Fail if 'and' and htis rule failed.
// Fail if 'and' and this rule failed.
return FALSE;
}
}
@@ -172,10 +172,12 @@ function ctools_css_cache($css, $filter = TRUE) {
// @todo Is this slow? Does it matter if it is?
$filename = $path . '/' . md5($css) . '.css';
// This will do renames if the file already exists, ensuring we don't
// accidentally overwrite other files who share the same md5. Yes this
// is a very miniscule chance but it's safe.
$filename = file_unmanaged_save_data($css, $filename);
// Generally md5 is considered unique enough to sign file downloads.
// So this replaces already existing files based on the assumption that two
// files with the same hash are identical content wise.
// If we rename, the cache folder can potentially fill up with thousands of
// files with the same content.
$filename = file_unmanaged_save_data($css, $filename, FILE_EXISTS_REPLACE);
return $filename;
}
@@ -0,0 +1,150 @@
<?php
/**
* @file
* Provides various callbacks for the whole core module integration.
* This is a copy of Entity API's functionality for use when Entity API isn't
* Enabled, and only works on view functions.
*/
/**
* Core hack to include entity api-esque 'access callback' functions to core
* entities without needing to rely on entity api.
* Exception: We don't touch file entity. You must have entity API enabled to
* view files.
*/
function _ctools_entity_access(&$entity_info, $entity_type) {
// If the access callback is already set, don't change anything.
if (isset($entity_info['access callback'])) {
return;
}
switch ($entity_type) {
case 'node':
// Sad panda, we don't use Entity API, lets manually add access callbacks.
$entity_info['access callback'] = 'ctools_metadata_no_hook_node_access';
break;
case 'user':
$entity_info['access callback'] = 'ctools_metadata_user_access';
break;
case 'comment':
if (module_exists('comment')) {
$entity_info['access callback'] = 'ctools_metadata_comment_access';
}
break;
case 'taxonomy_term':
if (module_exists('taxonomy')) {
$entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
}
break;
case 'taxonomy_vocabulary':
if (module_exists('taxonomy')) {
$entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
}
break;
}
}
/**
* Access callback for the node entity.
*
* This function does not implement hook_node_access(), thus it may not be
* called ctools_metadata_node_access().
*
* @see entity_access()
*
* @param $op
* The operation being performed. One of 'view', 'update', 'create' or
* 'delete'.
* @param $node
* A node to check access for. Must be a node object. Must have nid,
* except in the case of 'create' operations.
* @param $account
* The user to check for. Leave it to NULL to check for the global user.
*
* @throws EntityMalformedException
*
* @return boolean
* TRUE if access is allowed, FALSE otherwise.
*/
function ctools_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) {
// First deal with the case where a $node is provided.
if (isset($node)) {
// If a non-default revision is given, incorporate revision access.
$default_revision = node_load($node->nid);
if ($node->vid !== $default_revision->vid) {
return _node_revision_access($node, $op, $account);
}
else {
return node_access($op, $node, $account);
}
}
// No node is provided. Check for access to all nodes.
if (user_access('bypass node access', $account)) {
return TRUE;
}
if (!user_access('access content', $account)) {
return FALSE;
}
if ($op == 'view' && node_access_view_all_nodes($account)) {
return TRUE;
}
return FALSE;
}
/**
* Access callback for the user entity.
*/
function ctools_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type) {
$account = isset($account) ? $account : $GLOBALS['user'];
// Grant access to the users own user account and to the anonymous one.
if (isset($entity) && $op != 'delete' && (($entity->uid == $account->uid && $entity->uid) || (!$entity->uid && $op == 'view'))) {
return TRUE;
}
if (user_access('administer users', $account) || user_access('access user profiles', $account) && $op == 'view' && $entity->status) {
return TRUE;
}
return FALSE;
}
/**
* Access callback for the comment entity.
*/
function ctools_metadata_comment_access($op, $entity = NULL, $account = NULL) {
// When determining access to a comment, if comment has an associated node,
// the user must be able to view the node in order to access the comment.
if (isset($entity->nid)) {
if (!node_access('view', node_load($entity->nid), $account)) {
return FALSE;
}
}
// Comment administrators are allowed to perform all operations on all
// comments.
if (user_access('administer comments', $account)) {
return TRUE;
}
// Unpublished comments can never be accessed by non-admins.
if (isset($entity->status) && $entity->status == COMMENT_NOT_PUBLISHED) {
return FALSE;
}
if (user_access('access comments', $account) && $op == 'view') {
return TRUE;
}
return FALSE;
}
/**
* Access callback for the taxonomy entities.
*/
function ctools_metadata_taxonomy_access($op, $entity = NULL, $account = NULL, $entity_type) {
if ($entity_type == 'taxonomy_vocabulary') {
return user_access('administer taxonomy', $account);
}
if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') {
return TRUE;
}
return FALSE;
}
@@ -902,7 +902,8 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
$output = $indent . '$' . $identifier . ' = new ' . get_class($object) . "();\n";
if ($schema['export']['can disable']) {
$output .= $indent . '$' . $identifier . '->disabled = FALSE; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
$disabled = !isset($object->disabled) || $object->disabled != TRUE ? 'FALSE' : 'TRUE';
$output .= $indent . '$' . $identifier . '->disabled = ' . $disabled . '; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
}
if (!empty($schema['export']['api']['current_version'])) {
$output .= $indent . '$' . $identifier . '->api_version = ' . $schema['export']['api']['current_version'] . ";\n";
@@ -1227,7 +1228,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
$output .= " \${$export['identifier']}s = array();\n\n";
foreach ($objects as $object) {
$output .= ctools_export_crud_export($table, $object, ' ');
$output .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n";
$output .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
}
$output .= " return \${$export['identifier']}s;\n";
$output .= "}\n";
@@ -137,7 +137,7 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
*/
function ctools_fields_get_field_formatter_info($fields) {
$info = array();
$field_info = module_invoke_all('field_formatter_info');
$field_info = field_info_formatter_types();
foreach ($fields as $field) {
foreach ($field_info as $format_name => $formatter_info) {
if (in_array($field['type'], $formatter_info['field types'])) {
@@ -145,7 +145,6 @@ function ctools_fields_get_field_formatter_info($fields) {
}
}
}
drupal_alter('field_formatter_info', $info);
return $info;
}
@@ -51,7 +51,7 @@ function ctools_jump_menu($form, &$form_state, $select, $options = array()) {
'hide' => TRUE,
);
ctools_add_js('jump-menu');
$form['#attached']['js'][] = ctools_attach_js('jump-menu');
if (!empty($options['choose'])) {
$select = array('' => $options['choose']) + $select;
@@ -99,7 +99,7 @@ class ctools_math_expr {
'sqrt','abs','ln','log',
'time', 'ceil', 'floor', 'min', 'max', 'round');
function ctools_math_expr() {
function __construct() {
// make the variables a little more accurate
$this->v['pi'] = pi();
$this->v['e'] = exp(1);
@@ -271,7 +271,7 @@ class ctools_math_expr {
} elseif (in_array($op, $ops) and !$expecting_op) {
return $this->trigger("unexpected operator '$op'");
} else { // I don't even want to know what you did to get here
return $this->trigger("an unexpected error occured");
return $this->trigger("an unexpected error occurred");
}
if ($index == strlen($expr)) {
if (in_array($op, $ops)) { // did we end with an operator? bad.
@@ -66,6 +66,7 @@ function ctools_modal_add_js() {
drupal_add_library('system', 'jquery.form');
drupal_add_library('system', 'drupal.progress');
drupal_add_library('system', 'drupal.ajax');
drupal_add_library('system', 'ui');
ctools_add_js('modal');
ctools_add_css('modal');
@@ -79,7 +79,9 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Only process if version is between minimum and current, inclusive.
if (version_compare($version, $minimum_version, '>=') && version_compare($version, $current_version, '<=')) {
if (($version == $minimum_version) || ($version == $current_version)
|| (version_compare($version, $minimum_version, '>=')
&& version_compare($version, $current_version, '<='))) {
if (!isset($info['path'])) {
$info['path'] = drupal_get_path('module', $module);
}
@@ -110,7 +112,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Allow other modules to hook in.
drupal_alter($hook, $cache[$owner][$api]);
drupal_alter($hook, $cache[$owner][$api], $owner, $api);
}
return $cache[$owner][$api];
@@ -198,22 +200,22 @@ function ctools_plugin_api_get_hook($owner, $api) {
/**
* Fetch a group of plugins by name.
*
* @param $module
* The name of the module that utilizes this plugin system. It will be
* used to call hook_ctools_plugin_$plugin() to get more data about the plugin.
* @param $type
* @param string $module
* The name of the module that utilizes this plugin system. It will be used to
* get more data about the plugin as defined on hook_ctools_plugin_type().
* @param string $type
* The type identifier of the plugin.
* @param $id
* @param string $id
* If specified, return only information about plugin with this identifier.
* The system will do its utmost to load only plugins with this id.
*
* @return
* An array of information arrays about the plugins received. The contents
* of the array are specific to the plugin.
* @return array
* An array of information arrays about the plugins received. The contents of
* the array are specific to the plugin.
*/
function ctools_get_plugins($module, $type, $id = NULL) {
// Store local caches of plugins and plugin info so we don't have to do full
// lookups everytime.
// lookups every time.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['plugins'] = &drupal_static('ctools_plugins', array());
@@ -222,10 +224,14 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$info = ctools_plugin_get_plugin_type_info();
// Bail out noisily if an invalid module/type combination is requested.
if (!isset($info[$module][$type])) {
watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
return array();
// If we don't find the plugin we attempt a cache rebuild before bailing out
$info = ctools_plugin_get_plugin_type_info(TRUE);
// Bail out noisily if an invalid module/type combination is requested.
if (!isset($info[$module][$type])) {
watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
return array();
}
}
// Make sure our plugins array is populated.
@@ -233,8 +239,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = array();
}
// Attempt to shortcut this whole piece of code if we already have
// the requested plugin:
// Attempt to shortcut this whole piece of code if we already have the
// requested plugin:
if ($id && array_key_exists($id, $plugins[$module][$type])) {
return $plugins[$module][$type][$id];
}
@@ -269,8 +275,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]);
}
// Then see if we should load all files. We only do this if we
// want a list of all plugins or there was a cache miss.
// Then see if we should load all files. We only do this if we want a list of
// all plugins or there was a cache miss.
if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
$setup[$module][$type] = TRUE;
$plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
@@ -294,8 +300,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
}
// If we were told earlier that this is cacheable and the cache was
// empty, give something back.
// If we were told earlier that this is cacheable and the cache was empty,
// give something back.
if ($build_cache) {
cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']);
}
@@ -472,7 +478,7 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
}
else {
require_once DRUPAL_ROOT . '/' . $file->uri;
include_once DRUPAL_ROOT . '/' . $file->uri;
// .inc files have a special format for the hook identifier.
// For example, 'foo.inc' in the module 'mogul' using the plugin
// whose hook is named 'borg_type' should have a function named (deep breath)
@@ -500,7 +500,7 @@ class ctools_stylizer_image_processor {
$palette[$luminosity_input]['green'] = $green;
$palette[$luminosity_input]['blue'] = $blue;
// Now we complete the palette, first we'll do it tothe black, and then to
// Now we complete the palette, first we'll do it to the black, and then to
// the white.
// From input to black
@@ -9,7 +9,9 @@
/**
* Pattern for detecting a valid UUID.
*/
define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}');
if (!defined('UUID_PATTERN')) {
define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}');
}
/**
* Generates a UUID using the Windows internal GUID generator.
@@ -25,7 +27,8 @@ function _ctools_uuid_generate_com() {
* Generates an universally unique identifier using the PECL extension.
*/
function _ctools_uuid_generate_pecl() {
return uuid_create(UUID_TYPE_DEFAULT);
$uuid_type = UUID_TYPE_DEFAULT;
return uuid_create($uuid_type);
}
/**
@@ -36,9 +36,11 @@ Drupal.behaviors.CToolsAutoSubmit = {
attach: function(context) {
// 'this' references the form element
function triggerSubmit (e) {
var $this = $(this);
if (!$this.hasClass('ctools-ajaxing')) {
$this.find('.ctools-auto-submit-click').click();
if ($.contains(document.body, this)) {
var $this = $(this);
if (!$this.hasClass('ctools-ajaxing')) {
$this.find('.ctools-auto-submit-click').click();
}
}
}
@@ -97,7 +97,13 @@
else {
switch ($(trigger).attr('type')) {
case 'checkbox':
var val = $(trigger).attr('checked') ? true : false;
// **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
if ($().prop) {
var val = $(trigger).prop('checked') ? true : false;
}
else {
var val = $(trigger).attr('checked') ? true : false;
}
if (val) {
$(trigger).siblings('label').removeClass('hidden-options').addClass('expanded-options');
@@ -148,34 +154,41 @@
len++;
}
var object = $('#' + id + '-wrapper');
if (!object.size()) {
// Some elements can't use the parent() method or they can
// damage things. They are guaranteed to have wrappers but
// only if dependent.inc provided them. This check prevents
// problems when multiple AJAX calls cause settings to build
// up.
var $original = $('#' + id);
if ($original.is('fieldset') || $original.is('textarea')) {
continue;
}
object = $('#' + id).parent();
var $original = $('#' + id);
if ($original.is('fieldset') || $original.is('textarea')) {
continue;
}
var object = $original.parent();
if (Drupal.settings.CTools.dependent[id].type == 'disable') {
if (Drupal.settings.CTools.dependent[id].num <= len) {
// Show if the element if criteria is matched
object.attr('disabled', false);
object.addClass('dependent-options');
object.children().attr('disabled', false);
// **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
if (typeof $().prop == 'function') {
object.prop('disabled', false);
object.addClass('dependent-options');
object.children().prop('disabled', false);
}
else {
object.attr('disabled', false);
object.addClass('dependent-options');
object.children().attr('disabled', false);
}
}
else {
// Otherwise hide. Use css rather than hide() because hide()
// does not work if the item is already hidden, for example,
// in a collapsed fieldset.
object.attr('disabled', true);
object.children().attr('disabled', true);
// **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
if (typeof $().prop == 'function') {
object.prop('disabled', true);
object.children().prop('disabled', true);
}
else {
object.attr('disabled', true);
object.children().attr('disabled', true);
}
}
}
else {
+157 -27
View File
@@ -48,7 +48,8 @@
modalOptions: {
opacity: .55,
background: '#fff'
}
},
modalClass: 'default'
};
var settings = {};
@@ -97,8 +98,8 @@
resize();
$('span.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText);
Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed);
$('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme));
Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed, settings.modalClass);
$('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme)).addClass('ctools-modal-loading');
// Position autocomplete results based on the scroll position of the modal.
$('#modalContent .modal-content').delegate('input.form-autocomplete', 'keyup', function() {
@@ -120,18 +121,18 @@
*/
Drupal.theme.prototype.CToolsModalDialog = function () {
var html = ''
html += ' <div id="ctools-modal">'
html += ' <div class="ctools-modal-content">' // panels-modal-content
html += ' <div class="modal-header">';
html += ' <a class="close" href="#">';
html += Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage;
html += ' </a>';
html += ' <span id="modal-title" class="modal-title">&nbsp;</span>';
html += ' </div>';
html += ' <div id="modal-content" class="modal-content">';
html += ' </div>';
html += '<div id="ctools-modal">'
html += ' <div class="ctools-modal-content">' // panels-modal-content
html += ' <div class="modal-header">';
html += ' <a class="close" href="#">';
html += Drupal.CTools.Modal.currentSettings.closeText + Drupal.CTools.Modal.currentSettings.closeImage;
html += ' </a>';
html += ' <span id="modal-title" class="modal-title">&nbsp;</span>';
html += ' </div>';
html += ' <div id="modal-content" class="modal-content">';
html += ' </div>';
html += ' </div>';
html += '</div>';
return html;
}
@@ -141,11 +142,11 @@
*/
Drupal.theme.prototype.CToolsModalThrobber = function () {
var html = '';
html += ' <div id="modal-throbber">';
html += ' <div class="modal-throbber-wrapper">';
html += Drupal.CTools.Modal.currentSettings.throbber;
html += ' </div>';
html += '<div id="modal-throbber">';
html += ' <div class="modal-throbber-wrapper">';
html += Drupal.CTools.Modal.currentSettings.throbber;
html += ' </div>';
html += '</div>';
return html;
};
@@ -264,7 +265,10 @@
}
// An empty event means we were triggered via .click() and
// in jquery 1.4 this won't trigger a submit.
if (event.bubbles == undefined) {
// We also have to check jQuery version to prevent
// IE8 + jQuery 1.4.4 to break on other events
// bound to the submit button.
if (jQuery.fn.jquery === '1.4' && typeof event.bubbles === "undefined") {
$(this.form).trigger('submit');
return false;
}
@@ -299,6 +303,17 @@
// Attach behaviors within a modal dialog.
var settings = response.settings || ajax.settings || Drupal.settings;
Drupal.attachBehaviors('#modalContent', settings);
if ($('#modal-content').hasClass('ctools-modal-loading')) {
$('#modal-content').removeClass('ctools-modal-loading');
}
else {
// If the modal was already shown, and we are simply replacing its
// content, then focus on the first focusable element in the modal.
// (When first showing the modal, focus will be placed on the close
// button by the show() function called above.)
$('#modal-content :focusable:first').focus();
}
}
/**
@@ -349,8 +364,9 @@
* @param css obj of css attributes
* @param animation (fadeIn, slideDown, show)
* @param speed (valid animation speeds slow, medium, fast or # in ms)
* @param modalClass class added to div#modalContent
*/
Drupal.CTools.Modal.modalContent = function(content, css, animation, speed) {
Drupal.CTools.Modal.modalContent = function(content, css, animation, speed, modalClass) {
// If our animation isn't set, make it just show/pop
if (!animation) {
animation = 'show';
@@ -402,9 +418,56 @@
if( docHeight < winHeight ) docHeight = winHeight;
// Create our divs
$('body').append('<div id="modalBackdrop" style="z-index: 1000; display: none;"></div><div id="modalContent" style="z-index: 1001; position: absolute;">' + $(content).html() + '</div>');
$('body').append('<div id="modalBackdrop" class="backdrop-' + modalClass + '" style="z-index: 1000; display: none;"></div><div id="modalContent" class="modal-' + modalClass + '" style="z-index: 1001; position: absolute;">' + $(content).html() + '</div>');
// Keyboard and focus event handler ensures focus stays on modal elements only
// Get a list of the tabbable elements in the modal content.
var getTabbableElements = function () {
var tabbableElements = $('#modalContent :tabbable'),
radioButtons = tabbableElements.filter('input[type="radio"]');
// The list of tabbable elements from jQuery is *almost* right. The
// exception is with groups of radio buttons. The list from jQuery will
// include all radio buttons, when in fact, only the selected radio button
// is tabbable, and if no radio buttons in a group are selected, then only
// the first is tabbable.
if (radioButtons.length > 0) {
// First, build up an index of which groups have an item selected or not.
var anySelected = {};
radioButtons.each(function () {
var name = this.name;
if (typeof anySelected[name] === 'undefined') {
anySelected[name] = radioButtons.filter('input[name="' + name + '"]:checked').length !== 0;
}
});
// Next filter out the radio buttons that aren't really tabbable.
var found = {};
tabbableElements = tabbableElements.filter(function () {
var keep = true;
if (this.type == 'radio') {
if (anySelected[this.name]) {
// Only keep the selected one.
keep = this.checked;
}
else {
// Only keep the first one.
if (found[this.name]) {
keep = false;
}
found[this.name] = true;
}
}
return keep;
});
}
return tabbableElements.get();
};
// Keyboard and focus event handler ensures only modal elements gain focus.
modalEventHandler = function( event ) {
target = null;
if ( event ) { //Mozilla
@@ -428,7 +491,7 @@
return true;
}
else {
$('#modalContent').focus();
getTabbableElements()[0].focus();
}
event.preventDefault();
@@ -436,6 +499,59 @@
$('body').bind( 'focus', modalEventHandler );
$('body').bind( 'keypress', modalEventHandler );
// Keypress handler Ensures you can only TAB to elements within the modal.
// Based on the psuedo-code from WAI-ARIA 1.0 Authoring Practices section
// 3.3.1 "Trapping Focus".
modalTabTrapHandler = function (evt) {
// We only care about the TAB key.
if (evt.which != 9) {
return true;
}
var tabbableElements = getTabbableElements(),
firstTabbableElement = tabbableElements[0],
lastTabbableElement = tabbableElements[tabbableElements.length - 1],
singleTabbableElement = firstTabbableElement == lastTabbableElement,
node = evt.target;
// If this is the first element and the user wants to go backwards, then
// jump to the last element.
if (node == firstTabbableElement && evt.shiftKey) {
if (!singleTabbableElement) {
lastTabbableElement.focus();
}
return false;
}
// If this is the last element and the user wants to go forwards, then
// jump to the first element.
else if (node == lastTabbableElement && !evt.shiftKey) {
if (!singleTabbableElement) {
firstTabbableElement.focus();
}
return false;
}
// If this element isn't in the dialog at all, then jump to the first
// or last element to get the user into the game.
else if ($.inArray(node, tabbableElements) == -1) {
// Make sure the node isn't in another modal (ie. WYSIWYG modal).
var parents = $(node).parents().get();
for (var i = 0; i < parents.length; ++i) {
var position = $(parents[i]).css('position');
if (position == 'absolute' || position == 'fixed') {
return true;
}
}
if (evt.shiftKey) {
lastTabbableElement.focus();
}
else {
firstTabbableElement.focus();
}
}
};
$('body').bind('keydown', modalTabTrapHandler);
// Create our content div, get the dimensions, and hide it
var modalContent = $('#modalContent').css('top','-1000px');
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
@@ -457,12 +573,19 @@
$(document).bind('keydown', modalEventEscapeCloseHandler);
// Per WAI-ARIA 1.0 Authoring Practices, initial focus should be on the
// close button, but we should save the original focus to restore it after
// the dialog is closed.
var oldFocus = document.activeElement;
$('.close').focus();
// Close the open modal content and backdrop
function close() {
// Unbind the events
$(window).unbind('resize', modalContentResize);
$('body').unbind( 'focus', modalEventHandler);
$('body').unbind( 'keypress', modalEventHandler );
$('body').unbind( 'keydown', modalTabTrapHandler );
$('.close').unbind('click', modalContentClose);
$('body').unbind('keypress', modalEventEscapeCloseHandler);
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
@@ -478,12 +601,19 @@
// Remove the content
$('#modalContent').remove();
$('#modalBackdrop').remove();
// Restore focus to where it was before opening the dialog
$(oldFocus).focus();
};
// Move and resize the modalBackdrop and modalContent on resize of the window
modalContentResize = function(){
// Move and resize the modalBackdrop and modalContent on window resize.
modalContentResize = function(){
// position code lifted from http://www.quirksmode.org/viewport/compatibility.html
// Reset the backdrop height/width to get accurate document size.
$('#modalBackdrop').css('height', '').css('width', '');
// Position code lifted from:
// http://www.quirksmode.org/viewport/compatibility.html
if (self.pageYOffset) { // all except Explorer
var wt = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
@@ -509,8 +639,6 @@
modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show();
};
$(window).bind('resize', modalContentResize);
$('#modalContent').focus();
};
/**
@@ -533,7 +661,9 @@
$(window).unbind('resize', modalContentResize);
$('body').unbind('focus', modalEventHandler);
$('body').unbind('keypress', modalEventHandler);
$('body').unbind( 'keydown', modalTabTrapHandler );
$('.close').unbind('click', modalContentClose);
$('body').unbind('keypress', modalEventEscapeCloseHandler);
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
// jQuery magic loop through the instances and run the animations or removal.
@@ -0,0 +1,43 @@
/**
* @file
* Custom state for handling visibility
*/
/**
* Add a new state to Drupal #states. We use this to toggle element-invisible
* to show/hidden #states elements. This allows elements to be visible to
* screen readers.
*
* To use:
* $form['my_form_field'] = array(
* ..
* // Only show this field if 'some_other_field' is checked.
* '#states => array(
* 'show' => array(
* 'some-other-field' => array('checked' => TRUE),
* ),
* ),
* ..
* // Required to load the 'show' state handler.
* '#attached' => array(
* 'js' => array(ctools_attach_js('states-show')),
* ),
* );
*/
(function ($) {
'use strict';
Drupal.states.State.aliases.hidden = '!show';
// Show/hide form items by toggling the 'element-invisible' class. This is a
// more accessible option than the core 'visible' state.
$(document).bind('state:show', function(e) {
if (e.trigger) {
var element = $(e.target).closest('.form-item, .form-submit, .form-wrapper');
element.toggle(e.value);
e.value === true ? element.removeClass('element-invisible') : element.addClass('element-invisible');
}
});
})(jQuery);
@@ -5,7 +5,7 @@
Drupal.CTools.Stylizer.addFarbtastic = function(context) {
// This behavior attaches by ID, so is only valid once on a page.
if ($('ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
if ($('#ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
return;
}
@@ -4,7 +4,7 @@ Note: this page is currently very preliminary. Please visit <a href="http://drup
This is a quick summary:
<ul>
<li>Visit administer >> site building >> pages to get to the primary page manager interface.</li>
<li>Visit administer >> structure >> pages to get to the primary page manager interface.</li>
<li>You can add custom pages for your basic landing pages, front pages, whatever you like for normal content display.</li>
<li>You can use the system pages to create finer control of how taxonomy vocabularies, nodes and user profiles are displayed.</li>
<li>When you add your first custom page, do not bother with the optional features. You will not need these until you get to more advanced tasks.</li>
@@ -1421,7 +1421,7 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
'exists' => 'page_manager_handler_check_machine_name',
'source' => array('title'),
),
'#field_prefix' => '<span dir="ltr">' . $task['name'] . '__',
'#field_prefix' => '<span dir="ltr">' . $form_state['task_name'] . '__',
'#field_suffix' => '</span>&lrm;',
);
}
@@ -1466,7 +1466,7 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
* Check if handler's machine-name is unique
*/
function page_manager_handler_check_machine_name($name, $element, $form_state) {
$name = $form_state['task']['name'] . '__' . $name;
$name = $form_state['task_name'] . '__' . $name;
return count(ctools_export_load_object('page_manager_handlers', 'names', array($name)));
}
@@ -1542,25 +1542,42 @@ function page_manager_handler_import_submit(&$form, &$form_state) {
* Rearrange the order of variants.
*/
function page_manager_handler_rearrange($form, &$form_state) {
ctools_include('context-task-handler');
$page = $form_state['page'];
$form['handlers'] = array('#tree' => TRUE);
// Get the number of variants to be displayed in order to set the delta
// to the proper value. This fixes problems in previous versions with sorting
// large numbers of variants.
$delta = count($page->handler_info)/2 + 1;
foreach ($page->handler_info as $id => $info) {
if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) {
continue;
}
$handler = $page->handlers[$id];
$plugin = page_manager_get_task_handler($handler->handler);
$object = ctools_context_handler_get_task_object($page->task, $page->subtask, $handler);
$display = new stdClass();
$display->context = ctools_context_load_contexts($object, TRUE);
$content = page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id);
$access = ctools_access_group_summary(!empty($handler->conf['access']) ? $handler->conf['access'] : array(), $display->context);
if ($access) {
$access = t('This panel will be selected if @conditions.', array('@conditions' => $access));
}
else {
$access = t('This panel will always be selected.');
}
$content .= '<div>' . $access . '</div>';
$form['handlers'][$id]['title'] = array(
'#markup' => page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id),
'#markup' => $content,
);
$form['handlers'][$id]['weight'] = array(
'#type' => 'weight',
'#default_value' => $info['weight'],
'#delta' => 30,
'#delta' => $delta,
);
}
@@ -1671,6 +1688,12 @@ function page_manager_handler_clone_submit(&$form, &$form_state) {
page_manager_handler_add_to_page($form_state['page'], $handler, $form_state['values']['title']);
// Variant is cloned and added to the Page. Ensure the uuids are re-generated.
panels_panel_context_get_display($handler);
if (isset($handler->conf['display']) && method_exists($handler->conf['display'], 'clone_display')) {
$handler->conf['display'] = $handler->conf['display']->clone_display();
}
$plugin = page_manager_get_task_handler($handler->handler);
// It has no forms at all. Add the variant and go to its first operation.
$keys = array_keys($plugin['operations']);
@@ -5,9 +5,9 @@ dependencies[] = ctools
package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -440,13 +440,18 @@ function page_manager_cache_load($task_name) {
*/
function page_manager_handler_get_name($task_name, $handlers, $handler) {
$base = str_replace('-', '_', $task_name);
$name = '';
// Optional machine name.
if (!empty($handler->conf['name'])) {
$name = $base . '__' . $handler->conf['name'];
if (count(ctools_export_load_object('page_manager_handlers', 'names', array($name)))) {
$name = '';
}
}
// If no machine name was provided, generate a unique name.
else {
// If no machine name was provided or the name is in use, generate a unique name.
if (empty($name)) {
$base .= '__' . $handler->handler;
// Use the ctools uuid generator to generate a unique id.
@@ -472,6 +477,10 @@ function page_manager_handler_add_to_page(&$page, &$handler, $title = NULL) {
if ($title) {
$handler->conf['title'] = $title;
$handler->conf['name'] = trim(preg_replace('/[^a-z0-9_]+/', '-', strtolower($title)), '-');
}
else {
$handler->conf['name'] = '';
}
$name = page_manager_handler_get_name($page->task_name, $page->handlers, $handler);
@@ -1193,7 +1202,7 @@ function page_manager_page_manager_pages_to_hook_code($names = array(), $name =
foreach ($objects as $object) {
// Have to implement our own because this export func sig requires it
$code .= $export['export callback']($object, TRUE, ' ');
$code .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n";
$code .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
}
$code .= " return \${$export['identifier']}s;\n";
$code .= "}\n";
@@ -3,7 +3,8 @@
/**
* @file
*
* This is the task handler plugin to handle generating 403, 404 and 301 response codes.
* This is the task handler plugin to handle generating 403, 404, 301 and 302
* response codes.
*/
// Plugin definition
@@ -108,7 +109,8 @@ function page_manager_http_response_codes() {
403 => t('403 Access denied'),
404 => t('404 Page not found'),
410 => t('410 Gone'),
301 => t('301 Redirect'),
301 => t('301 Permanent redirect'),
302 => t('302 Temporary redirect'),
);
}
@@ -216,6 +218,9 @@ function page_manager_http_response_title($handler, $task, $subtask) {
* General settings for the panel
*/
function page_manager_http_response_edit_settings($form, &$form_state) {
ctools_include('page_manager.admin', 'page_manager', '');
ctools_include('export', 'ctools');
$conf = $form_state['handler']->conf;
$form['title'] = array(
'#type' => 'textfield',
@@ -253,7 +258,7 @@ function page_manager_http_response_edit_settings($form, &$form_state) {
'#type' => 'textfield',
'#title' => t('Redirect destination'),
'#default_value' => $conf['destination'],
'#dependency' => array('edit-code' => array(301)),
'#dependency' => array('edit-code' => array(301, 302)),
'#description' => t('Enter the path to redirect to. You may use keyword substitutions from contexts. You can use external urls (http://www.example.com/foo) or internal urls (node/1).'),
);
@@ -262,14 +267,28 @@ function page_manager_http_response_edit_settings($form, &$form_state) {
function page_manager_http_response_edit_settings_submit($form, &$form_state) {
$machine_name = $form_state['handler']->name;
$name = $form_state['task_id'] . '__' . $form_state['values']['name'];
$name = $form_state['task_name'] . '__' . $form_state['values']['name'];
// If new name doesn't equal machine name, we need to update and redirect.
if ($machine_name !== $name) {
$form_state['new trail'] = $form_state['trail'];
$delta = array_search($machine_name, $form_state['new trail']);
$form_state['new trail'][$delta] = $name;
$form_state['handler']->name = $name;
// If there's a trail, we need to replace it for redirection.
if (isset($form_state['trail'])) {
$form_state['new trail'] = $form_state['trail'];
$delta = array_search($machine_name, $form_state['new trail']);
$form_state['new trail'][$delta] = $name;
}
// If handler id is set, replace it.
if ($form_state['handler_id']) {
$form_state['handler_id'] = $name;
}
// If we're defining a new custom handler, move page handler to new name.
if (isset($form_state['page']->handlers[$machine_name]) && isset($form_state['page']->handler_info[$machine_name])) {
$form_state['page']->handlers[$name] = $form_state['page']->handlers[$machine_name];
unset($form_state['page']->handlers[$machine_name]);
$form_state['page']->handler_info[$name] = $form_state['page']->handler_info[$machine_name];
unset($form_state['page']->handler_info[$machine_name]);
}
}
$form_state['handler']->conf['title'] = $form_state['values']['title'];
@@ -296,7 +315,7 @@ function page_manager_http_response_render($handler, $base_contexts, $args, $tes
}
$info['response code'] = $handler->conf['code'];
if ($info['response code'] == 301) {
if ($info['response code'] == 301 || $info['response code'] == 302) {
$path = ctools_context_keyword_substitute($handler->conf['destination'], array(), $contexts);
$url = parse_url($path);
if (isset($url['query'])) {
@@ -108,7 +108,7 @@ function page_manager_node_edit($node) {
* Callback to handle the process of adding a node.
*
* This creates a basic $node and passes that off to page_manager_node_edit().
* It is modeled after Drupal's node_add() function.
* It is modelled after Drupal's node_add() function.
*
* Unlike node_add() we do not need to check node_access because that was
* already checked by the menu system.
@@ -78,10 +78,6 @@ function page_manager_node_view_menu_alter(&$items, $task) {
* node view, which is node_page_view().
*/
function page_manager_node_view_page($node) {
// Prep the node to be displayed so all of the regular hooks are triggered.
// Also save the output for later, in case it is needed.
$default_output = node_page_view($node);
// Load my task plugin
$task = page_manager_get_task('node_view');
@@ -107,6 +103,9 @@ function page_manager_node_view_page($node) {
}
}
// Prepare the node to be displayed so all of the regular hooks are triggered.
$default_output = node_page_view($node);
// Otherwise, fall back to the default output generated by node_page_view().
return $default_output;
}
@@ -61,7 +61,7 @@ function page_manager_page_menu(&$items, $task) {
}
$path = array();
$page_arguments = array($subtask_id);
$page_arguments = array((string) $subtask_id);
$access_arguments = array($subtask->access);
$load_arguments = array($subtask_id, '%index', '%map');
@@ -566,7 +566,7 @@ function page_manager_page_form_basic_validate(&$form, &$form_state) {
if (strpos($path, '%') === FALSE) {
$alias = db_query('SELECT alias, source FROM {url_alias} WHERE alias = :path', array(':path' => $path))->fetchObject();
if ($alias) {
form_error($form['path'], t('That path is currently assigned to be an alias for @alias. This system cannot override existing aliases.', array('@alias' => $alias->src)));
form_error($form['path'], t('That path is currently assigned to be an alias for @alias. This system cannot override existing aliases.', array('@alias' => $alias->source)));
}
}
else {
@@ -698,7 +698,7 @@ function page_manager_page_form_menu($form, &$form_state) {
'#title' => t('Title'),
'#type' => 'textfield',
'#default_value' => $menu['title'],
'#description' => t('If set to normal or tab, enter the text to use for the menu item.'),
'#description' => t('If set to normal or tab, enter the text to use for the menu item. Renaming the menu item using the Drupal menu system (admin/structure/menu) will override this, even if it is renamed again here.'),
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab', 'action')),
);
@@ -1462,6 +1462,15 @@ function page_manager_page_form_clone_submit(&$form, &$form_state) {
$original->path = $form_state['values']['path'];
$handlers = !empty($form_state['values']['handlers']) ? $form_state['page']->handlers : FALSE;
// Ensure the handler uuids are re-generated.
if ($handlers) {
foreach ($handlers as &$handler) {
if (isset($handler->conf['display']) && method_exists($handler->conf['display'], 'clone_display')) {
$handler->conf['display'] = $handler->conf['display']->clone_display();
}
}
}
// Export the handler, which is a fantastic way to clean database IDs out of it.
$export = page_manager_page_export($original, $handlers);
ob_start();
@@ -151,7 +151,7 @@ function page_manager_term_view_page($term, $depth = NULL) {
foreach (module_implements('page_manager_override') as $module) {
$call = $module . '_page_manager_override';
if (($rc = $call('term_view')) && function_exists($rc)) {
return $rc($node);
return $rc($term, $depth);
}
}
@@ -0,0 +1,44 @@
<?php
/**
* @file
* Plugin for controlling access based on the existence of a query string.
*/
$plugin = array(
'title' => t('Query string exists'),
'description' => t('Control access by whether or not a query string exists.'),
'callback' => 'ctools_query_string_exists_ctools_access_check',
'settings form' => 'ctools_query_string_exists_ctools_access_settings',
'summary' => 'ctools_query_string_exists_ctools_access_summary',
'defaults' => array('key' => ''),
);
/**
* Settings form.
*/
function ctools_query_string_exists_ctools_access_settings($form, &$form_state, $config) {
$form['settings']['key'] = array(
'#title' => t('Query string key'),
'#description' => t('Enter the key of the query string.'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => $config['key']
);
return $form;
}
/**
* Check for access.
*/
function ctools_query_string_exists_ctools_access_check($config, $context) {
return isset($_GET[$config['key']]);
}
/**
* Provide a summary description.
*/
function ctools_query_string_exists_ctools_access_summary($config, $context) {
return t('@identifier exists', array('@identifier' => $config['key']));
}
@@ -3,7 +3,7 @@
/**
* @file
*
* Plugin to provide an argument handler for all entity ids
* Plugin to provide an argument handler for all entity ids.
*/
/**
@@ -17,7 +17,7 @@ $plugin = array(
'get child' => 'ctools_argument_entity_id_get_child',
'get children' => 'ctools_argument_entity_id_get_children',
'default' => array(
'entity_id' => ''
'entity_id' => '',
),
'placeholder form' => 'ctools_argument_entity_id_ctools_argument_placeholder',
);
@@ -41,6 +41,7 @@ function ctools_argument_entity_id_get_children($original_plugin, $parent) {
$plugins[$plugin_id] = $plugin;
}
drupal_alter('ctools_entity_contexts', $plugins);
return $plugins;
}
@@ -60,9 +61,12 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
return ctools_context_create('entity:' . $entity_type, $arg);
}
// Trim spaces and other garbage.
$arg = trim($arg);
if (!is_numeric($arg)) {
$preg_matches = array();
$match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
$match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
if (!$match) {
$match = preg_match('/^id: (\d+)/', $arg, $preg_matches);
}
@@ -70,18 +74,18 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
if ($match) {
$id = $preg_matches[1];
}
if (is_numeric($id)) {
if (isset($id) && is_numeric($id)) {
return ctools_context_create('entity:' . $entity_type, $id);
}
return FALSE;
}
$entity = entity_load($entity_type, array($arg));
if (!$entity) {
$entities = entity_load($entity_type, array($arg));
if (empty($entities)) {
return FALSE;
}
return ctools_context_create('entity:' . $entity_type, $entity[$arg]);
return ctools_context_create('entity:' . $entity_type, reset($entities));
}
function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
@@ -119,7 +123,7 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
$form['settings']['entity_id'] = array(
'#type' => 'value',
'#value' => $conf['entity_id'],
'#value' => isset($conf['entity_id']) ? $conf['entity_id'] : '',
);
$form['settings']['entity_type'] = array(
@@ -132,11 +136,12 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
function ctools_argument_entity_id_ctools_argument_placeholder($conf) {
$conf = array(
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $conf['keyword'])),
'#type' => 'textfield',
'#maxlength' => 512,
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $conf['keyword'])),
'#type' => 'textfield',
'#maxlength' => 512,
'#autocomplete_path' => 'ctools/autocomplete/' . $conf['keyword'],
'#weight' => -10,
'#weight' => -10,
);
return $conf;
}
@@ -18,6 +18,7 @@ $plugin = array(
'context' => 'ctools_term_context',
'default' => array('input_form' => 'tid', 'breadcrumb' => TRUE, 'transform' => FALSE),
'settings form' => 'ctools_term_settings_form',
'settings form validate' => 'ctools_term_settings_form_validate',
'placeholder form' => 'ctools_term_ctools_argument_placeholder',
'breadcrumb' => 'ctools_term_breadcrumb',
);
@@ -31,6 +32,16 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create_empty('entity:taxonomy_term');
}
if (isset($conf['vocabularies'])) {
$vocabularies = $conf['vocabularies'];
}
else {
$vids = isset($conf['vids']) ? $conf['vids'] : array();
// Convert legacy use of vids to machine names.
$vocabularies = _ctools_term_vocabulary_machine_name_convert($vids);
}
if (is_object($arg)) {
$term = $arg;
}
@@ -50,12 +61,11 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
$terms = taxonomy_get_term_by_name($arg);
$conf['vids'] = is_array($conf['vids']) ? array_filter($conf['vids']) : NULL;
if ((count($terms) > 1) && isset($conf['vids'])) {
// If only one term is found, fall through to vocabulary check below.
if ((count($terms) > 1) && $vocabularies) {
foreach ($terms as $potential) {
foreach ($conf['vids'] as $vid => $active) {
if ($active && $potential->vid == $vid) {
foreach ($vocabularies as $machine_name) {
if ($potential->vocabulary_machine_name == $machine_name) {
$term = $potential;
// break out of the foreaches AND the case
break 3;
@@ -72,7 +82,7 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
}
if (!empty($conf['vids']) && array_filter($conf['vids']) && empty($conf['vids'][$term->vid])) {
if ($vocabularies && !isset($vocabularies[$term->vocabulary_machine_name])) {
return NULL;
}
@@ -98,13 +108,20 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
$vocabularies = taxonomy_get_vocabularies();
$options = array();
foreach ($vocabularies as $vid => $vocab) {
$options[$vid] = $vocab->name;
$options[$vocab->machine_name] = $vocab->name;
}
$form['settings']['vids'] = array(
// Fallback on legacy 'vids', when no vocabularies are available.
if (empty($conf['vocabularies']) && !empty($conf['vids'])) {
$conf['vocabularies'] = _ctools_term_vocabulary_machine_name_convert(array_filter($conf['vids']));
unset($conf['vids']);
}
$form['settings']['vocabularies'] = array(
'#title' => t('Limit to these vocabularies'),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => !empty($conf['vids']) ? $conf['vids'] : array(),
'#default_value' => !empty($conf['vocabularies']) ? $conf['vocabularies'] : array(),
'#description' => t('If no vocabularies are checked, terms from all vocabularies will be accepted.'),
);
@@ -123,6 +140,12 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
// return $form;
}
function ctools_term_settings_form_validate (&$form, &$form_state) {
// Filter the selected vocabularies to avoid storing redundant data.
$vocabularies = array_filter($form_state['values']['settings']['vocabularies']);
form_set_value($form['settings']['vocabularies'], $vocabularies, $form_state);
}
/**
* Form fragment to get an argument to convert a placeholder for preview.
*/
@@ -161,3 +184,20 @@ function ctools_term_breadcrumb($conf, $context) {
$breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
drupal_set_breadcrumb($breadcrumb);
}
/**
* Helper function to convert convert legacy vocabulary ids into machine names.
*
* @param array $vids
* Array of either vids.
* @return array
* A keyed array of machine names.
*/
function _ctools_term_vocabulary_machine_name_convert($vids) {
$vocabularies = taxonomy_vocabulary_load_multiple($vids);
$return = array();
foreach($vocabularies as $vocabulary) {
$return[$vocabulary->machine_name] = $vocabulary->machine_name;
}
return $return;
}
@@ -65,6 +65,7 @@ function ctools_terms_breadcrumb($conf, $context) {
return;
}
$current = new stdClass();
$current->tid = $context->tids[0];
$breadcrumb = array();
while ($parents = taxonomy_get_parents($current->tid)) {
@@ -372,9 +372,9 @@ function profile_ctools_block_info($module, $delta, &$info) {
}
function book_ctools_block_info($module, $delta, &$info) {
// Hide the book navigation block which isn't as rich as what we can
// do with context.
$info = NULL;
$info['title'] = t('Book navigation menu');
$info['icon'] = 'icon_core_block_menu.png';
$info['category'] = t('Node');
}
function blog_ctools_block_info($module, $delta, &$info) {
@@ -0,0 +1,74 @@
<?php
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'single' => TRUE,
'title' => t('Comment created date'),
'icon' => 'icon_comment.png',
'description' => t('The date the referenced comment was created.'),
'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
'category' => t('Comment'),
'defaults' => array(
'format' => 'small',
),
);
/**
* Render the custom content type.
*/
function ctools_comment_created_content_type_render($subtype, $conf, $panel_args, $context) {
if (empty($context) || empty($context->data)) {
return;
}
// Get a shortcut to the comment.
$comment = $context->data;
// Build the content type block.
$block = new stdClass();
$block->module = 'comment_created';
$block->title = t('Created date');
$block->content = format_date($comment->created, $conf['format']);
$block->delta = $comment->cid;
return $block;
}
/**
* Returns an edit form for custom type settings.
*/
function ctools_comment_created_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
$date_types = array();
foreach (system_get_date_types() as $date_type => $definition) {
$date_types[$date_type] = format_date(REQUEST_TIME, $date_type);
}
$form['format'] = array(
'#title' => t('Date format'),
'#type' => 'select',
'#options' => $date_types,
'#default_value' => $conf['format'],
);
return $form;
}
/**
* Submit handler for the custom type settings form.
*/
function ctools_comment_created_content_type_edit_form_submit($form, &$form_state) {
// Copy everything from our defaults.
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
/**
* Returns the administrative title for a type.
*/
function ctools_comment_created_content_type_admin_title($subtype, $conf, $context) {
return t('"@s" created date', array('@s' => $context->identifier));
}
@@ -26,7 +26,7 @@ function ctools_comment_links_content_type_render($subtype, $conf, $panel_args,
return;
}
$comment = isset($context->data) ? clone($context->data) : NULL;
$comment = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'comment';
$block->delta = $comment->cid;
@@ -25,7 +25,7 @@ if (module_exists('comment')) {
function ctools_comment_reply_form_content_type_render($subtype, $conf, $panel_args, $context) {
$comment = ($context[1]->identifier == t('No context')) ? NULL : clone($context[1]->data);
$comment = ($context[1]->identifier == t('No context')) ? NULL : clone $context[1]->data;
$block = new stdClass();
$block->module = 'comments';
if ($comment) $block->delta = $comment->cid;
@@ -16,7 +16,7 @@
$plugin = array(
'title' => t('Custom content'),
'no title override' => TRUE,
'defaults' => array('admin_title' => '', 'title' => '', 'body' => '', 'format' => filter_default_format(), 'substitute' => TRUE),
'defaults' => array('admin_title' => '', 'title' => '', 'title_heading' => 'h2', 'body' => '', 'format' => filter_default_format(), 'substitute' => TRUE),
'js' => array('misc/autocomplete.js', 'misc/textarea.js', 'misc/collapse.js'),
// Make sure the edit form is only used for some subtypes.
'edit form' => '',
@@ -135,6 +135,7 @@ function ctools_custom_content_type_get_conf($subtype, $conf) {
$settings = array(
'admin_title' => t('Missing/deleted content'),
'title' => '',
'title_heading' => '',
'body' => '',
'format' => filter_default_format(),
'substitute' => TRUE,
@@ -180,6 +181,8 @@ function ctools_custom_content_type_render($subtype, $conf, $args, $contexts) {
$block = new stdClass();
$block->subtype = ++$delta;
$block->title = filter_xss_admin($settings['title']);
$block->title_heading = isset($settings['title_heading']) ? $settings['title_heading'] : 'h2';
// Add keyword substitutions if we were configured to do so.
$content = $settings['body'];
@@ -277,10 +280,36 @@ function ctools_custom_content_type_edit_form($form, &$form_state) {
'#description' => t('This title will be used administratively to identify this pane. If blank, the regular title will be used.'),
);
// Copy over the title override settings for a title heading.
$form['aligner_start'] = array(
'#markup' => '<div class="option-text-aligner clearfix">',
);
$form['title'] = array(
'#type' => 'textfield',
'#default_value' => $settings['title'],
'#title' => t('Title'),
'#id' => 'override-title-textfield',
);
$form['title_heading'] = array(
'#type' => 'select',
'#default_value' => isset($settings['title_heading']) ? $settings['title_heading'] : 'h2',
'#options' => array(
'h1' => t('h1'),
'h2' => t('h2'),
'h3' => t('h3'),
'h4' => t('h4'),
'h5' => t('h5'),
'h6' => t('h6'),
'div' => t('div'),
'span' => t('span'),
),
'#id' => 'override-title-heading',
);
$form['aligner_stop'] = array(
'#markup' => '</div>',
);
$form['body'] = array(
@@ -34,6 +34,14 @@ function ctools_entity_field_content_type_content_types() {
return $types;
}
$cache_key = 'ctools_entity_field_content_type_content_types';
if ($cache = cache_get($cache_key)) {
$types = $cache->data;
if (!empty($types)) {
return $types;
}
}
// This will hold all the individual field content types.
$context_types = array();
$entities = entity_get_info();
@@ -82,6 +90,8 @@ function ctools_entity_field_content_type_content_types() {
unset($context_types[$key]['types']);
}
cache_set($cache_key, $types);
return $types;
}
@@ -127,25 +137,24 @@ function ctools_entity_field_content_type_render($subtype, $conf, $panel_args, $
$field_settings['settings'] = $conf['formatter_settings'];
}
$all_values = field_get_items($entity_type, $entity, $field_name, $language);
if (!is_array($all_values)) {
// Do not render if the field is empty.
return;
}
// Reverse values.
if (isset($conf['delta_reversed']) && $conf['delta_reversed']) {
$all_values = array_reverse($all_values, TRUE);
}
if (isset($conf['delta_limit'])) {
$offset = intval($conf['delta_offset']);
$limit = !empty($conf['delta_limit']) ? $conf['delta_limit'] : NULL;
$all_values = array_slice($all_values, $offset, $limit, TRUE);
}
$clone = clone $entity;
$clone->{$field_name}[$language] = $all_values;
$all_values = field_get_items($entity_type, $entity, $field_name, $language);
if (is_array($all_values)) {
// Reverse values.
if (isset($conf['delta_reversed']) && $conf['delta_reversed']) {
$all_values = array_reverse($all_values, TRUE);
}
if (isset($conf['delta_limit'])) {
$offset = intval($conf['delta_offset']);
$limit = !empty($conf['delta_limit']) ? $conf['delta_limit'] : NULL;
$all_values = array_slice($all_values, $offset, $limit, TRUE);
}
$clone->{$field_name}[$language] = $all_values;
}
$field_output = field_view_field($entity_type, $clone, $field_name, $field_settings, $language);
if (!empty($field_output) && !empty($conf['override_title'])) {
@@ -260,10 +269,7 @@ function ctools_entity_field_content_type_admin_title($subtype, $conf, $context)
$identifier = $context->identifier;
}
else {
$type = 'ctools_entity_field_content_type_admin_title';
$message = t('Context is missing for field: @name', array('@name' => $subtype));
$variables = array($subtype, $conf, $context);
watchdog($type, $message, $variables, $severity = WATCHDOG_NOTICE);
watchdog('ctools_entity_field_content_type_admin_title', 'Context is missing for field: @name', array('@name' => $subtype), WATCHDOG_NOTICE);
$identifier = t('Unknown');
}
@@ -57,6 +57,26 @@ function ctools_entity_form_field_content_type_content_types() {
}
}
if (module_exists('field_group')) {
foreach ($entities as $entity_type => $entity) {
foreach ($entity['bundles'] as $type => $bundle) {
if ($group_info = field_group_info_groups($entity_type, $type, "form")) {
foreach ($group_info as $group_name => $group) {
if (!isset($types[$entity_type . ':' . $group_name])) {
$types[$entity_type . ':' . $group_name] = array(
'category' => t('Form'),
'icon' => 'icon_field.png',
'title' => t('Group form: @widget_label', array('@widget_label' => $group->label)),
'description' => t('Field group on the referenced entity.'),
);
}
$content_types[$entity_type . ':' . $group_name]['types'][$type] = $bundle['label'];
}
}
}
}
}
// Create the required context for each field related to the bundle types.
foreach ($types as $key => $field_content_type) {
list($entity_type, $field_name) = explode(':', $key, 2);
@@ -85,16 +105,38 @@ function ctools_entity_form_field_content_type_render($subtype, $conf, $panel_ar
$ids = entity_extract_ids($entity_type, $entity);
$field = field_info_instance($entity_type, $field_name, $ids[2]);
// Do not render if the entity type does not have this field.
if (empty($field)) {
// Check for field groups.
if (empty($field) && module_exists('field_group')) {
$groups = field_group_info_groups($entity_type, $entity->type, "form");
$group = !empty($groups[$field_name]) ? $groups[$field_name] : NULL;
}
// Do not render if the entity type does not have this field or group.
if (empty($field) && empty($group)) {
return;
}
$block = new stdClass();
$block = new stdClass();
if (isset($context->form)) {
$block->content = array();
$block->content[$field_name] = $context->form[$field_name];
unset($context->form[$field_name]);
if (!empty($field)) {
$block->content[$field_name] = $context->form[$field_name];
unset($context->form[$field_name]);
}
else {
// Pre-render the form to populate field groups.
if (isset($context->form['#pre_render'])) {
foreach ($context->form['#pre_render'] as $function) {
if (function_exists($function)) {
$context->form = $function($context->form);
}
}
unset($context->form['#pre_render']);
}
$block->content[$field_name] = $context->form[$field_name];
unset($context->form[$field_name]);
}
}
else {
$block->content = t('Entity info.');
@@ -66,7 +66,7 @@ function ctools_node_content_type_render($subtype, $conf, $panel_args) {
// Don't store viewed node data on the node, this can mess up other
// views of the node.
$node = clone($node);
$node = clone $node;
$block->module = 'node';
$block->delta = $node->nid;
@@ -14,7 +14,7 @@ $plugin = array(
);
function ctools_node_attachments_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'attachments';
@@ -16,7 +16,7 @@ if (module_exists('book')) {
}
function ctools_node_book_children_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'book_children';
@@ -0,0 +1,101 @@
<?php
if (module_exists('book')) {
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'single' => TRUE,
'title' => t('Book navigation menu'),
'icon' => '../block/icon_core_block_menu.png',
'description' => t('The book menu belonging to the current book node.'),
'required context' => new ctools_context_required(t('Node'), 'node'),
'category' => t('Node'),
);
}
function ctools_node_book_menu_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$block = new stdClass();
$block->module = 'book_menu';
if ($conf['override_title']) {
$block->title = t($conf['override_title_text']);
}
else {
$block->title = t('Book navigation menu');
}
if ($node) {
$block->delta = $node->nid;
// TODO: the value is not available somehow?!?
$book_block_mode = isset($conf['book_block_mode']) ? $conf['book_block_mode'] : 'book pages';
// Code below is taken from function book_block_view().
$current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
if ($book_block_mode === 'all pages') {
$block->subject = t('Book navigation');
$book_menus = array();
$pseudo_tree = array(0 => array('below' => FALSE));
foreach (book_get_books() as $book_id => $book) {
if ($book['bid'] === $current_bid) {
// If the current page is a node associated with a book, the menu
// needs to be retrieved.
$book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
}
else {
// Since we know we will only display a link to the top node, there
// is no reason to run an additional menu tree query for each book.
$book['in_active_trail'] = FALSE;
// Check whether user can access the book link.
$book_node = node_load($book['nid']);
$book['access'] = node_access('view', $book_node);
$pseudo_tree[0]['link'] = $book;
$book_menus[$book_id] = menu_tree_output($pseudo_tree);
}
}
$book_menus['#theme'] = 'book_all_books_block';
$block->content = $book_menus;
}
elseif ($current_bid) {
// Only display this block when the user is browsing a book.
$select = db_select('node', 'n')
->fields('n', array('title'))
->condition('n.nid', $node->book['bid'])
->addTag('node_access');
$title = $select->execute()->fetchField();
// Only show the block if the user has view access for the top-level node.
if ($title) {
$tree = menu_tree_all_data($node->book['menu_name'], $node->book);
// There should only be one element at the top level.
$data = array_shift($tree);
// TODO: subject is not rendered
$block->subject = theme('book_title_link', array('link' => $data['link']));
$block->content = ($data['below']) ? menu_tree_output($data['below']) : '';
}
}
}
else {
$block->content = t('Book navigation pager goes here.');
$block->delta = 'unknown';
}
return $block;
}
function ctools_node_book_menu_content_type_admin_title($subtype, $conf, $context) {
return t('"@s" book navigation pager', array('@s' => $context->identifier));
}
function ctools_node_book_menu_content_type_edit_form($form, &$form_state) {
// Grab block form from the book module.
$block_form = book_block_configure($delta = '');
// TODO: this does not work yet.
// See TODO in: ctools_node_book_menu_content_type_render
if (isset($form_state['input']['book_block_mode'])) {
$block_form['book_block_mode']['#default_value'] = $form_state['input']['book_block_mode'];
}
$form += $block_form;
return $form;
}
@@ -7,26 +7,26 @@ if (module_exists('book')) {
*/
$plugin = array(
'single' => TRUE,
'title' => t('Book navigation'),
'icon' => 'icon_node.png',
'description' => t('The navigation menu the book the node belongs to.'),
'title' => t('Book navigation pager'),
'icon' => '../block/icon_core_booknavigation.png',
'description' => t('The navigational pager and sub pages of the current book node.'),
'required context' => new ctools_context_required(t('Node'), 'node'),
'category' => t('Node'),
);
}
function ctools_node_book_nav_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'book_nav';
$block->title = t('Book navigation');
$block->title = t('Book navigation pager');
if ($node) {
$block->content = isset($node->book) ? theme('book_navigation', array('book_link' => $node->book)) : '';
$block->delta = $node->nid;
}
else {
$block->content = t('Book navigation goes here.');
$block->content = t('Book navigation pager goes here.');
$block->delta = 'unknown';
}
@@ -34,7 +34,7 @@ function ctools_node_book_nav_content_type_render($subtype, $conf, $panel_args,
}
function ctools_node_book_nav_content_type_admin_title($subtype, $conf, $context) {
return t('"@s" book navigation', array('@s' => $context->identifier));
return t('"@s" book navigation pager', array('@s' => $context->identifier));
}
function ctools_node_book_nav_content_type_edit_form($form, &$form_state) {
@@ -17,7 +17,7 @@ if (module_exists('comment')) {
}
function ctools_node_comment_form_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'comments';
$block->delta = $node->nid;
@@ -77,20 +77,3 @@ function ctools_node_comment_form_content_type_edit_form_submit($form, &$form_st
}
}
/**
* Alter the comment form to get a little more control over it.
*/
function ctools_form_comment_form_alter(&$form, &$form_state) {
if (!empty($form_state['ctools comment alter'])) {
// Force the form to post back to wherever we are.
$form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
if (empty($form['#submit'])) {
$form['#submit'] = array('comment_form_submit');
}
$form['#submit'][] = 'ctools_node_comment_form_submit';
}
}
function ctools_node_comment_form_submit(&$form, &$form_state) {
$form_state['redirect'][0] = $_GET['q'];
}
@@ -23,7 +23,7 @@ if (module_exists('comment')) {
* Render the node comments.
*/
function ctools_node_comment_wrapper_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'comments';
$block->delta = $node->nid;
@@ -77,7 +77,7 @@ function ctools_node_comment_wrapper_content_type_render($subtype, $conf, $panel
/**
* Returns an edit form for the comment wrapper.
*/
*/
function ctools_node_comment_wrapper_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
$form['mode'] = array(
@@ -20,7 +20,7 @@ if (module_exists('comment')) {
}
function ctools_node_comments_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'comments';
$block->delta = $node->nid;
@@ -31,7 +31,7 @@ function ctools_node_content_content_type_render($subtype, $conf, $panel_args, $
return;
}
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'node';
$block->delta = $node->nid;
@@ -29,7 +29,7 @@ function ctools_node_links_content_type_render($subtype, $conf, $panel_args, $co
return;
}
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'node';
$block->delta = $node->nid;
@@ -18,7 +18,7 @@ $plugin = array(
* based on the module and delta supplied in the configuration.
*/
function ctools_node_type_desc_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? clone($context->data) : NULL;
$node = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'node_type';
@@ -29,6 +29,9 @@ $plugin = array(
* Outputs the page title of the current page.
*/
function ctools_page_title_content_type_render($subtype, $conf, $panel_args) {
if (!drupal_get_title()) {
return;
}
// TODO: This should have a setting or something for the markup.
if (empty($conf['markup'])) {
$conf['markup'] = 'h1';
@@ -14,12 +14,12 @@ $plugin = array(
);
function ctools_term_description_content_type_render($subtype, $conf, $panel_args, $context) {
$term = isset($context->data) ? clone($context->data) : NULL;
$term = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'node_type';
$block->title = $term->name;
if ($term) {
if (!empty($term)) {
$block->title = $term->name;
$block->content = check_markup($term->description, $term->format, '', TRUE);
$block->delta = $term->tid;
@@ -33,6 +33,7 @@ function ctools_term_description_content_type_render($subtype, $conf, $panel_arg
}
}
else {
$block->title = '';
$block->content = t('Term description goes here.');
$block->delta = 'unknown';
}
@@ -21,7 +21,7 @@ $plugin = array(
);
function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $context) {
$term = isset($context->data) ? clone($context->data) : NULL;
$term = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'term-list';
$path = empty($conf['path']) ? 'taxonomy/term/%tid' : $conf['path'];
@@ -21,7 +21,7 @@ if (module_exists('profile') && !(defined('MAINTENANCE_MODE') && MAINTENANCE_MOD
* 'Render' callback for the 'profile fields' content type.
*/
function ctools_profile_fields_content_type_render($subtype, $conf, $panel_args, $context) {
$account = isset($context->data) ? clone($context->data) : NULL;
$account = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'profile fields';
@@ -20,7 +20,7 @@ $plugin = array(
* Render the user profile content type.
*/
function ctools_user_profile_content_type_render($subtype, $conf, $panel_args, $context) {
$account = isset($context->data) ? clone($context->data) : NULL;
$account = isset($context->data) ? clone $context->data : NULL;
if (!$account) {
return NULL;
}
@@ -13,7 +13,7 @@ $plugin = array(
);
function ctools_user_signature_content_type_render($subtype, $conf, $panel_args, $context) {
$account = isset($context->data) ? clone($context->data) : NULL;
$account = isset($context->data) ? clone $context->data : NULL;
$block = new stdClass();
$block->module = 'user-signature';
@@ -21,7 +21,7 @@ if (module_exists('taxonomy')) {
* list of terms for the input vocabulary.
*/
function ctools_vocabulary_terms_content_type_render($subtype, $conf, $panel_args, $context) {
$vocab = isset($context->data) ? clone($context->data) : NULL;
$vocab = isset($context->data) ? clone $context->data : NULL;
$max_depth = (!empty($conf['max_depth']) ? (int)$conf['max_depth'] : NULL);
if ($conf['tree'] == FALSE) {
$terms = taxonomy_get_tree($vocab->vid, 0, $max_depth);
@@ -0,0 +1,89 @@
<?php
/**
* @file query_string.inc
* Context plugin that can extract arbitrary values from the query string.
*/
/**
* $plugin array which will be used by the system that includes this file.
*/
$plugin = array(
'title' => t('Query string value'),
'description' => t('A context that extracts a value from the query string.'),
'context' => 'ctools_context_query_string_create_query_string',
'context name' => 'query_string',
'keyword' => 'query_string',
'edit form' => 'ctools_context_query_string_settings_form',
'convert list' => array(
'raw' => t('Raw string'),
'html_safe' => t('HTML-safe string'),
),
'convert' => 'ctools_context_query_string_convert',
);
/**
* Create a context from manual configuration.
*/
function ctools_context_query_string_create_query_string($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context('query_string');
$context->plugin = 'query_string';
if ($empty) {
return $context;
}
if ($conf) {
if (!empty($_GET[$data['key']])) {
$context->data = $_GET[$data['key']];
}
else {
$context->data = $data['fallback_value'];
}
}
return $context;
}
/**
* Form builder; settings for the context.
*/
function ctools_context_query_string_settings_form($form, &$form_state) {
$form['key'] = array(
'#title' => t('Query string key'),
'#description' => t('Enter the key of the value that must be returned from the query string.'),
'#type' => 'textfield',
'#required' => TRUE
);
if (isset($form_state['conf']['key'])) {
$form['key']['#default_value'] = $form_state['conf']['key'];
}
$form['fallback_value'] = array(
'#title' => t('Fallback value'),
'#description' => t('Enter a value that must be returned if the above specified key does not exist in the query string.'),
'#type' => 'textfield',
);
if (!empty($form_state['conf']['fallback_value'])) {
$form['fallback_value']['#default_value'] = $form_state['conf']['fallback_value'];
}
return $form;
}
/**
* Submit handler; settings form for the context.
*/
function ctools_context_query_string_settings_form_submit($form, &$form_state) {
$form_state['conf']['key'] = $form_state['values']['key'];
$form_state['conf']['fallback_value'] = $form_state['values']['fallback_value'];
}
/**
* Convert a context into a string.
*/
function ctools_context_query_string_convert($context, $type) {
switch ($type) {
case 'raw':
return $context->data;
case 'html_safe':
return check_plain($context->data);
}
}
@@ -43,7 +43,9 @@ function ctools_context_create_user($empty, $data = NULL, $conf = FALSE) {
if ($data['type'] == 'current') {
global $user;
$data = user_load($user->uid);
$data->logged_in_user = TRUE;
if (user_is_logged_in()) {
$data->logged_in_user = TRUE;
}
}
else {
$data = user_load($data['uid']);
@@ -34,15 +34,15 @@ function ctools_context_create_user_edit_form($empty, $user = NULL, $conf = FALS
$category = !empty($conf['category']) ? $conf['category'] : FALSE;
unset($conf['category']);
// If no category was specified, use the default 'account'.
if (!$category) {
$category = 'account';
}
// Return previously created contexts, per category.
static $created = array();
if (!empty($created[$category])) {
return $created[$category];
}
// If no category was specified, use the default 'account'.
if (!$category) {
$category = 'account';
}
$context = new ctools_context(array('form', 'user_edit', 'user_form', 'user_edit_form', 'user', 'entity:user'));
// Store this context for later.
@@ -107,7 +107,7 @@ function ctools_context_user_edit_form_settings_form($form, &$form_state) {
);
if (!empty($conf['uid'])) {
$info = db_query('SELECT * FROM {user} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
$info = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => $conf['uid']))->fetchObject();
if ($info) {
$link = l(t("'%name' [user id %uid]", array('%name' => $info->name, '%uid' => $info->uid)), "user/$info->uid", array('attributes' => array('target' => '_blank', 'title' => t('Open in new window')), 'html' => TRUE));
$form['user']['#description'] = t('Currently set to !link', array('!link' => $link));
@@ -154,10 +154,10 @@ function ctools_context_user_edit_form_settings_form_validate($form, &$form_stat
$uid = $preg_matches[1];
}
if (is_numeric($uid)) {
$user = db_query('SELECT uid FROM {user} WHEREuid = :uid', array(':uid' => $uid))->fetchObject();
$user = db_query('SELECT uid FROM {users} WHERE uid = :uid', array(':uid' => $uid))->fetchObject();
}
else {
$user = db_query('SELECT uid FROM {user} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
$user = db_query('SELECT uid FROM {users} WHERE LOWER(name) = LOWER(:name)', array(':name' => $uid))->fetchObject();
}
form_set_value($form['uid'], $user->uid, $form_state);
@@ -724,7 +724,13 @@ class ctools_export_ui {
// Export the handler, which is a fantastic way to clean database IDs out of it.
$export = ctools_export_crud_export($this->plugin['schema'], $original);
$item = ctools_export_crud_import($this->plugin['schema'], $export);
$item->{$this->plugin['export']['key']} = 'clone_of_' . $item->{$this->plugin['export']['key']};
if (!empty($input[$this->plugin['export']['key']])) {
$item->{$this->plugin['export']['key']} = $input[$this->plugin['export']['key']];
}
else {
$item->{$this->plugin['export']['key']} = 'clone_of_' . $item->{$this->plugin['export']['key']};
}
}
// Tabs and breadcrumb disappearing, this helps alleviate through cheating.
@@ -1441,7 +1447,7 @@ function ctools_export_ui_delete_confirm_form($form, &$form_state) {
$export_key = $plugin['export']['key'];
$question = str_replace('%title', check_plain($item->{$export_key}), $plugin['strings']['confirmation'][$form_state['op']]['question']);
$path = empty($_REQUEST['cancel_path']) ? ctools_export_ui_plugin_base_path($plugin) : $_REQUEST['cancel_path'];
$path = (!empty($_REQUEST['cancel_path']) && !url_is_external($_REQUEST['cancel_path'])) ? $_REQUEST['cancel_path'] : ctools_export_ui_plugin_base_path($plugin);
$form = confirm_form($form,
$question,
@@ -185,7 +185,7 @@ function ctools_entity_from_field_context($context, $conf) {
$loaded_to_entity = array_shift($loaded_to_entity);
// Pass current user account and entity type to access callback.
if (function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {
if (isset($to_entity_info['access callback']) && function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {
return ctools_context_create_empty('entity:' . $to_entity, NULL);
}
else {
@@ -0,0 +1,70 @@
<?php
/**
* @file
* Plugin to provide an relationship handler for entities from query string.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('Entity from query string'),
'keyword' => 'query_string_entity',
'description' => t('Entity from query string.'),
'required context' => new ctools_context_required(t('Query string'), 'query_string'),
'context' => 'ctools_entity_from_query_string_context',
'edit form' => 'ctools_entity_from_query_string_settings_form',
);
/**
* Return a new context based on an existing context.
*/
function ctools_entity_from_query_string_context($context, $conf) {
$entity_type = $conf['entity_type'];
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || !isset($context->data) || !is_numeric($context->data)) {
return ctools_context_create_empty('entity:' . $entity_type, NULL);
}
if (!empty($context->data) && is_numeric($context->data)) {
// Load the entity from the query string value.
$entity_id = $context->data;
$entity = entity_load_single($entity_type, $entity_id);
// Send it to ctools.
return ctools_context_create('entity:' . $entity_type, $entity);
}
}
/**
* Settings form for the relationship.
*/
function ctools_entity_from_query_string_settings_form($form, &$form_state) {
//Get all avalible enity types
foreach (entity_get_info() as $key => $value) {
$entity_types[$key] = $value['label'];
}
$form['entity_type'] = array(
'#title' => t('Entity type'),
'#description' => t('Choose entity type to load from query value'),
'#type' => 'select',
'#options' => $entity_types,
);
if (isset($form_state['conf']['entity_type'])) {
$form['entity_type']['#default_value'] = $form_state['conf']['entity_type'];
}
return $form;
}
/**
* Submit handler; settings form for the context.
*/
function ctools_entity_from_query_string_settings_form_submit($form, &$form_state) {
$form_state['conf']['entity_type'] = $form_state['values']['entity_type'];
}
@@ -15,6 +15,8 @@ $plugin = array(
'description' => t('Adds user category edit form from a user context.'),
'required context' => new ctools_context_required(t('User'), 'user'),
'context' => 'ctools_user_category_edit_form_from_user_context',
'edit form' => 'ctools_user_category_edit_form_from_user_settings_form',
'defaults' => array('category' => NULL),
);
/**
@@ -25,7 +27,35 @@ function ctools_user_category_edit_form_from_user_context($context, $conf) {
return ctools_context_create_empty('user_edit_form', NULL);
}
if(!empty($conf['category'])) {
return ctools_context_create('user_edit_form', $context->data, array('category' => $conf['category']));
}
if (isset($context->data->user_category)) {
return ctools_context_create('user_edit_form', $context->data, array('category' => $context->data->user_category));
}
return ctools_context_create('user_edit_form', $context->data);
}
/**
* Settings form for the relationship.
*/
function ctools_user_category_edit_form_from_user_settings_form($form, &$form_state) {
$conf = $form_state['conf'];
$categories = _user_categories();
$options = array();
foreach($categories as $category) {
$options[$category['name']] = $category['title'];
}
$form['category'] = array(
'#type' => 'select',
'#title' => t('Category'),
'#options' => $options,
'#default_value' => isset($conf['category']) ? $conf['category'] : NULL,
'#empty_option' => 'Default',
);
return $form;
}
@@ -6,9 +6,9 @@ version = CTOOLS_MODULE_VERSION
dependencies[] = ctools
dependencies[] = color
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -25,28 +25,22 @@ $plugin = array(
* Settings form for the 'term depth' access plugin.
*/
function term_depth_term_depth_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
if (empty($conf)) {
$conf = array(
'vid' => 0,
);
}
if (!isset($conf['vid'])) {
$conf['vid'] = 0;
}
$vocabularies = taxonomy_get_vocabularies();
$options = array();
// Loop over each of the configured vocabularies.
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
$options[$vid] = $vocabulary->name;
foreach ($vocabularies as $vid => $vocab) {
$options[$vocab->machine_name] = $vocab->name;
}
$form['settings']['vid'] = array(
_term_depth_convert_config_vid_to_vocabulary_name($conf);
$form['settings']['vocabulary'] = array(
'#title' => t('Vocabulary'),
'#type' => 'select',
'#options' => $options,
'#description' => t('Select the vocabulary for this form. If there exists a parent term in that vocabulary, this access check will succeed.'),
'#id' => 'ctools-select-vid',
'#default_value' => $conf['vid'],
'#id' => 'ctools-select-vocabulary',
'#default_value' => !empty($conf['vocabulary']) ? $conf['vocabulary'] : array(),
'#required' => TRUE,
);
@@ -61,15 +55,24 @@ function term_depth_term_depth_ctools_access_settings($form, &$form_state, $conf
return $form;
}
/**
* @param $conf
*/
function _term_depth_convert_config_vid_to_vocabulary_name(&$conf) {
// Fallback on legacy 'vid', when no vocabularies are available.
if (empty($conf['vocabulary']) && !empty($conf['vid'])) {
$conf['vocabulary'] = reset(_ctools_term_vocabulary_machine_name_convert(array($conf['vid'])));
unset($conf['vid']);
}
}
/**
* Submit function for the access plugins settings.
*
* We cast all settings to numbers to ensure they can be safely handled.
*/
function term_depth_term_depth_ctools_access_settings_submit($form, $form_state) {
foreach (array('depth', 'vid') as $key) {
$form_state['conf'][$key] = (integer) $form_state['values']['settings'][$key];
}
$form_state['conf']['depth'] = (integer) $form_state['values']['settings']['depth'];
$form_state['conf']['vocabulary'] = array_filter($form_state['conf']['vocabulary']);
}
/**
@@ -82,10 +85,17 @@ function term_depth_term_depth_ctools_access_check($conf, $context) {
return FALSE;
}
// Get the $vid.
if (!isset($conf['vid'])) {
_term_depth_convert_config_vid_to_vocabulary_name($conf);
// Get the $vocabulary.
if (!isset($conf['vocabulary'])) {
return FALSE;
}
$vocab = taxonomy_vocabulary_machine_name_load($conf['vocabulary']);
if ($vocab->vid != $context->data->vid) {
return FALSE;
}
$depth = _term_depth($context->data->tid);
return ($depth == $conf['depth']);
@@ -95,9 +105,9 @@ function term_depth_term_depth_ctools_access_check($conf, $context) {
* Provide a summary description based upon the checked terms.
*/
function term_depth_term_depth_ctools_access_summary($conf, $context) {
$vocab = taxonomy_vocabulary_load($conf['vid']);
return t('"@term" has parent in vocabulary "@vocab" at @depth', array(
_term_depth_convert_config_vid_to_vocabulary_name($conf);
$vocab = taxonomy_vocabulary_machine_name_load($conf['vocabulary']);
return t('"@term" is in vocabulary "@vocab" at depth @depth', array(
'@term' => $context->identifier,
'@vocab' => $vocab->name,
'@depth' => $conf['depth'],
@@ -5,9 +5,9 @@ dependencies[] = ctools
package = Chaos tool suite
version = CTOOLS_MODULE_VERSION
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -5,7 +5,7 @@ class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase {
return array(
'name' => 'Keywords substitution',
'description' => 'Verify that keywords are properly replaced with data.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -51,6 +51,30 @@ class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase {
"%{$node->title}",
t('Keyword after escaped and unescaped percent sign has been replaced.'),
),
'%%foo:bar' => array(
"%foo:bar",
t('Non-existant context ignored.'),
),
'There was about 20%-30% difference in price.' => array(
'There was about 20%-30% difference in price.',
t('Non-keyword percent sign left untouched.'),
),
'href="my%20file%2dname.pdf"' => array(
'href="my%20file%2dname.pdf"',
t('HTTP URL escape left untouched.'),
),
'href="my%a0file%fdname.pdf"' => array(
'href="my%a0file%fdname.pdf"',
t('HTTP URL escape (high-chars) left untouched.'),
),
'<a href="http://www.example.com/here%20is%20a%20pdf.pdf">Click here!</a>' => array(
'<a href="http://www.example.com/here%20is%20a%20pdf.pdf">Click here!</a>',
t('HTTP URL escape percent sign left untouched in HTML.'),
),
'SELECT * FROM {table} WHERE field = "%s"' => array(
'SELECT * FROM {table} WHERE field = "%s"',
t('SQL percent sign left untouched.'),
),
);
foreach ($checks as $string => $expectations) {
list($expected_result, $message) = $expectations;
@@ -12,7 +12,7 @@ class CtoolsCssTestCase extends DrupalWebTestCase {
return array(
'name' => 'CSS Tools tests',
'description' => '...',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -16,7 +16,7 @@ class CtoolsObjectCache extends DrupalWebTestCase {
return array(
'name' => 'Ctools CSS cache',
'description' => 'Tests the custom CSS cache handler.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -12,7 +12,7 @@ class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase {
return array(
'name' => 'Get plugin info',
'description' => 'Verify that plugin type definitions can properly set and overide values.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -14,7 +14,7 @@ class CtoolsExportCrudTestCase extends DrupalWebTestCase {
return array(
'name' => 'CTools export CRUD tests',
'description' => 'Test the CRUD functionality for the ctools export system.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -8,9 +8,9 @@ hidden = TRUE
files[] = ctools_export.test
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -12,9 +12,9 @@ files[] = math_expression.test
files[] = math_expression_stack.test
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -13,7 +13,7 @@ class CtoolsMathExpressionTestCase extends DrupalWebTestCase {
return array(
'name' => 'CTools math expression tests',
'description' => 'Test the math expression library of ctools.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -13,7 +13,7 @@ class CtoolsMathExpressionStackTestCase extends DrupalWebTestCase {
return array(
'name' => 'CTools math expression stack tests',
'description' => 'Test the stack class of the math expression library.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -12,7 +12,7 @@ class CtoolsObjectCache extends DrupalWebTestCase {
return array(
'name' => 'Ctools object cache storage',
'description' => 'Verify that objects are written, readable and lockable.',
'group' => 'Chaos Tools Suite',
'group' => 'ctools',
);
}
@@ -1,7 +1,7 @@
<?php
/**
* @file
* A cached plugin object that tests inheritence including.
* A cached plugin object that tests inheritance including.
*/
class ctoolsCachedPluginArray {}
@@ -1,7 +1,7 @@
<?php
/**
* @file
* A cached plugin object that tests inheritence including.
* A cached plugin object that tests inheritance including.
*/
class ctoolsCachedPluginArray2 extends ctoolsCachedPluginArray {}
@@ -1,7 +1,7 @@
<?php
/**
* @file
* A cached plugin object that tests inheritence including.
* A cached plugin object that tests inheritance including.
*/
class ctoolsNotCachedPluginArray extends ctoolsNotCachedPluginArray2 {}
@@ -143,68 +143,11 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
return;
}
$conf['pane_contexts'] = $contexts;
$conf['panel_args'] = $panel_args;
$view->display_handler->set_pane_conf($conf);
$args = array();
$arguments = $view->display_handler->get_option('arguments');
$context_keys = isset($conf['context']) ? $conf['context'] : array();
foreach ($view->display_handler->get_argument_input() as $id => $argument) {
switch ($argument['type']) {
case 'context':
$key = array_shift($context_keys);
if (isset($contexts[$key])) {
if (strpos($argument['context'], '.')) {
list($context, $converter) = explode('.', $argument['context'], 2);
$args[] = ctools_context_convert_context($contexts[$key], $converter, array('sanitize' => FALSE));
}
else {
$args[] = $contexts[$key]->argument;
}
}
else {
$args[] = isset($arguments[$id]['exception']['value']) ? $arguments[$id]['exception']['value'] : 'all';
}
break;
case 'fixed':
$args[] = $argument['fixed'];
break;
case 'panel':
$args[] = isset($panel_args[$argument['panel']]) ? $panel_args[$argument['panel']] : NULL;
break;
case 'user':
$args[] = (isset($conf['arguments'][$id]) && $conf['arguments'][$id] !== '') ? ctools_context_keyword_substitute($conf['arguments'][$id], array(), $contexts) : NULL;
break;
case 'wildcard':
// Put in the wildcard.
$args[] = isset($arguments[$id]['wildcard']) ? $arguments[$id]['wildcard'] : '*';
break;
case 'none':
default:
// Put in NULL.
// views.module knows what to do with NULL (or missing) arguments
$args[] = NULL;
break;
}
}
// remove any trailing NULL arguments as these are non-args:
while (count($args) && end($args) === NULL) {
array_pop($args);
}
$view->set_arguments($args);
$allow = $view->display_handler->get_option('allow');
if (!empty($conf['path'])) {
$conf['path'] = ctools_context_keyword_substitute($conf['path'], array(), $contexts);
}
if ($allow['path_override'] && !empty($conf['path'])) {
$view->override_path = $conf['path'];
}
@@ -221,67 +164,6 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
$block->title_link = $view->get_url();
}
// more link
if ($allow['more_link']) {
if (empty($conf['more_link'])) {
$view->display_handler->set_option('use_more', FALSE);
}
else {
$view->display_handler->set_option('use_more', TRUE);
// make sure the view runs the count query so we know whether or not the
// more link applies.
$view->get_total_rows = TRUE;
}
}
if ($allow['items_per_page'] && isset($conf['items_per_page'])) {
$view->set_items_per_page($conf['items_per_page']);
}
if ($allow['offset']) {
$view->set_offset($conf['offset']);
}
if ($allow['use_pager']) {
// Only set use_pager if they differ, this way we can avoid overwriting the
// pager type that Views uses.
$pager = $view->display_handler->get_option('pager');
if ($conf['use_pager'] && ($pager['type'] == 'none' || $pager['type'] == 'some')) {
$pager['type'] = 'full';
}
elseif (!$conf['use_pager'] && $pager['type'] != 'none' && $pager['type'] != 'some') {
$pager['type'] = $view->get_items_per_page() || !empty($pager['options']['items_per_page']) ? 'some' : 'none';
}
if ($conf['use_pager']) {
if (!isset($pager['options']['id']) || (isset($conf['pager_id']) && $pager['options']['id'] != $conf['pager_id'])) {
$pager['options']['id'] = (int) $conf['pager_id'];
}
}
$view->display_handler->set_option('pager', $pager);
}
if ($allow['fields_override']) {
if ($conf['fields_override']) {
$fields = $view->get_items('field');
foreach ($fields as $field => $display) {
$fields[$field]['exclude'] = empty($conf['fields_override'][$field]);
}
$view->display_handler->set_option('fields', $fields);
}
}
if ($allow['exposed_form'] && !empty($conf['exposed'])) {
foreach ($conf['exposed'] as $filter_name => $filter_value) {
if (!is_array($filter_value)) {
$conf['exposed'][$filter_name] = ctools_context_keyword_substitute($filter_value, array(), $contexts);
}
}
$view->set_exposed_input($conf['exposed']);
}
$stored_feeds = drupal_add_feed();
$block->content = $view->preview();
@@ -321,6 +203,10 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a
function views_content_views_panes_add_defaults(&$conf, $view) {
$pager = $view->display_handler->get_option('pager');
if (empty($conf)) {
$conf = array();
}
$conf += array(
'link_to_view' => $view->display_handler->get_option('link_to_view'),
'more_link' => $view->display_handler->get_option('use_more'),
@@ -25,7 +25,7 @@ function views_content_views_plugins() {
'use more' => TRUE,
'accept attachments' => TRUE,
'help topic' => 'display-pane',
'contextual links locations' => array('panel_pane'),
'contextual links locations' => array('panel_pane', 'view'),
),
'ctools_context' => array(
'title' => t('Context'),
@@ -48,8 +48,12 @@ class views_content_plugin_display_panel_pane extends views_plugin_display {
return isset($this->has_pane_conf);
}
function set_pane_conf($conf = array()) {
function set_pane_conf($conf = array(), $set_cache = TRUE) {
$this->set_option('pane_conf', $conf);
$this->view->dom_id = !empty($this->view->dom_id) ? $this->view->dom_id : md5($this->view->name . REQUEST_TIME . rand());
if ($set_cache) {
cache_set('view_panel_pane_' . $this->view->dom_id, $conf);
}
$this->has_pane_conf = TRUE;
}
@@ -412,5 +416,153 @@ class views_content_plugin_display_panel_pane extends views_plugin_display {
return empty($conf['exposed_form']);
}
/**
* Set the pane configuration options
* Done here in handler for reuse between views_content_views_panes_content_type_render
* and views_content_views_pre_view
*/
function pane_process_conf() {
ctools_include('context');
$conf = $this->get_option('pane_conf');
if (!$conf) {
// See if dom id has been cached and get conf from there.
if (!empty($this->view->dom_id) && ($cache = cache_get('view_panel_pane_' . $this->view->dom_id))) {
$conf = $cache->data;
}
if (!$conf) {
return;
}
$this->set_pane_conf($conf);
}
$contexts = $conf['pane_contexts'];
$panel_args = $conf['panel_args'];
$args = array();
$arguments = $this->get_option('arguments');
$context_keys = isset($conf['context']) ? $conf['context'] : array();
foreach ($this->get_argument_input() as $id => $argument) {
switch ($argument['type']) {
case 'context':
$key = array_shift($context_keys);
if (isset($contexts[$key])) {
if (strpos($argument['context'], '.')) {
list($context, $converter) = explode('.', $argument['context'], 2);
$args[] = ctools_context_convert_context($contexts[$key], $converter, array('sanitize' => FALSE));
}
else {
$args[] = $contexts[$key]->argument;
}
}
else {
$args[] = isset($arguments[$id]['exception']['value']) ? $arguments[$id]['exception']['value'] : 'all';
}
break;
case 'fixed':
$args[] = $argument['fixed'];
break;
case 'panel':
$args[] = isset($panel_args[$argument['panel']]) ? $panel_args[$argument['panel']] : NULL;
break;
case 'user':
$args[] = (isset($conf['arguments'][$id]) && $conf['arguments'][$id] !== '') ? ctools_context_keyword_substitute($conf['arguments'][$id], array(), $contexts) : NULL;
break;
case 'wildcard':
// Put in the wildcard.
$args[] = isset($arguments[$id]['wildcard']) ? $arguments[$id]['wildcard'] : '*';
break;
case 'none':
default:
// Put in NULL.
// views.module knows what to do with NULL (or missing) arguments
$args[] = NULL;
break;
}
}
// remove any trailing NULL arguments as these are non-args:
while (count($args) && end($args) === NULL) {
array_pop($args);
}
$this->view->set_arguments($args);
$allow = $this->get_option('allow');
if (!empty($conf['path'])) {
$conf['path'] = ctools_context_keyword_substitute($conf['path'], array(), $contexts);
}
if ($allow['path_override'] && !empty($conf['path'])) {
$this->view->override_path = $conf['path'];
}
else if ($path = $this->get_option('inherit_panels_path')) {
$this->view->override_path = $_GET['q'];
}
// more link
if ($allow['more_link']) {
if (empty($conf['more_link'])) {
$this->set_option('use_more', FALSE);
}
else {
$this->set_option('use_more', TRUE);
// make sure the view runs the count query so we know whether or not the
// more link applies.
$this->view->get_total_rows = TRUE;
}
}
if ($allow['items_per_page'] && isset($conf['items_per_page'])) {
$this->view->set_items_per_page($conf['items_per_page']);
}
if ($allow['offset']) {
$this->view->set_offset($conf['offset']);
}
if ($allow['use_pager']) {
// Only set use_pager if they differ, this way we can avoid overwriting the
// pager type that Views uses.
$pager = $this->get_option('pager');
if ($conf['use_pager'] && ($pager['type'] == 'none' || $pager['type'] == 'some')) {
$pager['type'] = 'full';
}
elseif (!$conf['use_pager'] && $pager['type'] != 'none' && $pager['type'] != 'some') {
$pager['type'] = $this->view->get_items_per_page() || !empty($pager['options']['items_per_page']) ? 'some' : 'none';
}
if ($conf['use_pager']) {
if (!isset($pager['options']['id']) || (isset($conf['pager_id']) && $pager['options']['id'] != $conf['pager_id'])) {
$pager['options']['id'] = (int) $conf['pager_id'];
}
}
$this->set_option('pager', $pager);
}
if ($allow['fields_override']) {
if ($conf['fields_override']) {
$fields = $this->view->get_items('field');
foreach ($fields as $field => $field_display) {
$fields[$field]['exclude'] = empty($conf['fields_override'][$field]);
}
$this->set_option('fields', $fields);
}
}
if ($allow['exposed_form'] && !empty($conf['exposed'])) {
foreach ($conf['exposed'] as $filter_name => $filter_value) {
if (!is_array($filter_value)) {
$conf['exposed'][$filter_name] = ctools_context_keyword_substitute($filter_value, array(), $contexts);
}
}
$this->view->set_exposed_input($conf['exposed']);
}
}
}
@@ -10,9 +10,9 @@ files[] = plugins/views/views_content_plugin_display_ctools_context.inc
files[] = plugins/views/views_content_plugin_display_panel_pane.inc
files[] = plugins/views/views_content_plugin_style_ctools_context.inc
; Information added by Drupal.org packaging script on 2015-01-28
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-11-22
version = "7.x-1.12"
core = "7.x"
project = "ctools"
datestamp = "1422471484"
datestamp = "1479787162"
@@ -295,3 +295,24 @@ function views_content_get_pane_links_alter(&$links, $pane, $content_type) {
);
}
}
/**
* Implements hook_module_implements_alter()
*/
function views_content_module_implements_alter(&$implementations, $hook) {
if ($hook == 'views_pre_view') {
$group = $implementations['views_content'];
unset($implementations['views_content']);
$implementations = array('views_content' => $group) + $implementations;
}
}
/**
* Implements hook_views_pre_view()
*/
function views_content_views_pre_view(&$view) {
if (method_exists($view->display_handler, 'pane_process_conf')) {
// process the pane configuration to prevent loss when using ajax
$view->display_handler->pane_process_conf();
}
}