Commit d55b6e91 authored by q0rban's avatar q0rban

Update HEAD from DRUPAL-6--1.

parent 81be80a5
......@@ -12,4 +12,9 @@ per module, or even per block. For example, you can specify that menu module
blocks are only available in the header, or that the navigation menu block is
not available for any region.
Recommended additional modules are nodeblock, and region_visibility.
\ No newline at end of file
Recommended additional modules are NodeBlock, and Visibility API.
Region Manager also allows you to implement your own block creation methods.
Please see region_manager.nodeblock.inc for an example. Note: You may need to
implement your own submit handler, depending on what kind of block you are
creating. See region_manager_nodeapi() for an example.
\ No newline at end of file
......@@ -6,23 +6,18 @@
* Default theme implementation to configure blocks.
*
* Available variables:
* - $block_regions: An array of regions. Keyed by name with the title as value.
* - $block_states: An array of states. 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.
*
* Each $block_listing[$region] contains an array of blocks for that region.
* Each $block_listing[$state] contains an array of blocks for that region.
*
* Each $data in $block_listing[$region] contains:
* Each $data in $block_listing[$state] 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.
* - $data->block_config: Block title and other config options.
* - $data->state_select: Drop-down menu for assigning a state.
* - $data->weight_select: Drop-down menu for setting weights.
* - $data->throttle_check: Checkbox to enable throttling.
* - $data->configure_link: Block configuration link.
* - $data->delete_link: For deleting user added blocks.
*
* @see template_preprocess_block_admin_display_form()
* @see theme_block_admin_display()
* - $data->operations: Row containing all the operations for the block.
*/
?>
<?php
......@@ -30,32 +25,37 @@
drupal_add_js('misc/tableheader.js');
drupal_add_js(drupal_get_path('module', 'region_manager') .'/region_manager.js');
drupal_add_js(array('block_name' => _region_manager_block_name()), 'setting');
foreach ($block_regions as $region => $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);
foreach ($block_states as $state => $title) {
//drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-'. $region, NULL, FALSE);
drupal_add_tabledrag('region-manager-blocks-active_path', 'order', 'sibling', 'block-weight');
}
?>
<table id="blocks" class="sticky-enabled">
<tbody>
<?php $row = 0; ?>
<?php foreach ($block_regions as $region => $title): ?>
<tr class="region region-<?php print $region?>">
<td colspan="4" class="region"><?php print $title; ?></td>
</tr>
<tr class="region-message region-<?php print $region?>-message <?php print empty($block_listing[$region]) ? 'region-empty' : 'region-populated'; ?>">
<td colspan="4"><em><?php print t('No @blocks', array('@block' => _region_manager_block_name())); ?></em></td>
</tr>
<?php foreach ($block_listing[$region] as $delta => $data): ?>
<tr class="<?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' '. $data->row_class : ''; ?>">
<td class="block"><?php print $data->block_title; ?></td>
<td><?php print $data->region_select; ?></td>
<td><?php print $data->weight_select; ?></td>
<td class="title-link"><?php print $data->title_link; ?></td>
</tr>
<?php $row++; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php foreach ($block_states as $state => $title): ?>
<?php $row = 0; ?>
<?php print $state_prefix[$state] ?>
<div class="table-wrapper">
<table id="region-manager-blocks-<?php print $state; ?>">
<tbody>
<tr class="rm-state rm-state-<?php print $state ?>">
<td colspan="4" class="rm-state"><?php print $title ?></td>
</tr>
<tr class="rm-state-message rm-state-<?php print $state?>-message <?php print empty($block_listing[$state]) ? 'rm-state-empty' : 'rm-state-populated'; ?>">
<td colspan="4"><em><?php print t('No @blocks @state.', array('@block' => _region_manager_block_name(), '@state' => strtolower($title))); ?></em></td>
</tr>
<?php foreach ($block_listing[$state] as $delta => $data): ?>
<tr class="rm-block rm-block-<?php print $delta; ?> rm-state-<?php print $state ?> <?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' '. $data->row_class : ''; ?>">
<td class="block"><?php print $data->block_config; ?></td>
<td class="state"><?php print $data->state_select; ?></td>
<td class="weight"><?php print $data->weight_select; ?></td>
<td class="operations"><?php print $data->operations; ?></td>
</tr>
<?php $row++; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php print $state_suffix[$state] ?>
<?php endforeach; ?>
<?php print $form_submit; ?>
This diff is collapsed.
......@@ -24,10 +24,10 @@ showHideRows = function(module) {
}
});
if (show) {
$('#region-manager-blocks-form tr[class^=' + module + ']').not('tr.' + module).show();
$('#region-manager-blocks-form tr.' + module + '-child').show();
}
else {
$('#region-manager-blocks-form tr[class^=' + module + ']').not('tr.' + module).hide();
$('#region-manager-blocks-form tr.' + module + '-child').hide();
}
}
......
/* $Id$ */
/***************************
Region Manager Menu link
***************************/
div.region-manager-menu {
padding: 6px;
text-align: left;
border: 1px solid #535353;
background: #6e6e6e url(images/bg_dark.gif) repeat-x 0 bottom;
clear: both;
}
div.region-manager-menu:hover {
background-image: url(images/bg_dark-hover.gif);
}
.region-manager-menu a {
line-height: 20px;
padding-left: 56px;
height: 18px;
display: block;
background: url(images/manage-icon.png) no-repeat;
font-size: 12px;
text-transform: uppercase;
color: white !important;
}
/***************************
Region Manager Admin form
***************************/
#region-manager-blocks-form tr.module td {
border-top: 1.5em solid #fff;
border-bottom: 1px solid #b4d7f0;
......@@ -8,26 +39,233 @@
font-weight: bold;
}
html.js #region-manager-manage-form select.block-region-select,
html.js #region-manager-manage-form div.region-manager-block-title-wrapper,
#region-manager-manage-form div.region-manager-block-title-wrapper div.form-radios,
#region-manager-manage-form td.title-link a {
/***************************
Region Manager Manage form
***************************/
#region-manager-manage-form td.rm-state {
font-weight: bold;
font-size: 1.2em;
}
#region-manager-manage-form table tbody{
border: 0;
}
/***************************
Create Menu
***************************/
div.region-manager-create-menu div.item-list-wrapper {
display: none;
}
/* @group Region Manager Block Operations */
#region-manager-manage-form td.operations {
text-align: right;
vertical-align: top;
display: none;
}
html.js #region-manager-manage-form td.operations {
display: block;
}
#region-manager-manage-form td.operations div.item-list ul,
#region-manager-manage-form td.operations div.item-list ul li {
list-style: none;
background: none;
margin: 0;
padding: 0;
height: 36px;
}
#region-manager-manage-form td.operations li {
display: inline;
}
#region-manager-manage-form td.operations li a,
a.region-manager-create-menu-link {
display: block;
float: right;
text-align: left;
text-indent: -9999px;
height: 36px;
background-repeat: no-repeat;
background-position: 0 0;
outline: 0;
}
#region-manager-manage-form td.operations li a:hover,
a.region-manager-create-menu-link:hover {
background-position: 100% 0;
}
#region-manager-manage-form td.operations li.rm-block-configure-operation a {
width: 108px;
background-image: url(images/btn_configure.png);
}
#region-manager-manage-form td.operations li.rm-block-disable-operation a {
width: 94px;
background-image: url(images/btn_disable.png);
}
#region-manager-manage-form td.operations li.rm-block-add-operation a {
width: 74px;
background-image: url(images/btn_add.png);
}
#region-manager-manage-form td.operations li.rm-block-remove-operation a {
width: 100px;
background-image: url(images/btn_remove.png);
}
a.region-manager-create-menu-link {
float: none;
width: 89px;
background-image: url(images/btn_create.png);
}
#region-manager-manage-form tr.locked li.rm-block-remove-operation,
#region-manager-manage-form tr.locked li.rm-block-disable-operation,
#region-manager-blocks-active_path td.operations li.rm-block-add-operation,
#region-manager-blocks-active_path tr.rm-state-disabled li.rm-block-remove-operation,
#region-manager-blocks-active td.operations li.rm-block-configure-operation,
#region-manager-blocks-disabled td.operations li.rm-block-configure-operation,
#region-manager-blocks-active td.operations li.rm-block-remove-operation,
#region-manager-blocks-disabled td.operations li.rm-block-remove-operation,
#region-manager-blocks-disabled td.operations li.rm-block-disable-operation {
display: none;
}
/* @end */
tr.rm-state-populated,
#region-manager-manage-form td.weight,
#region-manager-manage-form td.state,
html.js #region-manager-manage-form div.region-manager-block-config-wrapper,
#region-manager-manage-form div.region-manager-block-config-wrapper div.form-radios {
display: none;
}
html.js #region-manager-manage-form td.title-link a {
display: inline;
display: inline;
}
html.js #region-manager-manage-form div.region-manager-block-config-wrapper div.form-radios {
display: block;
margin-left: 24px;
}
.region-manager-block-config-wrapper div.form-item {
background-color: transparent;
margin-left: 24px;
background-image: none;
margin-bottom: 12px;
}
html.js #region-manager-manage-form div.region-manager-block-title-wrapper div.form-radios {
display: block;
.region-manager-block-config-wrapper input.region-manager-manage-form-title {
}
#region-manager-manage-form td.title-link {
text-align: right;
vertical-align: top;
text-align: right;
}
#region-manager-manage-form .draggable a.tabledrag-handle {
height: 100%;
height: 100%;
padding-right: 7px;
margin-left: 0;
}
div.region-manager-create-menu {
padding: 12px;
border: 3px solid #a3a3a3;
margin-top: 18px;
margin-bottom: 18px;
background: #f2f2f2 url(images/bg_gradient-tall.png) repeat-x 0 top;
}
.region-manager-create-menu h4 {
margin: 2px 0 0;
padding: 0;
}
#region-manager-blocks-active_path td.rm-state {
font-size: 1.71em;
padding-bottom: 6px;
padding-top: 8px;
}
td.rm-state {
color: #292929;
padding-bottom: 6px;
padding-top: 12px;
}
#region-manager-active-path-wrapper div.table-wrapper {
border-width: 3px;
border-color: #808080;
}
div.table-wrapper {
border: 1px solid #cacaca;
padding: 18px;
margin-top: 18px;
margin-bottom: 18px;
border-bottom-color: #a3a3a3;
}
#region-manager-manage-form tr.odd td {
background: url(images/bg_gradient-short.png) repeat-x 0 top !important;
}
#region-manager-manage-form td {
padding-top: 6px;
padding-bottom: 4px;
}
#region-manager-active-path-wrapper .region-manager-create-menu div.item-list-wrapper {
border: 1px solid #e9e9e9;
padding: 12px;
background-color: white;
margin-top: 8px;
border-bottom-color: #dadada;
color: #464646;
}
.region-manager-create-menu ul {
padding: 0 !important;
}
.region-manager-create-menu ul li {
border-top: 1px dotted #c8c8c8;
margin: 0;
list-style-type: none;
line-height: 1em;
padding: 0;
}
.region-manager-create-menu ul li a {
line-height: 1em;
display: block;
padding-top: 9px;
padding-bottom: 9px;
padding-left: 12px;
background: url(images/arrow.png) no-repeat 0 10px;
}
.region-manager-create-menu ul li a:hover {
background: #f2f2f2 url(images/bg_gradient-short.png) repeat-x 0 -2px;
text-decoration: none;
}
#region-manager-blocks-active_path tr.rm-state-active td,
#region-manager-blocks-active_path tr.rm-state-active,
#region-manager-blocks-active_path tr.rm-state-disabled td,
#region-manager-blocks-active_path tr.rm-state-disabled {
background-color: #fbe28d !important;
background-image: none !important;
color: black !important;
}
\ No newline at end of file
This diff is collapsed.
; $Id$
name = Region Manager
description = Implements 'add new' block controls to select regions.
; dependencies[] =
core = 6.x
\ No newline at end of file
core = 6.x
......@@ -23,11 +23,23 @@ function region_manager_schema() {
'description' => 'Describes {blocks} access per region.',
'fields' => array(
'rid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique region ID.',
),
'theme_key' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '0',
'description' => 'A region ID, defined by the theme key and region.',
'default' => '',
'description' => 'The theme under which the region settings apply.',
),
'region' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The region.',
),
'blocked_blocks' => array(
'type' => 'text',
......@@ -44,6 +56,9 @@ function region_manager_schema() {
),
),
'primary key' => array('rid'),
'unique keys' => array(
'tr' => array('theme_key', 'region'),
),
);
return $schema;
......@@ -54,6 +69,69 @@ function region_manager_schema() {
*/
function region_manager_uninstall() {
drupal_uninstall_schema('region_manager');
cache_clear_all('region_manager:*', 'cache', TRUE);
variable_del('region_manager_block_name');
variable_del('region_manager_regions');
}
/**
* Change rid to serial, and add theme and region as a unique key.
*/
function region_manager_update_6100() {
$ret = array();
$theme_key_field = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The theme under which the region settings apply.',
);
$region_field = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The theme under which the region settings apply.',
);
$rid_field = array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique region ID.',
);
$new_keys = array(
'primary key' => array('rid'),
'unique keys' => array(
'tr' => array('theme_key', 'region'),
),
);
db_add_field($ret, 'region_manager_regions', 'region', $region_field);
db_add_field($ret, 'region_manager_regions', 'theme_key', $theme_key_field);
foreach(region_manager_regions_load_all() as $old_rid => $record) {
list($theme_key, $region) = explode(':', $old_rid);
$ret[] = update_sql("UPDATE {region_manager_regions} SET theme_key = '$theme_key', region = '$region' WHERE rid = '$old_rid'");
}
db_drop_primary_key($ret, 'region_manager_regions');
db_change_field($ret, 'region_manager_regions', 'rid', 'rid', $rid_field, $new_keys);
return $ret;
}
/**
* Separate region settings into per theme variables.
*/
function region_manager_update_6101() {
$themes = variable_get('region_manager_regions', NULL);
if ($themes) {
foreach($themes as $theme_key => $regions) {
variable_set('region_manager_regions_'. $theme_key, $regions);
}
variable_del('region_manager_regions');
}
return array();
}
\ No newline at end of file
// $Id$
$(function() {
// Move the textfields next to the label for the Use custom title radio.
/*
$('td.block div.region-manager-block-title-wrapper input.form-text').each(function () {
var title = $(this).parent();
$('input.form-radio', title.prev().children()).each(function () {
if ($(this).val() == 1) {
$(this).parent().parent().append(title);
}
});
});
*/
/**
* Show/hide form elements for editing a block title.
*/
Drupal.behaviors.blockTitle = function() {
// Show hide the textfield depending on the radio states.
$('input.region-manager-manage-form-title-status').change(function() {
if (this.checked) {
var id = $(this).attr('id');
var textfield = $('input.form-text', $(this).parents('td.block'));
switch (this.value) {
// Default Title
case '0':
textfield.val('').hide('fast');
break;
// Disable Title
case '1':
textfield.val('<none>').hide();
break;
// Custom Title
case '2':
if (textfield.val() == '<none>') {
textfield.val('');
......@@ -36,97 +30,65 @@ $(function() {
}
});
// Simulate a change so we can disable the title field if need be.
// Instantiate a change so we can hide the title field if need be.
$('input.region-manager-manage-form-title-status').change();
$('td.title-link a').click(function() {
var class = $(this).attr('class');
var wrapper = $('div.' + class);
if (wrapper.is(':hidden')) {
wrapper.show('fast');
}
else {
wrapper.hide('fast');
}
return false;
});
});
};
/**
* Move a block in the blocks table from one region to another via select list.
*
* This behavior is dependent on the tableDrag behavior, since it uses the
* objects initialized in that behavior to update the row.
* Perform actions from operation links
*/
Drupal.behaviors.blockDrag = function(context) {
var table = $('table#blocks');
var tableDrag = Drupal.tableDrag.blocks; // Get the blocks tableDrag object.
// Add a handler for when a row is swapped, update empty regions.
tableDrag.row.prototype.onSwap = function(swappedRow) {
checkEmptyRegions(table, this);
};
Drupal.behaviors.regionManagerOperations = function() {
$('td.operations a').click(function() {
var op = $(this).attr('class');
var rowClass = $(this).parents('ul').attr('class');
var row = $('tr.' + rowClass);
var configWrapper = $('div.region-manager-block-config-wrapper', row);
var tableDragObj = Drupal.tableDrag['region-manager-blocks-active_path'];
var tables = $('#region-manager-manage-form table');
// A custom message for the blocks page specifically.
Drupal.theme.tableDragChangedWarning = function () {
return '<div class="warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t("The changes to these @blocks will not be saved until the <em>@save</em> button is clicked.", { '@block' : Drupal.settings.block_name, '@save' : "Save " + Drupal.settings.block_name }) + '</div>';
};
switch(op) {
case 'add':
row.appendTo('table#region-manager-blocks-active_path').each(function() { tableDragObj.makeDraggable(this) });
$('select.block-state-select', row).val('active_path');
break;
case 'configure':
if (configWrapper.is(':hidden')) {
configWrapper.show('fast');
}
else {
configWrapper.hide('fast');
}
break;
// Add a handler so when a row is dropped, update fields dropped into new regions.
tableDrag.onDrop = function() {
dragObject = this;
if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) {
var regionRow = $(dragObject.rowObject.element).prev('tr').get(0);
var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
var regionField = $('select.block-region-select', dragObject.rowObject.element);
var weightField = $('select.block-weight', dragObject.rowObject.element);
var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
case 'remove':
row.insertAfter('table#region-manager-blocks-active tr.rm-state-message');
$('select.block-state-select', row).val('active');
$('a.tabledrag-handle', row).remove();
configWrapper.hide();
break;
if (!regionField.is('.block-region-'+ regionName)) {
regionField.removeClass('block-region-' + oldRegionName).addClass('block-region-' + regionName);
weightField.removeClass('block-weight-' + oldRegionName).addClass('block-weight-' + regionName);
regionField.val(regionName);
}
case 'disable':
row.insertAfter('table#region-manager-blocks-disabled tr.rm-state-message');
$('select.block-state-select', row).val('disabled');
$('a.tabledrag-handle', row).remove();
configWrapper.hide();
break;
}
};
// Add the behavior to each region select list.
$('select.block-region-select:not(.blockregionselect-processed)', context).each(function() {
$(this).change(function(event) {
// Make our new row and select field.
var row = $(this).parents('tr:first');
var select = $(this);
tableDrag.rowObject = new tableDrag.row(row);
// Find the correct region and insert the row as the first in the region.
$('tr.region-message', table).each(function() {
if ($(this).is('.region-' + select[0].value + '-message')) {
// Add the new row and remove the old one.
$(this).after(row);
// Manually update weights and restripe.
tableDrag.updateFields(row.get(0));
tableDrag.rowObject.changed = true;
if (tableDrag.oldRowElement) {
$(tableDrag.oldRowElement).removeClass('drag-previous');
}
tableDrag.oldRowElement = row.get(0);
tableDrag.restripeTable();
tableDrag.rowObject.markChanged();
tableDrag.oldRowElement = row;
$(row).addClass('drag-previous');
}
});
if (op != 'configure') {
tables.each(function() { checkEmptyRegions(this, row); });
}
$('tr', tables).filter(':odd').filter('.odd')
.removeClass('odd').addClass('even')
.end().end()
.filter(':even').filter('.even')
.removeClass('even').addClass('odd');
// Modify empty regions with added or removed fields.
checkEmptyRegions(table, row);
// Remove focus from selectbox.
select.get(0).blur();
});
$(this).addClass('blockregionselect-processed');
return false;
});
var checkEmptyRegions = function(table, rowObject) {
$('tr.region-message', table).each(function() {
$('tr.rm-state-message', table).each(function() {
// If the dragged row is in this region, but above the message row, swap it down one space.