Index: modules/dashboard/dashboard.api.php
===================================================================
RCS file: modules/dashboard/dashboard.api.php
diff -N modules/dashboard/dashboard.api.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/dashboard/dashboard.api.php 14 Oct 2009 05:08:13 -0000
@@ -0,0 +1,43 @@
+ "My module's dashboard region");
+}
+
+/**
+ * Alter dashboard regions provided by modules.
+ *
+ * @param $regions
+ * An array containing all dashboard regions, in the format provided by
+ * hook_dashboard_regions().
+ */
+function hook_dashboard_regions_alter($regions) {
+ // Remove the sidebar region defined by the core dashboard module.
+ unset($regions['dashboard_sidebar']);
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
Index: modules/dashboard/dashboard.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/dashboard/dashboard.module,v
retrieving revision 1.2
diff -u -p -r1.2 dashboard.module
--- modules/dashboard/dashboard.module 13 Oct 2009 21:16:43 -0000 1.2
+++ modules/dashboard/dashboard.module 14 Oct 2009 05:08:13 -0000
@@ -57,11 +57,11 @@ function dashboard_block_info_alter(&$bl
}
/**
- * Implement hook_page_alter().
+ * Implement hook_page_build().
*
* Display dashboard blocks in the main content region.
*/
-function dashboard_page_alter(&$page) {
+function dashboard_page_build(&$page) {
global $theme_key;
if (dashboard_is_visible()) {
@@ -154,6 +154,9 @@ function dashboard_theme() {
'dashboard' => array(
'arguments' => array('element' => NULL),
),
+ 'dashboard_admin' => array(
+ 'arguments' => array('element' => NULL),
+ ),
'dashboard_region' => array(
'arguments' => array('element' => NULL),
),
@@ -173,29 +176,32 @@ function dashboard_theme() {
* Whether to launch in customization mode right away. TRUE or FALSE.
*/
function dashboard_admin($launch_customize = FALSE) {
- $output = '';
- if (user_access('administer blocks')) {
- $output .= '
' . t('To customize the dashboard page, move blocks to the dashboard regions on !block-admin, or enable JavaScript on this page to use the drag-and-drop interface.', array('!block-admin' => l('the block administration page', 'admin/structure/block'))) . '
';
- drupal_add_js(drupal_get_path('module', 'dashboard') . '/dashboard.js');
- $settings = array(
- 'dashboard' => array(
- 'drawer' => url('admin/dashboard/drawer'),
- 'blockContent' => url('admin/dashboard/block-content'),
- 'updatePath' => url('admin/dashboard/update'),
- 'formToken' => drupal_get_token('dashboard-update'),
- 'launchCustomize' => $launch_customize,
- 'dashboard' => url('admin/dashboard'),
- 'emptyBlockText' => _dashboard_get_default_string('dashboard_empty_block_text'),
- 'emptyRegionTextInactive' => _dashboard_get_default_string('dashboard_empty_region_text_inactive'),
- 'emptyRegionTextActive' => _dashboard_get_default_string('dashboard_empty_region_text_active'),
+ $js_settings = array(
+ 'dashboard' => array(
+ 'drawer' => url('admin/dashboard/drawer'),
+ 'blockContent' => url('admin/dashboard/block-content'),
+ 'updatePath' => url('admin/dashboard/update'),
+ 'formToken' => drupal_get_token('dashboard-update'),
+ 'launchCustomize' => $launch_customize,
+ 'dashboard' => url('admin/dashboard'),
+ 'emptyBlockText' => _dashboard_get_default_string('dashboard_empty_block_text'),
+ 'emptyRegionTextInactive' => _dashboard_get_default_string('dashboard_empty_region_text_inactive'),
+ 'emptyRegionTextActive' => _dashboard_get_default_string('dashboard_empty_region_text_active'),
+ ),
+ );
+ $build = array(
+ '#theme' => 'dashboard_admin',
+ '#message' => t('To customize the dashboard page, move blocks to the dashboard regions on !block-admin, or enable JavaScript on this page to use the drag-and-drop interface.', array('!block-admin' => l('the block administration page', 'admin/structure/block'))),
+ '#access' => user_access('administer blocks'),
+ '#attached' => array(
+ 'js' => array(
+ drupal_get_path('module', 'dashboard') . '/dashboard.js',
+ array('data' => $js_settings, 'type' => 'setting'),
),
- );
- drupal_add_js($settings, array('type' => 'setting'));
- drupal_add_library('system', 'ui.sortable');
- }
- // We do not return any main page content, because the content of the page
- // will be populated via the dashboard regions in dashboard_page_alter().
- return $output;
+ 'library' => array(array('system', 'ui.sortable')),
+ ),
+ );
+ return $build;
}
/**
@@ -210,11 +216,9 @@ function dashboard_is_visible() {
* Return an array of dashboard region descriptions, keyed by region name.
*/
function dashboard_region_descriptions() {
- $default_regions = array(
- 'dashboard_main' => 'Dashboard main',
- 'dashboard_sidebar' => 'Dashboard sidebar',
- );
- return variable_get('dashboard_region_descriptions', $default_regions);
+ $regions = module_invoke_all('dashboard_regions');
+ drupal_alter('dashboard_regions', $regions);
+ return $regions;
}
/**
@@ -225,6 +229,16 @@ function dashboard_regions() {
}
/**
+ * Implement hook_dashboard_regions().
+ */
+function dashboard_dashboard_regions() {
+ return array(
+ 'dashboard_main' => 'Dashboard main',
+ 'dashboard_sidebar' => 'Dashboard sidebar',
+ );
+}
+
+/**
* AJAX callback to show disabled blocks in the dashboard customization mode.
*/
function dashboard_show_disabled() {
@@ -339,6 +353,25 @@ function theme_dashboard($variables) {
}
/**
+ * Theme the page containing the dashboard.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - elements: An associative array containing the properties of the element.
+ * Properties used: #message
+ * @return
+ * A themed HTML string representing the non-customizable part of the
+ * dashboard page.
+ *
+ * @ingroup themeable
+ */
+function theme_dashboard_admin($variables) {
+ // We only return a simple help message, since the actual content of the page
+ // will be populated via the dashboard regions in dashboard_page_build().
+ return '' . $variables['element']['#message'] . '
';
+}
+
+/**
* Theme a generic dashboard region.
*
* @param $variables