diff --git a/plugins/context_reaction_block.inc b/plugins/context_reaction_block.inc index abcafd8..f2a810a 100644 --- a/plugins/context_reaction_block.inc +++ b/plugins/context_reaction_block.inc @@ -77,7 +77,19 @@ class context_reaction_block extends context_reaction { '#weight' => $block->weight, '#type' => 'markup', '#tree' => TRUE, - 'weight' => array('#type' => 'weight', '#delta' => $weight_delta, '#default_value' => $block->weight), + 'title' => array( + '#attributes' => array('class' => array('block-title')), + '#default_value' => isset($block->title) ? $block->title : '', + '#type' => 'textfield', + '#size' => 30, + '#title' => t('Custom Title'), + ), + 'weight' => array( + '#attributes' => array('class' => array('block-weight', 'tabledrag-hide')), + '#type' => 'weight', + '#delta' => $weight_delta, + '#default_value' => $block->weight, + ), ); } } @@ -108,6 +120,7 @@ class context_reaction_block extends context_reaction { 'delta' => $block_info[$data->bid]->delta, 'region' => $region, 'weight' => $data->weight, + 'title' => $data->title, ); } } @@ -373,18 +386,21 @@ class context_reaction_block extends context_reaction { $options = $this->fetch_from_context($context); if (!empty($options['blocks'])) { foreach ($options['blocks'] as $context_block) { + $context_block += array('title' => NULL); $bid = "{$context_block['module']}-{$context_block['delta']}"; if (isset($info[$bid])) { $block = (object) array_merge((array) $info[$bid], $context_block); $block->context = $context->name; - $block->title = isset($info[$block->bid]->title) ? $info[$block->bid]->title : NULL; + if ($block->title && $block->title != '') { + $block->title = t($block->title); + } $block->cache = isset($info[$block->bid]->cache) ? $info[$block->bid]->cache : DRUPAL_NO_CACHE; $context_blocks[$block->region][$block->bid] = $block; } } } } - + $this->is_editable_check($context_blocks); global $theme; $active_regions = $this->system_region_list($theme); @@ -420,7 +436,7 @@ class context_reaction_block extends context_reaction { } /** - * Determine if there is an active context editor block, and set a flag. We will set a flag so + * Determine if there is an active context editor block, and set a flag. We will set a flag so * that we can make sure that blocks with empty content have some default content. This is * needed so the save of the context inline editor does not remove the blocks with no content. */ @@ -443,7 +459,7 @@ class context_reaction_block extends context_reaction { } } } - + /** * Generate the safe weight range for a block being added to a region such that * there are enough potential unique weights to support all blocks. @@ -568,6 +584,7 @@ class context_reaction_block extends context_reaction { (!isset($region) || (!empty($region) && $block['region'] == $region)) // No region specified or regions match. ) { $context_block = $block_info["{$block['module']}-{$block['delta']}"]; + $context_block->title = isset($block['title']) ? $block['title'] : ''; $context_block->weight = $block['weight']; $context_block->region = $block['region']; $context_block->context = !empty($context->name) ? $context->name : 'tempname'; @@ -629,7 +646,7 @@ class context_reaction_block extends context_reaction { module_load_include('module', 'block', 'block'); $block = $info[$bid]; $block->title = isset($block->title) ? $block->title : ''; - $block->context = $context; + $block->context = $context; $block->region = ''; $rendered_blocks = _block_render_blocks(array($block)); // For E_STRICT warning $block = array_shift($rendered_blocks); diff --git a/plugins/context_reaction_block.js b/plugins/context_reaction_block.js index 10e25a2..3138e31 100644 --- a/plugins/context_reaction_block.js +++ b/plugins/context_reaction_block.js @@ -56,9 +56,10 @@ DrupalContextBlockForm = function(blockForm) { var region = $(this).attr('id').split('context-blockform-region-')[1]; var blocks = []; $('tr', $(this)).each(function() { - var bid = $(this).attr('id'); - var weight = $(this).find('select,input').first().val(); - blocks.push({'bid' : bid, 'weight' : weight}); + var bid = $(this).attr('id'), + weight = $(this).find('.block-weight').first().val(), + title = $(this).find('.block-title').first().val(); + blocks.push({'bid' : bid, 'weight' : weight, 'title': title}); }); Drupal.contextBlockForm.state[region] = blocks; }); @@ -119,10 +120,11 @@ DrupalContextBlockForm = function(blockForm) { selected.each(function() { // create new block markup - var block = document.createElement('tr'); - var text = $(this).parents('div.form-item').eq(0).hide().children('label').text(); - var select = '
', + bid = $(this).attr('value'), + i; weight_warn = true; var selected_weight = max_weight_option; if (max_weight_option >= (1 + +max_observed_weight)) { @@ -138,9 +140,16 @@ DrupalContextBlockForm = function(blockForm) { select += '>' + i + ''; } select += '
'; - $(block).attr('id', $(this).attr('value')).addClass('draggable'); - $(block).html(""+ text + "" + select + "X"); + // Now add the title textfield. + var title = '
', + titleName = 'reactions[plugins][block][blocks][' + region + '][' + bid + '][title]'; + title += ' '; + title += ''; + title += '
'; + + $(block).attr('id', $(this).attr('value')).addClass('draggable'); + $(block).html("" + text + title + "" + select + "X"); // add block item to region //TODO : Fix it so long blocks don't get stuck when added to top regions and dragged towards bottom regions Drupal.tableDrag[base].makeDraggable(block); diff --git a/theme/context_reaction_block.theme.inc b/theme/context_reaction_block.theme.inc index 4f538bc..7a8c69d 100644 --- a/theme/context_reaction_block.theme.inc +++ b/theme/context_reaction_block.theme.inc @@ -40,11 +40,16 @@ function theme_context_block_regions_form($vars) { drupal_add_tabledrag($attr['id'], 'order', 'sibling', 'tabledrag-hide', NULL, NULL, FALSE); $rows = array(); foreach (element_children($form[$region]) as $id) { - $form[$region][$id]['weight']['#attributes'] = array('class' => array('tabledrag-hide')); $label = $form[$region][$id]['#value']; $remove = l(t('X'), $_GET['q'], array('fragment' => 'remove', 'attributes' => array('class' => array('remove')))); + $row = array( + '', + $label . drupal_render($form[$region][$id]['title']), + drupal_render($form[$region][$id]['weight']), + $remove, + ); $rows[] = array( - 'data' => array($label, drupal_render($form[$region][$id]['weight']), $remove), + 'data' => $row, 'class' => array('draggable'), 'id' => $id, );