Commit 85c269ef authored by Dries's avatar Dries

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

parent 6b88e617
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file block-admin-display-form.tpl.php
* @file
* Default theme implementation to configure blocks.
*
* Available variables:
......
......@@ -15,7 +15,7 @@ function block_admin_display($theme = NULL) {
// If non-default theme configuration has been selected, set the custom theme.
$custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
// Fetch and sort blocks
// Fetch and sort blocks.
$blocks = _block_rehash();
usort($blocks, '_block_compare');
......@@ -28,7 +28,6 @@ function block_admin_display($theme = NULL) {
function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
global $theme_key, $custom_theme;
// Add CSS
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.
......@@ -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') . '>');
// Build form tree
// Build the form tree.
$form = array(
'#action' => arg(3) ? url('admin/build/block/list/' . $theme_key) : url('admin/build/block'),
'#tree' => TRUE,
......@@ -54,11 +53,11 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
'#value' => $block['delta'],
);
$form[$key]['info'] = array(
'#value' => check_plain($block['info'])
'#value' => check_plain($block['info']),
);
$form[$key]['theme'] = array(
'#type' => 'hidden',
'#value' => $theme_key
'#value' => $theme_key,
);
$form[$key]['weight'] = array(
'#type' => 'weight',
......@@ -69,9 +68,15 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
'#default_value' => $block['region'],
'#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') {
$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) {
}
/**
* Process main blocks administration form submission.
* Process main blocks administration form submissions.
*/
function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) {
......@@ -135,9 +140,14 @@ function _block_compare($a, $b) {
* Menu callback; displays the block configuration form.
*/
function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
$form['module'] = array('#type' => 'value', '#value' => $module);
$form['delta'] = array('#type' => 'value', '#value' => $delta);
$form['module'] = array(
'#type' => 'value',
'#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));
......@@ -155,7 +165,6 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#weight' => -18,
);
// Module-specific block configurations.
if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
foreach ($settings as $k => $v) {
......@@ -187,7 +196,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#default_value' => $edit['custom'],
);
// Role-based visibility settings
// Role-based visibility settings.
$default_role_options = array();
$result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta);
while ($role = db_fetch_object($result)) {
......@@ -216,8 +225,8 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
'#title' => t('Page specific visibility settings'),
'#collapsible' => TRUE,
);
$access = user_access('use PHP for block visibility');
$access = user_access('use PHP for block visibility');
if ($edit['visibility'] == 2 && !$access) {
$form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
......@@ -310,6 +319,7 @@ function block_add_block_form_submit($form, &$form_state) {
cache_clear_all();
$form_state['redirect'] = 'admin/build/block';
return;
}
......
; $Id$
name = Block
description = Controls the boxes that are displayed around the main content.
package = Core - required
......
......@@ -167,4 +167,3 @@ function block_schema() {
return $schema;
}
......@@ -82,7 +82,7 @@ Drupal.behaviors.blockDrag = function(context) {
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) {
$(this).removeClass('region-populated').addClass('region-empty');
}
......
......@@ -6,10 +6,7 @@
* 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);
/**
......@@ -89,7 +86,7 @@ function block_help($path, $arg) {
}
/**
* Implementation of hook_theme()
* Implementation of hook_theme().
*/
function block_theme() {
return array(
......@@ -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) {
return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', '0'));
......@@ -396,7 +393,7 @@ function block_list($region) {
$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])) {
$blocks[$region] = array();
}
......@@ -407,7 +404,7 @@ function block_list($region) {
}
/**
* Load blocks information from the database
* Load blocks information from the database.
*/
function _block_load_blocks() {
global $user, $theme_key;
......@@ -419,7 +416,7 @@ function _block_load_blocks() {
if (!isset($blocks[$block->region])) {
$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 ($user->uid && isset($user->block[$block->module][$block->delta])) {
$enabled = $user->block[$block->module][$block->delta];
......@@ -432,7 +429,7 @@ function _block_load_blocks() {
$enabled = TRUE;
}
// Match path if necessary
// Match path if necessary.
if ($block->pages) {
if ($block->visibility < 2) {
$path = drupal_get_path_alias($_GET['q']);
......@@ -457,6 +454,7 @@ function _block_load_blocks() {
$block->page_match = $page_match;
$blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
}
return $blocks;
}
......@@ -464,7 +462,7 @@ function _block_load_blocks() {
* Render the content and subject for a set of 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
* 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