Commit 85c269ef authored by Dries's avatar Dries

- Patch #257634 by Senpai and catch: code clean-up

parent 6b88e617
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// $Id$ // $Id$
/** /**
* @file block-admin-display-form.tpl.php * @file
* Default theme implementation to configure blocks. * Default theme implementation to configure blocks.
* *
* Available variables: * Available variables:
......
...@@ -15,7 +15,7 @@ function block_admin_display($theme = NULL) { ...@@ -15,7 +15,7 @@ function block_admin_display($theme = NULL) {
// If non-default theme configuration has been selected, set the custom theme. // If non-default theme configuration has been selected, set the custom theme.
$custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland'); $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
// Fetch and sort blocks // Fetch and sort blocks.
$blocks = _block_rehash(); $blocks = _block_rehash();
usort($blocks, '_block_compare'); usort($blocks, '_block_compare');
...@@ -28,7 +28,6 @@ function block_admin_display($theme = NULL) { ...@@ -28,7 +28,6 @@ function block_admin_display($theme = NULL) {
function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
global $theme_key, $custom_theme; global $theme_key, $custom_theme;
// Add CSS
drupal_add_css(drupal_get_path('module', 'block') . '/block.css', 'module', 'all', FALSE); drupal_add_css(drupal_get_path('module', 'block') . '/block.css', 'module', 'all', FALSE);
// If non-default theme configuration has been selected, set the custom theme. // If non-default theme configuration has been selected, set the custom theme.
...@@ -37,7 +36,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { ...@@ -37,7 +36,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
$block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<' . t('none') . '>'); $block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<' . t('none') . '>');
// Build form tree // Build the form tree.
$form = array( $form = array(
'#action' => arg(3) ? url('admin/build/block/list/' . $theme_key) : url('admin/build/block'), '#action' => arg(3) ? url('admin/build/block/list/' . $theme_key) : url('admin/build/block'),
'#tree' => TRUE, '#tree' => TRUE,
...@@ -54,11 +53,11 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { ...@@ -54,11 +53,11 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
'#value' => $block['delta'], '#value' => $block['delta'],
); );
$form[$key]['info'] = array( $form[$key]['info'] = array(
'#value' => check_plain($block['info']) '#value' => check_plain($block['info']),
); );
$form[$key]['theme'] = array( $form[$key]['theme'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $theme_key '#value' => $theme_key,
); );
$form[$key]['weight'] = array( $form[$key]['weight'] = array(
'#type' => 'weight', '#type' => 'weight',
...@@ -69,9 +68,15 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { ...@@ -69,9 +68,15 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
'#default_value' => $block['region'], '#default_value' => $block['region'],
'#options' => $block_regions, '#options' => $block_regions,
); );
$form[$key]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/' . $block['module'] . '/' . $block['delta'])); $form[$key]['configure'] = array(
'#value' => l(t('configure'),
'admin/build/block/configure/' . $block['module'] . '/' . $block['delta']),
);
if ($block['module'] == 'block') { if ($block['module'] == 'block') {
$form[$key]['delete'] = array('#value' => l(t('delete'), 'admin/build/block/delete/' . $block['delta'])); $form[$key]['delete'] = array(
'#value' => l(t('delete'),
'admin/build/block/delete/' . $block['delta']),
);
} }
} }
...@@ -84,7 +89,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { ...@@ -84,7 +89,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
} }
/** /**
* Process main blocks administration form submission. * Process main blocks administration form submissions.
*/ */
function block_admin_display_form_submit($form, &$form_state) { function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) { foreach ($form_state['values'] as $block) {
...@@ -135,9 +140,14 @@ function _block_compare($a, $b) { ...@@ -135,9 +140,14 @@ function _block_compare($a, $b) {
* Menu callback; displays the block configuration form. * Menu callback; displays the block configuration form.
*/ */
function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
$form['module'] = array(
$form['module'] = array('#type' => 'value', '#value' => $module); '#type' => 'value',
$form['delta'] = array('#type' => 'value', '#value' => $delta); '#value' => $module,
);
$form['delta'] = array(
'#type' => 'value',
'#value' => $delta,
);
$edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta)); $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
...@@ -155,7 +165,6 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { ...@@ -155,7 +165,6 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#weight' => -18, '#weight' => -18,
); );
// Module-specific block configurations. // Module-specific block configurations.
if ($settings = module_invoke($module, 'block', 'configure', $delta)) { if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
foreach ($settings as $k => $v) { foreach ($settings as $k => $v) {
...@@ -187,7 +196,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { ...@@ -187,7 +196,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#default_value' => $edit['custom'], '#default_value' => $edit['custom'],
); );
// Role-based visibility settings // Role-based visibility settings.
$default_role_options = array(); $default_role_options = array();
$result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta); $result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta);
while ($role = db_fetch_object($result)) { while ($role = db_fetch_object($result)) {
...@@ -216,8 +225,8 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { ...@@ -216,8 +225,8 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#title' => t('Page specific visibility settings'), '#title' => t('Page specific visibility settings'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
); );
$access = user_access('use PHP for block visibility');
$access = user_access('use PHP for block visibility');
if ($edit['visibility'] == 2 && !$access) { if ($edit['visibility'] == 2 && !$access) {
$form['page_vis_settings'] = array(); $form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2); $form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
...@@ -310,6 +319,7 @@ function block_add_block_form_submit($form, &$form_state) { ...@@ -310,6 +319,7 @@ function block_add_block_form_submit($form, &$form_state) {
cache_clear_all(); cache_clear_all();
$form_state['redirect'] = 'admin/build/block'; $form_state['redirect'] = 'admin/build/block';
return; return;
} }
......
; $Id$ ; $Id$
name = Block name = Block
description = Controls the boxes that are displayed around the main content. description = Controls the boxes that are displayed around the main content.
package = Core - required package = Core - required
......
...@@ -167,4 +167,3 @@ function block_schema() { ...@@ -167,4 +167,3 @@ function block_schema() {
return $schema; return $schema;
} }
...@@ -82,7 +82,7 @@ Drupal.behaviors.blockDrag = function(context) { ...@@ -82,7 +82,7 @@ Drupal.behaviors.blockDrag = function(context) {
rowObject.swap('after', this); rowObject.swap('after', this);
} }
} }
// This region has become empty // This region has become empty.
if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').size() == 0) { if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').size() == 0) {
$(this).removeClass('region-populated').addClass('region-empty'); $(this).removeClass('region-populated').addClass('region-empty');
} }
......
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
* Controls the boxes that are displayed around the main content. * Controls the boxes that are displayed around the main content.
*/ */
/** // Denotes that a block is not enabled in any region and should not be shown.
* Denotes that a block is not enabled in any region and should not
* be shown.
*/
define('BLOCK_REGION_NONE', -1); define('BLOCK_REGION_NONE', -1);
/** /**
...@@ -89,7 +86,7 @@ function block_help($path, $arg) { ...@@ -89,7 +86,7 @@ function block_help($path, $arg) {
} }
/** /**
* Implementation of hook_theme() * Implementation of hook_theme().
*/ */
function block_theme() { function block_theme() {
return array( return array(
...@@ -168,7 +165,7 @@ function block_menu() { ...@@ -168,7 +165,7 @@ function block_menu() {
} }
/** /**
* Menu item access callback - only admin or enabled themes can be accessed * Menu item access callback - only admin or enabled themes can be accessed.
*/ */
function _block_themes_access($theme) { function _block_themes_access($theme) {
return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', '0')); return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', '0'));
...@@ -396,7 +393,7 @@ function block_list($region) { ...@@ -396,7 +393,7 @@ function block_list($region) {
$blocks = _block_load_blocks(); $blocks = _block_load_blocks();
} }
// Create an empty array if there were no entries // Create an empty array if there were no entries.
if (!isset($blocks[$region])) { if (!isset($blocks[$region])) {
$blocks[$region] = array(); $blocks[$region] = array();
} }
...@@ -407,7 +404,7 @@ function block_list($region) { ...@@ -407,7 +404,7 @@ function block_list($region) {
} }
/** /**
* Load blocks information from the database * Load blocks information from the database.
*/ */
function _block_load_blocks() { function _block_load_blocks() {
global $user, $theme_key; global $user, $theme_key;
...@@ -419,7 +416,7 @@ function _block_load_blocks() { ...@@ -419,7 +416,7 @@ function _block_load_blocks() {
if (!isset($blocks[$block->region])) { if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array(); $blocks[$block->region] = array();
} }
// Use the user's block visibility setting, if necessary // Use the user's block visibility setting, if necessary.
if ($block->custom != 0) { if ($block->custom != 0) {
if ($user->uid && isset($user->block[$block->module][$block->delta])) { if ($user->uid && isset($user->block[$block->module][$block->delta])) {
$enabled = $user->block[$block->module][$block->delta]; $enabled = $user->block[$block->module][$block->delta];
...@@ -432,7 +429,7 @@ function _block_load_blocks() { ...@@ -432,7 +429,7 @@ function _block_load_blocks() {
$enabled = TRUE; $enabled = TRUE;
} }
// Match path if necessary // Match path if necessary.
if ($block->pages) { if ($block->pages) {
if ($block->visibility < 2) { if ($block->visibility < 2) {
$path = drupal_get_path_alias($_GET['q']); $path = drupal_get_path_alias($_GET['q']);
...@@ -457,6 +454,7 @@ function _block_load_blocks() { ...@@ -457,6 +454,7 @@ function _block_load_blocks() {
$block->page_match = $page_match; $block->page_match = $page_match;
$blocks[$block->region]["{$block->module}_{$block->delta}"] = $block; $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
} }
return $blocks; return $blocks;
} }
...@@ -464,7 +462,7 @@ function _block_load_blocks() { ...@@ -464,7 +462,7 @@ function _block_load_blocks() {
* Render the content and subject for a set of blocks. * Render the content and subject for a set of blocks.
* *
* @param $region_blocks * @param $region_blocks
* An array of block objects such as returned for one region by _block_load_blocks() * An array of block objects such as returned for one region by _block_load_blocks().
* *
* @return * @return
* An array of visible blocks with subject and content rendered. * An array of visible blocks with subject and content rendered.
......
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