Commit dd5ded83 authored by Dries's avatar Dries

- Patch #544360 by Gábor Hojtsy, ksenzee, David_Rothstein, seutje, JacobSingh,...

- Patch #544360 by Gábor Hojtsy, ksenzee, David_Rothstein, seutje, JacobSingh, paul.lovvik, EclipseGc et al: Dashboard module 1.0. Wo-hoot!
parent bc9a742f
......@@ -1438,6 +1438,14 @@ function install_finished(&$install_state) {
$output .= '<p>' . st('For more information on configuring Drupal, refer to the <a href="@help">help section</a>.', array('@help' => url('admin/help'))) . '</p>';
}
// Rebuild the module and theme data, in case any newly-installed modules
// need to modify it via hook_system_info_alter(). We need to clear the
// theme static cache first, to make sure that the theme data is actually
// rebuilt.
drupal_static_reset('_system_get_theme_data');
system_get_module_data();
system_get_theme_data();
// Rebuild menu and registry to get content type links registered by the
// profile, and possibly any other menu items created through the tasks.
menu_rebuild();
......
......@@ -243,20 +243,34 @@ function block_page_build(&$page) {
* The requested region.
*/
function block_get_blocks_by_region($region) {
$weight = 0;
$build = array();
if ($list = block_list($region)) {
foreach ($list as $key => $block) {
$build[$key] = $block->content;
unset($block->content);
$build[$key] += array(
'#block' => $block,
'#weight' => ++$weight,
);
$build[$key]['#theme_wrappers'][] ='block';
}
$build['#sorted'] = TRUE;
$build = _block_get_renderable_array($list);
}
return $build;
}
/**
* Get an array of blocks suitable for drupal_render().
*
* @param $list
* A list of blocks such as that returned by block_list().
* @return
* A renderable array.
*/
function _block_get_renderable_array($list = array()) {
$weight = 0;
$build = array();
foreach ($list as $key => $block) {
$build[$key] = $block->content;
unset($block->content);
$build[$key] += array(
'#block' => $block,
'#weight' => ++$weight,
);
$build[$key]['#theme_wrappers'][] ='block';
}
$build['#sorted'] = TRUE;
return $build;
}
......
/* $Id$ */
#dashboard div.dashboard-region {
float: left;
min-height: 1px;
}
#dashboard div#dashboard_main {
width: 65%;
}
#dashboard div#dashboard_sidebar {
width: 35%;
}
#dashboard div.block {
margin-bottom: 20px;
}
#dashboard .dashboard-region .block {
clear: both;
}
#dashboard div.block h2 {
background-color:#e2e1dc;
padding: 3px 5px;
}
#dashboard div.block div.content {
padding: 10px 5px 5px 5px;
}
#dashboard div.block div.content ul.menu {
margin-left:20px;
}
#dashboard #disabled-blocks .block, #dashboard .block-placeholder {
background: #e2e1dc;
padding: 6px 4px;
margin: 3px 3px 3px 0;
float: left;
-moz-border-radius: 4px;
}
#dashboard .ui-sortable {
border: 3px dashed #ccc;
padding: 10px;
}
#dashboard .canvas-content {
background-color: #4d4d4d;
padding: 10px;
color: #fff;
}
#dashboard .canvas-content a {
color: #fff;
text-decoration: underline;
}
#dashboard #disabled-blocks .ui-sortable {
padding: 0;
background-color: #4d4d4d;
border: 0;
}
#dashboard .canvas-content input {
float: right;
margin: 0 0 0 10px;
}
#dashboard .region {
margin: 5px;
}
#dashboard #disabled-blocks .section {
margin: 0 7em 0 0;
height: 100px;
overflow: auto;
}
#dashboard #disabled-blocks {
padding: 5px 0;
}
#dashboard div.dragging {
width: 30%;
}
#dashboard #disabled-blocks h2 {
display: inline;
font-weight: normal;
white-space: nowrap;
color: #000;
}
#dashboard #disabled-blocks .block .content, #dashboard .ui-sortable-helper .content {
display: none;
}
#dashboard .ui-sortable .block {
cursor: move;
}
#dashboard .dashboard-region .block-placeholder {
margin: 0 0 20px 0;
padding: 0;
display: block;
height: 1.6em;
width: 100%;
}
#dashboard #disabled-blocks .block-placeholder {
width: 30px;
height: 1.6em;
}
; $Id$
name = Dashboard
description = A module that provides a dashboard interface for organizing and tracking various information within your site.
core = 7.x
package = Core
version = VERSION
files[] = dashboard.module
dependencies[] = block
// $Id$
(function ($) {
/**
* Implementation of Drupal.behaviors for dashboard.
*/
Drupal.behaviors.dashboard = {
attach: function () {
$('#dashboard').prepend('<div class="customize"><ul class="action-links"><a href="#">' + Drupal.t('Customize') + '</a></ul><div class="canvas"></div></div>');
$('#dashboard .customize .action-links a').click(Drupal.behaviors.dashboard.enterCustomizeMode);
if ($('#dashboard .region .block').length == 0) {
Drupal.settings.dashboard.launchCustomize = true;
}
Drupal.behaviors.dashboard.addPlaceholders();
if (Drupal.settings.dashboard.launchCustomize) {
Drupal.behaviors.dashboard.enterCustomizeMode();
}
},
addPlaceholders: function() {
$('#dashboard .dashboard-region .region').each(function () {
var empty_text = "";
if ($('.block', this).length == 0) {
// We need a placeholder.
if ($('#dashboard').hasClass('customize_mode')) {
empty_text = Drupal.settings.dashboard.emptyRegionTextActive;
} else {
empty_text = Drupal.settings.dashboard.emptyRegionTextInactive;
}
if ($('.placeholder', this).length == 0) {
$(this).append('<div class="placeholder"></div>');
}
$('.placeholder', this).html(empty_text);
}
else {
$('.placeholder', this).remove();
}
});
},
/**
* Enter "customize" mode by displaying disabled blocks.
*/
enterCustomizeMode: function () {
$('#dashboard').addClass('customize_mode');
Drupal.behaviors.dashboard.addPlaceholders();
$('#dashboard .customize .action-links').hide();
$('div.customize .canvas').load(Drupal.settings.dashboard.drawer, Drupal.behaviors.dashboard.setupDrawer);
},
/**
* Exit "customize" mode by simply forcing a page refresh.
*/
exitCustomizeMode: function () {
$('#dashboard').removeClass('customize_mode');
Drupal.behaviors.dashboard.addPlaceholders();
location.href = Drupal.settings.dashboard.dashboard;
},
/**
* Helper for enterCustomizeMode; sets up drag-and-drop and close button.
*/
setupDrawer: function () {
$('div.customize .canvas-content').prepend('<input type="button" class="form-submit" value="' + Drupal.t('Done') + '"></input>');
$('div.customize .canvas-content input').click(Drupal.behaviors.dashboard.exitCustomizeMode);
// Initialize drag-and-drop.
var regions = $('#dashboard div.region');
regions.sortable({
connectWith: regions,
cursor: 'move',
cursorAt: {top:0},
dropOnEmpty: true,
items: '>div.block, div.disabled-block',
opacity: 0.8,
helper: 'block-dragging',
placeholder: 'block-placeholder clearfix',
start: Drupal.behaviors.dashboard.start,
update: Drupal.behaviors.dashboard.update
});
},
/**
* While dragging, make the block appear as a disabled block
*
* This function is called on the jQuery UI Sortable "start" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that is being dragged.
*/
start: function (event, ui) {
var item = $(ui.item);
// If the block is already in disabled state, don't do anything.
if (!item.hasClass('disabled-block')) {
item.css({height: 'auto'});
}
},
/**
* Send block order to the server, and expand previously disabled blocks.
*
* This function is called on the jQuery UI Sortable "update" event.
*
* @param event
* The event that triggered this callback.
* @param ui
* An object containing information about the item that was just dropped.
*/
update: function (event, ui) {
var item = $(ui.item);
// If the user dragged a disabled block, load the block contents.
if (item.hasClass('disabled-block')) {
var module, delta, itemClass;
itemClass = item.attr('class');
// Determine the block module and delta.
module = itemClass.match(/\bmodule-(\S+)\b/)[1];
delta = itemClass.match(/\bdelta-(\S+)\b/)[1];
// Load the newly enabled block's content.
$.get(Drupal.settings.dashboard.blockContent + '/' + module + '/' + delta, {},
function (block) {
var blockContent = "";
if (block) {
blockContent = $("div.content", $(block));
}
if (!blockContent) {
blockContent = $('<div class="content">' + Drupal.settings.dashboard.emptyBlockText + '</div>');
}
$("div.content", item).after(blockContent).remove();
},
'html'
);
// Remove the "disabled-block" class, so we don't reload its content the
// next time it's dragged.
item.removeClass("disabled-block");
}
Drupal.behaviors.dashboard.addPlaceholders();
// Let the server know what the new block order is.
$.post(Drupal.settings.dashboard.updatePath, {
'form_token': Drupal.settings.dashboard.formToken,
'regions': Drupal.behaviors.dashboard.getOrder
}
);
},
/**
* Return the current order of the blocks in each of the sortable regions,
* in query string format.
*/
getOrder: function () {
var order = [];
$('#dashboard div.region').each(function () {
var region = $(this).parent().attr('id').replace(/-/g, '_');
var blocks = $(this).sortable('toArray');
var i;
for (i = 0; i < blocks.length; i++) {
order.push(region + '[]=' + blocks[i]);
}
});
order = order.join('&');
return order;
}
};
})(jQuery);
This diff is collapsed.
......@@ -183,7 +183,7 @@ function system_test_exit() {
/**
* Implement hook_system_info_alter().
*/
function system_test_system_info_alter(&$info, $file) {
function system_test_system_info_alter(&$info, $file, $type) {
// We need a static otherwise the last test will fail to alter common_test.
static $test;
if (($dependencies = variable_get('dependencies', array())) || $test) {
......
......@@ -26,7 +26,7 @@ function toolbar_install() {
$items = array(
'node/add' => 'Add content',
'admin/content' => 'Find content',
'admin' => 'Dashboard',
'admin/dashboard' => 'Dashboard',
);
$weight = -20;
foreach ($items as $path => $title) {
......
......@@ -6,6 +6,7 @@ core = 7.x
dependencies[] = block
dependencies[] = color
dependencies[] = comment
dependencies[] = dashboard
dependencies[] = help
dependencies[] = image
dependencies[] = menu
......
......@@ -110,6 +110,26 @@ function default_install() {
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'management',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'dashboard_main',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'new',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'dashboard_sidebar',
'pages' => '',
'cache' => -1,
),
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment