From 547569b701510eb8f05cda543fd6865ab13ddd69 Mon Sep 17 00:00:00 2001 From: Eric Rasmussen <eric@unl.edu> Date: Mon, 19 Dec 2011 15:34:26 +0000 Subject: [PATCH] [gh-270] Merging test into staging -c1327 git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1353 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/ctools/API.txt | 3 +- .../ctools/bulk_export/bulk_export.info | 6 +- sites/all/modules/ctools/ctools.api.php | 15 ++++ sites/all/modules/ctools/ctools.info | 6 +- sites/all/modules/ctools/ctools.module | 2 +- .../ctools_access_ruleset.info | 6 +- .../css/ctools-ajax-sample.css | 8 +- .../ctools_ajax_sample.info | 6 +- .../ctools_ajax_sample.module | 5 +- .../ctools_custom_content.info | 6 +- .../ctools_plugin_example.info | 6 +- sites/all/modules/ctools/help/export.html | 27 ++++++- sites/all/modules/ctools/includes/cache.inc | 2 +- .../ctools/includes/context-task-handler.inc | 74 ++++++++++++------- .../all/modules/ctools/includes/dependent.inc | 2 +- .../all/modules/ctools/includes/export-ui.inc | 3 +- sites/all/modules/ctools/includes/export.inc | 7 +- sites/all/modules/ctools/includes/fields.inc | 3 + .../all/modules/ctools/includes/jump-menu.inc | 12 ++- .../all/modules/ctools/includes/math-expr.inc | 4 +- sites/all/modules/ctools/includes/plugins.inc | 2 +- sites/all/modules/ctools/js/ajax-responder.js | 2 +- sites/all/modules/ctools/js/auto-submit.js | 2 +- sites/all/modules/ctools/js/dependent.js | 21 +++++- sites/all/modules/ctools/js/jump-menu.js | 12 ++- sites/all/modules/ctools/js/modal.js | 3 + .../ctools/page_manager/page_manager.info | 6 +- .../page_manager/plugins/tasks/page.inc | 1 - .../ctools/plugins/access/entity_bundle.inc | 2 +- .../modules/ctools/plugins/arguments/term.inc | 1 + .../modules/ctools/plugins/arguments/uid.inc | 2 +- .../content_types/contact/user_contact.inc | 2 +- .../plugins/content_types/custom/custom.inc | 13 +++- .../entity_context/entity_field.inc | 2 +- .../content_types/node_context/node_terms.inc | 12 +-- .../content_types/search/search_result.inc | 13 ++-- .../user_context/user_picture.inc | 17 +++-- .../ctools/plugins/contexts/entity.inc | 11 +-- .../ctools/plugins/contexts/node_add_form.inc | 35 ++++++--- .../plugins/contexts/node_edit_form.inc | 11 ++- .../modules/ctools/plugins/contexts/terms.inc | 3 +- .../export_ui/ctools_export_ui.class.php | 10 ++- .../relationships/entity_from_field.inc | 51 +++++++++++-- .../plugins/relationships/term_from_node.inc | 2 +- .../plugins/relationships/terms_from_node.inc | 27 ++++--- .../all/modules/ctools/stylizer/stylizer.info | 6 +- .../modules/ctools/stylizer/stylizer.install | 6 ++ .../ctools/tests/ctools_plugin_test.info | 6 +- .../plugins/content_types/views.inc | 2 + .../plugins/content_types/views_row.inc | 6 +- .../plugins/relationships/node_from_view.inc | 4 +- .../plugins/relationships/term_from_view.inc | 4 +- .../plugins/relationships/user_from_view.inc | 4 +- ...iews_content_plugin_display_panel_pane.inc | 5 ++ ...ws_content_plugin_style_ctools_context.inc | 11 --- .../ctools/views_content/views_content.info | 6 +- 56 files changed, 363 insertions(+), 163 deletions(-) diff --git a/sites/all/modules/ctools/API.txt b/sites/all/modules/ctools/API.txt index 29000a48b..fe208a8e9 100644 --- a/sites/all/modules/ctools/API.txt +++ b/sites/all/modules/ctools/API.txt @@ -9,7 +9,8 @@ API Version 2.0.1 ctools_export_crud_set_status() and requisite changes. Introduce 'object factory' to export schema, allowing modules to control how the exportable objects are instantiated. - + Introduce 'hook_ctools_math_expression_functions_alter'. + API Version 2.0 Remove the deprecated callback-based behavior of the 'defaults' property on plugin types; array addition is now the only option. If you need more diff --git a/sites/all/modules/ctools/bulk_export/bulk_export.info b/sites/all/modules/ctools/bulk_export/bulk_export.info index 7e17fd735..f01bb3704 100644 --- a/sites/all/modules/ctools/bulk_export/bulk_export.info +++ b/sites/all/modules/ctools/bulk_export/bulk_export.info @@ -4,9 +4,9 @@ core = 7.x dependencies[] = ctools package = Chaos tool suite -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/ctools.api.php b/sites/all/modules/ctools/ctools.api.php index 8e74d06b0..b6a3cd920 100644 --- a/sites/all/modules/ctools/ctools.api.php +++ b/sites/all/modules/ctools/ctools.api.php @@ -117,6 +117,21 @@ function hook_ctools_plugin_post_alter(&$plugin, &$info) { } } + +/** + * Alter the available functions to be used in ctools math expression api. + * + * One usecase would be to create your own function in your module and + * allow to use it in the math expression api. + * + * @param $functions + * An array which has the functions as value. + */ +function hook_ctools_math_expression_functions_alter(&$functions) { + // Allow to convert from degrees to radiant. + $functions[] = 'deg2rad'; +} + /** * @} End of "addtogroup hooks". */ diff --git a/sites/all/modules/ctools/ctools.info b/sites/all/modules/ctools/ctools.info index 08b788775..4d3007b24 100644 --- a/sites/all/modules/ctools/ctools.info +++ b/sites/all/modules/ctools/ctools.info @@ -6,9 +6,9 @@ files[] = includes/context.inc files[] = includes/math-expr.inc files[] = includes/stylizer.inc -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/ctools.module b/sites/all/modules/ctools/ctools.module index 7b7499eec..01156f9b7 100644 --- a/sites/all/modules/ctools/ctools.module +++ b/sites/all/modules/ctools/ctools.module @@ -760,7 +760,7 @@ function ctools_block_list_alter(&$blocks) { foreach ($blocks as $block_id => $block) { // @todo -- possibly we can set configuration for this so that users can // specify which blocks will not get rendered. - if (substr_compare($block->region, 'sidebar', 0) >= 0) { + if (strpos($block->region, 'sidebar') !== FALSE) { unset($blocks[$block_id]); } } diff --git a/sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info index b1af3988b..c73784f5f 100644 --- a/sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info +++ b/sites/all/modules/ctools/ctools_access_ruleset/ctools_access_ruleset.info @@ -4,9 +4,9 @@ core = 7.x package = Chaos tool suite dependencies[] = ctools -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css b/sites/all/modules/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css index dc83b0b0f..8df17de5f 100644 --- a/sites/all/modules/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css +++ b/sites/all/modules/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css @@ -47,6 +47,7 @@ div.ctools-sample-modal-content .popups-box tr { div.ctools-sample-modal-content td.popups-border { background: url(../images/popups-border.png); background-color:transparent; + border: none; } div.ctools-sample-modal-content td.popups-tl, div.ctools-sample-modal-content td.popups-tr, @@ -61,9 +62,8 @@ div.ctools-sample-modal-content td.popups-t, div.ctools-sample-modal-content td.popups-b { background-position: 0px -40px; background-repeat: repeat-x; - height:10px; } -div.ctools-sample-modal-content td.popups-tr { background-position: 0px -10px; } +div.ctools-sample-modal-content td.popups-tr { background-position: 0px -10px; width: 10px; } div.ctools-sample-modal-content td.popups-cl, div.ctools-sample-modal-content td.popups-cr { background-position: -10px 0; @@ -72,10 +72,10 @@ div.ctools-sample-modal-content td.popups-cr { } div.ctools-sample-modal-content td.popups-cl, div.ctools-sample-modal-content td.popups-cr, -div.ctools-sample-modal-content td.popups-c { padding:0; } +div.ctools-sample-modal-content td.popups-c { padding:0; border: none; } div.ctools-sample-modal-content td.popups-c { background:#fff; } div.ctools-sample-modal-content td.popups-bl { background-position: 0px -20px; } -div.ctools-sample-modal-content td.popups-br { background-position: 0px -30px; } +div.ctools-sample-modal-content td.popups-br { background-position: 0px -30px; width: 10px; } div.ctools-sample-modal-content .popups-box, div.ctools-sample-modal-content #popups-loading { diff --git a/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info b/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info index 1f1159be3..6ae890784 100644 --- a/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info +++ b/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.info @@ -4,9 +4,9 @@ package = Chaos tool suite dependencies[] = ctools core = 7.x -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module b/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module index 463e4a806..2a30c2a56 100644 --- a/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module +++ b/sites/all/modules/ctools/ctools_ajax_sample/ctools_ajax_sample.module @@ -561,6 +561,7 @@ function ctools_ajax_sample_start($form, &$form_state) { '#default_value' => $form_state['object']->type, '#required' => TRUE, ); + return $form; } @@ -738,8 +739,10 @@ function ctools_ajax_sample_ajax_button_form() { $form['url'] = array( '#type' => 'hidden', + // The name of the class is the #id of $form['ajax_button'] with "-url" + // suffix. '#attributes' => array('class' => array('ctools-ajax-sample-button-url')), - '#value' => 'ctools_ajax_sample/nojs/animal', + '#value' => url('ctools_ajax_sample/nojs/animal'), ); $form['ajax_button'] = array( diff --git a/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info b/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info index 09e989876..53a21eeab 100644 --- a/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info +++ b/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.info @@ -4,9 +4,9 @@ core = 7.x package = Chaos tool suite dependencies[] = ctools -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info b/sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info index b6ba31ede..7ce5305c2 100644 --- a/sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info +++ b/sites/all/modules/ctools/ctools_plugin_example/ctools_plugin_example.info @@ -7,9 +7,9 @@ dependencies[] = page_manager dependencies[] = advanced_help core = 7.x -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/help/export.html b/sites/all/modules/ctools/help/export.html index 350190296..234ef1527 100644 --- a/sites/all/modules/ctools/help/export.html +++ b/sites/all/modules/ctools/help/export.html @@ -117,6 +117,12 @@ function mymodule_schema() { <dt>object factory</dt> <dd>Function used to create the object. The function receives the schema and the loaded data as a parameters: your_factory_function($schema, $data). If this is set, 'object' has no effect since you can use your function to create whatever class you wish.</dd> +<dt>admin_title</dt> +<dd>A convenience field that may contain the field which represents the human readable administrative title for use in export UI. If a field "admin_title" exists, it will automatically be used.</dd> + +<dt>admin_description</dt> +<dd>A convenience field that may contain the field which represents the human readable administrative title for use in export UI. If a field "admin_title" exists, it will automatically be used.</dd> + <dt>can disable</dt> <dd>Control whether or not the exportable objects can be disabled. All this does is cause the 'disabled' field on the object to always be set appropriately, and a variable is kept to record the state. Changes made to this state must be handled by the owner of the object. Defaults to TRUE.</dd> @@ -146,7 +152,7 @@ function mymodule_schema() { <dt>to hook code callback</dt> <dd>Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'.</dt> -</dl> + <dt>create callback</dt> <dd>CRUD callback to use to create a new exportable item in memory. If not provided, the default function will be used. The single argument is a boolean used to determine if defaults should be set on the object. This object will not be written to the database by this callback.</dd> @@ -172,6 +178,25 @@ function mymodule_schema() { <dt>status callback</dt> <dd>CRUD callback to use for updating the status of an object. If the status is TRUE the object will be disabled. If the status is FALSE the object will be enabled.</dd> +<dt>api</dt> +<dd>The 'api' key can optionally contain some information for the plugin API definition. This means that the imports can be tied to an API name which is used to have automatic inclusion of files, and can be used to prevent dangerous objects from older versions from being loaded, causing a loss of functionality rather than site crashes or security loopholes. + +If not present, no additional files will be loaded and the default hook will always be a simple hook that must be either part of the .module file or loaded during normal operations. + +api supports these subkeys: +<dl> +<dt>owner</dt> +<dd>The module that owns the API. Typically this is the name of the module that owns the schema. This will be one of the two keys used by hook_ctools_plugin_api() to determine version compatibility. Note that the name of this hook can be tailored via the use of hook_ctools_plugin_api_hook_name(). See ctools_plugin_api_get_hook() for details.</dd> +<dt>api</dt> +<dd>This is the name of the API, and will be the second parameter to the above mentioned hook. It will also be used as part of the name of the file that the hook containing default objects will be in, which comes in the form of MODULENAME.API.inc.</dd> +<dt>minimum_version</dt> +<dd>The minimum version supported. Any module reporting an API less than this will not have its default objects used. This should be updated only when API changes can cause older objects to crash or otherwise break badly.</dd> +<dt>current_version</dt> +<dd>The current version of the API. Any module reporting a required API higher than this will not have its default objects used.</dd> +</dl> +</dd> + +</dl> In addition, each field can contain the following: <dl> <dt>no export</dt> diff --git a/sites/all/modules/ctools/includes/cache.inc b/sites/all/modules/ctools/includes/cache.inc index ca6e6f34d..3918683b0 100644 --- a/sites/all/modules/ctools/includes/cache.inc +++ b/sites/all/modules/ctools/includes/cache.inc @@ -93,7 +93,7 @@ function ctools_cache_set($mechanism, $key, $object) { * The key used to identify the cache. */ function ctools_cache_clear($mechanism, $key) { - return ctools_cache_operation($mechanism, $key, 'clear', $object); + return ctools_cache_operation($mechanism, $key, 'clear'); } diff --git a/sites/all/modules/ctools/includes/context-task-handler.inc b/sites/all/modules/ctools/includes/context-task-handler.inc index e1f786172..a1d9cd4ec 100644 --- a/sites/all/modules/ctools/includes/context-task-handler.inc +++ b/sites/all/modules/ctools/includes/context-task-handler.inc @@ -160,6 +160,53 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte } } + $plugin = page_manager_get_task_handler($handler->handler); + + if (module_exists('contextual') && user_access('access contextual links') && user_access('administer page manager') && isset($handler->task)) { + // Provide a tab to edit this context: + ctools_include('menu'); + $task = page_manager_get_task($handler->task); + + $title = !empty($task['tab title']) ? $task['tab title'] : t('Edit @type', array('@type' => $plugin['title'])); + $trail = array(); + if (!empty($plugin['tab operation'])) { + if (is_array($plugin['tab operation'])) { + $trail = $plugin['tab operation']; + } + else if (function_exists($plugin['tab operation'])) { + $trail = $plugin['tab operation']($handler, $contexts, $args); + } + } + + $build = array( + '#theme_wrappers' => array('container'), + '#attributes' => array('class' => array('contextual-links-region')), + ); + + if (!is_array($info['content'])) { + $build['content']['#markup'] = $info['content']; + } + else { + $build['content'] = $info['content']; + } + + $path = page_manager_edit_url(page_manager_make_task_name($handler->task, $handler->subtask), $trail); + $build['contextual_links'] = array( + '#prefix' => '<div class="contextual-links-wrapper">', + '#suffix' => '</div>', + '#theme' => 'links__contextual', + '#links' => array(array( + 'href' => $path, + 'title' => $title, + )), + '#attributes' => array('class' => array('contextual-links')), + '#attached' => array( + 'library' => array(array('contextual', 'contextual-links')), + ), + ); + $info['content'] = drupal_render($build); + } + foreach (ctools_context_handler_get_task_arguments($task, $subtask) as $id => $argument) { $plugin = ctools_get_argument($argument['name']); $cid = ctools_context_id($argument, 'argument'); @@ -182,32 +229,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte /** * Called to execute actions that should happen before a handler is rendered. */ -function ctools_context_handler_pre_render($handler, $contexts, $args) { - $plugin = page_manager_get_task_handler($handler->handler); - - if (user_access('administer page manager') && isset($handler->task)) { - // Provide a tab to edit this context: - ctools_include('menu'); - $task = page_manager_get_task($handler->task); - - $title = !empty($task['tab title']) ? $task['tab title'] : t('Edit @type', array('@type' => $plugin['title'])); - $trail = array(); - if (!empty($plugin['tab operation'])) { - if (is_array($plugin['tab operation'])) { - $trail = $plugin['tab operation']; - } - else if (function_exists($plugin['tab operation'])) { - $trail = $plugin['tab operation']($handler, $contexts, $args); - } - } - - ctools_menu_add_tab(array( - 'title' => $title, - 'href' => page_manager_edit_url(page_manager_make_task_name($handler->task, $handler->subtask), $trail), - 'type' => MENU_LOCAL_ACTION - )); - } -} +function ctools_context_handler_pre_render($handler, $contexts, $args) { } /** * Compare arguments to contexts for selection purposes. diff --git a/sites/all/modules/ctools/includes/dependent.inc b/sites/all/modules/ctools/includes/dependent.inc index e812cb977..74de91971 100644 --- a/sites/all/modules/ctools/includes/dependent.inc +++ b/sites/all/modules/ctools/includes/dependent.inc @@ -174,7 +174,7 @@ function ctools_dependent_pre_render($element) { * because you don't have to add #process. */ function ctools_dependent_element_info_alter(&$type) { - $form_elements = array('checkbox', 'checkboxes', 'fieldset', 'item', 'markup', 'radio', 'radios', 'select', 'textarea', 'textfield', 'text_format'); + $form_elements = array('checkbox', 'checkboxes', 'date', 'fieldset', 'item', 'machine_name', 'markup', 'radio', 'radios', 'select', 'textarea', 'textfield', 'text_format'); foreach ($form_elements as $element) { $type[$element]['#pre_render'][] = 'ctools_dependent_pre_render'; } diff --git a/sites/all/modules/ctools/includes/export-ui.inc b/sites/all/modules/ctools/includes/export-ui.inc index 2868ae8f5..455a3cc57 100644 --- a/sites/all/modules/ctools/includes/export-ui.inc +++ b/sites/all/modules/ctools/includes/export-ui.inc @@ -164,7 +164,8 @@ function ctools_export_ui_process(&$plugin, $info) { 'load arguments' => array($plugin['name']), 'access callback' => 'ctools_export_ui_task_access', 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'type' => MENU_CALLBACK, + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, ), ); diff --git a/sites/all/modules/ctools/includes/export.inc b/sites/all/modules/ctools/includes/export.inc index eebf7f576..66aa3b673 100644 --- a/sites/all/modules/ctools/includes/export.inc +++ b/sites/all/modules/ctools/includes/export.inc @@ -772,7 +772,12 @@ function _ctools_export_unpack_object($schema, $data, $object = 'stdClass') { // Go through our schema and build correlations. foreach ($schema['fields'] as $field => $info) { - $object->$field = empty($info['serialize']) ? $data->$field : unserialize($data->$field); + if (isset($data->$field)) { + $object->$field = empty($info['serialize']) ? $data->$field : unserialize($data->$field); + } + else { + $data->$field = NULL; + } } if (isset($schema['join'])) { diff --git a/sites/all/modules/ctools/includes/fields.inc b/sites/all/modules/ctools/includes/fields.inc index 1617d3acb..f4debb477 100644 --- a/sites/all/modules/ctools/includes/fields.inc +++ b/sites/all/modules/ctools/includes/fields.inc @@ -71,6 +71,9 @@ function ctools_fields_fake_field_instance($field_name, $view_mode = 'ctools', $ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type, &$form, $form_state, $view_mode = 'ctools') { $conf = $form_state['conf']; $formatter = field_info_formatter_types($formatter_type); + if (isset($formatter['settings'])) { + $conf['formatter_settings'] += $formatter['settings']; + } $function = $formatter['module'] . '_field_formatter_settings_form'; if (function_exists($function)) { $instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']); diff --git a/sites/all/modules/ctools/includes/jump-menu.inc b/sites/all/modules/ctools/includes/jump-menu.inc index f58672766..ac776ece4 100644 --- a/sites/all/modules/ctools/includes/jump-menu.inc +++ b/sites/all/modules/ctools/includes/jump-menu.inc @@ -116,7 +116,17 @@ function ctools_jump_menu($form, &$form_state, $select, $options = array()) { * This is normally only invoked upon submit without javascript enabled. */ function ctools_jump_menu_submit($form, &$form_state) { - $redirect = $form_state['values']['jump']; + // If the path we are redirecting to contains the string :: then treat the + // the string after the double colon as the path to redirect to. + // This allows duplicate paths to be used in jump menus for multiple options. + $redirect_array = explode("::", $form_state['values']['jump']); + + if(isset($redirect_array[1]) && !empty($redirect_array[1])){ + $redirect = $redirect_array[1]; + } + else { + $redirect = $form_state['values']['jump']; + } // If the path we are redirecting to starts with the base path (for example, // "/somepath/node/1"), we need to strip the base path off before passing it diff --git a/sites/all/modules/ctools/includes/math-expr.inc b/sites/all/modules/ctools/includes/math-expr.inc index 325d44400..b4b7fb730 100644 --- a/sites/all/modules/ctools/includes/math-expr.inc +++ b/sites/all/modules/ctools/includes/math-expr.inc @@ -95,12 +95,14 @@ class ctools_math_expr { 'sin','sinh','arcsin','asin','arcsinh','asinh', 'cos','cosh','arccos','acos','arccosh','acosh', 'tan','tanh','arctan','atan','arctanh','atanh', - 'sqrt','abs','ln','log'); + 'sqrt','abs','ln','log', + 'time', 'ceil', 'floor', 'min', 'max', 'round'); function ctools_math_expr() { // make the variables a little more accurate $this->v['pi'] = pi(); $this->v['e'] = exp(1); + drupal_alter('ctools_math_expression_functions', $this->fb); } function e($expr) { diff --git a/sites/all/modules/ctools/includes/plugins.inc b/sites/all/modules/ctools/includes/plugins.inc index f395dbc18..572d8a2d7 100644 --- a/sites/all/modules/ctools/includes/plugins.inc +++ b/sites/all/modules/ctools/includes/plugins.inc @@ -156,7 +156,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers require_once DRUPAL_ROOT . "/$plugin_info[path]/$file"; } else if (file_exists(DRUPAL_ROOT . "/$file")) { - require_once DRUPAL_ROOT . "/$plugin_info[path]/$file"; + require_once DRUPAL_ROOT . "/$file"; } $already_done[$owner][$api][$module] = TRUE; } diff --git a/sites/all/modules/ctools/js/ajax-responder.js b/sites/all/modules/ctools/js/ajax-responder.js index 61ddcf690..e244106fe 100644 --- a/sites/all/modules/ctools/js/ajax-responder.js +++ b/sites/all/modules/ctools/js/ajax-responder.js @@ -26,7 +26,7 @@ // Grab all the links that match this url and add the fetching class. // This allows the caching system to grab each url once and only once // instead of grabbing the url once per <a>. - var $objects = $('a[href=' + old_url + ']') + var $objects = $('a[href="' + old_url + '"]') $objects.addClass('ctools-fetching'); try { url = old_url.replace(/\/nojs(\/|$)/g, '/ajax$1'); diff --git a/sites/all/modules/ctools/js/auto-submit.js b/sites/all/modules/ctools/js/auto-submit.js index 4a80f79ee..f84db2371 100644 --- a/sites/all/modules/ctools/js/auto-submit.js +++ b/sites/all/modules/ctools/js/auto-submit.js @@ -31,7 +31,7 @@ Drupal.behaviors.CToolsAutoSubmit = { var timeoutID = 0; // Bind to any select widgets that will be auto submitted. - $('select.ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form select:not(.ctools-auto-submit-processed)') + $('select.ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form *[type!=input]:not(.ctools-auto-submit-processed)') .addClass('.ctools-auto-submit-processed') .change(function() { $(this.form).find('.ctools-auto-submit-click').click(); diff --git a/sites/all/modules/ctools/js/dependent.js b/sites/all/modules/ctools/js/dependent.js index 9ed0a3215..cca362221 100644 --- a/sites/all/modules/ctools/js/dependent.js +++ b/sites/all/modules/ctools/js/dependent.js @@ -54,6 +54,8 @@ // Iterate through all relationships for (id in Drupal.settings.CTools.dependent) { + // Test to make sure the id even exists; this helps clean up multiple + // AJAX calls with multiple forms. // Drupal.CTools.dependent.activeBindings[id] is a boolean, // whether the binding is active or not. Defaults to no. @@ -87,6 +89,10 @@ } var getValue = function(item, trigger) { + if ($(trigger).size() == 0) { + return null; + } + if (item.substring(0, 6) == 'radio:') { var val = $(trigger + ':checked').val(); } @@ -115,9 +121,12 @@ var changeTrigger = function() { var val = getValue(bind_id, trigger_id); + if (val == null) { + return; + } + for (i in Drupal.CTools.dependent.bindings[bind_id]) { var id = Drupal.CTools.dependent.bindings[bind_id][i]; - // Fix numerous errors if (typeof id != 'string') { continue; @@ -143,6 +152,16 @@ 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(); } diff --git a/sites/all/modules/ctools/js/jump-menu.js b/sites/all/modules/ctools/js/jump-menu.js index f515c8c5d..6bd0af6be 100644 --- a/sites/all/modules/ctools/js/jump-menu.js +++ b/sites/all/modules/ctools/js/jump-menu.js @@ -10,7 +10,11 @@ .addClass('ctools-jump-menu-processed') .change(function() { var loc = $(this).val(); - if (loc) { + var urlArray = loc.split('::'); + if (urlArray[1]) { + location.href = urlArray[1]; + } + else { location.href = loc; } return false; @@ -24,7 +28,11 @@ // Find our sibling value. var $select = $(this).parents('form').find('.ctools-jump-menu-select'); var loc = $select.val(); - if (loc) { + var urlArray = loc.split('::'); + if (urlArray[1]) { + location.href = urlArray[1]; + } + else { location.href = loc; } return false; diff --git a/sites/all/modules/ctools/js/modal.js b/sites/all/modules/ctools/js/modal.js index 4d6c6f81e..c98c50fa7 100644 --- a/sites/all/modules/ctools/js/modal.js +++ b/sites/all/modules/ctools/js/modal.js @@ -269,6 +269,9 @@ * AJAX responder command to place HTML within the modal. */ Drupal.CTools.Modal.modal_display = function(ajax, response, status) { + if ($('#modalContent').length == 0) { + Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(ajax.element)); + } $('#modal-title').html(response.title); $('#modal-content').html(response.output); Drupal.attachBehaviors(); diff --git a/sites/all/modules/ctools/page_manager/page_manager.info b/sites/all/modules/ctools/page_manager/page_manager.info index 4791bc318..1c2ee0162 100644 --- a/sites/all/modules/ctools/page_manager/page_manager.info +++ b/sites/all/modules/ctools/page_manager/page_manager.info @@ -4,9 +4,9 @@ core = 7.x dependencies[] = ctools package = Chaos tool suite -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/page_manager/plugins/tasks/page.inc b/sites/all/modules/ctools/page_manager/plugins/tasks/page.inc index aba99c7d9..095c39064 100644 --- a/sites/all/modules/ctools/page_manager/plugins/tasks/page.inc +++ b/sites/all/modules/ctools/page_manager/plugins/tasks/page.inc @@ -290,7 +290,6 @@ function page_manager_page_execute($subtask_id) { $argument['keyword'] = $name; if (isset($args[$count])) { // Hack: use a special argument config variable to learn if we need - $plugin = ctools_get_argument($argument['name']); // to use menu_tail style behavior: if (empty($argument['settings']['use_tail'])) { $value = $args[$count]; diff --git a/sites/all/modules/ctools/plugins/access/entity_bundle.inc b/sites/all/modules/ctools/plugins/access/entity_bundle.inc index ffb83f572..cce241b7f 100644 --- a/sites/all/modules/ctools/plugins/access/entity_bundle.inc +++ b/sites/all/modules/ctools/plugins/access/entity_bundle.inc @@ -121,6 +121,6 @@ function ctools_entity_bundle_ctools_access_summary($conf, $context) { return t('@identifier is any bundle', array('@identifier' => $context->identifier)); } - return format_plural(count($names), '@identifier is type "@types"', '@identifier type is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier)); + return format_plural(count($names), '@identifier is bundle "@types"', '@identifier bundle is one of "@types"', array('@types' => implode(', ', $names), '@identifier' => $context->identifier)); } diff --git a/sites/all/modules/ctools/plugins/arguments/term.inc b/sites/all/modules/ctools/plugins/arguments/term.inc index 652c5c16c..93d2f0a2e 100644 --- a/sites/all/modules/ctools/plugins/arguments/term.inc +++ b/sites/all/modules/ctools/plugins/arguments/term.inc @@ -141,6 +141,7 @@ function ctools_term_breadcrumb($conf, $context) { } $breadcrumb = array(); + $current = new stdClass(); $current->tid = $context->data->tid; while ($parents = taxonomy_get_parents($current->tid)) { $current = array_shift($parents); diff --git a/sites/all/modules/ctools/plugins/arguments/uid.inc b/sites/all/modules/ctools/plugins/arguments/uid.inc index a730b2164..f9d5315cc 100644 --- a/sites/all/modules/ctools/plugins/arguments/uid.inc +++ b/sites/all/modules/ctools/plugins/arguments/uid.inc @@ -44,7 +44,7 @@ function ctools_argument_uid_context($arg = NULL, $conf = NULL, $empty = FALSE) return NULL; } - $account = user_load(array('uid' => $arg)); + $account = user_load($arg); if (!$account) { return NULL; } diff --git a/sites/all/modules/ctools/plugins/content_types/contact/user_contact.inc b/sites/all/modules/ctools/plugins/content_types/contact/user_contact.inc index cb643bfdc..9b3726ab8 100644 --- a/sites/all/modules/ctools/plugins/content_types/contact/user_contact.inc +++ b/sites/all/modules/ctools/plugins/content_types/contact/user_contact.inc @@ -41,7 +41,7 @@ function ctools_user_contact_content_type_render($subtype, $conf, $panel_args, $ /** * Returns an edit form for custom type settings. */ -function ctools_user_contact_content_type_edit_form(&$form, &$form_state) { +function ctools_user_contact_content_type_edit_form($form, &$form_state) { // Empty so that we can have title override. return $form; } diff --git a/sites/all/modules/ctools/plugins/content_types/custom/custom.inc b/sites/all/modules/ctools/plugins/content_types/custom/custom.inc index f60497a60..a4a2def63 100644 --- a/sites/all/modules/ctools/plugins/content_types/custom/custom.inc +++ b/sites/all/modules/ctools/plugins/content_types/custom/custom.inc @@ -174,6 +174,17 @@ function ctools_custom_content_type_render($subtype, $conf, $args, $contexts) { } $block->content = check_markup($content, $settings['format']); + if ($settings['custom_type'] == 'fixed' && user_access('administer custom content')) { + $block->admin_links = array( + array( + 'title' => t('Configure content pane'), + 'alt' => t("Configure this pane in administer >> structure >> custom content panes"), + 'href' => 'admin/structure/ctools-content/list/' . $settings['content']->name . '/edit', + 'query' => drupal_get_destination(), + ), + ); + } + return $block; } @@ -300,7 +311,7 @@ function ctools_custom_content_type_edit_form($form, &$form_state) { } } $header = array(t('Keyword'), t('Value')); - $form['contexts']['context'] = array('#value' => theme('table', $header, $rows)); + $form['contexts']['context'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $rows))); } if (!user_access('administer custom content') || !module_exists('ctools_custom_content')) { diff --git a/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc b/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc index e252064a6..d729d6520 100644 --- a/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc +++ b/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc @@ -110,7 +110,7 @@ function ctools_entity_field_content_type_render($subtype, $conf, $panel_args, $ 'type' => $conf['formatter'], ); - // Get the field output, and the title.\ + // Get the field output, and the title. if (!empty($conf['formatter_settings'])) { $field_settings['settings'] = $conf['formatter_settings']; } diff --git a/sites/all/modules/ctools/plugins/content_types/node_context/node_terms.inc b/sites/all/modules/ctools/plugins/content_types/node_context/node_terms.inc index 6cb5e7ce9..1b9c55394 100644 --- a/sites/all/modules/ctools/plugins/content_types/node_context/node_terms.inc +++ b/sites/all/modules/ctools/plugins/content_types/node_context/node_terms.inc @@ -82,20 +82,16 @@ function ctools_node_terms_content_type_render($subtype, $conf, $panel_args, $co switch ($conf['term_format']) { case 'term-links': drupal_alter('link', $terms, $node); - $formatted_terms = theme('links', $terms); + $formatted_terms = theme('links', array('links' => $terms)); break; case 'ul': - $formatted_terms = theme('item_list', $terms); + $formatted_terms = theme('item_list', array('items' => $terms)); break; case 'inline-delimited': - $term_names = array(); - foreach ($terms AS $term) { - $term_names[] = $term['title']; - } $delimiter = isset($conf['term_delimiter']) ? $conf['term_delimiter'] : ', '; - $formatted_terms = implode($delimiter, $term_names); + $formatted_terms = implode($delimiter, $terms); break; } @@ -103,7 +99,7 @@ function ctools_node_terms_content_type_render($subtype, $conf, $panel_args, $co $block = new stdClass(); $block->module = 'node_terms'; $block->delta = $node->nid; - $block->title = $type->title_label; + $block->title = t('Terms'); $block->content = $formatted_terms; return $block; diff --git a/sites/all/modules/ctools/plugins/content_types/search/search_result.inc b/sites/all/modules/ctools/plugins/content_types/search/search_result.inc index 44cfbac5e..eae987082 100644 --- a/sites/all/modules/ctools/plugins/content_types/search/search_result.inc +++ b/sites/all/modules/ctools/plugins/content_types/search/search_result.inc @@ -65,21 +65,18 @@ function ctools_search_result_content_type_render($subtype, $conf, $panel_args, $results = ''; - // Only search if there are keywords or non-empty conditions. - if ($keys || !empty($conditions)) { + // Only search if there are keywords or non-empty conditions. + if ($keys || !empty($conditions)) { - // Collect the search results. - $results = search_data($keys, $info['module'], $conditions); - } + // Collect the search results. + $results = search_data($keys, $info['module'], $conditions); + } if (!empty($conf['log'])) { // Log the search keys: watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), $_GET['q'])); } - // Collect the search results: - $results = search_data($keys, $conf['type'], $conditions); - if (!empty($results['#results'])) { $output = "<ol class=\"search-results $conf[type]-results\">\n"; foreach ($results['#results'] as $result) { diff --git a/sites/all/modules/ctools/plugins/content_types/user_context/user_picture.inc b/sites/all/modules/ctools/plugins/content_types/user_context/user_picture.inc index dbe42428e..f8a9e8ac5 100644 --- a/sites/all/modules/ctools/plugins/content_types/user_context/user_picture.inc +++ b/sites/all/modules/ctools/plugins/content_types/user_context/user_picture.inc @@ -14,14 +14,21 @@ $plugin = array( ); function ctools_user_picture_content_type_render($subtype, $conf, $panel_args, $context) { - $account = isset($context->data) ? clone($context->data) : FALSE; - $block = new stdClass(); - $block->module = 'term-list'; + global $user; - if ($account === FALSE || ($account->access == 0 && !user_access('administer users'))) { - return drupal_not_found(); + if (empty($context->data)) { + return; } + $account = clone $context->data; + + // Check if user has permissions to access the user + if ($user->uid != $account->uid && (!user_access('access user profiles') && !user_access('administer users'))) { + return; + } + + $block = new stdClass(); + $block->module = 'user-profile'; $block->title = check_plain($account->name); $block->content = theme('user_picture', array('account' => $account)); diff --git a/sites/all/modules/ctools/plugins/contexts/entity.inc b/sites/all/modules/ctools/plugins/contexts/entity.inc index 99bfb293a..3915667c7 100644 --- a/sites/all/modules/ctools/plugins/contexts/entity.inc +++ b/sites/all/modules/ctools/plugins/contexts/entity.inc @@ -79,8 +79,7 @@ function ctools_context_create_entity($empty, $data = NULL, $conf = FALSE, $plug if (is_array($data)) { $data = entity_load($entity_type, array($id)); - $data = $data[$id]; - //$language = field_language($entity_type, $data); + $data = !empty($data[$id]) ? $data[$id] : FALSE; } if (!empty($data)) { @@ -262,10 +261,8 @@ function ctools_context_entity_convert($context, $type) { $tokens = token_info(); - if (isset($tokens['tokens'][$token][$type])) { - $values = token_generate($token, array($type => $type), array($token => $context->data)); - if (isset($values[$type])) { - return $values[$type]; - } + $values = token_generate($token, array($type => $type), array($token => $context->data)); + if (isset($values[$type])) { + return $values[$type]; } } diff --git a/sites/all/modules/ctools/plugins/contexts/node_add_form.inc b/sites/all/modules/ctools/plugins/contexts/node_add_form.inc index 55219330a..fcd92d402 100644 --- a/sites/all/modules/ctools/plugins/contexts/node_add_form.inc +++ b/sites/all/modules/ctools/plugins/contexts/node_add_form.inc @@ -31,14 +31,14 @@ $plugin = array( * are not always created from the UI. */ function ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE) { - static $created; + static $creating = FALSE; $context = new ctools_context(array('form', 'node_add', 'node_form')); $context->plugin = 'node_add_form'; - if ($empty || (isset($created) && $created)) { + if ($empty || ($creating)) { return $context; } - $created = TRUE; + $creating = TRUE; if ($conf && (isset($data['types']) || isset($data['type']))) { // Holdover from typo'd config. @@ -53,19 +53,27 @@ function ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE if (isset($types[$type]) && node_access('create', $type)) { // Initialize settings: global $user; - $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type); + $node = (object) array( + 'uid' => $user->uid, + 'name' => (isset($user->name) ? $user->name : ''), + 'type' => $type, + 'language' => LANGUAGE_NONE, + ); - $form_id = $node['type'] . '_node_form'; + $form_id = $type . '_node_form'; - $form_state = array('want form' => TRUE, 'build_info' => array('args' => array($node))); + $form_state = array( + 'want form' => TRUE, + 'build_info' => array( + 'args' => array($node) + ) + ); - $file = drupal_get_path('module', 'node') . '/node.pages.inc'; - include_once './' . $file; - // This piece of information can let other modules know that more files - // need to be included if this form is loaded from cache: - $form_state['build_info']['files'] = array($file); + // Use module_load_include so that caches and stuff can know to load this. + form_load_include($form_state, 'inc', 'node', 'node.pages'); $form = drupal_build_form($form_id, $form_state); + // In a form, $data is the object being edited. $context->data = $type; $context->title = $types[$type]->name; @@ -74,14 +82,17 @@ function ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE // These are specific pieces of data to this form. // All forms should place the form here. $context->form = $form; - $context->form_id = $type . '_node_form'; + $context->form_id = $form_id; $context->form_title = t('Submit @name', array('@name' => $types[$type]->name)); $context->node_type = $type; $context->restrictions['type'] = array($type); $context->restrictions['form'] = array('form'); + + $creating = FALSE; return $context; } } + $creating = FALSE; } function ctools_context_node_add_form_settings_form($form, &$form_state) { diff --git a/sites/all/modules/ctools/plugins/contexts/node_edit_form.inc b/sites/all/modules/ctools/plugins/contexts/node_edit_form.inc index a7b04523a..cd4ff0a8a 100644 --- a/sites/all/modules/ctools/plugins/contexts/node_edit_form.inc +++ b/sites/all/modules/ctools/plugins/contexts/node_edit_form.inc @@ -31,14 +31,14 @@ $plugin = array( * are not always created from the UI. */ function ctools_context_create_node_edit_form($empty, $node = NULL, $conf = FALSE) { - static $created; - $context = new ctools_context(array('form', 'node_edit', 'node_form', 'node', 'node_edit_form')); + static $creating = FALSE; + $context = new ctools_context(array('form', 'node_edit', 'node_form', 'node_edit_form')); $context->plugin = 'node_edit_form'; - if ($empty || (isset($created) && $created)) { + if ($empty || ($creating)) { return $context; } - $created = TRUE; + $creating = TRUE; if ($conf) { // In this case, $node is actually our $conf array. @@ -81,8 +81,11 @@ function ctools_context_create_node_edit_form($empty, $node = NULL, $conf = FALS $context->node_type = $node->type; $context->restrictions['type'] = array($node->type); $context->restrictions['form'] = array('form'); + + $creating = FALSE; return $context; } + $creating = FALSE; } function ctools_context_node_edit_form_settings_form($form, &$form_state) { diff --git a/sites/all/modules/ctools/plugins/contexts/terms.inc b/sites/all/modules/ctools/plugins/contexts/terms.inc index b076a6199..64ec6829b 100644 --- a/sites/all/modules/ctools/plugins/contexts/terms.inc +++ b/sites/all/modules/ctools/plugins/contexts/terms.inc @@ -17,7 +17,6 @@ $plugin = array( 'keyword' => 'terms', // This context is deprecated and should not be usable in the UI. 'no ui' => TRUE, - 'no required context ui' => TRUE, 'context name' => 'terms', 'convert list' => array( 'tid' => t('Term ID of first term'), @@ -39,7 +38,7 @@ function ctools_context_create_terms($empty, $data = NULL, $conf = FALSE) { // The input is expected to be an object as created by ctools_break_phrase // which contains a group of terms. - $context = new ctools_context(array('terms', 'term')); + $context = new ctools_context(array('terms', 'entity:taxonomy_term')); $context->plugin = 'terms'; if ($empty) { diff --git a/sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php b/sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php index 4a919eacf..7fe005582 100644 --- a/sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php +++ b/sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php @@ -121,7 +121,7 @@ class ctools_export_ui { switch ($op) { case 'import': - return user_access('use PHP for block visibility'); + return user_access('use PHP for settings'); case 'revert': return ($item->export_type & EXPORT_IN_DATABASE) && ($item->export_type & EXPORT_IN_CODE); case 'delete': @@ -1311,6 +1311,10 @@ function ctools_export_ui_list_form_submit(&$form, &$form_state) { * This simply loads the object defined in the plugin and hands it off. */ function ctools_export_ui_edit_item_form($form, &$form_state) { + // When called using #ajax via ajax_form_callback(), 'export' may + // not be included so include it here. + ctools_include('export'); + $form = array(); $form_state['object']->edit_form($form, $form_state); return $form; @@ -1401,6 +1405,10 @@ function ctools_export_ui_delete_confirm_form($form, &$form_state) { * This simply loads the object defined in the plugin and hands it off. */ function ctools_export_ui_edit_item_wizard_form($form, &$form_state) { + // When called using #ajax via ajax_form_callback(), 'export' may + // not be included so include it here. + ctools_include('export'); + $method = 'edit_form_' . $form_state['step']; if (!method_exists($form_state['object'], $method)) { $method = 'edit_form'; diff --git a/sites/all/modules/ctools/plugins/relationships/entity_from_field.inc b/sites/all/modules/ctools/plugins/relationships/entity_from_field.inc index 99d6f2d6d..e5e658266 100644 --- a/sites/all/modules/ctools/plugins/relationships/entity_from_field.inc +++ b/sites/all/modules/ctools/plugins/relationships/entity_from_field.inc @@ -13,8 +13,10 @@ $plugin = array( 'title' => t('Entity'), 'description' => t('Creates an entity context from a foreign key on a field.'), 'context' => 'ctools_entity_from_field_context', + 'edit form' => 'ctools_entity_from_field_edit_form', 'get child' => 'ctools_entity_from_field_get_child', 'get children' => 'ctools_entity_from_field_get_children', + 'defaults' => array('delta' => 0), ); function ctools_entity_from_field_get_child($plugin, $parent, $child) { @@ -59,6 +61,12 @@ function ctools_entity_from_field_get_children($parent_plugin, $parent) { if (isset($info['table'])) { foreach ($entities as $to_entity => $to_entity_info) { $from_entity_info = $entities[$from_entity]; + // If somehow the bundle doesn't exist on the to-entity, + // skip. + if (!isset($from_entity_info['bundles'][$bundle])) { + continue; + } + if (isset($to_entity_info['base table']) && $to_entity_info['base table'] == $info['table'] && isset($info['columns'][$to_entity_info['entity keys']['id']])) { $name = $field_name . '-' . $from_entity . '-' . $to_entity; $plugin_id = $parent . ':' . $name; @@ -153,6 +161,7 @@ function ctools_entity_from_field_get_children($parent_plugin, $parent) { * Return a new context based on an existing context. */ function ctools_entity_from_field_context($context, $conf) { + $delta = !empty($conf['delta']) ? intval($conf['delta']) : 0; $plugin = $conf['name']; list($plugin, $plugin_name) = explode(':', $plugin); list($field_name, $from_entity, $to_entity_info) = explode('-', $plugin_name); @@ -167,13 +176,45 @@ function ctools_entity_from_field_context($context, $conf) { $id = $context->data->{$entity_info['entity keys']['id']}; $entity = entity_load($from_entity, array($id)); $entity = $entity[$id]; - if (isset($entity->$field_name)) { - $language = field_language($from_entity, $entity, $field_name); + if ($items = field_get_items($from_entity, $entity, $field_name)) { $to_entity_info_info = entity_get_info($to_entity_info); - $to_entity_info_id = $entity->{$field_name}[$language][0][$to_entity_info_info['entity keys']['id']]; + if (isset($items[$delta])) { + $to_entity_info_id = $items[$delta][$to_entity_info_info['entity keys']['id']]; + + // Send it to ctools. + return ctools_context_create('entity:' . $to_entity_info, $to_entity_info_id); + } + else { + // In case that delta was empty. + return ctools_context_create_empty('entity:' . $to_entity_info, NULL); + } + } + } +} - // Send it to ctools. - return ctools_context_create('entity:' . $to_entity_info, $to_entity_info_id); +function ctools_entity_from_field_edit_form($form, &$form_state) { + $field = field_info_field($form_state['plugin']['field name']); + $conf = $form_state['conf']; + + if ($field && $field['cardinality'] != 1) { + if ($field['cardinality'] == -1) { + $form['delta'] = array( + '#type' => 'textfield', + '#title' => t('Delta'), + '#description' => t('The relationship can only create one context, but multiple items can be related. Please select which one. Since this can have unlimited items, type in the number you want. The first one will be 0.'), + '#default_value' => !empty($conf['delta']) ? $conf['delta'] : 0, + ); + } + else { + $form['delta'] = array( + '#type' => 'select', + '#title' => t('Delta'), + '#description' => t('The relationship can only create one context, but multiple items can be related. Please select which one.'), + '#options' => range(1, $field['cardinality']), + '#default_value' => !empty($conf['delta']) ? $conf['delta'] : 0, + ); } } + + return $form; } diff --git a/sites/all/modules/ctools/plugins/relationships/term_from_node.inc b/sites/all/modules/ctools/plugins/relationships/term_from_node.inc index 230436782..38f6aeaa0 100644 --- a/sites/all/modules/ctools/plugins/relationships/term_from_node.inc +++ b/sites/all/modules/ctools/plugins/relationships/term_from_node.inc @@ -25,7 +25,7 @@ $plugin = array( function ctools_term_from_node_context($context, $conf) { // If unset it wants a generic, unfilled context, which is just NULL. if (empty($context->data)) { - return ctools_context_create_empty('entity_taxonomy:term', NULL); + return ctools_context_create_empty('entity:taxonomy_term', NULL); } if (isset($context->data->taxonomy)) { diff --git a/sites/all/modules/ctools/plugins/relationships/terms_from_node.inc b/sites/all/modules/ctools/plugins/relationships/terms_from_node.inc index e8eaa545c..ddba9ed47 100644 --- a/sites/all/modules/ctools/plugins/relationships/terms_from_node.inc +++ b/sites/all/modules/ctools/plugins/relationships/terms_from_node.inc @@ -29,18 +29,25 @@ function ctools_terms_from_node_context($context, $conf) { } // Collect all terms for the chosen vocabulary and concatenate them. - if (isset($context->data->taxonomy)) { - $terms = array(); - foreach ($context->data->taxonomy as $term) { - if (in_array($term->vid, $conf['vid'])) { - $terms[] = $term->tid; + $node = $context->data; + $terms = array(); + + $fields = field_info_instances('node', $node->type); + foreach ($fields as $name => $info) { + $field_info = field_info_field($name); + if ($field_info['type'] == 'taxonomy_term_reference') { + $items = field_get_items('node', $node, $name); + if (is_array($items)) { + foreach ($items as $item) { + $terms[] = $item['tid']; + } } } - - if (!empty($terms)) { - $all_terms = ctools_break_phrase(implode($conf['concatenator'], $terms)); - return ctools_context_create('terms', $all_terms); - } + } + + if (!empty($terms)) { + $all_terms = ctools_break_phrase(implode($conf['concatenator'], $terms)); + return ctools_context_create('terms', $all_terms); } } diff --git a/sites/all/modules/ctools/stylizer/stylizer.info b/sites/all/modules/ctools/stylizer/stylizer.info index 96b7db6f3..5398713d3 100644 --- a/sites/all/modules/ctools/stylizer/stylizer.info +++ b/sites/all/modules/ctools/stylizer/stylizer.info @@ -5,9 +5,9 @@ package = Chaos tool suite dependencies[] = ctools dependencies[] = color -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/stylizer/stylizer.install b/sites/all/modules/ctools/stylizer/stylizer.install index cee8b7481..5cefb0ddf 100644 --- a/sites/all/modules/ctools/stylizer/stylizer.install +++ b/sites/all/modules/ctools/stylizer/stylizer.install @@ -18,6 +18,12 @@ function stylizer_schema_1() { 'can disable' => TRUE, 'identifier' => 'style', 'primary key' => 'sid', + 'api' => array( + 'owner' => 'stylizer', + 'api' => 'stylizer', + 'minimum_version' => 1, + 'current_version' => 1, + ), ), 'fields' => array( 'sid' => array( diff --git a/sites/all/modules/ctools/tests/ctools_plugin_test.info b/sites/all/modules/ctools/tests/ctools_plugin_test.info index 83ec9dc0b..b15e4649b 100644 --- a/sites/all/modules/ctools/tests/ctools_plugin_test.info +++ b/sites/all/modules/ctools/tests/ctools_plugin_test.info @@ -7,9 +7,9 @@ files[] = ctools.plugins.test files[] = object_cache.test hidden = TRUE -; Information added by drupal.org packaging script on 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" diff --git a/sites/all/modules/ctools/views_content/plugins/content_types/views.inc b/sites/all/modules/ctools/views_content/plugins/content_types/views.inc index 1a7be12d7..04b6869ac 100644 --- a/sites/all/modules/ctools/views_content/plugins/content_types/views.inc +++ b/sites/all/modules/ctools/views_content/plugins/content_types/views.inc @@ -427,6 +427,8 @@ function views_content_views_content_type_admin_info($subtype, $conf, $contexts) } $display = empty($conf['display']) ? $view->current_display : $conf['display']; + $block = new stdClass(); + $block->title = t('View information'); $block->content = '<ul>'; diff --git a/sites/all/modules/ctools/views_content/plugins/content_types/views_row.inc b/sites/all/modules/ctools/views_content/plugins/content_types/views_row.inc index 827d36035..254f7b5f2 100644 --- a/sites/all/modules/ctools/views_content/plugins/content_types/views_row.inc +++ b/sites/all/modules/ctools/views_content/plugins/content_types/views_row.inc @@ -163,7 +163,11 @@ function views_content_views_row_edit_submit(&$form, &$form_state) { } function views_content_views_row_content_type_admin_info($subtype, $conf, $contexts) { - $context = $contexts[$conf['context']]; + // Go through this route to make sure we catch changes in configuration + // that can happen. + $plugin = ctools_get_content_type('views_row'); + $context = ctools_content_select_context($plugin, $subtype, $conf, $contexts); + $block->title = t('Row information'); if (!empty($conf['use_fields'])) { diff --git a/sites/all/modules/ctools/views_content/plugins/relationships/node_from_view.inc b/sites/all/modules/ctools/views_content/plugins/relationships/node_from_view.inc index 55ed94576..0f3fa8e0a 100644 --- a/sites/all/modules/ctools/views_content/plugins/relationships/node_from_view.inc +++ b/sites/all/modules/ctools/views_content/plugins/relationships/node_from_view.inc @@ -15,8 +15,8 @@ $plugin = array( 'description' => t('Extract a node context from a view context of the base type node.'), 'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'node')), 'context' => 'views_content_node_from_view_context', - 'settings form' => 'views_content_node_from_view_settings_form', - 'settings form validate' => 'views_content_node_from_view_settings_form_validate', + 'edit form' => 'views_content_node_from_view_settings_form', + 'edit form validate' => 'views_content_node_from_view_settings_form_validate', 'defaults' => array('row' => 1), ); diff --git a/sites/all/modules/ctools/views_content/plugins/relationships/term_from_view.inc b/sites/all/modules/ctools/views_content/plugins/relationships/term_from_view.inc index bc75062a5..bdd25b850 100644 --- a/sites/all/modules/ctools/views_content/plugins/relationships/term_from_view.inc +++ b/sites/all/modules/ctools/views_content/plugins/relationships/term_from_view.inc @@ -15,8 +15,8 @@ $plugin = array( 'description' => t('Extract a term context from a view context of the base type term.'), 'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'term_data')), 'context' => 'views_content_term_from_view_context', - 'settings form' => 'views_content_term_from_view_settings_form', - 'settings form validate' => 'views_content_term_from_view_settings_form_validate', + 'edit form' => 'views_content_term_from_view_settings_form', + 'edit form validate' => 'views_content_term_from_view_settings_form_validate', 'defaults' => array('row' => 1), ); diff --git a/sites/all/modules/ctools/views_content/plugins/relationships/user_from_view.inc b/sites/all/modules/ctools/views_content/plugins/relationships/user_from_view.inc index eb5948593..47c4693cc 100644 --- a/sites/all/modules/ctools/views_content/plugins/relationships/user_from_view.inc +++ b/sites/all/modules/ctools/views_content/plugins/relationships/user_from_view.inc @@ -15,8 +15,8 @@ $plugin = array( 'description' => t('Extract a user context from a view context of the base type user.'), 'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'users')), 'context' => 'views_content_user_from_view_context', - 'settings form' => 'views_content_user_from_view_settings_form', - 'settings form validate' => 'views_content_user_from_view_settings_form_validate', + 'edit form' => 'views_content_user_from_view_settings_form', + 'edit form validate' => 'views_content_user_from_view_settings_form_validate', 'defaults' => array('row' => 1), ); diff --git a/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_display_panel_pane.inc b/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_display_panel_pane.inc index 06225afbb..2b45849b6 100644 --- a/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_display_panel_pane.inc +++ b/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_display_panel_pane.inc @@ -384,6 +384,11 @@ class views_content_plugin_display_panel_pane extends views_plugin_display { return $this->view->override_path; } + function uses_exposed_form_in_block() { + // We'll always allow the exposed form in a block, regardless of path. + return TRUE; + } + /** * Determine if this display should display the exposed * filters widgets, so the view will know whether or not diff --git a/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_style_ctools_context.inc b/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_style_ctools_context.inc index 837f2e177..513de3ce5 100644 --- a/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_style_ctools_context.inc +++ b/sites/all/modules/ctools/views_content/plugins/views/views_content_plugin_style_ctools_context.inc @@ -13,17 +13,6 @@ class views_content_plugin_style_ctools_context extends views_plugin_style { var $rows = array(); - /** - * Set default options - */ - function options(&$options) { - parent::options($options); - } - - function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); - } - /** * Render the display in this style. */ diff --git a/sites/all/modules/ctools/views_content/views_content.info b/sites/all/modules/ctools/views_content/views_content.info index 1da408bf2..f484b8557 100644 --- a/sites/all/modules/ctools/views_content/views_content.info +++ b/sites/all/modules/ctools/views_content/views_content.info @@ -9,9 +9,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 2011-05-31 -version = "7.x-1.0-beta1" +; Information added by drupal.org packaging script on 2011-07-28 +version = "7.x-1.0-rc1" core = "7.x" project = "ctools" -datestamp = "1306885315" +datestamp = "1311894415" -- GitLab