Commit 94c3dcee authored by Dries's avatar Dries

- Patch #240873 by Gábor Hojtsy: move custom help settings to blocks. Very exciting.

parent 1ed25923
......@@ -1237,17 +1237,6 @@ function theme_breadcrumb($breadcrumb) {
}
}
/**
* Return a themed help message.
*
* @return a string containing the helptext for the current page.
*/
function theme_help() {
if ($help = menu_get_active_help()) {
return '<div class="help">' . $help . '</div>';
}
}
/**
* Return a themed submenu, typically displayed under the tabs.
*
......@@ -1859,7 +1848,6 @@ function template_preprocess_page(&$variables) {
$variables['feed_icons'] = drupal_get_feeds();
$variables['footer_message'] = filter_xss_admin(variable_get('site_footer', FALSE));
$variables['head'] = drupal_get_html_head();
$variables['help'] = theme('help');
$variables['language'] = $GLOBALS['language'];
$variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
$variables['logo'] = theme_get_setting('logo');
......
......@@ -164,11 +164,6 @@ function contact_admin_delete_submit($form, &$form_state) {
}
function contact_admin_settings() {
$form['contact_form_information'] = array('#type' => 'textarea',
'#title' => t('Additional information'),
'#default_value' => t('You can leave a message using the contact form below.'),
'#description' => t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))),
);
$form['contact_hourly_threshold'] = array('#type' => 'select',
'#title' => t('Hourly threshold'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
......
......@@ -47,9 +47,6 @@ function contact_mail_page() {
}
$form['#token'] = $user->uid ? $user->name . $user->mail : '';
$form['contact_information'] = array(
'#markup' => filter_xss_admin(variable_get('contact_form_information', t('You can leave a message using the contact form below.'))),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
......
......@@ -27,8 +27,6 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
// Set settings.
$edit = array();
$contact_form_information = $this->randomName(100);
$edit['contact_form_information'] = $contact_form_information;
$edit['contact_hourly_threshold'] = 3;
$edit['contact_default_status'] = TRUE;
$this->drupalPost('admin/build/contact/settings', $edit, t('Save configuration'));
......@@ -82,7 +80,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->setPermission('anonymous user', array('access site-wide contact form' => TRUE));
$this->drupalLogout();
$this->drupalGet('contact');
$this->assertText($contact_form_information, t('Contact form is shown when there is one category.'));
$this->assertText(t('Contact'), t('Contact form is shown when there is one category.'));
$this->assertNoText(t('Category'), t('When there is only one category, the category selection element is hidden.'));
$this->drupalLogin($admin_user);
......@@ -113,9 +111,6 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->drupalGet('contact');
$this->assertResponse(200, t('Access granted to anonymous user with permission.'));
// Check that "Additional information" is displayed on the page.
$this->assertText($edit['contact_form_information'], t('Contact information displayed.'));
// Submit contact form with invalid values.
$this->submitContact('', $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64));
$this->assertText(t('Your name field is required.'), t('Name required.'));
......
......@@ -3254,6 +3254,50 @@ function system_update_7020() {
return $ret;
}
/**
* Add help block to the help region, migrate custom variables to blocks.
*/
function system_update_7021() {
$ret = array();
// Collect a list of themes with blocks.
$themes_with_blocks = array();
$result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
foreach ($result as $theme) {
$themes_with_blocks[] = $theme->name;
// Add new system generated help block.
$ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'help', '". $theme->name ."', 1, 0, 'help', '', 1)");
}
// Migrate contact form information and user register help to blocks.
$bid_max = db_query("SELECT MAX(bid) FROM {box}")->fetchField();
if ($contact_help = variable_get('contact_form_information', '')) {
db_insert('box')->fields(array('body' => $contact_help, 'info' => 'Contact page help', 'format' => FILTER_FORMAT_DEFAULT))->execute();
foreach ($themes_with_blocks as $theme) {
// Add contact help block for themes, which had blocks.
$ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 1) ."', '". $theme ."', 1, 5, 'help', 1, 'contact', -1)");
}
drupal_set_message('The contact form information setting was migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 1)) . '">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.');
}
if ($user_help = variable_get('user_registration_help', '')) {
db_insert('box')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => FILTER_FORMAT_DEFAULT))->execute();
foreach ($themes_with_blocks as $theme) {
// Add user registration help block for themes, which had blocks.
$ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 2) ."', '". $theme ."', 1, 5, 'help', 1, 'user/register', -1)");
}
drupal_set_message('The user registration guidelines were migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 2)) . '">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.');
}
// Remove the two variables (even if they were saved empty on the admin interface),
// to avoid keeping clutter in the variables table.
variable_del('contact_form_information');
variable_del('user_registration_help');
// Rebuild theme data, so the new 'help' region is identified.
system_theme_data();
return $ret;
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......
......@@ -895,6 +895,10 @@ function system_block_list() {
// Not worth caching.
'cache' => BLOCK_NO_CACHE,
);
$blocks['help'] = array(
'info' => t('System help'),
'weight' => '5',
);
// System-defined menu blocks.
foreach (menu_list_system_menus() as $menu_name => $title) {
$blocks[$menu_name]['info'] = t($title);
......@@ -960,6 +964,13 @@ function system_block_view($delta = '') {
$block['subject'] = NULL;
$block['content'] = theme('system_powered_by', $image_path);
return $block;
case 'help':
return array(
// Don't display a title.
'subject' => NULL,
'content' => menu_get_active_help(),
);
break;
default:
// All system menu blocks.
$system_menus = menu_list_system_menus();
......@@ -1121,6 +1132,7 @@ function system_theme_default() {
'content' => 'Content',
'header' => 'Header',
'footer' => 'Footer',
'help' => 'Help',
),
'description' => '',
'features' => array(
......
......@@ -242,7 +242,6 @@ function user_admin_settings() {
$form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'));
$form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
$form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.'));
$form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t('This text is displayed at the top of the user registration form and is useful for helping or instructing your users.'));
// Account cancellation settings.
module_load_include('inc', 'user', 'user.pages');
......
......@@ -2850,11 +2850,6 @@ function user_register() {
$form = array();
// Display the registration form.
if (!$admin) {
$form['user_registration_help'] = array('#markup' => filter_xss_admin(variable_get('user_registration_help', '')));
}
// Merge in the default user edit fields.
$form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));
if ($admin) {
......
......@@ -91,11 +91,64 @@ function default_profile_task_list() {
*/
function default_profile_tasks(&$task, $url) {
// Enable 4 standard blocks.
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1);
// Enable 5 standard blocks.
$values = array(
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'navigation',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'management',
'theme' => 'garland',
'status' => 1,
'weight' => 1,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'powered-by',
'theme' => 'garland',
'status' => 1,
'weight' => 10,
'region' => 'footer',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1
),
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
$query->values($record);
}
$query->execute();
// Insert default user-defined node types into the database. For a complete
// list of available node type attributes, refer to the node type API
......
......@@ -42,10 +42,54 @@ function expert_profile_task_list() {
* Perform any final installation tasks for this profile.
*/
function expert_profile_tasks(&$task, $url) {
// Enable 3 standard blocks.
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
// Enable 4 standard blocks.
$values = array(
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'navigation',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'management',
'theme' => 'garland',
'status' => 1,
'weight' => 1,
'region' => 'left',
'pages' => '',
'cache' => -1
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1
),
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
$query->values($record);
}
$query->execute();
}
/**
......
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