Commit a09822b3 authored by webchick's avatar webchick

#606640 by eojthebrave and sun: Use proper menu router paths for the block module.

parent 81bba297
......@@ -88,12 +88,12 @@ function block_admin_display_form($form, &$form_state, $blocks, $theme) {
);
$form[$key]['configure'] = array(
'#markup' => l(t('configure'),
'admin/structure/block/configure/' . $block['module'] . '/' . $block['delta']),
'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure'),
);
if ($block['module'] == 'block') {
$form[$key]['delete'] = array(
'#markup' => l(t('delete'),
'admin/structure/block/delete/' . $block['delta']),
'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete'),
);
}
}
......@@ -174,21 +174,16 @@ function _block_compare($a, $b) {
/**
* Menu callback; displays the block configuration form.
*/
function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0) {
function block_admin_configure($form, &$form_state, $block) {
$form['module'] = array(
'#type' => 'value',
'#value' => $module,
'#value' => $block->module,
);
$form['delta'] = array(
'#type' => 'value',
'#value' => $delta,
'#value' => $block->delta,
);
$edit = db_query("SELECT pages, visibility, custom, title FROM {block} WHERE module = :module AND delta = :delta", array(
':module' => $module,
':delta' => $delta,
))->fetchAssoc();
$form['block_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Block specific settings'),
......@@ -198,8 +193,8 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
'#type' => 'textfield',
'#title' => t('Block title'),
'#maxlength' => 64,
'#description' => $module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>&lt;none&gt;</em> to display no title, or leave blank to use the default block title.'),
'#default_value' => $edit['title'],
'#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>&lt;none&gt;</em> to display no title, or leave blank to use the default block title.'),
'#default_value' => isset($block->title) ? $block->title : '',
'#weight' => -18,
);
......@@ -220,8 +215,8 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
// Only display enabled themes
if ($theme->status) {
$region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(
':module' => $module,
':delta' => $delta,
':module' => $block->module,
':delta' => $block->delta,
':theme' => $key,
))->fetchField();
......@@ -237,16 +232,16 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
}
// Module-specific block configurations.
if ($settings = module_invoke($module, 'block_configure', $delta)) {
if ($settings = module_invoke($block->module, 'block_configure', $block->delta)) {
foreach ($settings as $k => $v) {
$form['block_settings'][$k] = $v;
}
}
// Get the block subject for the page title.
$info = module_invoke($module, 'block_info');
if (isset($info[$delta])) {
drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])), PASS_THROUGH);
$info = module_invoke($block->module, 'block_info');
if (isset($info[$block->delta])) {
drupal_set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
}
$form['page_vis_settings'] = array(
......@@ -257,10 +252,13 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
);
$access = user_access('use PHP for settings');
if ($edit['visibility'] == 2 && !$access) {
if (isset($block->visibility) && $block->visibility == 2 && !$access) {
$form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
$form['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $edit['pages']);
$form['page_vis_settings']['pages'] = array(
'#type' => 'value',
'#value' => isset($block->pages) ? $block->pages : '',
);
}
else {
$options = array(t('Every page except those specified below.'), t('Only the pages specified below.'));
......@@ -274,20 +272,20 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
'#type' => 'radios',
'#title' => t('Show block on specific pages'),
'#options' => $options,
'#default_value' => $edit['visibility'],
'#default_value' => isset($block->visibility) ? $block->visibility : '',
);
$form['page_vis_settings']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $edit['pages'],
'#default_value' => isset($block->pages) ? $block->pages : '',
'#description' => $description,
);
}
// Role-based visibility settings.
$default_role_options = db_query("SELECT rid FROM {block_role} WHERE module = :module AND delta = :delta", array(
':module' => $module,
':delta' => $delta,
':module' => $block->module,
':delta' => $block->delta,
))->fetchCol();
$role_options = db_query('SELECT rid, name FROM {role} ORDER BY name')->fetchAllKeyed();
$form['role_vis_settings'] = array(
......@@ -306,8 +304,8 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
// Content type specific configuration.
$default_type_options = db_query("SELECT type FROM {block_node_type} WHERE module = :module AND delta = :delta", array(
':module' => $module,
':delta' => $delta,
':module' => $block->module,
':delta' => $block->delta,
))->fetchCol();
$form['content_type_vis_settings'] = array(
'#type' => 'fieldset',
......@@ -339,7 +337,7 @@ function block_admin_configure($form, &$form_state, $module = NULL, $delta = 0)
t('Hide this block by default but let individual users show it.')
),
'#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
'#default_value' => $edit['custom'],
'#default_value' => isset($block->custom) ? $block->custom : '',
);
$form['submit'] = array(
......@@ -426,7 +424,10 @@ function block_admin_configure_submit($form, &$form_state) {
* Menu callback: display the custom block addition form.
*/
function block_add_block_form($form, &$form_state) {
return block_admin_configure($form, $form_state, 'block', NULL);
$block = new stdClass;
$block->module = 'block';
$block->delta = NULL;
return block_admin_configure($form, $form_state, $block);
}
function block_add_block_form_validate($form, &$form_state) {
......@@ -508,10 +509,10 @@ function block_add_block_form_submit($form, &$form_state) {
/**
* Menu callback; confirm deletion of custom blocks.
*/
function block_custom_block_delete($form, &$form_state, $bid = 0) {
$custom_block = block_custom_block_get($bid);
function block_custom_block_delete($form, &$form_state, $block) {
$custom_block = block_custom_block_get($block->delta);
$form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']);
$form['bid'] = array('#type' => 'hidden', '#value' => $bid);
$form['bid'] = array('#type' => 'hidden', '#value' => $block->delta);
return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $custom_block['info'])), 'admin/structure/block', '', t('Delete'), t('Cancel'));
}
......
......@@ -95,18 +95,20 @@ function block_menu() {
'type' => MENU_CALLBACK,
'file' => 'block.admin.inc',
);
$items['admin/structure/block/configure'] = array(
$items['admin/structure/block/manage/%block/%/configure'] = array(
'title' => 'Configure block',
'page callback' => 'drupal_get_form',
'page arguments' => array('block_admin_configure'),
'page arguments' => array('block_admin_configure', 4),
'load arguments' => array(5),
'access arguments' => array('administer blocks'),
'type' => MENU_CALLBACK,
'file' => 'block.admin.inc',
);
$items['admin/structure/block/delete'] = array(
$items['admin/structure/block/manage/%block/%/delete'] = array(
'title' => 'Delete block',
'page callback' => 'drupal_get_form',
'page arguments' => array('block_custom_block_delete'),
'page arguments' => array('block_custom_block_delete', 4),
'load arguments' => array(5),
'access arguments' => array('administer blocks'),
'type' => MENU_CALLBACK,
'file' => 'block.admin.inc',
......@@ -586,6 +588,36 @@ function block_list($region) {
return $blocks[$region];
}
/**
* Load a block object from the database.
*
* @param $module
* Name of the module that implements the block to load.
* @param $delta
* Unique ID of the block within the context of $module.
*
* @return
* A block object.
*/
function block_load($module, $delta) {
$block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta',
array(
':module' => $module,
':delta' => $delta
))
->fetchObject();
// If the block does not exist in the database yet return a stub block
// object.
if (!$block) {
$block = new stdClass;
$block->module = $module;
$block->delta = $delta;
}
return $block;
}
/**
* Load blocks information from the database.
*/
......
......@@ -58,10 +58,14 @@ class BlockTestCase extends DrupalWebTestCase {
$this->moveBlockToRegion($custom_block, $region);
}
// Delete the created custom block & verify that it's been deleted and no longer appearing on the page.
// Verify presence of configure and delete links for custom block.
$this->drupalGet('admin/structure/block');
$this->assertRaw(l(t('configure'), 'admin/structure/block/manage/block/' . $bid . '/configure'), t('Custom block configure link found.'));
$this->assertRaw(l(t('delete'), 'admin/structure/block/manage/block/' . $bid . '/delete'), t('Custom block delete link found.'));
// Delete the created custom block & verify that it's been deleted and no longer appearing on the page.
$this->clickLink(t('delete'));
$this->drupalPost('admin/structure/block/delete/' . $bid, array(), t('Delete'));
$this->drupalPost('admin/structure/block/manage/block/' . $bid . '/delete', array(), t('Delete'));
$this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), t('Custom block successfully deleted.'));
$this->assertNoText(t($custom_block['title']), t('Custom block no longer appears on page.'));
}
......@@ -92,9 +96,9 @@ class BlockTestCase extends DrupalWebTestCase {
// but can still submit the form without errors.
$block_admin = $this->drupalCreateUser(array('administer blocks'));
$this->drupalLogin($block_admin);
$this->drupalGet('admin/structure/block/configure/block/' . $bid);
$this->drupalGet('admin/structure/block/manage/block/' . $bid . '/configure');
$this->assertNoText(t('Block body'));
$this->drupalPost('admin/structure/block/configure/block/' . $bid, array(), t('Save block'));
$this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', array(), t('Save block'));
$this->assertNoText(t('Please ensure that each block description is unique.'));
// Confirm that the custom block is still being displayed using configured text format.
......@@ -128,7 +132,7 @@ class BlockTestCase extends DrupalWebTestCase {
$edit = array();
$edit['pages'] = 'user*';
$edit['roles[2]'] = TRUE;
$this->drupalPost('admin/structure/block/configure/' . $block['module'] . '/' . $block['delta'], $edit, t('Save block'));
$this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
// Move block to the first sidebar.
$this->moveBlockToRegion($block, $this->regions[1]);
......@@ -156,7 +160,7 @@ class BlockTestCase extends DrupalWebTestCase {
$block['title'] = $this->randomName(8);
// Set block title to confirm that interface works and override any custom titles.
$this->drupalPost('admin/structure/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => $block['title']), t('Save block'));
$this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => $block['title']), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block title set.'));
$bid = db_query("SELECT bid FROM {block} WHERE module = :module AND delta = :delta", array(
':module' => $block['module'],
......@@ -190,7 +194,7 @@ class BlockTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to first sidebar region.'));
$this->drupalPost('admin/structure/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => 'Navigation'), t('Save block'));
$this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => 'Navigation'), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block title set.'));
}
......
......@@ -215,7 +215,7 @@ class BookBlockTestCase extends DrupalWebTestCase {
function testBookNavigationBlock() {
// Set block title to confirm that the interface is availble.
$this->drupalPost('admin/structure/block/configure/book/navigation', array('title' => $this->randomName(8)), t('Save block'));
$this->drupalPost('admin/structure/block/manage/book/navigation/configure', array('title' => $this->randomName(8)), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the block to a region to confirm block is availble.
......
......@@ -777,7 +777,7 @@ class CommentBlockFunctionalTest extends CommentHelperCase {
'title' => $this->randomName(),
'comment_block_count' => 2,
);
$this->drupalPost('admin/structure/block/configure/comment/recent', $block, t('Save block'));
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
// Add some test comments, one without a subject.
......@@ -806,7 +806,7 @@ class CommentBlockFunctionalTest extends CommentHelperCase {
$block = array(
'comment_block_count' => 10,
);
$this->drupalPost('admin/structure/block/configure/comment/recent', $block, t('Save block'));
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
// Post an additional comment.
......
......@@ -81,7 +81,7 @@ function locale_help($path, $arg) {
return '<p>' . t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (<em>.po</em>) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (<em>.pot</em>) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') . '</p>';
case 'admin/config/regional/translate/translate':
return '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings found within a specific text group or in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
case 'admin/structure/block/configure':
case 'admin/structure/block/manage':
if ($arg[4] == 'locale' && $arg[5] == 0) {
return '<p>' . t('This block is only shown if <a href="@languages">at least two languages are enabled</a> and <a href="@configuration">language negotiation</a> is set to something other than <em>None</em>.', array('@languages' => url('admin/config/regional/language'), '@configuration' => url('admin/config/regional/language/configure'))) . '</p>';
}
......
......@@ -490,7 +490,7 @@ class NodeBlockTestCase extends DrupalWebTestCase {
function testSearchFormBlock() {
// Set block title to confirm that the interface is availble.
$this->drupalPost('admin/structure/block/configure/node/syndicate', array('title' => $this->randomName(8)), t('Save block'));
$this->drupalPost('admin/structure/block/manage/node/syndicate/configure', array('title' => $this->randomName(8)), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the block to a region to confirm block is availble.
......
......@@ -260,7 +260,7 @@ class PollBlockTestCase extends PollTestCase {
function testRecentBlock() {
// Set block title to confirm that the interface is available.
$this->drupalPost('admin/structure/block/configure/poll/recent', array('title' => $this->randomName(8)), t('Save block'));
$this->drupalPost('admin/structure/block/manage/poll/recent/configure', array('title' => $this->randomName(8)), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the block to a region to confirm block is available.
......
......@@ -314,7 +314,7 @@ class ProfileBlockTestCase extends DrupalWebTestCase {
function testAuthorInformationBlock() {
// Set block title to confirm that the interface is availble.
$this->drupalPost('admin/structure/block/configure/profile/author-information', array('title' => $this->randomName(8)), t('Save block'));
$this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array('title' => $this->randomName(8)), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the block to a region to confirm block is availble.
......
......@@ -404,7 +404,7 @@ class SearchBlockTestCase extends DrupalWebTestCase {
function testSearchFormBlock() {
// Set block title to confirm that the interface is availble.
$this->drupalPost('admin/structure/block/configure/search/form', array('title' => $this->randomName(8)), t('Save block'));
$this->drupalPost('admin/structure/block/manage/search/form/configure', array('title' => $this->randomName(8)), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the block to a region to confirm block is availble.
......@@ -434,7 +434,7 @@ class SearchBlockTestCase extends DrupalWebTestCase {
// Test a search from the block when it doesn't appear on the search page.
$edit = array('pages' => 'search');
$this->drupalPost('admin/structure/block/configure/search/form', $edit, t('Save block'));
$this->drupalPost('admin/structure/block/manage/search/form/configure', $edit, t('Save block'));
$this->drupalPost('node', $terms, t('Search'));
$this->assertText('Your search yielded no results');
}
......
......@@ -2223,7 +2223,7 @@ function system_update_7021() {
'cache' => -1,
));
}
drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
}
$insert->execute();
......@@ -2246,7 +2246,7 @@ function system_update_7021() {
'cache' => -1,
));
}
drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
$insert->execute();
}
......@@ -2269,7 +2269,7 @@ function system_update_7021() {
'cache' => -1,
));
}
drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
$insert->execute();
// Migrate mission to RSS site description.
variable_set('feed_description', $mission);
......@@ -2295,7 +2295,7 @@ function system_update_7021() {
'cache' => -1,
));
}
drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/configure/block/' . $bid) . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
$insert->execute();
}
......
......@@ -123,7 +123,7 @@ function system_help($path, $arg) {
return $output;
case 'admin/config/modules/uninstall':
return '<p>' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main <a href="@modules">modules page</a>. Not all modules support this feature.', array('@modules' => url('admin/config/modules'))) . '</p>';
case 'admin/structure/block/configure':
case 'admin/structure/block/manage':
if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
return '<p>' . t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '</p>';
}
......
......@@ -972,7 +972,7 @@ class SystemBlockTestCase extends DrupalWebTestCase {
*/
function testPoweredByBlock() {
// Set block title and some settings to confirm that the interface is availble.
$this->drupalPost('admin/structure/block/configure/system/powered-by', array('title' => $this->randomName(8), 'color' => 'powered-black', 'size' => '135x42'), t('Save block'));
$this->drupalPost('admin/structure/block/manage/system/powered-by/configure', array('title' => $this->randomName(8), 'color' => 'powered-black', 'size' => '135x42'), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
// Set the powered-by block to the footer region.
......@@ -997,7 +997,7 @@ class SystemBlockTestCase extends DrupalWebTestCase {
$edit = array();
$edit['system_powered-by[region]'] = 'footer';
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this->drupalPost('admin/structure/block/configure/system/powered-by', array('title' => '', 'color' => 'powered-blue', 'size' => '80x15'), t('Save block'));
$this->drupalPost('admin/structure/block/manage/system/powered-by/configure', array('title' => '', 'color' => 'powered-blue', 'size' => '80x15'), t('Save block'));
}
}
......
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