? .DS_Store ? actions_14.patch ? actions_help.patch ? block_dnd-add_drag_drop_to_blocks-181066-86.patch ? block_sane_help.patch ? book_ahahapi_4.patch ? comment_notice.patch ? drupal_drag_and_drop_12.patch ? files ? fix_garland_and_menu_theme.patch ? form_expand_ahah.patch ? install_profile_notice.patch ? jquery_upgrade.patch ? lower_13.patch ? lower_14.patch ? powered_by_drupal.patch ? powered_by_drupal_2.patch ? tracker-union-2.patch ? misc/tabledrag.js ? modules/.DS_Store ? modules/block/.DS_Store ? modules/block/block.js ? modules/tracker/.DS_Store ? profiles/.DS_Store ? profiles/single_user_blog ? sites/.DS_Store ? sites/views ? sites/all/.DS_Store ? sites/all/modules ? sites/all/themes ? sites/default/settings.php ? themes/.DS_Store ? themes/engines/.DS_Store Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.710 diff -u -p -r1.710 common.inc --- includes/common.inc 4 Nov 2007 21:24:09 -0000 1.710 +++ includes/common.inc 11 Nov 2007 01:34:27 -0000 @@ -1927,6 +1927,113 @@ function drupal_get_js($scope = 'header' } /** + * Assist in adding the tableDrag JavaScript behavior to a themed table. + * + * Draggable tables should be used wherever an outline or list of sortable items + * needs to be arranged by an end-user. Draggable tables are very flexible and + * can manipulate the value of form elements placed within individual columns. + * + * To setup a table to use drag and drop in place of weight select-lists or + * in place of a form that contains parent relationships, the form must be + * themed into a table. The table must have an id attribute set. If using + * theme_table(), the id may be set as such: + * @code + * $output = theme('table', $header, $rows, array('id' => 'my-module-table')); + * return $output; + * @endcode + * + * In the theme function for the form, a special class must be added to each + * form element within the same column, "grouping" them together. + * + * In a situation where a single weight column is being sorted in the table, the + * classes could be added like this (in the theme function): + * @code + * $form['my_elements'][$delta]['weight']['attributes']['class'] = "my-elements-weight"; + * @endcode + * + * Calling drupal_add_tabledrag() would then be written as such: + * @code + * drupal_add_tabledrag('my-module-table', 'sort', 'sibling', 'my-elements-weight'); + * @endcode + * + * In a more complex case where there are several groups in one column (such as + * the block regions on the admin/build/block page), a separate subgroup class + * must also be added to differentiate the groups. + * @code + * $form['my_elements'][$region][$delta]['weight']['attributes']['class'] = "my-elements-weight my-elements-weight-". $region; + * @endcode + * + * $group is still 'my-element-weight', and the additional $subgroup variable + * will be passed in as 'my-elements-weight-'. $region. This also means that + * you'll need to call drupal_add_tabledrag() once for every region added. + * + * @code + * foreach ($regions as $region) { + * drupal_add_tabledrag('my-module-table', 'sort', 'sibling', 'my-elements-weight', 'my-elements-weight-'. $region); + * } + * @endcode + * + * In a situation where tree relationships are present, adding multiple + * subgroups is not necessary, because the table will contain indentations that + * provide enough information about the sibling and parent relationships. + * See theme_menu_overview_form() for an example creating a table containing + * parent relationships. + * + * Please note that this function should be called from the theme layer, such as + * in a .tpl.php file, theme_ function, or in a template_preprocess function, + * not in a form declartion. Though the same JavaScript could be added to the + * page using drupal_add_js() directly, this function helps keep template files + * clean and readable. It also prevents tabledrag.js from being added twice + * accidentally. + * + * @param $table_id + * String containing the target table's id attribute. If the table does not + * have an id, one will need to be set, such as . + * @param $action + * String describing the action to be done on the form item. Either 'match' or + * 'sort'. Match is typically used for parent relationships, sort is typically + * used to set weights on other form elements with the same group. + * @param $relationship + * String describing where the $action variable should be performed. Either + * 'parent' or 'sibling'. Parent will only look for fields up the tree. + * Sibling will look for fields in the same group in rows above and below it. + * @param $group + * A class name applied on all related form elements for this action. + * @param $subgroup + * (optional) If the group has several subgroups within it, this string should + * contain the class name identifying fields in the same subgroup. + * @param $source + * (optional) If the $action is 'match', this string should contain the class + * name identifying what field will be used as the source value when matching + * the value in $subgroup. + * @param $hidden + * (optional) The column containing the field elements may be entirely hidden + * from view dynamically when the JavaScript is loaded. Set to FALSE if the + * column should not be hidden. + * @see block-admin-display-form.tpl.php + * @see theme_menu_overview_form() + */ +function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE) { + static $js_added = FALSE; + if (!$js_added) { + drupal_add_js('misc/tabledrag.js', 'core'); + $js_added = TRUE; + } + + // If a subgroup or source isn't set, assume it is the same as the group. + $target = isset($subgroup) ? $subgroup : $group; + $source = isset($source) ? $source : $target; + $settings['tableDrag'][$table_id][$group][] = array( + 'target' => $target, + 'source' => $source, + 'relationship' => $relationship, + 'action' => $action, + 'hidden' => $hidden, + ); + drupal_add_js($settings, 'setting'); +} + +/** * Aggregate JS files, putting them in the files directory. * * @param $files Index: modules/block/block-admin-display-form.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block-admin-display-form.tpl.php,v retrieving revision 1.1 diff -u -p -r1.1 block-admin-display-form.tpl.php --- modules/block/block-admin-display-form.tpl.php 5 Oct 2007 09:36:52 -0000 1.1 +++ modules/block/block-admin-display-form.tpl.php 11 Nov 2007 01:34:27 -0000 @@ -6,13 +6,14 @@ * Default theme implementation to configure blocks. * * Available variables: - * - $block_listing: An array of block controls within regions. + * - $block_regions: An array of regions. Keyed by name with the title as value. + * - $block_listing: An array of blocks keyed by region and then delta. * - $form_submit: Form submit button. * - $throttle: TRUE or FALSE depending on throttle module being enabled. * - * Each $data in $block_listing contains: - * - $data->is_region_first: TRUE or FALSE depending on the listed blocks - * positioning. Used here to insert a region header. + * Each $block_listing[$region] contains an array of blocks for that region. + * + * Each $data in $block_listing[$region] contains: * - $data->region_title: Region title for the listed block. * - $data->block_title: Block title. * - $data->region_select: Drop-down menu for assigning a region. @@ -25,9 +26,15 @@ * @see theme_block_admin_display() */ ?> - - - + $title) { + drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-'. $region, NULL, FALSE); + drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-'. $region); + } +?>
@@ -42,15 +49,16 @@ - - is_region_first): ?> - - + $title): ?> + + - - - - + + + + $data): ?> + + @@ -60,6 +68,7 @@ +
region_title; ?>
block_title; ?>block_modified ? '*' : ''; ?>
block_title; ?> region_select; ?> weight_select; ?> delete_link; ?>
Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.9 diff -u -p -r1.9 block.admin.inc --- modules/block/block.admin.inc 5 Oct 2007 09:35:09 -0000 1.9 +++ modules/block/block.admin.inc 11 Nov 2007 01:34:28 -0000 @@ -36,16 +36,14 @@ function block_admin_display_form(&$form init_theme(); $throttle = module_exists('throttle'); - $block_regions = array(BLOCK_REGION_NONE => '<'. t('none') .'>') + system_region_list($theme_key); + $block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<'. t('none') .'>'); // Build form tree $form = array( '#action' => arg(3) ? url('admin/build/block/list/'. $theme_key) : url('admin/build/block'), '#tree' => TRUE, - '#cache' => TRUE, - '#prefix' => '
', - '#suffix' => '
', ); + foreach ($blocks as $i => $block) { $key = $block['module'] .'_'. $block['delta']; $form[$key]['module'] = array( @@ -69,7 +67,7 @@ function block_admin_display_form(&$form ); $form[$key]['region'] = array( '#type' => 'select', - '#default_value' => $block['status'] ? (isset($block['region']) ? $block['region'] : system_default_region($theme_key)) : BLOCK_REGION_NONE, + '#default_value' => $block['region'], '#options' => $block_regions, ); @@ -82,20 +80,9 @@ function block_admin_display_form(&$form } } - // Attach the AHAH events to the submit button. Set the AHAH selector to every - // select element in the form. The AHAH event could be attached to every select - // element individually, but using the selector is more efficient, especially - // on a page where hundreds of AHAH enabled elements may be present. $form['submit'] = array( '#type' => 'submit', '#value' => t('Save blocks'), - '#ahah' => array( - 'path' => 'admin/build/block/list/js/'. $theme_key, - 'selector' => '#block-admin-display-form-wrapper select', - 'wrapper' => 'block-admin-display-form-wrapper', - 'event' => 'change', - 'effect' => 'fade', - ), ); return $form; @@ -115,104 +102,28 @@ function block_admin_display_form_submit } /** - * Javascript callback for AHAH replacement. Re-generate the form with the - * updated values and return necessary html. - */ -function block_admin_display_js($theme = NULL) { - // Load the cached form. - $form_cache = cache_get('form_'. $_POST['form_build_id'], 'cache_form'); - - // Set the new weights and regions for each block. - $blocks = array(); - foreach (element_children($form_cache->data) as $key) { - $field = $form_cache->data[$key]; - if (isset($field['info'])) { - $block = array( - 'module' => $field['module']['#value'], - 'delta' => $field['delta']['#value'], - 'info' => html_entity_decode($field['info']['#value'], ENT_QUOTES), - 'region' => $_POST[$key]['region'], - 'weight' => $_POST[$key]['weight'], - 'status' => $_POST[$key]['region'] == BLOCK_REGION_NONE ? 0 : 1, - ); - - $throttle = module_exists('throttle'); - if ($throttle) { - $block['throttle'] = $_POST[$key]['throttle']; - } - - if ($block['weight'] != $form_cache->data[$key]['weight']['#default_value'] || $block['region'] != $form_cache->data[$key]['region']['#default_value']) { - $changed_block = $block['module'] .'_'. $block['delta']; - } - - $blocks[] = $block; - } - } - - // Resort the blocks with the new weights. - usort($blocks, '_block_compare'); - - // Create a form in the new order. - $form_state = array('submitted' => FALSE); - $form = block_admin_display_form($form_state, $blocks, $theme); - - // Maintain classes set on individual blocks. - foreach (element_children($form_cache->data) as $key) { - if (isset($form_cache->data[$key]['#attributes'])) { - $form[$key]['#attributes'] = $form_cache->data[$key]['#attributes']; - } - } - - // Preserve the order of the new form while merging the previous data. - $form_order = array_flip(array_keys($form)); // Save the form order. - $form = array_merge($form_cache->data, $form); // Merge the data. - $form = array_merge($form_order, $form); // Put back into the correct order. - - // Add a permanent class to the changed block. - $form[$changed_block]['#attributes']['class'] = 'block-modified'; - - cache_set('form_'. $_POST['form_build_id'], $form, 'cache_form', $form_cache->expire); - - // Add a temporary class to mark the new AHAH content. - $form[$changed_block]['#attributes']['class'] = empty($form[$changed_block]['#attributes']['class']) ? 'ahah-new-content' : $form[$changed_block]['#attributes']['class'] .' ahah-new-content'; - $form['js_modified'] = array( - '#type' => 'value', - '#value' => TRUE, - ); - - $form['#post'] = $_POST; - $form['#theme'] = 'block_admin_display_form'; - - // Add messages to our output. - drupal_set_message(t('Your settings will not be saved until you click the Save blocks button.'), 'warning'); - - // Render the form. - drupal_alter('form', $form, array(), 'block_admin_display_form'); - $form = form_builder('block_admin_display_form', $form, $form_state); - - // Remove the wrapper from the form to prevent duplicate div IDs. - unset($form['#prefix'], $form['#suffix']); - - $output = drupal_render($form); - - // Return the output in JSON format. - drupal_json(array('status' => TRUE, 'data' => $output)); -} - -/** * Helper function for sorting blocks on admin/build/block. * * Active blocks are sorted by region, then by weight. * Disabled blocks are sorted by name. */ function _block_compare($a, $b) { - $status = $b['status'] - $a['status']; + global $theme_key; + static $regions; + + // We need the region list to correctly order by region. + if (!isset($regions)) { + $regions = array_flip(array_keys(system_region_list($theme_key))); + $regions[BLOCK_REGION_NONE] = count($regions); + } + // Separate enabled from disabled. + $status = $b['status'] - $a['status']; if ($status) { return $status; } - // Sort by region. - $place = strcmp($a['region'], $b['region']); + // Sort by region (in the order defined by theme .info file). + $place = $regions[$a['region']] - $regions[$b['region']]; if ($place) { return $place; } @@ -442,14 +353,20 @@ function block_box_delete_submit($form, function template_preprocess_block_admin_display_form(&$variables) { global $theme_key; - $variables['throttle'] = module_exists('throttle'); $block_regions = system_region_list($theme_key); + $variables['throttle'] = module_exists('throttle'); + $variables['block_regions'] = $block_regions + array(BLOCK_REGION_NONE => t('Disabled')); - // Highlight regions on page to provide visual reference. foreach ($block_regions as $key => $value) { + // Highlight regions on page to provide visual reference. drupal_set_content($key, '
'. $value .'
'); + // Initialize an empty array for the region. + $variables['block_listing'][$key] = array(); } + // Initialize disabled blocks array. + $variables['block_listing'][BLOCK_REGION_NONE] = array(); + // Setup to track previous region in loop. $last_region = ''; foreach (element_children($variables['form']) as $i) { @@ -460,34 +377,23 @@ function template_preprocess_block_admin // Fetch region for current block. $region = $block['region']['#default_value']; - // Track first block listing to insert region header inside block_admin_display.tpl.php. - $is_region_first = FALSE; - if ($last_region != $region) { - $is_region_first = TRUE; - // Set region title. Block regions already translated. - if ($region != BLOCK_REGION_NONE) { - $region_title = drupal_ucfirst($block_regions[$region]); - } - else { - $region_title = t('Disabled'); - } - } - - $variables['block_listing'][$i]->is_region_first = $is_region_first; - $variables['block_listing'][$i]->row_class = isset($block['#attributes']['class']) ? $block['#attributes']['class'] : ''; - $variables['block_listing'][$i]->block_modified = isset($block['#attributes']['class']) && strpos($block['#attributes']['class'], 'block-modified') !== FALSE ? TRUE : FALSE; - $variables['block_listing'][$i]->region_title = $region_title; - $variables['block_listing'][$i]->block_title = drupal_render($block['info']); - $variables['block_listing'][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); - $variables['block_listing'][$i]->weight_select = drupal_render($block['weight']); - $variables['block_listing'][$i]->throttle_check = $variables['throttle'] ? drupal_render($block['throttle']) : ''; - $variables['block_listing'][$i]->configure_link = drupal_render($block['configure']); - $variables['block_listing'][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : ''; + // Set special classes needed for table drag and drop. + $variables['form'][$i]['region']['#attributes']['class'] = 'block-region-select block-region-'. $region; + $variables['form'][$i]['weight']['#attributes']['class'] = 'block-weight block-weight-'. $region; + + $variables['block_listing'][$region][$i]->row_class = isset($block['#attributes']['class']) ? $block['#attributes']['class'] : ''; + $variables['block_listing'][$region][$i]->block_modified = isset($block['#attributes']['class']) && strpos($block['#attributes']['class'], 'block-modified') !== FALSE ? TRUE : FALSE; + $variables['block_listing'][$region][$i]->block_title = drupal_render($block['info']); + $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); + $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']); + $variables['block_listing'][$region][$i]->throttle_check = $variables['throttle'] ? drupal_render($block['throttle']) : ''; + $variables['block_listing'][$region][$i]->configure_link = drupal_render($block['configure']); + $variables['block_listing'][$region][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : ''; + $variables['block_listing'][$region][$i]->printed = FALSE; $last_region = $region; } } - $variables['messages'] = isset($variables['form']['js_modified']) ? theme('status_messages') : ''; $variables['form_submit'] = drupal_render($variables['form']); } Index: modules/block/block.css =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.css,v retrieving revision 1.5 diff -u -p -r1.5 block.css --- modules/block/block.css 10 Oct 2007 10:24:25 -0000 1.5 +++ modules/block/block.css 11 Nov 2007 01:34:28 -0000 @@ -3,8 +3,13 @@ #blocks td.region { font-weight: bold; } -#blocks td.block { - padding-left: 1.5em; /* LTR */ +#blocks tr.region-message { + font-weight: normal; + font-size: 0.9em; + color: #999; +} +#blocks tr.region-populated { + display: none; } .block-region { background-color: #ff6; @@ -12,12 +17,3 @@ margin-bottom: 4px; padding: 3px; } -#blocks select { - margin-right: 24px; /* LTR */ -} -#blocks select.progress-disabled { - margin-right: 0px; /* LTR */ -} -#blocks tr.ahah-new-content { - background-color: #ffd; -} Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.286 diff -u -p -r1.286 block.module --- modules/block/block.module 7 Nov 2007 21:13:31 -0000 1.286 +++ modules/block/block.module 11 Nov 2007 01:34:28 -0000 @@ -240,6 +240,7 @@ function _block_rehash() { $block['module'] = $module; $block['delta'] = $delta; $block['theme'] = $theme_key; + $block['region'] = (!empty($block['region']))? $block['region'] : BLOCK_REGION_NONE; if (!isset($block['pages'])) { // {block}.pages is type 'text', so it cannot have a // default value, and not null, so we need to provide Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.38 diff -u -p -r1.38 system.css --- modules/system/system.css 4 Nov 2007 21:09:22 -0000 1.38 +++ modules/system/system.css 11 Nov 2007 01:34:28 -0000 @@ -3,6 +3,9 @@ /* ** HTML elements */ +body.drag { + cursor: move; +} th.active img { display: inline; } @@ -11,6 +14,12 @@ tr.even, tr.odd { border-bottom: 1px solid #ccc; padding: 0.1em 0.6em; } +tr.drag { + background-color: #fffff0; +} +tr.drag-previous { + background-color: #ffd; +} td.active { background-color: #ddd; } @@ -32,6 +41,21 @@ thead th { .breadcrumb { padding-bottom: .5em } +div.indentation { + width: 20px; + margin: -0.4em 0.2em -0.4em -0.4em; + padding: 0.4em 0 0.4em 0.6em; + float: left; +} +div.tree-child { + background: url(../../misc/tree.png) no-repeat 11px center; +} +div.tree-child-last { + background: url(../../misc/tree-bottom.png) no-repeat 11px center; +} +div.tree-child-horizontal { + background: url(../../misc/tree.png) no-repeat -11px center; +} .error { color: #e55; } @@ -334,6 +358,30 @@ html.js .resizable-textarea textarea { } /* +** Table drag and drop. +*/ +a.tabledrag-handle { + cursor: move; + float: left; + height: 1.7em; + margin: -0.42em 0 -0.42em -0.5em; + padding: 0.42em 1.5em 0.42em 0.5em; + text-decoration: none; +} +a.tabledrag-handle:hover { + text-decoration: none; +} +a.tabledrag-handle .handle { + margin-top: 4px; + height: 13px; + width: 13px; + background: url(../../misc/draggable.png) no-repeat 0 0; +} +a.tabledrag-handle-hover .handle { + background-position: 0 -20px; +} + +/* ** Teaser splitter */ .joined + .grippie { Index: themes/garland/style.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/style.css,v retrieving revision 1.28 diff -u -p -r1.28 style.css --- themes/garland/style.css 9 Nov 2007 22:14:41 -0000 1.28 +++ themes/garland/style.css 11 Nov 2007 01:34:28 -0000 @@ -226,6 +226,14 @@ tr.even { background-color: #fff; } +tr.drag { + background-color: #fffff0; +} + +tr.drag-previous { + background-color: #ffd; +} + tr.odd td.active { background-color: #ddecf5; }