diff --git a/sites/all/modules/ctools/API.txt b/sites/all/modules/ctools/API.txt index bb9748e68e4c5b4b3c4462b40e38492e841ace83..2df7e22ce830b903bb72ebba86413af28e8b998e 100644 --- a/sites/all/modules/ctools/API.txt +++ b/sites/all/modules/ctools/API.txt @@ -3,6 +3,10 @@ Current API Version: 2.0.5 Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes. This file contains a log of changes to the API. +API Version 2.0.7 + All ctools object cache database functions can now accept session_id as an optional + argument to facilitate using non-session id keys. + API Version 2.0.6 Introduce a hook to alter the implementors of a certain api via hook_[ctools_api_hook]_alter. diff --git a/sites/all/modules/ctools/bulk_export/bulk_export.info b/sites/all/modules/ctools/bulk_export/bulk_export.info index 1e5061c1b66f049f0669e48d0d09db5dfb43b8ab..6f57712ddf51dddf7259c10d165fad96052b25c0 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/css/modal.css b/sites/all/modules/ctools/css/modal.css index 66c4a1c3ba1f477323ef41a12385f32458c1d88a..d9f44e2692006cd024217ac12f6f17b9024c451d 100644 --- a/sites/all/modules/ctools/css/modal.css +++ b/sites/all/modules/ctools/css/modal.css @@ -23,7 +23,6 @@ div.ctools-modal-content .modal-header { div.ctools-modal-content .modal-header a { color: white; - float: right; } div.ctools-modal-content .modal-content { @@ -37,6 +36,7 @@ div.ctools-modal-content .modal-form { div.ctools-modal-content a.close { color: white; + float: right; } div.ctools-modal-content a.close:hover { diff --git a/sites/all/modules/ctools/ctools.info b/sites/all/modules/ctools/ctools.info index 82fd1e257758b214338870d1a71b0b0d11bb54e9..c3e56fb3f74d1d57205ece746ccbb33b6e8bcfde 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/ctools.module b/sites/all/modules/ctools/ctools.module index f8e336910cecaa4dd76f7fbf36d4e2e2d279aa81..7dfc989b2a778290b7f59edbbf37934ef7f7d2e1 100644 --- a/sites/all/modules/ctools/ctools.module +++ b/sites/all/modules/ctools/ctools.module @@ -9,7 +9,7 @@ * must be implemented in the module file. */ -define('CTOOLS_API_VERSION', '2.0.6'); +define('CTOOLS_API_VERSION', '2.0.7'); /** * Test the CTools API version. 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 77e559335c52b82b4a76000314c3ba2fecda9230..04c92c349310e2a5aa0324cbad38f1cdc3684843 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/ctools_access_ruleset/plugins/access/ruleset.inc b/sites/all/modules/ctools/ctools_access_ruleset/plugins/access/ruleset.inc index 782c7cabf77ddae5f83e4f40dccc7386de407921..f8abea6df74b42a97ff069748b446ab6e72d2b87 100644 --- a/sites/all/modules/ctools/ctools_access_ruleset/plugins/access/ruleset.inc +++ b/sites/all/modules/ctools/ctools_access_ruleset/plugins/access/ruleset.inc @@ -99,7 +99,7 @@ function ctools_ruleset_ctools_access_check($conf, $context, $plugin) { * Provide a summary description based upon the checked roles. */ function ctools_ruleset_ctools_access_summary($conf, $context, $plugin) { - if (!empty($form_state['plugin']['ruleset']->admin_description)) { + if (!empty($plugin['ruleset']->admin_description)) { return check_plain($plugin['ruleset']->admin_description); } else { 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 0cb5d92e1ce4d3f1053760f574635a2f51b4c00a..bbf708cd1e083152f6123f257276396fe91d2788 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" 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 ca83b8a8ed6f405d4871b0a9052059440c33ed7a..b56e3be7ac92e2b7bda77e1cf5df94a52259d897 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.install b/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.install index 8348434b5f827f66067248db32eefb49ec441e5d..b4512f2a4cd5c839650ff6b45405e61728b3be8c 100644 --- a/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.install +++ b/sites/all/modules/ctools/ctools_custom_content/ctools_custom_content.install @@ -17,7 +17,7 @@ function ctools_custom_content_schema_1() { 'bulk export' => TRUE, 'primary key' => 'cid', 'api' => array( - 'owner' => 'ctools', + 'owner' => 'ctools_custom_content', 'api' => 'ctools_content', 'minimum_version' => 1, 'current_version' => 1, 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 4d4aace05715d0ae595048fc68c64435c909a9a6..c9f12e7d2005fdb80189f0ffe4051705c240bfba 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/drush/ctools.drush.inc b/sites/all/modules/ctools/drush/ctools.drush.inc index 353bbde4a66f8d74a0f193e93f71be43665ffb00..bf1df1f2bfc01400280c7a2f731c7547cce949e7 100644 --- a/sites/all/modules/ctools/drush/ctools.drush.inc +++ b/sites/all/modules/ctools/drush/ctools.drush.inc @@ -11,8 +11,12 @@ function ctools_drush_command() { $items = array(); + $module_text = 'Filter the list of exportables by module. This will come from the \'export_module\' key on the exportable.'; + $all_text = 'Perform this operation all CTools exportables available on the system (all tables).'; + $items['ctools-export'] = array( 'aliases' => array('ctex'), + 'callback' => 'ctools_drush_export', 'description' => 'Export multiple CTools exportable objects directly to code.', 'arguments' => array( 'module' => 'Name of your module.', @@ -20,36 +24,40 @@ function ctools_drush_command() { 'options' => array( 'subdir' => 'The name of the sub directory to create the module in. Defaults to ctools_export which will be placed into sites/all/modules.', 'remove' => 'Remove existing files before writing, except the .module file.', + 'filter' => 'Filter the list of exportables by status. Available options are enabled, disabled, overridden, database, code and all. Defaults to enabled.', + 'tables' => 'Comma separated list of exportable table names to filter by.', ), - 'drupal dependencies' => array('bulk_export'), 'examples' => array( 'drush ctex export_module' => 'Export CTools exportables to a module called "export_module".', 'drush ctex export_module --subdir=exports' => 'Same as above, but into the sites/all/modules/exports directory.', 'drush ctex export_module --subdir=exports --remove' => 'Same as above, but automatically removing all files, except for the .module file.', + 'drush ctex --filter="views_view"' => 'Filter export selection to the views_view table only.', ), ); $items['ctools-export-info'] = array( 'aliases' => array('ctei'), + 'callback' => 'ctools_drush_export_info', 'description' => 'Show available CTools exportable objects.', 'arguments' => array(), 'options' => array( 'format' => 'Display exportables info in a different format such as print_r, json, export. The default is to show in a tabular format.', 'tables-only' => 'Only show list of exportable types/table names and not available objects.', - 'enabled' => 'Only show exportables that are currently enabled.', - 'disabled' => 'Only show exportables that are currently disabled.', - 'overridden' => 'Only show exportables that have been overridden in the database.', - 'database' => 'Only show exportables defined in the database (and not in code).', + 'filter' => 'Filter the list of exportables by status. Available options are enabled, disabled, overridden, database, and code.', + 'module' => $module_text, ), 'examples' => array( 'drush ctools-export-info' => 'View export info on all exportables.', 'drush ctools-export-info views_view variable' => 'View export info for views_view and variable exportable types only.', + 'drush ctei --filter=enabled' => 'Show all enabled exportables.', + 'drush ctei views_view --filter=disabled' => 'Show all enabled exportables.', + 'drush ctei views_view --module=node' => 'Show all exportables provided by/on behalf of the node module.', ), ); $items['ctools-export-view'] = array( 'aliases' => array('ctev'), - 'callback' => 'drush_ctools_export_op_command', + 'callback' => 'ctools_drush_export_op_command', 'description' => 'View CTools exportable object code output.', 'arguments' => array( 'table name' => 'Base table of the exportable you want to view.', @@ -58,6 +66,8 @@ function ctools_drush_command() { 'options' => array( 'indent' => 'The string to use for indentation when dispalying 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, ), 'examples' => array( 'drush ctools-export-view views_view' => 'View all views exportable objects.', @@ -67,28 +77,35 @@ function ctools_drush_command() { $items['ctools-export-revert'] = array( 'aliases' => array('cter'), - 'callback' => 'drush_ctools_export_op_command', + 'callback' => 'ctools_drush_export_op_command', 'description' => 'Revert CTools exportables from changes overridden in the database.', 'arguments' => array( 'table name' => 'Base table of the exportable you want to revert.', 'machine names' => 'Space separated list of exportables you want to revert.', ), - 'options' => array(), + 'options' => array( + 'module' => $module_text, + 'all' => $all_text, + ), 'examples' => array( 'drush ctools-export-revert views_view' => 'Revert all overridden views exportable objects.', 'drush ctools-export-revert views_view archive' => 'Revert overridden default views archive view.', + 'drush ctools-export-revert --all' => 'Revert all exportables on the system.', ), ); $items['ctools-export-enable'] = array( 'aliases' => array('ctee'), - 'callback' => 'drush_ctools_export_op_command', + 'callback' => 'ctools_drush_export_op_command', 'description' => 'Enable CTools exportables.', 'arguments' => array( 'table name' => 'Base table of the exportable you want to enable.', 'machine names' => 'Space separated list of exportables you want to enable.', ), - 'options' => array(), + 'options' => array( + 'module' => $module_text, + 'all' => $all_text, + ), 'examples' => array( 'drush ctools-export-enable views_view' => 'Enable all overridden views exportable objects.', 'drush ctools-export-enable views_view archive' => 'Enable overridden default views archive view.', @@ -97,13 +114,16 @@ function ctools_drush_command() { $items['ctools-export-disable'] = array( 'aliases' => array('cted'), - 'callback' => 'drush_ctools_export_op_command', + 'callback' => 'ctools_drush_export_op_command', 'description' => 'Disable CTools exportables.', 'arguments' => array( 'table name' => 'Base table of the exportable you want to disable.', 'machine names' => 'Space separated list of exportables you want to disable.', ), - 'options' => array(), + 'options' => array( + 'module' => $module_text, + 'all' => $all_text, + ), 'examples' => array( 'drush ctools-export-disable views_view' => 'Disable all overridden views exportable objects.', 'drush ctools-export-disable views_view archive' => 'Disable overridden default views archive view.', @@ -128,7 +148,7 @@ function ctools_drush_help($section) { /** * Drush callback: export */ -function drush_ctools_export($module = 'foo') { +function ctools_drush_export($module = 'foo') { $error = FALSE; if (preg_match('@[^a-z_]+@', $module)) { $error = dt('The name of the module must contain only lowercase letters and underscores') . '.'; @@ -136,6 +156,15 @@ function drush_ctools_export($module = 'foo') { return; } + // Filter by tables. + $tables = _ctools_drush_explode_options('tables'); + + // Check status. + $filter = drush_get_option('filter', FALSE); + if (empty($filter)) { + drush_set_option('filter', 'enabled'); + } + // Selection. $options = array('all' => dt('Export everything'), 'select' => dt('Make selection')); $selection = drush_choice($options, dt('Select to proceed')); @@ -146,10 +175,11 @@ function drush_ctools_export($module = 'foo') { // Present the selection screens. if ($selection == 'select') { - $selections = _drush_ctools_selection_screen(); + $selections = _ctools_drush_selection_screen($tables); } else { - $selections = _drush_ctools_export_info(); + $info = _ctools_drush_export_info($tables, TRUE); + $selections = $info['exportables']; } // Subdirectory. @@ -177,7 +207,7 @@ function drush_ctools_export($module = 'foo') { // Remove files (except for the .module file) if the destination folder exists. if ($remove && $dest_exists) { - _drush_ctools_file_delete($dest); + _ctools_drush_file_delete($dest); } // Create new dir if needed. @@ -190,6 +220,9 @@ function drush_ctools_export($module = 'foo') { // Create destination directory. drush_mkdir($dest); + // Load bulk export module. + module_load_include('module', 'bulk_export'); + // Create options and call Bulk export function. // We create an array, because maybe in the future we can pass in more // options to the export function (pre-selected modules and/or exportables). @@ -199,6 +232,14 @@ function drush_ctools_export($module = 'foo') { ); $files = bulk_export_export(TRUE, $options); + $alter = array( + 'module' => $module, + 'files' => $files, + ); + // Let other drush commands alter the files. + drush_command_invoke_all_ref('drush_ctex_files_alter', $alter); + $files = $alter['files']; + // Start writing. if (is_array($files)) { foreach ($files as $base_file => $data) { @@ -220,7 +261,6 @@ function drush_ctools_export($module = 'foo') { drush_log(dt('Error writing !filename', array('!filename' => $filename)), 'error'); } } - drush_log("\n" . dt('No penguins were harmed in the generation of this code.') . "\n", 'success'); } else { drush_log(dt('No files were found to be written.'), 'error'); @@ -230,19 +270,24 @@ function drush_ctools_export($module = 'foo') { /** * Helper function to select the exportables. By default, all exportables * will be selected, so it will be easier to deselect them. + * + * @param $tables */ -function _drush_ctools_selection_screen() { +function _ctools_drush_selection_screen(array $tables = array()) { $selections = $build = array(); $files = system_rebuild_module_data(); $selection_number = 0; - $exportables = _drush_ctools_export_info(); + $info = _ctools_drush_export_info($tables, TRUE); + $exportables = $info['exportables']; + $schemas = $info['schemas']; + $export_tables = array(); foreach (array_keys($exportables) as $table) { natcasesort($exportables[$table]); - $export_tables[$table] = $files[$schema['module']]->info['name'] . ' (' . $table . ')'; + $export_tables[$table] = $files[$schemas[$table]['module']]->info['name'] . ' (' . $table . ')'; } foreach ($export_tables as $table => $table_title) { @@ -268,7 +313,7 @@ function _drush_ctools_selection_screen() { // Present the tables choice. $table_rows = array(); foreach ($build as $table => $info) { - $table_rows[$table] = $info['title'] . ' (' . dt($info['count']) . ')'; + $table_rows[$table] = $info['title'] . ' (' . $info['count'] . ')'; } $table_choice = drush_choice($table_rows, dt('Select a table. Select cancel to start writing files.')); @@ -305,7 +350,7 @@ function _drush_ctools_selection_screen() { * @param $path * Path to directory in which to remove files. */ -function _drush_ctools_file_delete($path) { +function _ctools_drush_file_delete($path) { if (is_dir($path)) { $files = new DirectoryIterator($path); foreach ($files as $fileInfo) { @@ -320,74 +365,40 @@ function _drush_ctools_file_delete($path) { * Drush callback: Export info. * * @params $table_names - * Each argument will be taken as a CTools exportable table name. + * Each argument will be taken as a CTools exportable table name. */ -function drush_ctools_export_info() { +function ctools_drush_export_info() { // Collect array of table names from args. $table_names = func_get_args(); // Get format option to allow for alternative output. $format = drush_get_option('format', FALSE); $tables_only = drush_get_option('tables-only', FALSE); - $show_overridden = drush_get_option('overridden', FALSE); - $show_enabled = drush_get_option('enabled', FALSE); - $show_disabled = drush_get_option('disabled', FALSE); - $show_database_only = drush_get_option('database', FALSE); + $filter = drush_get_option('filter', FALSE); + $export_module = drush_get_option('module', FALSE); - // Only load exportable objects for each type fully if we need to. - $load = ($show_overridden || $show_enabled || $show_disabled || $show_database_only) ? TRUE : FALSE; + $load = (bool) $filter || $export_module; - // Get info on these tables, or all if none specified. - $exportables = _drush_ctools_export_info($table_names, $load); + // Get info on these tables, or all tables if none specified. + $info = _ctools_drush_export_info($table_names, $load); + $exportables = $info['exportables']; if (empty($exportables)) { drush_log(dt('There are no exportables available.'), 'warning'); return; } - // The order of these conditionals set a hierarchy for options if there are mulitple. - // Show enabled exportables only. - if ($show_enabled) { - foreach ($exportables as $table => $objects) { - foreach ($objects as $key => $object) { - if (_ctools_drush_object_is_disabled($object)) { - unset($exportables[$table][$key]); - } - } - } - } - // Show disabled exportables only. - elseif ($show_disabled) { - foreach ($exportables as $table => $objects) { - foreach ($objects as $key => $object) { - if (!_ctools_drush_object_is_disabled($object)) { - unset($exportables[$table][$key]); - } - } - } - } - // Show overridden exportables only. - elseif ($show_overridden) { - foreach ($exportables as $table => $objects) { - foreach ($objects as $key => $object) { - if (!_ctools_drush_object_is_overridden($object)) { - unset($exportables[$table][$key]); - } - } - } + // Filter by export module. + if (is_string($export_module)) { + $exportables = _ctools_drush_export_module_filter($exportables, $export_module); } - // Show database only exportables. - elseif ($show_database_only) { - foreach ($exportables as $table => $objects) { - foreach ($objects as $key => $object) { - if (!_ctools_drush_object_is_db_only($object)) { - unset($exportables[$table][$key]); - } - } - } + + if (empty($exportables)) { + drush_log(dt('There are no exportables matching this criteria.'), 'notice'); + return; } - $exportables = array_filter($exportables); + $exportable_counts = _ctools_drush_count_exportables($exportables); // Only use array keys if --tables-only option is set. if ($tables_only) { @@ -396,7 +407,12 @@ function drush_ctools_export_info() { // Use format from --format option if it's present, and send to drush_format. if ($format) { - drush_print(drush_format($exportables, NULL, $format)); + // Create array with all exportable info and counts in one. + $output = array( + 'exportables' => $exportables, + 'count' => $exportable_counts, + ); + drush_print(drush_format($output, NULL, $format)); } // Build a tabular output as default. else { @@ -416,19 +432,22 @@ function drush_ctools_export_info() { } } if (!empty($rows)) { + drush_print("\n"); array_unshift($rows, $header); - drush_print_table($rows, TRUE); - } - else { - drush_log(dt('There are no exportables matching this criteria.'), 'notice'); + drush_print_table($rows, TRUE, array(20)); + drush_print(dt('Total exportables found: !total', array('!total' => $exportable_counts['total']))); + foreach ($exportable_counts['exportables'] as $table_name => $count) { + drush_print(dt('!table_name (!count)', array('!table_name' => $table_name, '!count' => $count)), 2); + } + drush_print("\n"); } } } - /** - * Drush callback: Acts as the hub for all op commands to keep all arg handling etc in one place. + * Drush callback: Acts as the hub for all op commands to keep + * all arg handling etc in one place. */ -function drush_ctools_export_op_command() { +function ctools_drush_export_op_command() { // Get all info for the current drush command. $command = drush_get_command(); $op = ''; @@ -453,17 +472,34 @@ function drush_ctools_export_op_command() { return; } - $args = func_get_args(); - // Table name should always be first arg... - $table_name = array_shift($args); - // Any additional args are assumed to be exportable names. - $object_names = $args; + if (drush_get_option('all', FALSE)) { + $info = _ctools_drush_export_info('', TRUE); + $exportable_info = $info['exportables']; - // Return any exportables based on table name, object names, options. - $exportables = _drush_ctools_export_op_command_logic($op, $table_name, $object_names); + $all = drush_confirm(dt('Are you sure you would like to !op all exportables on the system?', + array('!op' => _ctools_drush_export_op_alias($op)))); - if ($exportables) { - drush_ctools_export_op($op, $table_name, $exportables); + if ($all && $exportable_info) { + foreach ($exportable_info as $table => $exportables) { + if (!empty($exportables)) { + ctools_drush_export_op($op, $table, $exportables); + } + } + } + } + else { + $args = func_get_args(); + // Table name should always be first arg... + $table_name = array_shift($args); + // Any additional args are assumed to be exportable names. + $object_names = $args; + + // Return any exportables based on table name, object names, options. + $exportables = _ctools_drush_export_op_command_logic($op, $table_name, $object_names); + + if ($exportables) { + ctools_drush_export_op($op, $table_name, $exportables); + } } } @@ -476,10 +512,10 @@ function drush_ctools_export_op_command() { * @param $exportables * */ -function drush_ctools_export_op($op = '', $table_name = '', $exportables = NULL) { +function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL) { $objects = ctools_export_crud_load_multiple($table_name, array_keys($exportables)); - $function = '_drush_ctools_export_' . $op; + $function = '_ctools_drush_export_' . $op; if (function_exists($function)) { foreach ($objects as $object) { $function($table_name, $object); @@ -500,27 +536,27 @@ function drush_ctools_export_op($op = '', $table_name = '', $exportables = NULL) * @param $object_names * * @return - * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not. + * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not. */ -function _drush_ctools_export_op_command_logic($op = '', $table_name = NULL, $object_names = array()) { +function _ctools_drush_export_op_command_logic($op = '', $table_name = NULL, array $object_names = array()) { if (!$table_name) { - drush_log(dt('Exportable table name empty.'), 'error'); + drush_log(dt('Exportable table name empty. Use the --all command if you want to perform this operation on all tables.'), 'error'); return FALSE; } // Get export info based on table name. - $info = _drush_ctools_export_info(array($table_name)); + $info = _ctools_drush_export_info(array($table_name), TRUE); - if (!isset($info[$table_name])) { + if (!isset($info['exportables'][$table_name])) { drush_log(dt('Exportable table name not found.'), 'error'); return FALSE; } - $exportables = $info[$table_name]; + $exportables = &$info['exportables']; if (empty($object_names)) { $all = drush_confirm(dt('No object names entered. Would you like to try and !op all exportables of type !type', - array('!op' => _drush_ctools_export_op_aliases($op), '!type' => $table_name))); + array('!op' => _ctools_drush_export_op_alias($op), '!type' => $table_name))); if (!$all) { drush_log(dt('Command cancelled'), 'success'); return FALSE; @@ -530,20 +566,26 @@ function _drush_ctools_export_op_command_logic($op = '', $table_name = NULL, $ob // Iterate through object names and check they exist in exportables array. // Log error and unset them if they don't. foreach ($object_names as $object_name) { - if (!isset($exportables[$object_name])) { + if (!isset($exportables[$table_name][$object_name])) { drush_log(dt('Invalid exportable: !exportable', array('!exportable' => $object_name)), 'error'); - unset($object_names[$object_name]); + unset($object_names[$table_name][$object_name]); } } // Iterate through exportables to get just a list of selected ones. - foreach (array_keys($exportables) as $exportable) { + foreach (array_keys($exportables[$table_name]) as $exportable) { if (!in_array($exportable, $object_names)) { - unset($exportables[$exportable]); + unset($exportables[$table_name][$exportable]); } } } - return $exportables; + $export_module = drush_get_option('module', FALSE); + + if (is_string($export_module)) { + $exportables = _ctools_drush_export_module_filter($exportables, $export_module); + } + + return $exportables[$table_name]; } /** @@ -551,15 +593,15 @@ function _drush_ctools_export_op_command_logic($op = '', $table_name = NULL, $ob * ctools_export_get_schemas(). * * @param $table_names - * Array of table names to return. + * Array of table names to return. * @param $load - * (bool) should ctools exportable objects be loaded for each type. - * The default behaviour will load just a list of exportable names. + * (bool) should ctools exportable objects be loaded for each type. + * The default behaviour will load just a list of exportable names. * * @return - * Nested arrays of available exportables, keyed by table name. + * Nested arrays of available exportables, keyed by table name. */ -function _drush_ctools_export_info($table_names = array(), $load = FALSE) { +function _ctools_drush_export_info(array $table_names = array(), $load = FALSE) { ctools_include('export'); // Get available schemas that declare exports. $schemas = ctools_export_get_schemas(TRUE); @@ -592,7 +634,12 @@ function _drush_ctools_export_info($table_names = array(), $load = FALSE) { } } - return $exportables; + if ($load) { + $filter = drush_get_option('filter', FALSE); + $exportables = _ctools_drush_filter_exportables($exportables, $filter); + } + + return array('exportables' => $exportables, 'schemas' => $schemas); } /* @@ -601,12 +648,12 @@ function _drush_ctools_export_info($table_names = array(), $load = FALSE) { * @param $table_name * @param $object */ -function _drush_ctools_export_view($table_name, $object) { +function _ctools_drush_export_view($table_name, $object) { $indent = drush_get_option('indent', ''); $no_colour = drush_get_option('no-colour', FALSE); $export = ctools_export_crud_export($table_name, $object, $indent); if ($no_colour) { - drush_print($export); + drush_print("\n$export"); } else { drush_print(shellColours::getColouredOutput("\n$export", 'light_green')); @@ -619,14 +666,16 @@ function _drush_ctools_export_view($table_name, $object) { * @param $table_name * @param $object */ -function _drush_ctools_export_delete($table_name, $object) { +function _ctools_drush_export_delete($table_name, $object) { + $name = _ctools_drush_get_export_name($table_name, $object); + if (_ctools_drush_object_is_overridden($object)) { // Remove from db. ctools_export_crud_delete($table_name, $object); - drush_log("Reverted object: $object->name", 'success'); + drush_log("Reverted object: $name", 'success'); } else { - drush_log("Nothing to revert for: $object->name", 'notice'); + drush_log("Nothing to revert for: $name", 'notice'); } } @@ -636,14 +685,17 @@ function _drush_ctools_export_delete($table_name, $object) { * @param $table_name * @param $object */ -function _drush_ctools_export_enable($table_name, $object) { +function _ctools_drush_export_enable($table_name, $object) { + $name = _ctools_drush_get_export_name($table_name, $object); + if (_ctools_drush_object_is_disabled($object)) { + // Enable object. ctools_export_crud_enable($table_name, $object); - drush_log("Enabled object: $object->name", 'success'); + drush_log("Enabled object: $name", 'success'); } else { - drush_log("$object->name is already Enabled", 'notice'); + drush_log("$name is already Enabled", 'notice'); } } @@ -653,64 +705,216 @@ function _drush_ctools_export_enable($table_name, $object) { * @param $table_name * @param $object */ -function _drush_ctools_export_disable($table_name, $object) { +function _ctools_drush_export_disable($table_name, $object) { + $name = _ctools_drush_get_export_name($table_name, $object); + if (!_ctools_drush_object_is_disabled($object)) { // Disable object. ctools_export_crud_disable($table_name, $object); - drush_log("Disabled object: $object->name", 'success'); + drush_log("Disabled object: $name", 'success'); } else { - drush_log("$object->name is already disabled", 'notice'); + drush_log("$name is already disabled", 'notice'); + } +} + +/** + * Filter a nested array of exportables by export module. + * + * @param $exportables array + * Passed by reference. A nested array of exportables, keyed by table name. + * @param $export_module string + * The name of the export module providing the exportable. + */ +function _ctools_drush_export_module_filter($exportables, $export_module) { + $module_list = module_list(); + + if (!isset($module_list[$export_module])) { + drush_log(dt('Invalid export module: !export_module', array('!export_module' => $export_module)), 'error'); + } + + foreach ($exportables as $table => $objects) { + foreach ($objects as $key => $object) { + if (empty($object->export_module) || ($object->export_module !== $export_module)) { + unset($exportables[$table][$key]); + } + } } + + return array_filter($exportables); } /** - * Helper to determine if an object is disabled. + * Gets the key for an exportable type. * + * @param $table_name + * The exportable table name. * @param $object - * Loaded CTools exportable object. + * The exportable object. * - * @return TRUE or FALSE + * @return string + * The key defined in the export schema data. */ -function _ctools_drush_object_is_disabled($object) { - return (isset($object->disabled) && ($object->disabled == TRUE)) ? TRUE : FALSE; +function _ctools_drush_get_export_name($table_name, $object) { + $info = _ctools_drush_export_info(array($table_name)); + $key = $info['schemas'][$table_name]['export']['key']; + return $object->{$key}; } /** - * Helper to determine if an object is overridden. + * Determine if an object is disabled. * * @param $object - * Loaded CTools exportable object. + * Loaded CTools exportable object. * * @return TRUE or FALSE */ +function _ctools_drush_object_is_disabled($object) { + return (isset($object->disabled) && ($object->disabled == TRUE)) ? TRUE : FALSE; +} + +/** + * Determine if an object is enabled. + * + * @see _ctools_drush_object_is_disabled. + */ +function _ctools_drush_object_is_enabled($object) { + return (empty($object->disabled)) ? TRUE : FALSE; +} + +/** + * Determine if an object is overridden. + */ function _ctools_drush_object_is_overridden($object) { - return ($object->export_type == 3) ? TRUE : FALSE; + $status = EXPORT_IN_CODE + EXPORT_IN_DATABASE; + return ($object->export_type == $status) ? TRUE : FALSE; +} + +/** + * Determine if an object is not overridden. + */ +function _ctools_drush_object_is_not_overridden($object) { + $status = EXPORT_IN_CODE + EXPORT_IN_DATABASE; + return ($object->export_type == $status) ? FALSE : TRUE; +} + +/** + * Determine if an object is only in the db. + */ +function _ctools_drush_object_is_db_only($object) { + return ($object->export_type == EXPORT_IN_DATABASE) ? TRUE : FALSE; +} + +/** + * Determine if an object is not in the db. + */ +function _ctools_drush_object_is_not_db_only($object) { + return ($object->export_type == EXPORT_IN_DATABASE) ? FALSE : TRUE; +} + +/** + * Determine if an object is a code only default. + */ +function _ctools_drush_object_is_code_only($object) { + return ($object->export_type == EXPORT_IN_CODE) ? TRUE : FALSE; +} + +/** + * Determine if an object is not a code only default. + */ +function _ctools_drush_object_is_not_code_only($object) { + return ($object->export_type == EXPORT_IN_CODE) ? FALSE : TRUE; } /** - * Helper to determine if an object is only in the db. + * Return an array of count information based on exportables array. * - * @param $object - * Loaded CTools exportable object. + * @param $exportables + * Array of exportables to count. * - * @return TRUE or FALSE + * @return + * Array of count data containing the following: + * 'total' - A total count of all exportables. + * 'exportables' - An array of exportable counts per table. */ -function _ctools_drush_object_is_db_only($object) { - return ($object->export_type == 1) ? TRUE : FALSE; +function _ctools_drush_count_exportables($exportables) { + $count = array('exportables' => array()); + + foreach ($exportables as $table => $objects) { + // Add the object count for each table. + $count['exportables'][$table] = count($objects); + } + + // Once all tables have been counted, total these up. + $count['total'] = array_sum($count['exportables']); + + return $count; } /** - * Return any aliases for an op, that will be used to show as output. + * Filters a collection of exportables based on filters. + * + * @param $exportables + * @param $filter + */ +function _ctools_drush_filter_exportables($exportables, $filter) { + $eval = FALSE; + + if (is_string($filter)) { + switch ($filter) { + // Show enabled exportables only. + case 'enabled': + $eval = '_ctools_drush_object_is_disabled'; + break; + // Show disabled exportables only. + case 'disabled': + $eval = '_ctools_drush_object_is_enabled'; + break; + // Show overridden exportables only. + case 'overridden': + $eval = '_ctools_drush_object_is_not_overridden'; + break; + // Show database only exportables. + case 'database': + $eval = '_ctools_drush_object_is_not_db_only'; + break; + // Show code only exportables. + case 'code': + $eval = '_ctools_drush_object_is_not_code_only'; + break; + // Do nothing. + case 'all': + break; + default: + drush_log(dt('Invalid filter option. Available options are: enabled, disabled, overridden, database, and code.'), 'error'); + return; + } + + if ($eval) { + foreach ($exportables as $table => $objects) { + foreach ($objects as $key => $object) { + if ($eval($object)) { + unset($exportables[$table][$key]); + } + } + } + } + } + + return array_filter($exportables); +} + +/** + * Return an alias for an op, that will be used to show as output. * For now, this is mainly necessary for delete => revert alias. * * @param $op - * The op name. Such as 'enable', 'disable', or 'delete'. + * The op name. Such as 'enable', 'disable', or 'delete'. * * @return - * The matched alias value or the original $op passed in if not found. + * The matched alias value or the original $op passed in if not found. */ -function _drush_ctools_export_op_aliases($op) { +function _ctools_drush_export_op_alias($op) { $aliases = array( 'delete' => 'revert', ); @@ -722,6 +926,25 @@ function _drush_ctools_export_op_aliases($op) { return $op; } +/** + * Convert the drush options from a csv list into an array. + * + * @param $drush_option + * The drush option name to invoke. + * + * @return + * Exploded array of options. + */ +function _ctools_drush_explode_options($drush_option) { + $options = drush_get_option($drush_option, array()); + if (!empty($options)) { + $options = explode(',', $options); + return array_map('trim', $options); + } + + return $options; +} + /** * Class to deal with wrapping output strings with * colour formatting for the shell. diff --git a/sites/all/modules/ctools/help/about.html b/sites/all/modules/ctools/help/about.html index 8184565f22411461c423b265fec760d0d507fbe8..30b64c2d31dae5ecde99fe3e499e82642598256b 100644 --- a/sites/all/modules/ctools/help/about.html +++ b/sites/all/modules/ctools/help/about.html @@ -1,28 +1,28 @@ -<p>The Chaos Tool Suite is a series of tools for developers to make code that I've found to be very useful to Views and Panels more readily available. Certain methods of doing things, particularly with AJAX, exportable objects, and a plugin system are proving to be ideas that are useful outside of just Views and Panels. This module does not offer much directly ot the end user, but instead creates a library for other modules to use. If you are an end user and some module asked you to install the CTools suite, then this is far as you really need to go. If you're a developer and are interested in these tools, read on!</p> +<p>The Chaos Tool Suite is a series of tools for developers to make code that I've found to be very useful to Views and Panels more readily available. Certain methods of doing things, particularly with AJAX, exportable objects and a plugin system, are proving to be ideas that are useful outside of just Views and Panels. This module does not offer much directly to the end user, but instead, creates a library for other modules to use. If you are an end user and some module asked you to install the CTools suite, then this is far as you really need to go. If you're a developer and are interested in these tools, read on!</p> <h2>Tools provided by CTools</h2> <dl> <dt><a href="&topic:ctools/plugins&">Plugins</a></dt> -<dd>The plugins tool allows a module to allow <b>other</b> modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionaly they offer can differ wildly. +<dd>The plugins tool allows a module to allow <b>other</b> modules (and themes!) to provide plugins which provide some kind of functionality or some kind of task. For example, in Panels there are several types of plugins: Content types (which are like blocks), layouts (which are page layouts) and styles (which can be used to style a panel). Each plugin is represented by a .inc file, and the functionality they offer can differ wildly.</dd> <dt><a href="&topic:ctools/context&">Context</a></dt> <dd>Context is the idea that the objects that are used in page generation have more value than simply creating a single piece of output. Instead, contexts can be used to create multiple pieces of content that can all be put onto the page. Additionally, contexts can be used to derive other contexts via relationships, such as determining the node author and displaying data about the new context.</dd> <dt><a href="&topic:ctools/ajax&">AJAX Tools</a></dt> -<dd>AJAX (also known as AHAH) is a method of allowing the browser and the server to communicate without requiring a page refresh. It can be used to create complicated interactive forms, but it is somewhat difficult to integrate into Drupal's Form API. These tools make it easier to accomplish this goal. In addition, CTools provides a few other javascript helpers, such as a modal dialog, a collapsible div, a simple dropdown and dependent checkboxes. +<dd>AJAX (also known as AHAH) is a method of allowing the browser and the server to communicate without requiring a page refresh. It can be used to create complicated interactive forms, but it is somewhat difficult to integrate into Drupal's Form API. These tools make it easier to accomplish this goal. In addition, CTools provides a few other javascript helpers, such as a modal dialog, a collapsible div, a simple dropdown and dependent checkboxes.</dd> <dt><a href="&topic:ctools/css&">CSS scrubbing and caching</a></dt> -<dd>Drupal comes with a fantastic array of tools to ensure HTML is safe to output, but does not contain any similar tools for CSS. CTools provides a small tool to sanitize CSS so that user-input CSS code can still be safely used. It also provides a method for caching CSS for better performance.</dd> +<dd>Drupal comes with a fantastic array of tools to ensure HTML is safe to output but does not contain any similar tools for CSS. CTools provides a small tool to sanitize CSS, so user-input CSS code can still be safely used. It also provides a method for caching CSS for better performance.</dd> <dt><a href="&topic:ctools/export&">Exportable objects</a></dt> -<dd>Views and Panels both use objects that can either be in code or in the database, and the object can be exported into a piece of PHP code so that it can be moved from site to site or out of the database entirely. This library abstracts that so that other modules can use this same concept for their data.</dd> +<dd>Views and Panels both use objects that can either be in code or in the database, and the objects can be exported into a piece of PHP code, so they can be moved from site to site or out of the database entirely. This library abstracts that functionality, so other modules can use this same concept for their data.</dd> <dt><a href="&topic:ctools/form&">Form tools</a></dt> <dd>Drupal 6's FAPI really improved over Drupal 5, and made a lot of things possible. Still, it missed a few items that were needed to make form wizards and truly dynamic AJAX forms possible. CTools includes a replacement for drupal_get_form() that has a few more options and allows the caller to examine the $form_state once the form has completed.</dd> <dt><a href="&topic:ctools/wizard&">Form wizards</a></dt> -<dd>Finally! An easy way to have form wizards, which is any 'form' which is actually a string of forms that build up to a final conclusion. The form wizard supports a single entry point, the ability to choose whether or not the user can go forward/back/up on the form and easy callbacks to handle the difficult job of dealing with data in between forms.</dd> +<dd>Finally! An easy way to have form wizards, which is any 'form' that is actually a string of forms that build up to a final conclusion. The form wizard supports a single entry point, the ability to choose whether or not the user can go forward/back/up on the form and easy callbacks to handle the difficult job of dealing with data in between forms.</dd> <dt><a href="&topic:ctools/object-cache&">Temporary object cache</a></dt> <dd>For normal forms, all of the data needed for an object is stored in the form so that the browser handles a lot of the work. For multi-step and ajax forms, however, this is impractical, and letting the browser store data can be insecure. The object cache provides a non-volatile location to store temporary data while the form is being worked on. This is much safer than the standard Drupal caching mechanism, which is volatile, meaning it can be cleared at any time and any system using it must be capable of recreating the data that was there. This system also allows for object locking, since any object which has an item in the cache from another person can be assumed to be 'locked for editing'.</dd> diff --git a/sites/all/modules/ctools/help/export.html b/sites/all/modules/ctools/help/export.html index 57ccd9394ffc46831ae502c1c85f9ef701a0ff85..3a774e8217635cdd43a1c887d02de57aff8a3f78 100644 --- a/sites/all/modules/ctools/help/export.html +++ b/sites/all/modules/ctools/help/export.html @@ -112,7 +112,7 @@ function mymodule_schema() { <dd>Human readable title of the export key. Defaults to 'Name'. Because the schema is cached, do not translate this. It must instead be translated when used.</dd> <dt>primary key</dt> -<dd>Objects should contain a primary key which is a database identifier primarily used to determine if an object has been written or not. This is required for the default CRUD save callback to work.</dd> +<dd>A single field within the table that is to be used as the main identifier to discern whether or not the object has been written. As the schema definition's primary key value will be used by default, it is not usually necessary to define this.</dd> <dt>object</dt> <dd>The class the object should be created as, if 'object factory' is not set. If this is not set either, defaults as stdClass.</dd> diff --git a/sites/all/modules/ctools/help/object-cache.html b/sites/all/modules/ctools/help/object-cache.html index 7e31c7454ce3b83a4fe7756081637ee1c60a5cbb..801a83672225e47ed1f2760056fecaa948a5e4e7 100644 --- a/sites/all/modules/ctools/help/object-cache.html +++ b/sites/all/modules/ctools/help/object-cache.html @@ -16,7 +16,7 @@ ctools_include('object-cache'); * will not result in multiple database reads. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being stored. @@ -34,7 +34,7 @@ function ctools_object_cache_get($obj, $name, $skip_cache = FALSE) { * Store an object in the non-volatile ctools cache. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being stored. @@ -49,7 +49,7 @@ function ctools_object_cache_set($obj, $name, $cache) { * Remove an object from the non-volatile ctools cache * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. @@ -67,7 +67,7 @@ function ctools_object_cache_clear($obj, $name) { * modify them. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. @@ -89,7 +89,7 @@ function ctools_object_cache_test($obj, $name) { * This is useful for clearing a lock. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. diff --git a/sites/all/modules/ctools/help/plugins-creating.html b/sites/all/modules/ctools/help/plugins-creating.html index 186bb74c4c6a613e09754ebca9154a54c5fb743d..29a9014f189de24c1a569c15d3d037389b8c7866 100644 --- a/sites/all/modules/ctools/help/plugins-creating.html +++ b/sites/all/modules/ctools/help/plugins-creating.html @@ -1,7 +1,7 @@ There are two primary pieces to using plugins. The first is getting the data, and the second is using the data. <h2>Defining a plugin</h2> -To define that you offer a plugin that modules can implement, you first must implement hook_ctools_plugin_type() to tell the plugin system about your plugin. +To define that you offer a plugin that modules can implement, you first must implement hook_ctools_plugin_type() to tell the plugin system about your plugin. <pre> /** @@ -49,7 +49,7 @@ The following information can be specified for each plugin type: <dd><em>Defaults to:</em> <strong>FALSE</strong></dd> <dd>If set to TRUE, the plugin type can automatically have 'child plugins' meaning each plugin can actually provide multiple plugins. This is mostly used for plugins that store some of their information in the database, such as views, blocks or exportable custom versions of plugins.</dd> <dd>To implement, each plugin can have a 'get child' and 'get children' callback. Both of these should be implemented for performance reasons, since it is best to avoid getting all children if necessary, but if 'get child' is not implemented, it will fall back to 'get children' if it has to.</dd> -<dd>Child plugins should be named parent:child, with the : being the separator, so that it knows which parent plugin to ask for teh child. The 'get children' method should at least return the parent plugin as part of the list, unless it wants the parent plugin itself to not be a choosable option, which is not unheard of. </dd> +<dd>Child plugins should be named parent:child, with the : being the separator, so that it knows which parent plugin to ask for the child. The 'get children' method should at least return the parent plugin as part of the list, unless it wants the parent plugin itself to not be a choosable option, which is not unheard of. </dd> <dd>'get children' arguments are ($plugin, $parent) and 'get child' arguments are ($plugin, $parent, $child). </dl> diff --git a/sites/all/modules/ctools/help/plugins-implementing.html b/sites/all/modules/ctools/help/plugins-implementing.html index ea62aa26ce32d53fd17d292f0901909fa2826d4c..070f08ded1b292d5f83741127cfa7ab9f6e480e1 100644 --- a/sites/all/modules/ctools/help/plugins-implementing.html +++ b/sites/all/modules/ctools/help/plugins-implementing.html @@ -56,4 +56,6 @@ $plugin = array( <p>Several values will be filled in for you automatically, but you can override them if necessary. They include 'name', 'path', 'file' and 'module'. Additionally, the plugin can owner can provide other defaults as well.</p> +<p>There are no required keys by the plugin system itself. The only requirements in the $plugin array will be defined by the plugin type.</p> + <p>After this array, if your plugin needs functions, they can be declared. Different plugin types have different needs here, so exactly what else will be needed will change from type to type.</p> diff --git a/sites/all/modules/ctools/includes/cleanstring.inc b/sites/all/modules/ctools/includes/cleanstring.inc index 530fc0ff3b8a4e9cdb74ed5d9690c56219d26abd..56b3e36f47857654ec9f9972c0b458d7c67e65d3 100644 --- a/sites/all/modules/ctools/includes/cleanstring.inc +++ b/sites/all/modules/ctools/includes/cleanstring.inc @@ -58,10 +58,9 @@ define('CTOOLS_PREG_CLASS_ALNUM', '\x{2ce5}-\x{2cff}\x{2d6f}\x{2e00}-\x{3005}\x{3007}-\x{303b}\x{303d}-\x{303f}' . '\x{3099}-\x{309e}\x{30a0}\x{30fb}-\x{30fe}\x{3190}-\x{319f}\x{31c0}-\x{31cf}' . '\x{3200}-\x{33ff}\x{4dc0}-\x{4dff}\x{a015}\x{a490}-\x{a716}\x{a802}\x{a806}' . -'\x{a80b}\x{a823}-\x{a82b}\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}\x{fd3f}\x{fdfc}-' . -'\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}\x{ff5b}-\x{ff65}' . -'\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}'); - +'\x{a80b}\x{a823}-\x{a82b}\x{e000}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}\x{fd3f}' . +'\x{fdfc}-\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}\x{ff5b}-' . +'\x{ff65}\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}'); /** * Clean up a string value provided by a module. diff --git a/sites/all/modules/ctools/includes/content.inc b/sites/all/modules/ctools/includes/content.inc index 134c951dfa78782c15c18a299285093b0742293e..890ec23a70ae9c1946d9776f6bceaff710a355d7 100644 --- a/sites/all/modules/ctools/includes/content.inc +++ b/sites/all/modules/ctools/includes/content.inc @@ -458,9 +458,12 @@ function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) { if ($function = ctools_plugin_get_function($plugin, 'admin info')) { $output = $function($subtype, $conf, $context); } + if (empty($output) || !is_object($output)) { $output = new stdClass(); - $output->title = t('No info'); + // replace the _ with " " for a better output + $subtype = check_plain(str_replace("_", " ", $subtype)); + $output->title = $subtype; $output->content = t('No info available.'); } return $output; diff --git a/sites/all/modules/ctools/includes/context-admin.inc b/sites/all/modules/ctools/includes/context-admin.inc index aeb7270d2eb3f8b5de7667cdbc71a1e6f3b28fd1..7e5cd02b9ef83b7c14b4e365adb9fcff8ba31385 100644 --- a/sites/all/modules/ctools/includes/context-admin.inc +++ b/sites/all/modules/ctools/includes/context-admin.inc @@ -636,8 +636,8 @@ function ctools_context_get_defaults($plugin_definition, $object, $type) { 'name' => $plugin_definition['name'], ); - if (isset($plugin['defaults'])) { - $defaults = $plugin['defaults']; + if (isset($plugin_definition['defaults'])) { + $defaults = $plugin_definition['defaults']; } else if (isset($subtype['defaults'])) { $defaults = $subtype['defaults']; diff --git a/sites/all/modules/ctools/includes/context-task-handler.inc b/sites/all/modules/ctools/includes/context-task-handler.inc index 3735870ebd4b9e96911123aa9bc9b12d2ef89bce..617f20eb35b5e0e9137fc9ecf3119820b0aad913 100644 --- a/sites/all/modules/ctools/includes/context-task-handler.inc +++ b/sites/all/modules/ctools/includes/context-task-handler.inc @@ -66,9 +66,9 @@ function ctools_context_handler_get_render_handler($task, $subtask, $handlers, $ // If not, if it's a 'context' type handler, use the default tester. if ($plugin['handler type'] == 'context') { $test = ctools_context_handler_default_test($handler, $contexts, $args); - } - if ($test) { - return $id; + if ($test) { + return $id; + } } } } @@ -100,6 +100,24 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte return NULL; } + if ($page) { + if ($subtask) { + $task_name = page_manager_make_task_name($task['name'], $subtask['name']); + } + else { + $task_name = $task['name']; + } + + page_manager_get_current_page(array( + 'name' => $task_name, + 'task' => $task, + 'subtask' => $subtask, + 'contexts' => $contexts, + 'arguments' => $args, + 'handler' => $handler, + )); + } + $info = $function($handler, $contexts, $args); if (!$info) { return NULL; @@ -119,22 +137,6 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte return $info; } - if ($subtask) { - $task_name = page_manager_make_task_name($task['name'], $subtask['name']); - } - else { - $task_name = $task['name']; - } - - page_manager_get_current_page(array( - 'name' => $task_name, - 'task' => $task, - 'subtask' => $subtask, - 'contexts' => $contexts, - 'arguments' => $args, - 'handler' => $handler, - )); - if (!empty($info['response code']) && $info['response code'] != 200) { switch ($info['response code']) { case 403: diff --git a/sites/all/modules/ctools/includes/context.inc b/sites/all/modules/ctools/includes/context.inc index cc6d39c46b3ff37fda8834ba9436ced69017bf65..5c7a4ceedae803acce77bf4da9be7124e3039627 100644 --- a/sites/all/modules/ctools/includes/context.inc +++ b/sites/all/modules/ctools/includes/context.inc @@ -509,7 +509,7 @@ function ctools_context_get_all_converters() { /** * Let the context convert an argument based upon the converter that was given. */ -function ctools_context_convert_context($context, $converter) { +function ctools_context_convert_context($context, $converter, $converter_options = array()) { // Contexts without plugins might be optional placeholders. if (empty($context->plugin)) { return; @@ -518,12 +518,12 @@ function ctools_context_convert_context($context, $converter) { $value = $context->argument; $plugin = ctools_get_context($context->plugin); if ($function = ctools_plugin_get_function($plugin, 'convert')) { - $value = $function($context, $converter); + $value = $function($context, $converter, $converter_options); } foreach (module_implements('ctools_context_converter_alter') as $module) { $function = $module . '_ctools_context_converter_alter'; - $function($context, $converter, $value); + $function($context, $converter, $value, $converter_options); } return $value; @@ -619,7 +619,7 @@ function ctools_context_create_empty($type) { /** * Perform keyword and context substitutions. */ -function ctools_context_keyword_substitute($string, $keywords, $contexts) { +function ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()) { // Ensure a default keyword exists: $keywords['%%'] = '%'; @@ -633,7 +633,7 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts) { // Look for context matches we we only have to convert known matches. $matches = array(); - if (preg_match_all('/%([a-zA-Z0-9%:_-]+)/us', $string, $matches)) { + if (preg_match_all('/%(%|[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?)/us', $string, $matches)) { foreach ($matches[1] as $keyword) { // Ignore anything it finds with %%. if ($keyword[0] == '%') { @@ -666,7 +666,7 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts) { $keywords['%' . $keyword] = ''; } else if (!empty($converter)) { - $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter); + $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options); } else { $keywords['%' . $keyword] = $context_keywords[$keyword]->title; diff --git a/sites/all/modules/ctools/includes/css.inc b/sites/all/modules/ctools/includes/css.inc index 29ac2ec9d9032d83bb4967c1e64dcf96323dd499..ee11d488453220098c2296b6636411ba549ea7bf 100644 --- a/sites/all/modules/ctools/includes/css.inc +++ b/sites/all/modules/ctools/includes/css.inc @@ -284,8 +284,10 @@ function ctools_css_disassemble($css) { $disassembled_css = array(); // Remove comments. $css = preg_replace("/\/\*(.*)?\*\//Usi", "", $css); - // Split out each statement - $statements = explode("}", $css); + // Split out each statement. Match either a right curly brace or a semi-colon + // that precedes a left curly brace with no right curly brace separating them. + $statements = preg_split('/}|;(?=[^}]*{)/', $css); + // If we have any statements, parse them. if (!empty($statements)) { // Iterate through all of the statements. @@ -306,7 +308,10 @@ function ctools_css_disassemble($css) { } // Disassemble the declaration, check it and tuck it into an array. - $disassembled_css[$selector_str] = _ctools_css_disassemble_declaration($declaration); + if (!isset($disassembled_css[$selector_str])) { + $disassembled_css[$selector_str] = array(); + } + $disassembled_css[$selector_str] += _ctools_css_disassemble_declaration($declaration); } } return $disassembled_css; diff --git a/sites/all/modules/ctools/includes/export-ui.inc b/sites/all/modules/ctools/includes/export-ui.inc index 89b6d16d10c84c910889a80a3e6b9d9748e9c8d1..16e57d6ed4b0a94318002c88d553c3740e93fd28 100644 --- a/sites/all/modules/ctools/includes/export-ui.inc +++ b/sites/all/modules/ctools/includes/export-ui.inc @@ -19,6 +19,7 @@ function ctools_export_ui_process(&$plugin, $info) { 'export' => array(), 'allowed operations' => array(), 'menu' => array(), + 'redirect' => array(), 'form' => array(), 'strings' => array(), 'list' => NULL, @@ -115,171 +116,176 @@ function ctools_export_ui_process(&$plugin, $info) { ); $plugin['menu']['items'] += array( - 'list callback' => array( - 'path' => '', - // Menu items are translated by the menu system. - // TODO: We need more flexibility in title. The title of the admin page - // is not necessarily the title of the object, plus we need - // plural, singular, proper, not proper, etc. - 'title' => $plugin['menu']['menu title'], - 'description' => $plugin['menu']['menu description'], - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'list'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'list'), - 'type' => MENU_NORMAL_ITEM, - ), - 'list' => array( - 'path' => 'list', - 'title' => 'List', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'list'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'list'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ), - 'add' => array( - 'path' => 'add', - 'title' => 'Add', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'add'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'add'), - 'type' => MENU_LOCAL_ACTION, - ), - 'edit callback' => array( - 'path' => 'list/%ctools_export_ui', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), - 'edit' => array( - 'path' => 'list/%ctools_export_ui/edit', - 'title' => 'Edit', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ), + 'list callback' => array(), + 'list' => array(), + 'add' => array(), + 'edit callback' => array(), + 'edit' => array(), + ); + + $plugin['menu']['items']['list callback'] += array( + 'path' => '', + // Menu items are translated by the menu system. + // TODO: We need more flexibility in title. The title of the admin page + // is not necessarily the title of the object, plus we need + // plural, singular, proper, not proper, etc. + 'title' => $plugin['menu']['menu title'], + 'description' => $plugin['menu']['menu description'], + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'list'), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'list'), + 'type' => MENU_NORMAL_ITEM, + ); + + $plugin['menu']['items']['list'] += array( + 'path' => 'list', + 'title' => 'List', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'list'), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'list'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + + $plugin['menu']['items']['add'] += array( + 'path' => 'add', + 'title' => 'Add', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'add'), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'add'), + 'type' => MENU_LOCAL_ACTION, + ); + + $plugin['menu']['items']['edit callback'] += array( + 'path' => 'list/%ctools_export_ui', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), + 'type' => MENU_CALLBACK, + ); + + $plugin['menu']['items']['edit'] += array( + 'path' => 'list/%ctools_export_ui/edit', + 'title' => 'Edit', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, ); if ($plugin['allowed operations']['import']) { - $plugin['menu']['items'] += array( - 'import' => array( - 'path' => 'import', - 'title' => 'Import', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'import'), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'import'), - 'type' => MENU_LOCAL_ACTION, - ), + $plugin['menu']['items'] += array('import' => array()); + $plugin['menu']['items']['import'] += array( + 'path' => 'import', + 'title' => 'Import', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'import'), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'import'), + 'type' => MENU_LOCAL_ACTION, ); } if ($plugin['allowed operations']['export']) { - $plugin['menu']['items'] += array( - 'export' => array( - 'path' => 'list/%ctools_export_ui/export', - 'title' => 'Export', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'export', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'export', $prefix_count + 2), - 'type' => MENU_LOCAL_TASK, - ), + $plugin['menu']['items'] += array('export' => array()); + $plugin['menu']['items']['export'] += array( + 'path' => 'list/%ctools_export_ui/export', + 'title' => 'Export', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'export', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'export', $prefix_count + 2), + 'type' => MENU_LOCAL_TASK, ); } if ($plugin['allowed operations']['revert']) { - $plugin['menu']['items'] += array( - 'revert' => array( - 'path' => 'list/%ctools_export_ui/revert', - 'title' => 'Revert', - 'page callback' => 'ctools_export_ui_switcher_page', - // Note: Yes, 'delete' op is correct. - 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'revert', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), + $plugin['menu']['items'] += array('revert' => array()); + $plugin['menu']['items']['revert'] += array( + 'path' => 'list/%ctools_export_ui/revert', + 'title' => 'Revert', + 'page callback' => 'ctools_export_ui_switcher_page', + // Note: Yes, 'delete' op is correct. + 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'revert', $prefix_count + 2), + 'type' => MENU_CALLBACK, ); } if ($plugin['allowed operations']['delete']) { - $plugin['menu']['items'] += array( - 'delete' => array( - 'path' => 'list/%ctools_export_ui/delete', - 'title' => 'Delete', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'delete', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), + $plugin['menu']['items'] += array('delete' => array()); + $plugin['menu']['items']['delete'] += array( + 'path' => 'list/%ctools_export_ui/delete', + 'title' => 'Delete', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'delete', $prefix_count + 2), + 'type' => MENU_CALLBACK, ); } if ($plugin['allowed operations']['clone']) { - $plugin['menu']['items'] += array( - 'clone' => array( - 'path' => 'list/%ctools_export_ui/clone', - 'title' => 'Clone', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'clone', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'clone', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), + $plugin['menu']['items'] += array('clone' => array()); + $plugin['menu']['items']['clone'] += array( + 'path' => 'list/%ctools_export_ui/clone', + 'title' => 'Clone', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'clone', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'clone', $prefix_count + 2), + 'type' => MENU_CALLBACK, ); } if ($plugin['allowed operations']['enable']) { - $plugin['menu']['items'] += array( - 'enable' => array( - 'path' => 'list/%ctools_export_ui/enable', - 'title' => 'Enable', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'enable', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'enable', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), + $plugin['menu']['items'] += array('enable' => array()); + $plugin['menu']['items']['enable'] += array( + 'path' => 'list/%ctools_export_ui/enable', + 'title' => 'Enable', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'enable', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'enable', $prefix_count + 2), + 'type' => MENU_CALLBACK, ); } if ($plugin['allowed operations']['disable']) { - $plugin['menu']['items'] += array( - 'disable' => array( - 'path' => 'list/%ctools_export_ui/disable', - 'title' => 'Disable', - 'page callback' => 'ctools_export_ui_switcher_page', - 'page arguments' => array($plugin['name'], 'disable', $prefix_count + 2), - 'load arguments' => array($plugin['name']), - 'access callback' => 'ctools_export_ui_task_access', - 'access arguments' => array($plugin['name'], 'disable', $prefix_count + 2), - 'type' => MENU_CALLBACK, - ), + $plugin['menu']['items'] += array('disable' => array()); + $plugin['menu']['items']['disable'] += array( + 'path' => 'list/%ctools_export_ui/disable', + 'title' => 'Disable', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'disable', $prefix_count + 2), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'disable', $prefix_count + 2), + 'type' => MENU_CALLBACK, ); } - // Define some redirects that should happen after edit/add/clone operations. - $plugin['redirect'] = array( + // Define some redirects that should happen after edit/add/clone/delete operations. + $plugin['redirect'] += array( 'add' => $base_path, 'clone' => $base_path, 'edit' => $base_path, + 'delete' => $base_path, + 'revert' => $base_path, 'import' => $base_path, ); diff --git a/sites/all/modules/ctools/includes/export.inc b/sites/all/modules/ctools/includes/export.inc index dfbe74b9e57dba97fbcef4bf76b39a26a90464e9..0b2ef46dfa2e1a5e63fda9535ba71e89f3f93685 100644 --- a/sites/all/modules/ctools/includes/export.inc +++ b/sites/all/modules/ctools/includes/export.inc @@ -386,10 +386,15 @@ function ctools_export_crud_disable($table, $object) { */ function ctools_export_load_object($table, $type = 'all', $args = array()) { $cache = &drupal_static(__FUNCTION__); + $cache_table_exists = &drupal_static(__FUNCTION__ . '_table_exists', array()); $cached_database = &drupal_static('ctools_export_load_object_all'); + if (!array_key_exists($table, $cache_table_exists)) { + $cache_table_exists[$table] = db_table_exists($table); + } + $schema = ctools_export_get_schema($table); - if (empty($schema) || !db_table_exists($table)) { + if (empty($schema) || !$cache_table_exists[$table]) { return array(); } diff --git a/sites/all/modules/ctools/includes/object-cache.inc b/sites/all/modules/ctools/includes/object-cache.inc index 5de4df71c6c306e3a2cc809cce1e6f8730576044..29225b05bdda8ef6102c5509790b43679e918a61 100644 --- a/sites/all/modules/ctools/includes/object-cache.inc +++ b/sites/all/modules/ctools/includes/object-cache.inc @@ -16,26 +16,33 @@ * will not result in multiple database reads. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being stored. * @param $skip_cache * Skip the memory cache, meaning this must be read from the db again. + * @param $sid + * The session id, allowing someone to use Session API or their own solution; + * defaults to session_id(). * * @deprecated $skip_cache is deprecated in favor of drupal_static* * @return * The data that was cached. */ -function ctools_object_cache_get($obj, $name, $skip_cache = FALSE) { +function ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL) { $cache = &drupal_static(__FUNCTION__, array()); $key = "$obj:$name"; if ($skip_cache) { unset($cache[$key]); } + if (!$sid) { + $sid = session_id(); + } + if (!array_key_exists($key, $cache)) { - $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => session_id(), ':object' => $obj, ':name' => $name)) + $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => $sid, ':object' => $obj, ':name' => $name)) ->fetchObject(); if ($data) { $cache[$key] = unserialize($data->data); @@ -48,14 +55,17 @@ function ctools_object_cache_get($obj, $name, $skip_cache = FALSE) { * Store an object in the non-volatile ctools cache. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being stored. * @param $cache * The object to be cached. This will be serialized prior to writing. + * @param $sid + * The session id, allowing someone to use Session API or their own solution; + * defaults to session_id(). */ -function ctools_object_cache_set($obj, $name, $cache) { +function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) { // Store the CTools session id in the user session to force a // session for anonymous users in Drupal 7 and Drupal 6 Pressflow. // see http://drupal.org/node/562374, http://drupal.org/node/861778 @@ -63,10 +73,15 @@ function ctools_object_cache_set($obj, $name, $cache) { $_SESSION['ctools_hold_session'] = TRUE; } - ctools_object_cache_clear($obj, $name); + ctools_object_cache_clear($obj, $name, $sid); + + if (!$sid) { + $sid = session_id(); + } + db_insert('ctools_object_cache') ->fields(array( - 'sid' => session_id(), + 'sid' => $sid, 'obj' => $obj, 'name' => $name, 'data' => serialize($cache), @@ -79,14 +94,22 @@ function ctools_object_cache_set($obj, $name, $cache) { * Remove an object from the non-volatile ctools cache * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. + * @param $sid + * The session id, allowing someone to use Session API or their own solution; + * defaults to session_id(). */ -function ctools_object_cache_clear($obj, $name) { +function ctools_object_cache_clear($obj, $name, $sid = NULL) { + + if (!$sid) { + $sid = session_id(); + } + db_delete('ctools_object_cache') - ->condition('sid', session_id()) + ->condition('sid', $sid) ->condition('obj', $obj) ->condition('name', $name) ->execute(); @@ -102,16 +125,24 @@ function ctools_object_cache_clear($obj, $name) { * modify them. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. + * @param $sid + * The session id, allowing someone to use Session API or their own solution; + * defaults to session_id(). * * @return * An object containing the UID and updated date if found; NULL if not. */ -function ctools_object_cache_test($obj, $name) { - return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => session_id(), ':obj' => $obj, ':name' => $name)) +function ctools_object_cache_test($obj, $name, $sid = NULL) { + + if (!$sid) { + $sid = session_id(); + } + + return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => $sid, ':obj' => $obj, ':name' => $name)) ->fetchObject(); } @@ -122,7 +153,7 @@ function ctools_object_cache_test($obj, $name) { * an an administration UI. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $names * An array of names of objects @@ -141,7 +172,7 @@ function ctools_object_cache_test_objects($obj, $names) { * This is useful for clearing a lock. * * @param $obj - * A 32 character or less string to define what kind of object is being + * A 128 character or less string to define what kind of object is being * stored; primarily this is used to prevent collisions. * @param $name * The name of the object being removed. diff --git a/sites/all/modules/ctools/includes/plugins.inc b/sites/all/modules/ctools/includes/plugins.inc index a6d4bd65923e77e42306e2a3754f6849e9cc11b4..2dbdd48494404009259b7cf4bd1ff116b259b94f 100644 --- a/sites/all/modules/ctools/includes/plugins.inc +++ b/sites/all/modules/ctools/includes/plugins.inc @@ -246,17 +246,10 @@ function ctools_get_plugins($module, $type, $id = NULL) { $cache = cache_get("plugins:$module:$type", $info[$module][$type]['cache table']); if (!empty($cache->data)) { - // Verify that the file exists as it may have been moved in a multisite environment - if (isset($cache->data['path'])) { - // Files to be registered may be in two locations. Check for both of them. - if ((is_array($cache->data['path']) && file_exists($cache->data['path']['file'])) || - file_exists($cache->data['path'])) { - // Cache load succeeded so use the cached plugin list. - $plugins[$module][$type] = $cache->data; - // Set $setup to true so we know things where loaded. - $setup[$module][$type] = TRUE; - } - } + // Cache load succeeded so use the cached plugin list. + $plugins[$module][$type] = $cache->data; + // Set $setup to true so we know things where loaded. + $setup[$module][$type] = TRUE; } else { // Cache load failed so store that we need to build and write the cache. diff --git a/sites/all/modules/ctools/includes/stylizer.inc b/sites/all/modules/ctools/includes/stylizer.inc index 1f945986bf032a320f2bb69c007a0b5500944085..9fdc81d771481aedf81d220f99762515dffbf75d 100644 --- a/sites/all/modules/ctools/includes/stylizer.inc +++ b/sites/all/modules/ctools/includes/stylizer.inc @@ -960,7 +960,7 @@ function ctools_stylizer_edit_style_form_choose_submit($form, &$form_state) { function ctools_stylizer_edit_style_form_default($form, &$form_state) { ctools_add_js('stylizer'); ctools_add_css('stylizer'); - drupal_add_library('system', 'drupal.farbtastic'); + drupal_add_library('system', 'farbtastic'); $plugin = &$form_state['base_style_plugin']; $settings = &$form_state['settings']; diff --git a/sites/all/modules/ctools/includes/wizard.inc b/sites/all/modules/ctools/includes/wizard.inc index 0e2e11ddf3d109215392c32aaef363043fd8f49f..6f5d7944b863ec48f4934a24dfb7fd749399f1fb 100644 --- a/sites/all/modules/ctools/includes/wizard.inc +++ b/sites/all/modules/ctools/includes/wizard.inc @@ -256,16 +256,13 @@ function ctools_wizard_wrapper($form, &$form_state) { if (!empty($form_info['show trail'])) { if (!empty($form_info['free trail'])) { - // ctools_wizard_get_path() returns results suitable for #redirect - // which can only be directly used in drupal_goto. We have to futz - // with it. + // ctools_wizard_get_path() returns results suitable for + // $form_state['redirect] which can only be directly used in + // drupal_goto. We have to futz a bit with it. $path = ctools_wizard_get_path($form_info, $id); $options = array(); if (!empty($path[1])) { - $options['query'] = $path[1]; - } - if (!empty($path[2])) { - $options['fragment'] = $path[2]; + $options = $path[1]; } $title = l($title, $path[0], $options); } @@ -433,6 +430,12 @@ function ctools_wizard_submit(&$form, &$form_state) { } else if ($type == 'next') { $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']); + if (!empty($_GET['destination'])) { + // We don't want drupal_goto redirect this request + // back. ctools_wizard_get_path ensures that the destination is + // carried over on subsequent pages. + unset($_GET['destination']); + } } else if (isset($form_state['form_info']['return path'])) { $form_state['redirect'] = $form_state['form_info']['return path']; @@ -452,11 +455,27 @@ function ctools_wizard_get_path($form_info, $step) { foreach ($form_info['path'] as $id => $part) { $form_info['path'][$id] = str_replace('%step', $step, $form_info['path'][$id]); } - return $form_info['path']; + $path = $form_info['path']; } else { - return array(str_replace('%step', $step, $form_info['path'])); + $path = array(str_replace('%step', $step, $form_info['path'])); } + + // If destination is set, carry it over so it'll take effect when + // saving. The submit handler will unset destination to avoid drupal_goto + // redirecting us. + if (!empty($_GET['destination'])) { + // Ensure that options is an array. + if (!isset($path[1]) || !is_array($path[1])) { + $path[1] = array(); + } + // Ensure that the query part of options is an array. + $path[1] += array('query' => array()); + // Add the destination parameter, if not set already. + $path[1]['query'] += drupal_get_destination(); + } + + return $path; } /** diff --git a/sites/all/modules/ctools/js/ajax-responder.js b/sites/all/modules/ctools/js/ajax-responder.js index e244106fe7b4d355ad621caab2d430b2121bf976..1cad618efbdbc0e82fcb4128efd08e2c49014f14 100644 --- a/sites/all/modules/ctools/js/ajax-responder.js +++ b/sites/all/modules/ctools/js/ajax-responder.js @@ -88,10 +88,11 @@ var url_class = '.' + $(item).attr('id') + '-url'; $(url_class).each( function() { - if (url && $(this).val()) { + var $this = $(this); + if (url && $this.val()) { url += '/'; } - url += $(this).val(); + url += $this.val(); }); return url; }; diff --git a/sites/all/modules/ctools/js/auto-submit.js b/sites/all/modules/ctools/js/auto-submit.js index bc5a58ea4eb71a986cd99cd76089db708c0ad5de..890dd1ffde6da0e0664390b71680701f865c2e59 100644 --- a/sites/all/modules/ctools/js/auto-submit.js +++ b/sites/all/modules/ctools/js/auto-submit.js @@ -16,6 +16,12 @@ * '#attributes' => array('class' => array('ctools-auto-submit-full-form')), * @endcode * + * If you want to exclude a field from the ctool-auto-submit-full-form auto submission, + * add the class ctools-auto-submit-exclude to the form element. With FAPI, add: + * @code + * '#attributes' => array('class' => array('ctools-auto-submit-exclude')), + * @endcode + * * Finally, you have to identify which button you want clicked for autosubmit. * The behavior of this button will be honored if it's ajaxy or not: * @code @@ -30,15 +36,16 @@ Drupal.behaviors.CToolsAutoSubmit = { attach: function(context) { // 'this' references the form element function triggerSubmit (e) { - if (!$(this).hasClass('ctools-ajaxing')) { - $(this).find('.ctools-auto-submit-click').click(); + var $this = $(this); + if (!$this.hasClass('ctools-ajaxing')) { + $this.find('.ctools-auto-submit-click').click(); } } // the change event bubbles so we only need to bind it to the outer form $('form.ctools-auto-submit-full-form', context) .add('.ctools-auto-submit', context) - .filter('form, select, input:not(:text, :submit)') + .filter('form, select, input:not(:text, :submit, .ctools-auto-submit-exclude)') .once('ctools-auto-submit') .change(function (e) { // don't trigger on text change for full-form @@ -67,6 +74,7 @@ Drupal.behaviors.CToolsAutoSubmit = { ]; // Don't wait for change event on textfields $('.ctools-auto-submit-full-form input:text, input:text.ctools-auto-submit', context) + .filter(':not(.ctools-auto-submit-exclude)') .once('ctools-auto-submit', function () { // each textinput element has his own timeout var timeoutID = 0; diff --git a/sites/all/modules/ctools/js/collapsible-div.js b/sites/all/modules/ctools/js/collapsible-div.js index 363345c18dff3bf92a45168dff24408dab926e43..da9bff9e9b331cc0e5556f0ed9df5bf5ef3a811a 100644 --- a/sites/all/modules/ctools/js/collapsible-div.js +++ b/sites/all/modules/ctools/js/collapsible-div.js @@ -232,11 +232,9 @@ /** * Support Drupal's 'behaviors' system for binding. */ - Drupal.behaviors.CToolsCollapsible = { + Drupal.behaviors.CToolsCollapsible = { attach: function(context) { - $('.ctools-collapsible-container:not(.ctools-collapsible-processed)', context) - .each(Drupal.CTools.bindCollapsible) - .addClass('ctools-collapsible-processed'); + $('.ctools-collapsible-container', context).once('ctools-collapsible', Drupal.CTools.bindCollapsible); } } })(jQuery); diff --git a/sites/all/modules/ctools/js/dependent.js b/sites/all/modules/ctools/js/dependent.js index cca36222197539f491a1951fdf436dfb90416c59..07ff021eac27d86074b7f64e95478bb91a718689 100644 --- a/sites/all/modules/ctools/js/dependent.js +++ b/sites/all/modules/ctools/js/dependent.js @@ -1,17 +1,15 @@ /** * @file - * - * Written by dmitrig01 (Dmitri Gaskin) for CTools; this provides dependent - * visibility for form items in CTools' ajax forms. + * Provides dependent visibility for form items in CTools' ajax forms. * * To your $form item definition add: - * - '#process' => array('CTools_process_dependency'), - * - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that, - make, this, item, show), + * - '#process' => array('ctools_process_dependency'), + * - '#dependency' => array('id-of-form-item' => array(list, of, values, that, + * make, this, item, show), * * Special considerations: - * - radios are harder. Because Drupal doesn't give radio groups individual ids, - * use 'radio:name-of-radio' + * - Radios are harder. Because Drupal doesn't give radio groups individual IDs, + * use 'radio:name-of-radio'. * * - Checkboxes don't have their own id, so you need to add one in a div * around the checkboxes via #prefix and #suffix. You actually need to add TWO @@ -215,8 +213,8 @@ // Really large sets of fields are too slow with the above method, so this // is a sort of hacked one that's faster but much less flexible. - $("select.ctools-master-dependent:not(.ctools-processed)") - .addClass('ctools-processed') + $("select.ctools-master-dependent") + .once('ctools-dependent') .change(function() { var val = $(this).val(); if (val == 'all') { diff --git a/sites/all/modules/ctools/js/dropbutton.js b/sites/all/modules/ctools/js/dropbutton.js index 4dd20b0b8020ac9b5bacf1125059591cb14f0e87..49bc10749205f09f1f671e24aa4c9bb614a411a1 100644 --- a/sites/all/modules/ctools/js/dropbutton.js +++ b/sites/all/modules/ctools/js/dropbutton.js @@ -26,13 +26,12 @@ Drupal.behaviors.CToolsDropbutton = { attach: function() { // Process buttons. All dropbuttons are buttons. - $('.ctools-button:not(.ctools-button-processed)') - .removeClass('ctools-no-js') - .addClass('ctools-button-processed'); + $('.ctools-button') + .once('ctools-button') + .removeClass('ctools-no-js'); + // Process dropbuttons. Not all buttons are dropbuttons. - $('.ctools-dropbutton:not(.ctools-dropbutton-processed)') - .addClass('ctools-dropbutton-processed') - .each(function() { + $('.ctools-dropbutton').once('ctools-dropbutton', function() { var $dropbutton = $(this); var $button = $('.ctools-content', $dropbutton); var $secondaryActions = $('li', $button).not(':first'); diff --git a/sites/all/modules/ctools/js/dropdown.js b/sites/all/modules/ctools/js/dropdown.js index 522f4d5d7643789d2903f25d486caff796f4d5c3..c829ae2fe134cbf97064fcf44fe8b9425636009a 100644 --- a/sites/all/modules/ctools/js/dropdown.js +++ b/sites/all/modules/ctools/js/dropdown.js @@ -24,50 +24,50 @@ (function ($) { Drupal.behaviors.CToolsDropdown = { attach: function() { - $('div.ctools-dropdown:not(.ctools-dropdown-processed)') - .removeClass('ctools-dropdown-no-js') - .addClass('ctools-dropdown-processed') - .each(function() { - var $dropdown = $(this); - var open = false; - var hovering = false; - var timerID = 0; + $('div.ctools-dropdown').once('ctools-dropdown', function() { + var $dropdown = $(this); + var open = false; + var hovering = false; + var timerID = 0; - var toggle = function(close) { - // if it's open or we're told to close it, close it. - if (open || close) { - // If we're just toggling it, close it immediately. - if (!close) { - open = false; - $("div.ctools-dropdown-container", $dropdown).slideUp(100); - } - else { - // If we were told to close it, wait half a second to make - // sure that's what the user wanted. - // Clear any previous timer we were using. - if (timerID) { - clearTimeout(timerID); - } - timerID = setTimeout(function() { - if (!hovering) { - open = false; - $("div.ctools-dropdown-container", $dropdown).slideUp(100); - }}, 500); - } + $dropdown.removeClass('ctools-dropdown-no-js'); + + var toggle = function(close) { + // if it's open or we're told to close it, close it. + if (open || close) { + // If we're just toggling it, close it immediately. + if (!close) { + open = false; + $("div.ctools-dropdown-container", $dropdown).slideUp(100); } else { - // open it. - open = true; - $("div.ctools-dropdown-container", $dropdown) - .animate({height: "show", opacity: "show"}, 100); + // If we were told to close it, wait half a second to make + // sure that's what the user wanted. + // Clear any previous timer we were using. + if (timerID) { + clearTimeout(timerID); + } + timerID = setTimeout(function() { + if (!hovering) { + open = false; + $("div.ctools-dropdown-container", $dropdown).slideUp(100); + } + }, 500); } } - $("a.ctools-dropdown-link", $dropdown).click(function() { - toggle(); - return false; - }); + else { + // open it. + open = true; + $("div.ctools-dropdown-container", $dropdown) + .animate({height: "show", opacity: "show"}, 100); + } + } + $("a.ctools-dropdown-link", $dropdown).click(function() { + toggle(); + return false; + }); - $dropdown.hover( + $dropdown.hover( function() { hovering = true; }, // hover in @@ -76,12 +76,12 @@ toggle(true); return false; }); - // @todo -- just use CSS for this noise. - $("div.ctools-dropdown-container a").hover( - function() { $(this).addClass('ctools-dropdown-hover'); }, - function() { $(this).removeClass('ctools-dropdown-hover'); } - ); - }); + // @todo -- just use CSS for this noise. + $("div.ctools-dropdown-container a").hover( + function() { $(this).addClass('ctools-dropdown-hover'); }, + function() { $(this).removeClass('ctools-dropdown-hover'); } + ); + }); } } })(jQuery); diff --git a/sites/all/modules/ctools/js/jump-menu.js b/sites/all/modules/ctools/js/jump-menu.js index 6bd0af6be78fa9283dbbebec71c6ce1339395a38..7b0928a68e79fdbb2d3490094b59b56ac6477a7a 100644 --- a/sites/all/modules/ctools/js/jump-menu.js +++ b/sites/all/modules/ctools/js/jump-menu.js @@ -1,13 +1,13 @@ (function($) { - Drupal.behaviors.CToolsJumpMenu = { + Drupal.behaviors.CToolsJumpMenu = { attach: function(context) { - $('.ctools-jump-menu-hide:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') + $('.ctools-jump-menu-hide') + .once('ctools-jump-menu') .hide(); - $('.ctools-jump-menu-change:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') + $('.ctools-jump-menu-change') + .once('ctools-jump-menu') .change(function() { var loc = $(this).val(); var urlArray = loc.split('::'); @@ -20,8 +20,8 @@ return false; }); - $('.ctools-jump-menu-button:not(.ctools-jump-menu-processed)') - .addClass('ctools-jump-menu-processed') + $('.ctools-jump-menu-button') + .once('ctools-jump-menu') .click(function() { // Instead of submitting the form, just perform the redirect. diff --git a/sites/all/modules/ctools/js/modal.js b/sites/all/modules/ctools/js/modal.js index acb2227a6b4f501ec97bf0c99b5fc439b052c6e8..5b417d02be2aa8f7fc2c7de4ea4390db516ee11b 100644 --- a/sites/all/modules/ctools/js/modal.js +++ b/sites/all/modules/ctools/js/modal.js @@ -175,10 +175,10 @@ * Submit responder to do an AJAX submit on all modal forms. */ Drupal.CTools.Modal.submitAjaxForm = function(e) { - var url = $(this).attr('action'); - var form = $(this); + var $form = $(this); + var url = $form.attr('action'); - setTimeout(function() { Drupal.CTools.AJAX.ajaxSubmit(form, url); }, 1); + setTimeout(function() { Drupal.CTools.AJAX.ajaxSubmit($form, url); }, 1); return false; } @@ -192,83 +192,79 @@ // used together safely. /* * @todo remimplement the warm caching feature - $('a.ctools-use-modal-cache:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxCacheLink) - .each(function () { - Drupal.CTools.AJAX.warmCache.apply(this); - }); + $('a.ctools-use-modal-cache', context).once('ctools-use-modal', function() { + $(this).click(Drupal.CTools.Modal.clickAjaxCacheLink); + Drupal.CTools.AJAX.warmCache.apply(this); + }); */ - $('area.ctools-use-modal:not(.ctools-use-modal-processed), a.ctools-use-modal:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxLink) - .each(function () { - // Create a drupal ajax object - var element_settings = {}; - if ($(this).attr('href')) { - element_settings.url = $(this).attr('href'); - element_settings.event = 'click'; - element_settings.progress = { type: 'throbber' }; - } - var base = $(this).attr('href'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - - // Attach the display behavior to the ajax object + $('area.ctools-use-modal, a.ctools-use-modal', context).once('ctools-use-modal', function() { + var $this = $(this); + $this.click(Drupal.CTools.Modal.clickAjaxLink); + // Create a drupal ajax object + var element_settings = {}; + if ($this.attr('href')) { + element_settings.url = $this.attr('href'); + element_settings.event = 'click'; + element_settings.progress = { type: 'throbber' }; } - ); + var base = $this.attr('href'); + Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); + }); // Bind buttons - $('input.ctools-use-modal:not(.ctools-use-modal-processed), button.ctools-use-modal:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .click(Drupal.CTools.Modal.clickAjaxLink) - .each(function() { - var button = this; - var element_settings = {}; - - // AJAX submits specified in this manner automatically submit to the - // normal form action. - element_settings.url = Drupal.CTools.Modal.findURL(this); - element_settings.event = 'click'; - - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - - // Make sure changes to settings are reflected in the URL. - $('.' + $(button).attr('id') + '-url').change(function() { - Drupal.ajax[base].options.url = Drupal.CTools.Modal.findURL(button); - }); + $('input.ctools-use-modal, button.ctools-use-modal', context).once('ctools-use-modal', function() { + var $this = $(this); + $this.click(Drupal.CTools.Modal.clickAjaxLink); + var button = this; + var element_settings = {}; + + // AJAX submits specified in this manner automatically submit to the + // normal form action. + element_settings.url = Drupal.CTools.Modal.findURL(this); + element_settings.event = 'click'; + + var base = $this.attr('id'); + Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); + + // Make sure changes to settings are reflected in the URL. + $('.' + $(button).attr('id') + '-url').change(function() { + Drupal.ajax[base].options.url = Drupal.CTools.Modal.findURL(button); }); + }); // Bind our custom event to the form submit - $('#modal-content form:not(.ctools-use-modal-processed)', context) - .addClass('ctools-use-modal-processed') - .each(function() { - var element_settings = {}; - - element_settings.url = $(this).attr('action'); - element_settings.event = 'submit'; - element_settings.progress = { 'type': 'throbber' } - var base = $(this).attr('id'); - - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - Drupal.ajax[base].form = $(this); - - $('input[type=submit], button', this).click(function() { - Drupal.ajax[base].element = this; - this.form.clk = this; - }); - + $('#modal-content form', context).once('ctools-use-modal', function() { + var $this = $(this); + var element_settings = {}; + + element_settings.url = $this.attr('action'); + element_settings.event = 'submit'; + element_settings.progress = { 'type': 'throbber' } + var base = $this.attr('id'); + + Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); + Drupal.ajax[base].form = $this; + + $('input[type=submit], button', this).click(function(event) { + Drupal.ajax[base].element = this; + this.form.clk = this; + // An empty event means we were triggered via .click() and + // in jquery 1.4 this won't trigger a submit. + if (event.bubbles == undefined) { + $(this.form).trigger('submit'); + return false; + } }); + }); // Bind a click handler to allow elements with the 'ctools-close-modal' // class to close the modal. - $('.ctools-close-modal', context).once('ctools-close-modal-processed', function () { - $(this).click(function() { + $('.ctools-close-modal', context).once('ctools-close-modal') + .click(function() { Drupal.CTools.Modal.dismiss(); return false; }); - }); } }; @@ -282,7 +278,10 @@ Drupal.CTools.Modal.show(Drupal.CTools.Modal.getSettings(ajax.element)); } $('#modal-title').html(response.title); - $('#modal-content').html(response.output); + // Simulate an actual page load by scrolling to the top after adding the + // content. This is helpful for allowing users to see error messages at the + // top of a form, etc. + $('#modal-content').html(response.output).scrollTop(0); Drupal.attachBehaviors(); } @@ -318,10 +317,11 @@ var url_class = '.' + $(item).attr('id') + '-url'; $(url_class).each( function() { - if (url && $(this).val()) { + var $this = $(this); + if (url && $this.val()) { url += '/'; } - url += $(this).val(); + url += $this.val(); }); return url; }; @@ -508,12 +508,23 @@ // jQuery magic loop through the instances and run the animations or removal. content.each(function(){ if ( animation == 'fade' ) { - $('#modalContent').fadeOut(speed,function(){$('#modalBackdrop').fadeOut(speed, function(){$(this).remove();});$(this).remove();}); + $('#modalContent').fadeOut(speed, function() { + $('#modalBackdrop').fadeOut(speed, function() { + $(this).remove(); + }); + $(this).remove(); + }); } else { if ( animation == 'slide' ) { - $('#modalContent').slideUp(speed,function(){$('#modalBackdrop').slideUp(speed, function(){$(this).remove();});$(this).remove();}); + $('#modalContent').slideUp(speed,function() { + $('#modalBackdrop').slideUp(speed, function() { + $(this).remove(); + }); + $(this).remove(); + }); } else { - $('#modalContent').remove();$('#modalBackdrop').remove(); + $('#modalContent').remove(); + $('#modalBackdrop').remove(); } } }); diff --git a/sites/all/modules/ctools/js/stylizer.js b/sites/all/modules/ctools/js/stylizer.js index dc1caaa5bf0616433746ed75af525779c4c23c86..16d6c49d5ea9650cd2146adc5cc42efd59712a28 100644 --- a/sites/all/modules/ctools/js/stylizer.js +++ b/sites/all/modules/ctools/js/stylizer.js @@ -183,11 +183,12 @@ }; // Add hook + var $this = $(this); var hook = $('<div class="hook"></div>'); - $(this).after(hook); + $this.after(hook); hooks.push(hook); - $(this).parent().find('.lock').click(); + $this.parent().find('.lock').click(); this.i = i; inputs.push(this); }) diff --git a/sites/all/modules/ctools/page_manager/page_manager.admin.inc b/sites/all/modules/ctools/page_manager/page_manager.admin.inc index 22ecd63c828866e9c8e5d3f70aa30c9a6e7a94c4..c01961be87cae74ef8415132b6ae96d33a9010f5 100644 --- a/sites/all/modules/ctools/page_manager/page_manager.admin.inc +++ b/sites/all/modules/ctools/page_manager/page_manager.admin.inc @@ -27,7 +27,11 @@ function page_manager_list_page($js = NULL) { } if (module_exists('advanced_help') && !$js) { - drupal_set_message(theme('advanced_help_topic', 'page_manager', 'getting-started', t('See the getting started guide for more information.'))); + drupal_set_message(theme('advanced_help_topic', array( + 'module' => 'page_manager', + 'topic' => 'getting-started', + 'type' => t('See the getting started guide for more information.'), + ))); } $tasks = page_manager_get_tasks_by_type('page'); @@ -1208,7 +1212,10 @@ function page_manager_render_operations(&$page, $operations, $active_trail, $att } if ($output[$location]) { - $output[$location] = '<ul class="page-manager-operations ' . $attributes['class'] . '">' . $output[$location] . '</ul>'; + $classes = isset($attributes['class']) && is_array($attributes['class']) ? $attributes['class'] : array(); + $classes[] = 'page-manager-operations'; + + $output[$location] = '<ul class="' . implode(' ', $classes) . '">' . $output[$location] . '</ul>'; if (!empty($attributes['title'])) { $class = ''; diff --git a/sites/all/modules/ctools/page_manager/page_manager.info b/sites/all/modules/ctools/page_manager/page_manager.info index 28ef10855334e27e9f662bb22387019f7487612c..d3e358809d12dce56a64b2eb55dd07bf863860d0 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/page_manager/page_manager.install b/sites/all/modules/ctools/page_manager/page_manager.install index ad2781c8c7ef603e0db001946aa7c3b84b678ba2..b170ce7215913c0d6964440c48fba5dc98de7182 100644 --- a/sites/all/modules/ctools/page_manager/page_manager.install +++ b/sites/all/modules/ctools/page_manager/page_manager.install @@ -23,6 +23,8 @@ function page_manager_schema_1() { 'identifier' => 'handler', 'bulk export' => TRUE, 'export callback' => 'page_manager_export_task_handler', + 'load callback' => 'page_manager_export_task_handler_load', + 'delete callback' => 'page_manager_delete_task_handler', 'primary key' => 'did', 'api' => array( 'owner' => 'page_manager', diff --git a/sites/all/modules/ctools/page_manager/page_manager.module b/sites/all/modules/ctools/page_manager/page_manager.module index 790c64ed6afed6ffc6ca7057f2273ec863769bbe..62f6d275cfa3afcff48f6f88e6bc4cdfc1372e08 100644 --- a/sites/all/modules/ctools/page_manager/page_manager.module +++ b/sites/all/modules/ctools/page_manager/page_manager.module @@ -140,7 +140,6 @@ function page_manager_menu() { // Provide menu items for each task. foreach ($tasks as $task_id => $task) { - $handlers = page_manager_get_task_handler_plugins($task); // Allow the task to add its own menu items. if ($function = ctools_plugin_get_function($task, 'hook menu')) { $function($items, $task); @@ -696,6 +695,44 @@ function page_manager_export_task_handler($handler, $indent = '') { return $output; } +/** + * Loads page manager handler for export. + * + * Callback to load page manager handler within ctools_export_crud_load(). + * + * @param string $name + * The name of the handler to load. + * + * @return + * Loaded page manager handler object, extended with external properties. + */ +function page_manager_export_task_handler_load($name) { + $table = 'page_manager_handlers'; + $schema = ctools_export_get_schema($table); + $export = $schema['export']; + + $result = ctools_export_load_object($table, 'names', array($name)); + if (isset($result[$name])) { + $handler = $result[$name]; + + // Weight is stored in additional table so that in-code task handlers + // don't need to get written to the database just because they have their + // weight changed. Therefore, handler could have no correspondent database + // entry. Revert will not be performed for this handler and the weight + // will not be reverted. To make possible revert of the weight field + // export_type must simulate that the handler is stored in the database. + $handler->export_type = EXPORT_IN_DATABASE; + + // Also, page manager handler weight should be overriden with correspondent + // weight from page_manager_weights table, if there is one. + $result = db_query('SELECT weight FROM {page_manager_weights} WHERE name = (:names)', array(':names' => $handler->name))->fetchField(); + if (is_numeric($result)) { + $handler->weight = $result; + } + return $handler; + } +} + /** * Create a new task handler object. * diff --git a/sites/all/modules/ctools/page_manager/plugins/tasks/page.admin.inc b/sites/all/modules/ctools/page_manager/plugins/tasks/page.admin.inc index 4e6e749431b3f3d744cb193a3b1f4279d8a550eb..69ac02deee71d0e8eed17a332521e12fe48fc305 100644 --- a/sites/all/modules/ctools/page_manager/plugins/tasks/page.admin.inc +++ b/sites/all/modules/ctools/page_manager/plugins/tasks/page.admin.inc @@ -1056,7 +1056,6 @@ function page_manager_page_subtask_argument_ajax($step = NULL, $task_name = NULL $clone_state = $form_state; $clone_state['allow temp'] = TRUE; - page_manager_page_form_argument($form, $clone_state); $form = drupal_build_form('page_manager_page_form_argument', $form_state); // Render just the table portion. diff --git a/sites/all/modules/ctools/plugins/access/entity_field_value.inc b/sites/all/modules/ctools/plugins/access/entity_field_value.inc index 1fb1fe8ceb2fefcb0772289042f5b4e6f8af100b..59b01fbb8600467d86b54f623c51ee225c392d52 100644 --- a/sites/all/modules/ctools/plugins/access/entity_field_value.inc +++ b/sites/all/modules/ctools/plugins/access/entity_field_value.inc @@ -141,7 +141,13 @@ function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin) if ($field_items = field_get_items($entity_type, $context->data, $field_name)) { $langcode = field_language($entity_type, $context->data, $field_name); - + // Get field storage columns. + $instance = field_info_instance($entity_type, $field_name, $bundle_type); + $field = field_info_field_by_id($instance['field_id']); + $columns = array(); + foreach ($field['columns'] as $column => $attributes) { + $columns[$column] = _field_sql_storage_columnname($field_name, $column); + } foreach ($conf as $potential_field => $values) { if ($field_name === $potential_field) { @@ -152,8 +158,14 @@ function ctools_entity_field_value_ctools_access_check($conf, $context, $plugin) // Check field value. foreach ($field_items as $field_value) { - if (in_array($field_value['value'], $conf_value_array)) { - return TRUE; + foreach ($field_value as $field_column => $value) { + // Iterate through config values. + foreach ($conf_value_array as $conf_value) { + // + if ($value == $conf_value[$field_column]) { + return TRUE; + } + } } } } @@ -168,8 +180,8 @@ function _ctools_entity_field_value_ctools_access_get_conf_field_values($values, } $conf_values = array(); - foreach ($values[$langcode] as $value) { - $conf_values[] = $value['value']; + foreach ($values[$langcode] as $delta => $value) { + $conf_values[$delta] = $value; } return $conf_values; diff --git a/sites/all/modules/ctools/plugins/content_types/block/block.inc b/sites/all/modules/ctools/plugins/content_types/block/block.inc index 866f72e63cbb2fe429d8f582912026f9d93f37aa..f5b00632d97f4798c3940d0e1310734c7978a774 100644 --- a/sites/all/modules/ctools/plugins/content_types/block/block.inc +++ b/sites/all/modules/ctools/plugins/content_types/block/block.inc @@ -77,6 +77,57 @@ function _ctools_block_content_type_content_type($module, $delta, $block) { return $info; } +/** + * Load block info from the database. + * + * This is copied from _block_load_blocks(). It doesn't use that + * function because _block_load_blocks sorts by region, and it + * doesn't cache its results anyway. + */ +function _ctools_block_load_blocks() { + $blocks = &drupal_static(__FUNCTION__, NULL); + if (!isset($blocks)) { + global $theme_key; + + $query = db_select('block', 'b'); + $result = $query + ->fields('b') + ->condition('b.theme', $theme_key) + ->orderBy('b.region') + ->orderBy('b.weight') + ->orderBy('b.module') + ->addTag('block_load') + ->addTag('translatable') + ->execute(); + + $block_info = $result->fetchAllAssoc('bid'); + // Allow modules to modify the block list. + drupal_alter('block_list', $block_info); + + $blocks = array(); + foreach ($block_info as $block) { + $blocks["{$block->module}_{$block->delta}"] = $block; + } + } + + return $blocks; +} + +/** + * Fetch the stored info for a block. + * + * The primary reason to use this is so that modules which perform alters + * can have their alters make it to the block. + */ +function _ctools_get_block_info($module, $delta) { + $blocks = _ctools_block_load_blocks(); + + $key = $module . '_' . $delta; + if (isset($blocks[$key])) { + return $blocks[$key]; + } +} + /** * Output function for the 'block' content type. Outputs a block * based on the module and delta supplied in the configuration. @@ -84,15 +135,15 @@ function _ctools_block_content_type_content_type($module, $delta, $block) { function ctools_block_content_type_render($subtype, $conf) { list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf); - $info = new stdClass; - $info->module = $module; - $info->delta = $delta; + $info = _ctools_get_block_info($module, $delta); $block = module_invoke($module, 'block_view', $delta); - // Allow modules to modify the block before it is viewed, via either - // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter(). - drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info); - $block = (object) $block; + if (!empty($info)) { + // Allow modules to modify the block before it is viewed, via either + // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter(). + drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info); + $block = (object) $block; + } if (empty($block)) { return; @@ -101,7 +152,10 @@ function ctools_block_content_type_render($subtype, $conf) { $block->module = $module; $block->delta = $delta; - if (isset($block->subject)) { + if ($module == 'block') { + $block->title = $info->title; + } + else if (isset($block->subject)) { $block->title = $block->subject; } else { 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 acc56841699dbd56fd2056f98f75e3b4c06d8469..2da4044d80446523736a6b944bae38e988214364 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 @@ -154,6 +154,10 @@ function ctools_entity_field_content_type_render($subtype, $conf, $panel_args, $ $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'])) { + $field_output['#title'] = filter_xss_admin($conf['override_title_text']); + } + // Build the content type block. $block = new stdClass(); $block->module = 'entity_field'; @@ -219,9 +223,10 @@ function ctools_entity_field_content_type_formatter_styles($form, &$form_state) $subtype = $form_state['subtype_name']; list($entity_type, $field_name) = explode(':', $subtype, 2); $field = field_info_field($field_name); - module_load_include('inc', 'field_ui', 'field_ui.admin'); - ctools_include('fields'); + ctools_form_include($form_state, 'field_ui.admin', 'field_ui', ''); + ctools_form_include($form_state, 'fields'); + $form['ctools_field_list'] = array( '#type' => 'value', '#value' => array(), diff --git a/sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc b/sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc index 1caec710799e484db0c651b7186540567cd48f5a..0183fc6dcc289d2e6c4e7737cdc497a827451abd 100644 --- a/sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc +++ b/sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc @@ -84,8 +84,10 @@ function ctools_entity_form_field_content_type_render($subtype, $conf, $panel_ar if (empty($field)) { return; } + $block = new stdClass(); if (isset($context->form)) { + $block->content = array(); $block->content[$field_name] = $context->form[$field_name]; unset($context->form[$field_name]); } diff --git a/sites/all/modules/ctools/plugins/content_types/node_form/node_form_author.inc b/sites/all/modules/ctools/plugins/content_types/node_form/node_form_author.inc index 5cb6a344daeb44db50b2a21e0045f91ab39f8cdb..350df40a962d7a2e0f2c5bb42fc56d794ff6e4db 100644 --- a/sites/all/modules/ctools/plugins/content_types/node_form/node_form_author.inc +++ b/sites/all/modules/ctools/plugins/content_types/node_form/node_form_author.inc @@ -43,7 +43,7 @@ function ctools_node_form_author_content_type_render($subtype, $conf, $panel_arg } function ctools_node_form_author_content_type_admin_title($subtype, $conf, $context) { - return t('"@s" node form publishing options', array('@s' => $context->identifier)); + return t('"@s" node form author information', array('@s' => $context->identifier)); } function ctools_node_form_author_content_type_edit_form($form, &$form_state) { diff --git a/sites/all/modules/ctools/plugins/content_types/node_form/node_form_publishing.inc b/sites/all/modules/ctools/plugins/content_types/node_form/node_form_publishing.inc index 3f3cf25d3ca9c5a89944b300ee062e42d9310467..e73cff21b600e856b02c515ae2f8511166d39bac 100644 --- a/sites/all/modules/ctools/plugins/content_types/node_form/node_form_publishing.inc +++ b/sites/all/modules/ctools/plugins/content_types/node_form/node_form_publishing.inc @@ -45,7 +45,7 @@ function ctools_node_form_publishing_content_type_render($subtype, $conf, $panel } function ctools_node_form_publishing_content_type_admin_title($subtype, $conf, $context) { - return t('"@s" node form author information', array('@s' => $context->identifier)); + return t('"@s" node form publishing options', array('@s' => $context->identifier)); } function ctools_node_form_publishing_content_type_edit_form($form, &$form_state) { diff --git a/sites/all/modules/ctools/plugins/content_types/term_context/term_description.inc b/sites/all/modules/ctools/plugins/content_types/term_context/term_description.inc index dc1d26f07d2f0e91e1dd9d7bd65f8095ecae0f28..2b953ed01cd3ae89ca89bc9adf2bdc1beec95cf8 100644 --- a/sites/all/modules/ctools/plugins/content_types/term_context/term_description.inc +++ b/sites/all/modules/ctools/plugins/content_types/term_context/term_description.inc @@ -20,14 +20,14 @@ function ctools_term_description_content_type_render($subtype, $conf, $panel_arg $block->title = $term->name; if ($term) { - $block->content = _filter_autop(filter_xss_admin($term->description)); + $block->content = check_markup($term->description, $term->format, '', TRUE); $block->delta = $term->tid; if (user_access('administer taxonomy')) { $block->admin_links['update'] = array( 'title' => t('Edit term'), 'alt' => t("Edit this term"), - 'href' => "admin/content/taxonomy/edit/term/$term->tid", + 'href' => "taxonomy/term/$term->tid/edit", 'query' => drupal_get_destination(), ); } diff --git a/sites/all/modules/ctools/plugins/content_types/term_context/term_list.inc b/sites/all/modules/ctools/plugins/content_types/term_context/term_list.inc index c5ea4a6bfa961a52c16f54d3188b60a4e6914c00..4585611fa580d08a359d5c607eae1928ec000405 100644 --- a/sites/all/modules/ctools/plugins/content_types/term_context/term_list.inc +++ b/sites/all/modules/ctools/plugins/content_types/term_context/term_list.inc @@ -77,7 +77,9 @@ function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $con } } - $block->content = theme('item_list', array('items' => $items, 'type' => $conf['list_type'])); + if (!empty($items)) { + $block->content = theme('item_list', array('items' => $items, 'type' => $conf['list_type'])); + } } } else { diff --git a/sites/all/modules/ctools/plugins/contexts/entity.inc b/sites/all/modules/ctools/plugins/contexts/entity.inc index 4cccdf6907b1f12c68da9c3e6e51ed582063cd35..b214aa06b7aef12cab4432a1c7d9733561866900 100644 --- a/sites/all/modules/ctools/plugins/contexts/entity.inc +++ b/sites/all/modules/ctools/plugins/contexts/entity.inc @@ -247,7 +247,7 @@ function ctools_context_entity_convert_list($plugin) { /** * Convert a context into a string. */ -function ctools_context_entity_convert($context, $type) { +function ctools_context_entity_convert($context, $type, $options = array()) { $entity_type = $context->type[2]; $entity = entity_get_info($entity_type); @@ -266,7 +266,7 @@ function ctools_context_entity_convert($context, $type) { $tokens = token_info(); - $values = token_generate($token, array($type => $type), array($token => $context->data)); + $values = token_generate($token, array($type => $type), array($token => $context->data), $options); if (isset($values[$type])) { return $values[$type]; } 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 d326dd93f241527bf58b36fb70dd1af571dd4e60..4b44c4a8a9957c4364e9801c2531db95442de61e 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 @@ -339,7 +339,6 @@ class ctools_export_ui { function list_form_submit(&$form, &$form_state) { // Filter and re-sort the pages. $plugin = $this->plugin; - $schema = ctools_export_get_schema($this->plugin['schema']); $prefix = ctools_export_ui_plugin_base_path($plugin); @@ -350,44 +349,7 @@ class ctools_export_ui { continue; } - // Note: Creating this list seems a little clumsy, but can't think of - // better ways to do this. - $allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations'])); - $not_allowed_operations = array('import'); - - if ($item->{$schema['export']['export type string']} == t('Normal')) { - $not_allowed_operations[] = 'revert'; - } - elseif ($item->{$schema['export']['export type string']} == t('Overridden')) { - $not_allowed_operations[] = 'delete'; - } - else { - $not_allowed_operations[] = 'revert'; - $not_allowed_operations[] = 'delete'; - } - - $not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable'; - - foreach ($not_allowed_operations as $op) { - // Remove the operations that are not allowed for the specific - // exportable. - unset($allowed_operations[$op]); - } - - $operations = array(); - - foreach ($allowed_operations as $op) { - $operations[$op] = array( - 'title' => $plugin['allowed operations'][$op]['title'], - 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name), - ); - if (!empty($plugin['allowed operations'][$op]['ajax'])) { - $operations[$op]['attributes'] = array('class' => array('use-ajax')); - } - if (!empty($plugin['allowed operations'][$op]['token'])) { - $operations[$op]['query'] = array('token' => drupal_get_token($op)); - } - } + $operations = $this->build_operations($item); $this->list_build_row($item, $form_state, $operations); } @@ -500,6 +462,52 @@ class ctools_export_ui { ctools_add_css('export-ui-list'); } + /** + * Builds the operation links for a specific exportable item. + */ + function build_operations($item) { + $plugin = $this->plugin; + $schema = ctools_export_get_schema($plugin['schema']); + $operations = $plugin['allowed operations']; + $operations['import'] = FALSE; + + if ($item->{$schema['export']['export type string']} == t('Normal')) { + $operations['revert'] = FALSE; + } + elseif ($item->{$schema['export']['export type string']} == t('Overridden')) { + $operations['delete'] = FALSE; + } + else { + $operations['revert'] = FALSE; + $operations['delete'] = FALSE; + } + if (empty($item->disabled)) { + $operations['enable'] = FALSE; + } + else { + $operations['disable'] = FALSE; + } + + $allowed_operations = array(); + + foreach ($operations as $op => $info) { + if (!empty($info)) { + $allowed_operations[$op] = array( + 'title' => $info['title'], + 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $item->{$this->plugin['export']['key']}), + ); + if (!empty($info['ajax'])) { + $allowed_operations[$op]['attributes'] = array('class' => array('use-ajax')); + } + if (!empty($info['token'])) { + $allowed_operations[$op]['query'] = array('token' => drupal_get_token($op)); + } + } + } + + return $allowed_operations; + } + /** * Build a row based on the item. * @@ -1187,16 +1195,25 @@ class ctools_export_ui { $output = drupal_build_form('ctools_export_ui_delete_confirm_form', $form_state); if (!empty($form_state['executed'])) { - ctools_export_crud_delete($this->plugin['schema'], $item); - $export_key = $this->plugin['export']['key']; - $message = str_replace('%title', check_plain($item->{$export_key}), $this->plugin['strings']['confirmation'][$form_state['op']]['success']); - drupal_set_message($message); - drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); + $this->delete_form_submit($form_state); + $this->redirect($form_state['op'], $item); } return $output; } + /** + * Deletes exportable items from the database. + */ + function delete_form_submit(&$form_state) { + $item = $form_state['item']; + + ctools_export_crud_delete($this->plugin['schema'], $item); + $export_key = $this->plugin['export']['key']; + $message = str_replace('%title', check_plain($item->{$export_key}), $this->plugin['strings']['confirmation'][$form_state['op']]['success']); + drupal_set_message($message); + } + /** * Page callback to display export information for an exportable item. */ diff --git a/sites/all/modules/ctools/stylizer/stylizer.info b/sites/all/modules/ctools/stylizer/stylizer.info index 6bff8dd2cbc0677f6bced0e64a4b26e7637068f9..9c7f1173ab7231e863f5d7e2fdfc62cf85b90dd1 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" diff --git a/sites/all/modules/ctools/tests/context.test b/sites/all/modules/ctools/tests/context.test new file mode 100644 index 0000000000000000000000000000000000000000..b5f6fb10a16074c8a36e18c538eca29e0d71d9b8 --- /dev/null +++ b/sites/all/modules/ctools/tests/context.test @@ -0,0 +1,58 @@ +<?php + +class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Keywords substitution', + 'description' => 'Verify that keywords are properly replaced with data.', + 'group' => 'Chaos Tools Suite', + ); + } + + public function setUp() { + parent::setUp('ctools'); + + ctools_include('context'); + } + + public function testKeywordsSubstitution() { + // Create node context for substitution. + $node = $this->drupalCreateNode(); + $context = ctools_context_create('node', $node); + $contexts = array('argument_1' => $context); + + // Run tests on some edge cases. + $checks = array( + '%node:title' => array( + "{$node->title}", + t('Keyword and converter have been replaced.'), + ), + '%%node:title' => array( + "%node:title", + t('Keyword after escaped percent sign left untouched.'), + ), + '%node:title%node:nid' => array( + "{$node->title}{$node->nid}", + t('Multiple substitutions have been replaced.'), + ), + '%node:title:' => array( + "{$node->title}:", + t('Colon after keyword and converter left untouched.'), + ), + '%node:title%%' => array( + "{$node->title}%", + t('Escaped percent sign after keyword and converter left untouched.'), + ), + '%%%node:title' => array( + "%{$node->title}", + t('Keyword after escaped and unescaped percent sign has been replaced.'), + ), + ); + foreach ($checks as $string => $expectations) { + list($expected_result, $message) = $expectations; + $actual_result = ctools_context_keyword_substitute($string, array(), $contexts); + $this->assertEqual($actual_result, $expected_result, $message); + } + } + +} diff --git a/sites/all/modules/ctools/tests/css.test b/sites/all/modules/ctools/tests/css.test index 039e9757b6099d2851b2bdeecfc397b8f4fe96a1..4a5200caad76ae039d0c30a946531006a09ff53f 100644 --- a/sites/all/modules/ctools/tests/css.test +++ b/sites/all/modules/ctools/tests/css.test @@ -65,5 +65,17 @@ class CtoolsCssTestCase extends DrupalWebTestCase { $font_size = (strpos($filtered, 'font-size:12px;') !== FALSE); $color = (strpos($filtered, 'color:blue') !== FALSE); $this->assertTrue($font_size && $color, 'Multiple properties are merged.'); + + $css = '@import url("other.css");p {color: red;}'; + $filtered = ctools_css_filter($css); + $other_css = (strpos($filtered, 'other.css') === FALSE); + $color = (strpos($filtered, 'color:red') !== FALSE); + $this->assertTrue($other_css && $color, 'CSS is properly sanitized.'); + + $css = ';p {color: red; font-size: 12px;}'; + $filtered = ctools_css_filter($css); + $font_size = (strpos($filtered, 'font-size:12px;') !== FALSE); + $color = (strpos($filtered, 'color:red') !== FALSE); + $this->assertTrue($font_size && $color, 'Multiple properties are retained.'); } } diff --git a/sites/all/modules/ctools/tests/ctools.drush.sh b/sites/all/modules/ctools/tests/ctools.drush.sh index 1a02cd6c9320fc9f93e46c29b5996fcf821fc4e1..31bdee359e95697c5e3716fbcfbb61b12419aa98 100755 --- a/sites/all/modules/ctools/tests/ctools.drush.sh +++ b/sites/all/modules/ctools/tests/ctools.drush.sh @@ -15,8 +15,8 @@ MODULE_NAME="ctools_drush_test" stamp -echo 'Enabling views module.' -drush en views ctools --yes +echo 'Enabling ctools, views, and bulk_export modules.' +drush en ctools views bulk_export --yes stamp echo 'Reading all export info' @@ -36,12 +36,24 @@ drush ctools-export-info --tables-only --format=json stamp echo 'Reading all disabled exportables' -drush ctools-export-info --disabled +drush ctools-export-info --filter=disabled stamp echo 'Enabling all default views' drush ctools-export-enable views_view --yes +stamp +echo 'Reading all enabled exportables' +drush ctools-export-info --filter=enabled + +stamp +echo 'Reading all overridden exportables' +drush ctools-export-info --filter=overridden + +stamp +echo 'Reading all database only exportables' +drush ctools-export-info --filter=database + stamp echo 'View all default views export data' drush ctools-export-view views_view --yes @@ -70,6 +82,30 @@ stamp echo 'Revert all default views' drush ctools-export-revert views_view --yes +stamp +echo 'Enable all node views' +drush ctools-export-enable views_view --module=node --yes + +stamp +echo 'Disable all node views' +drush ctools-export-disable views_view --module=node --yes + +stamp +echo 'Revert all node views' +drush ctools-export-revert views_view --module=node --yes + +stamp +echo 'Revert all exportables' +drush ctools-export-revert --all --yes + +stamp +echo 'Enable all exportables' +drush ctools-export-enable --all --yes + +stamp +echo 'Disable all exportables' +drush ctools-export-disable --all --yes + stamp echo 'Bulk export all objects' drush ctools-export $MODULE_NAME --subdir='tests' --choice=1 diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test new file mode 100644 index 0000000000000000000000000000000000000000..1accfd740cc260fe9bb141860f211a800fd905fd --- /dev/null +++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export.test @@ -0,0 +1,215 @@ +<?php + +/** + * @file + * Tests for the CTools export system. + */ + +/** + * Tests export CRUD. + */ +class CtoolsExportCrudTestCase extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'CTools export CRUD tests', + 'description' => 'Test the CRUD functionality for the ctools export system.', + 'group' => 'Chaos Tools Suite', + ); + } + + protected function setUp() { + parent::setUp('ctools_export_test'); + $this->resetAll(); + } + + /** + * Tests CRUD operation: Load. + */ + function testCrudExportLoad() { + $loaded_export = ctools_export_crud_load('ctools_export_test', 'database_test'); + + $expected_export = new stdClass(); + $expected_export->machine = 'database_test'; + $expected_export->title = 'Database test'; + $expected_export->number = 0; + $expected_export->data = array( + 'test_1' => 'Test 1', + 'test_2' => 'Test 2', + ); + $expected_export->table = 'ctools_export_test'; + $expected_export->export_type = EXPORT_IN_DATABASE; + $expected_export->type = 'Normal'; + + $this->assertEqual($expected_export, $loaded_export, 'An exportable object has been loaded correctly from the database.'); + } + + /** + * Tests CRUD operation: Load multiple. + */ + function testCrudExportLoadMultiple() { + $exportable_names = array('database_test', 'overridden_test', 'default_test'); + $loaded_exports = ctools_export_crud_load_multiple('ctools_export_test', $exportable_names); + + $this->assertEqual(count($loaded_exports), 3, 'All exportables have been loaded.'); + } + + /** + * Tests CRUD operation: Load all. + */ + function testCrudExportLoadAll() { + $loaded_exports = ctools_export_crud_load_all('ctools_export_test'); + + $this->assertEqual(count($loaded_exports), 3, 'All exportables have been loaded.'); + } + + /** + * Tests CRUD operation: Save. + */ + function testCrudExportSave() { + $default_export = ctools_export_crud_load('ctools_export_test', 'default_test'); + + $this->assertTrue($default_export->in_code_only,'The loaded exportable is in code only.'); + + ctools_export_crud_save('ctools_export_test', $default_export); + + // Clear the static cache. + ctools_export_load_object_reset('ctools_export_test'); + + $overridden_export = ctools_export_crud_load('ctools_export_test', 'default_test'); + + $this->assertTrue($overridden_export->export_type === 3, 'The loaded exportable is overridden in the database.'); + } + + /** + * Tests CRUD operation: New. + */ + function testCrudExportNew() { + // Default exportable with defualt values. + $new_export = ctools_export_crud_new('ctools_export_test'); + + $expected_export = new stdClass(); + $expected_export->machine = ''; + $expected_export->title = ''; + $expected_export->number = 0; + $expected_export->data = NULL; + $expected_export->export_type = NULL; + $expected_export->type = 'Local'; + + $this->assertEqual($expected_export, $new_export, 'An exportable with default values is created.'); + + // Default exportable without default values. + $new_export = ctools_export_crud_new('ctools_export_test', FALSE); + + $expected_export = new stdClass(); + $expected_export->machine = ''; + $expected_export->title = ''; + $expected_export->number = NULL; + $expected_export->data = NULL; + + $this->assertEqual($expected_export, $new_export, 'An exportable without default values has been created.'); + } + + /** + * Tests CRUD operation: Revert. + */ + function testCrudExportRevert() { + // Load exportable, will come from database. + $original_export = ctools_export_crud_load('ctools_export_test', 'overridden_test'); + + $this->assertTrue($original_export->export_type === 3, 'Loaded export is overridden.'); + + $machine = $original_export->machine; + ctools_export_crud_delete('ctools_export_test', $original_export); + + $result = db_query("SELECT machine FROM {ctools_export_test} WHERE machine = :machine", array(':machine' => $machine))->fetchField(); + + $this->assertFalse($result, 'The exportable object has been removed from the database.'); + + // Clear the static cache. + ctools_export_load_object_reset('ctools_export_test'); + + // Reload the same object. + $default_export = ctools_export_crud_load('ctools_export_test', 'overridden_test'); + + // Check the exportable is now in_code_only. + $this->assertTrue($default_export->in_code_only, 'The loaded exportable is in the database only.'); + + // Make sure the default object loaded matches the same overridden one in the database. + $this->assertEqual($original_export->machine, $default_export->machine, 'The default exportable has been loaded and matches the overridden exportable.'); + } + + /** + * Tests CRUD operation: Delete. + */ + function testCrudExportDelete() { + // Create a stub entry save it and delete it from the database. + $new_export = ctools_export_crud_new('ctools_export_test'); + ctools_export_crud_save('ctools_export_test', $new_export); + + $machine = $new_export->machine; + ctools_export_crud_delete('ctools_export_test', $new_export); + $result = ctools_export_crud_load('ctools_export_test', $machine); + + $this->assertFalse($result, 'The new exportable has been removed from the database.'); + + // Load the database only exportable. + $database_export = ctools_export_crud_load('ctools_export_test', 'database_test'); + + $machine = $database_export->machine; + ctools_export_crud_delete('ctools_export_test', $database_export); + // Clear the exportable caches as it's been loaded above. + ctools_export_load_object_reset('ctools_export_test'); + $result = ctools_export_crud_load('ctools_export_test', $machine); + + $this->assertFalse($result, 'The database exportable has been removed from the database.'); + } + + /** + * Tests CRUD operation: Set status. + */ + function testCrudExportSetStatus() { + // Database only object. + $database_export = ctools_export_crud_load('ctools_export_test', 'database_test'); + ctools_export_crud_disable('ctools_export_test', $database_export); + ctools_export_load_object_reset('ctools_export_test'); + $disabled_export = ctools_export_crud_load('ctools_export_test', 'database_test'); + + $this->assertTrue($disabled_export->disabled, 'The database only exportable has been disabled.'); + + ctools_export_crud_enable('ctools_export_test', $disabled_export); + ctools_export_load_object_reset('ctools_export_test'); + $enabled_export = ctools_export_crud_load('ctools_export_test', 'database_test'); + + $this->assertTrue(empty($enabled_export->disabled), 'The database only exportable has been enabled.'); + + // Overridden object. + $overridden_export = ctools_export_crud_load('ctools_export_test', 'overridden_test'); + ctools_export_crud_disable('ctools_export_test', $overridden_export); + ctools_export_load_object_reset('ctools_export_test'); + $disabled_export = ctools_export_crud_load('ctools_export_test', 'overridden_test'); + + $this->assertTrue($disabled_export->disabled, 'The overridden exportable has been disabled.'); + + ctools_export_crud_enable('ctools_export_test', $disabled_export); + ctools_export_load_object_reset('ctools_export_test'); + $enabled_export = ctools_export_crud_load('ctools_export_test', 'overridden_test'); + + $this->assertTrue(empty($enabled_export->disabled), 'The overridden exportable has been enabled.'); + + // Default object. + $default_export = ctools_export_crud_load('ctools_export_test', 'default_test'); + ctools_export_crud_disable('ctools_export_test', $default_export); + ctools_export_load_object_reset('ctools_export_test'); + $disabled_export = ctools_export_crud_load('ctools_export_test', 'default_test'); + + $this->assertTrue($disabled_export->disabled, 'The default exportable has been disabled.'); + + ctools_export_crud_enable('ctools_export_test', $disabled_export); + ctools_export_load_object_reset('ctools_export_test'); + $enabled_export = ctools_export_crud_load('ctools_export_test', 'default_test'); + + $this->assertTrue(empty($enabled_export->disabled), 'The default exportable has been enabled.'); + } + +} diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc new file mode 100644 index 0000000000000000000000000000000000000000..9f2dd6c6b268150c90f2d35dc085ca530c06c4f7 --- /dev/null +++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.default_ctools_export_tests.inc @@ -0,0 +1,31 @@ +<?php + +/** + * Implements hook_default_export_tests(). + */ +function ctools_export_test_default_ctools_export_tests() { + $ctools_export_tests = array(); + + $ctools_export_test = new stdClass(); + $ctools_export_test->disabled = FALSE; /* Edit this to true to make a default export_test disabled initially */ + $ctools_export_test->api_version = 1; + $ctools_export_test->machine = 'overridden_test'; + $ctools_export_test->title = 'Overridden test'; + $ctools_export_test->number = 1; + $ctools_export_test->data = array( + 'test_1' => 'Test 1', + 'test_2' => 'Test 2', + ); + $ctools_export_tests['overridden_test'] = $ctools_export_test; + + $ctools_export_test = new stdClass(); + $ctools_export_test->disabled = FALSE; /* Edit this to true to make a default export_test disabled initially */ + $ctools_export_test->api_version = 1; + $ctools_export_test->machine = 'default_test'; + $ctools_export_test->title = 'Default test'; + $ctools_export_test->number = 2; + $ctools_export_test->data = ''; + $ctools_export_tests['default_test'] = $ctools_export_test; + + return $ctools_export_tests; +} diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info new file mode 100644 index 0000000000000000000000000000000000000000..2d975c37bc6453831864631ab18a48ea7e3cd4f4 --- /dev/null +++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.info @@ -0,0 +1,15 @@ +name = CTools export test +description = CTools export test module +core = 7.x +package = Chaos tool suite +dependencies[] = ctools +hidden = TRUE + +files[] = ctools_export.test + +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" +core = "7.x" +project = "ctools" +datestamp = "1345319204" + diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install new file mode 100644 index 0000000000000000000000000000000000000000..2eb54ca398e223dc2ff3e04d36b120ddc2cfeb70 --- /dev/null +++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.install @@ -0,0 +1,86 @@ +<?php + +/** + * Implements hook_schema(); + */ +function ctools_export_test_schema() { + $schema['ctools_export_test'] = array( + 'description' => 'CTools export test data table', + 'export' => array( + 'key' => 'machine', + 'identifier' => 'ctools_export_test', + 'default hook' => 'default_ctools_export_tests', + 'bulk export' => TRUE, + 'api' => array( + 'owner' => 'ctools_export_test', + 'api' => 'default_ctools_export_tests', + 'minimum_version' => 1, + 'current_version' => 1, + ), + ), + 'fields' => array( + 'machine' => array( + 'description' => "The unique machine name (required by ctools).", + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'title' => array( + 'description' => "The human readable title.", + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'number' => array( + 'description' => "A number.", + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'data' => array( + 'type' => 'blob', + 'description' => "A serialized array of data.", + 'serialize' => TRUE, + 'serialized default' => 'a:0:{}', + ), + ), + 'primary key' => array('machine'), + ); + + return $schema; +} + +/** + * Implments hook_install(); + */ +function ctools_export_test_install() { + $ctools_export_tests = array(); + // Put this default in the database only (no default). + $ctools_export_test = new stdClass(); + $ctools_export_test->machine = 'database_test'; + $ctools_export_test->title = 'Database test'; + $ctools_export_test->number = 0; + $ctools_export_test->data = array( + 'test_1' => 'Test 1', + 'test_2' => 'Test 2', + ); + $ctools_export_tests['database_test'] = $ctools_export_test; + + // Put this default in the database, so we have this in code and in the database. + $ctools_export_test = new stdClass(); + $ctools_export_test->machine = 'overridden_test'; + $ctools_export_test->title = 'Overridden test'; + $ctools_export_test->number = 1; + $ctools_export_test->data = array( + 'test_1' => 'Test 1', + 'test_2' => 'Test 2', + ); + $ctools_export_tests['overridden_test'] = $ctools_export_test; + + foreach ($ctools_export_tests as $ctools_export_test) { + // Save the record to the database. + drupal_write_record('ctools_export_test', $ctools_export_test); + } +} diff --git a/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module new file mode 100644 index 0000000000000000000000000000000000000000..80f1adbb3761025d3e5ea7cdc44b92741880bf1e --- /dev/null +++ b/sites/all/modules/ctools/tests/ctools_export_test/ctools_export_test.module @@ -0,0 +1,10 @@ +<?php + +/** + * Implements hook_ctools_plugin_api(). + */ +function ctools_export_test_ctools_plugin_api($module, $api) { + if ($module == 'ctools_export_test' && $api == 'default_ctools_export_tests') { + return array('version' => 1); + } +} diff --git a/sites/all/modules/ctools/tests/ctools_plugin_test.info b/sites/all/modules/ctools/tests/ctools_plugin_test.info index a5b7688b30ae08aef4881c79647f663e8622d329..6d5e9cd4e19cfc5af152351f228df49ed696aa39 100644 --- a/sites/all/modules/ctools/tests/ctools_plugin_test.info +++ b/sites/all/modules/ctools/tests/ctools_plugin_test.info @@ -5,11 +5,13 @@ core = 7.x dependencies[] = ctools files[] = ctools.plugins.test files[] = object_cache.test +files[] = css.test +files[] = context.test hidden = TRUE -; Information added by drupal.org packaging script on 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204" 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 04b6869ac462e576d4319b39e162c14638ba4630..deea7411a7af047fecb4f73041e161f660956b84 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 @@ -147,6 +147,10 @@ function views_content_views_content_type_render($subtype, $conf, $panel_args, $ $arg = ctools_context_convert_context($contexts[$cid], $converter); array_splice($args, $count, 0, array($arg)); } + else { + // Make sure we put an argument in even if it was not there. + $arg = NULL; + } } } diff --git a/sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc b/sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc index 181f02f1b1a02358df3dc557647207cf1ec38fdd..a27a26c588828c38ece9a1974a328d4350e9a5c5 100644 --- a/sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc +++ b/sites/all/modules/ctools/views_content/plugins/content_types/views_panes.inc @@ -232,44 +232,31 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a } if ($allow['items_per_page'] && isset($conf['items_per_page'])) { - $view->display_handler->set_option('items_per_page', $conf['items_per_page']); - // And here too, which works in Views 3 where the above does not. $view->set_items_per_page($conf['items_per_page']); } if ($allow['offset']) { - $view->display_handler->set_option('offset', $conf['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. - // Views 3 version - if (method_exists($view, 'init_pager')) { - $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'; - } + $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'] = $conf['pager_id']; - } + if ($conf['use_pager']) { + if (!isset($pager['options']['id']) || (isset($conf['pager_id']) && $pager['options']['id'] != $conf['pager_id'])) { + $pager['options']['id'] = $conf['pager_id']; } - - $view->display_handler->set_option('pager', $pager); } - else { - if (!$view->display_handler->get_option('use_pager') || empty($conf['use_pager'])) { - $view->display_handler->set_option('use_pager', $conf['use_pager']); - } - $view->display_handler->set_option('pager_element', $conf['pager_id']); - } + $view->display_handler->set_option('pager', $pager); } if ($allow['fields_override']) { @@ -296,7 +283,7 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a $block->title = $view->get_title(); - if (empty($view->total_rows) || $view->total_rows <= $view->display_handler->get_option('items_per_page')) { + if (empty($view->total_rows) || $view->total_rows <= $view->get_items_per_page()) { unset($block->more); } @@ -319,14 +306,16 @@ function views_content_views_panes_content_type_render($subtype, $conf, $panel_a * settings for a particular item. */ function views_content_views_panes_add_defaults(&$conf, $view) { + $pager = $view->display_handler->get_option('pager'); + $conf += array( 'link_to_view' => $view->display_handler->get_option('link_to_view'), 'more_link' => $view->display_handler->get_option('more_link'), 'feed_icons' => FALSE, - 'use_pager' => $view->display_handler->get_option('use_pager'), - 'pager_id' => $view->display_handler->get_option('element_id'), - 'items_per_page' => $view->display_handler->get_option('items_per_page'), - 'offset' => $view->display_handler->get_option('offset'), + 'use_pager' => $pager['type'] != 'none' && $pager['type'] != 'some', + 'pager_id' => isset($pager['options']['id']) ? $pager['options']['id'] : 0, + 'items_per_page' => !empty($pager['options']['items_per_page']) ? $pager['options']['items_per_page'] : 10, + 'offset' => !empty($pager['options']['offset']) ? $pager['options']['offset'] : 0, 'path_override' => FALSE, 'path' => $view->get_path(), 'fields_override' => $view->display_handler->get_option('fields_override'), @@ -426,13 +415,13 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) { $form['use_pager'] = array( '#type' => 'checkbox', '#title' => t('Use pager'), - '#default_value' => isset($conf['use_pager']) ? $conf['use_pager'] : $view->display_handler->get_option('use_pager'), + '#default_value' => $conf['use_pager'], '#id' => 'use-pager-checkbox', '#prefix' => '<div class="container-inline">', ); $form['pager_id'] = array( '#type' => 'textfield', - '#default_value' => isset($conf['pager_id']) ? $conf['pager_id'] : $view->display_handler->get_option('element_id'), + '#default_value' => $conf['pager_id'], '#title' => t('Pager ID'), '#size' => 4, '#id' => 'use-pager-textfield', @@ -443,7 +432,7 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) { if ($allow['items_per_page']) { $form['items_per_page'] = array( '#type' => 'textfield', - '#default_value' => isset($conf['items_per_page']) ? $conf['items_per_page'] : $view->display_handler->get_option('items_per_page'), + '#default_value' => $conf['items_per_page'], '#title' => t('Num items'), '#size' => 4, '#description' => t('Select the number of items to display, or 0 to display all results.'), @@ -452,7 +441,7 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) { if ($allow['offset']) { $form['offset'] = array( '#type' => 'textfield', - '#default_value' => isset($conf['offset']) ? $conf['offset'] : $view->display_handler->get_option('offset'), + '#default_value' => $conf['offset'], '#title' => t('Offset'), '#size' => 4, '#description' => t('Enter the number of items to skip; enter 0 to skip no items.'), @@ -537,6 +526,16 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) { } } + // The exposed sort stuff doesn't fall into $exposed_form['#info'] so we + // have to handle it separately. + if (isset($exposed_form['sort_by'])) { + $form['exposed']['sort_by'] = $exposed_form['sort_by']; + } + + if (isset($exposed_form['sort_order'])) { + $form['exposed']['sort_order'] = $exposed_form['sort_order']; + } + // Add the view object to the form to allow additional customization $form_state['view'] = $view; diff --git a/sites/all/modules/ctools/views_content/views_content.info b/sites/all/modules/ctools/views_content/views_content.info index a85ae302a2ef81f69b5b99c4d1af066c6106b428..cd7ce44c580028f25fe14fe8b2585dc24d8f8808 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 2012-03-28 -version = "7.x-1.0" +; Information added by drupal.org packaging script on 2012-08-18 +version = "7.x-1.2" core = "7.x" project = "ctools" -datestamp = "1332962446" +datestamp = "1345319204"