* Menu callback; Provide the administration overview page.
*/
function system_main_admin_page($arg = NULL) {
// If we received an argument, they probably meant some other page.
// Let's 404 them since the menu system cannot be told we do not
// accept arguments.
if (isset($arg) && substr($arg, 0, 3) != 'by-') {
return drupal_not_found();
}
// Check for status report errors.
if (system_status(TRUE) && user_access('administer site configuration')) {
drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
}
$blocks = array();
if ($admin = db_fetch_array(db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin' AND module = 'system'"))) {
$result = db_query("
SELECT m.*, ml.*
FROM {menu_links} ml
INNER JOIN {menu_router} m ON ml.router_path = m.path
WHERE ml.link_path != 'admin/help' AND menu_name = '%s' AND ml.plid = %d AND hidden = 0", $admin);
while ($item = db_fetch_array($result)) {
_menu_link_translate($item);
if (!$item['access']) {
continue;
}
// The link 'description' either derived from the hook_menu 'description'
// or entered by the user via menu module is saved as the title attribute.
if (!empty($item['localized_options']['attributes']['title'])) {
'#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
drupal_set_message(t('Please note that the <a href="!admin_theme_page">administration theme</a> is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
$form['engine_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-engine-specific settings'), '#description' => t('These settings only exist for all the templates and styles based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)));
$form['theme_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-specific settings'), '#description' => t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $themes[$key]->info['name'])));
$items[] = format_plural(count($missing_dependencies), 'You must enable the @dependencies module to install @module.', 'You must enable the @dependencies modules to install @module.', $t_argument);
// Synchronize to catch any actions that were added or removed.
actions_synchronize();
return;
}
/**
* Generate a list of dependencies for modules that are going to be switched on.
*
* @param $modules
* The list of modules to check.
* @param $form_values
* Submitted form values used to determine what modules have been enabled.
* @return
* An array of dependencies.
*/
function system_module_build_dependencies($modules, $form_values) {
static $dependencies;
if (!isset($dependencies) && isset($form_values)) {
$dependencies = array();
foreach ($modules as $name => $module) {
// If the module is disabled, will be switched on and it has dependencies.
if (!$module->status && $form_values['status'][$name] && isset($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependency) {
if (!$form_values['status'][$dependency] && isset($modules[$dependency])) {
if (!isset($dependencies[$name])) {
$dependencies[$name] = array();
}
$dependencies[$name][] = $dependency;
}
}
}
}
}
return $dependencies;
}
/**
* Uninstall functions
*/
/**
* Builds a form of currently disabled modules.
*
* @ingroup forms
* @see system_modules_uninstall_validate()
* @see system_modules_uninstall_submit()
* @param $form_state['values']
* Submitted form values.
* @return
* A form array representing the currently disabled modules.
*/
function system_modules_uninstall($form_state = NULL) {
// Make sure the install API is available.
include_once './includes/install.inc';
// Display the confirm form if any modules have been submitted.
if (isset($form_state) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
return $confirm_form;
}
$form = array();
// Pull all disabled modules from the system table.
$disabled_modules = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > %d ORDER BY name", SCHEMA_UNINSTALLED);
while ($module = db_fetch_object($disabled_modules)) {
// Grab the module info
$info = unserialize($module->info);
// Load the .install file, and check for an uninstall hook.
// If the hook exists, the module can be uninstalled.
// Display a confirm form if modules have been selected.
if (isset($uninstall)) {
$form['#confirmed'] = TRUE;
$form['uninstall']['#tree'] = TRUE;
$form['modules'] = array('#value' => '<p>'. t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') .'</p>'. theme('item_list', $uninstall));
$form = confirm_form(
$form,
t('Confirm uninstall'),
'admin/build/modules/uninstall',
t('Would you like to continue with uninstalling the above?'),
t('Uninstall'),
t('Cancel'));
return $form;
}
}
/**
* Validates the submitted uninstall form.
*/
function system_modules_uninstall_validate($form, &$form_state) {
// Form submitted, but no modules selected.
if (!count(array_filter($form_state['values']['uninstall']))) {
'#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
$item['link_path'] = $normal_path;
}
if (!empty($item) && !menu_valid_path($item)) {
form_set_error('site_frontpage', t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $item['link_path'])));
}
}
/**
* Form builder; Configure error reporting settings.
'#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
'#description' => t('Specify where Drupal, PHP and SQL errors are logged. While it is recommended that a site running in a production environment write errors to the log only, in a development or testing environment it may be helpful to write errors both to the log and to the screen.')
);
return system_settings_form($form);
}
/**
* Menu callback; Menu page for the various logging options.
*/
function system_logging_overview() {
$item = menu_get_item('admin/settings/logging');
$content = system_admin_menu_block($item);
$output = theme('admin_block_content', $content);
return $output;
}
/**
* Form builder; Configure site performance settings.
*
* @ingroup forms
* @see system_settings_form()
*/
function system_performance_settings() {
$description = '<p>'. t("The normal cache mode is suitable for most sites and does not cause any side effects. The aggressive cache mode causes Drupal to skip the loading (boot) and unloading (exit) of enabled modules when serving a cached page. This results in an additional performance boost but can cause unwanted side effects.") .'</p>';
$description .= '<p>'. t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and will not function properly: %modules</strong>', array('%modules' => implode(', ', $problem_modules))) .'.</p>';
}
else {
$description .= '<p>'. t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') .'</p>';
}
$form['page_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Page cache'),
'#description' => t('Enabling the page cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time it is viewed.'),
'#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended for production sites, no side effects)'), CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)')),
'#description' => t('On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
'#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression."),
);
$form['block_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Block cache'),
'#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on each page load. If the page cache is also enabled, performance increases from enabling the block cache will mainly benefit authenticated users.'),
'#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
);
$form['bandwidth_optimizations'] = array(
'#type' => 'fieldset',
'#title' => t('Bandwidth optimizations'),
'#description' => t('<p>Drupal can automatically optimize external resources like CSS and JavaScript, which can reduce both the size and number of requests made to your website. CSS files can be aggregated and compressed into a single file, while JavaScript files are aggregated (but not compressed). These optional optimizations may reduce server load, bandwidth requirements, and page loading times.</p><p>These options are disabled if you have not set up your files directory, or if your download method is set to private.</p>')
'#description' => t('This option can interfere with module development and should only be enabled in a production environment.'),
);
$form['clear_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Clear cached data'),
'#description' => t('Caching data improves performance, but may cause problems while troubleshooting new modules, themes, or translations, if outdated information has been cached. To refresh all cached data on your site, click the button below. <em>Warning: high-traffic sites will experience performance slowdowns while cached data is rebuilt.</em>'),
);
$form['clear_cache']['clear'] = array(
'#type' => 'submit',
'#value' => t('Clear cached data'),
'#submit' => array('system_clear_cache_submit'),
);
$form['#submit'][] = 'drupal_clear_css_cache';
$form['#submit'][] = 'drupal_clear_js_cache';
return system_settings_form($form);
}
/**
* Submit callback; clear system caches.
*
* @ingroup forms
*/
function system_clear_cache_submit(&$form_state, $form) {
drupal_flush_all_caches();
drupal_set_message('Caches cleared.');
}
/**
* Form builder; Configure the site file handling.
*
* @ingroup forms
* @see system_settings_form()
*/
function system_file_system_settings() {
$form['file_directory_path'] = array(
'#type' => 'textfield',
'#title' => t('File system path'),
'#default_value' => file_directory_path(),
'#maxlength' => 255,
'#description' => t('A file system path where the files will be stored. This directory must exist and be writable by Drupal. If the download method is set to public, this directory must be relative to the Drupal installation directory and be accessible over the web. If the download method is set to private, this directory should not be accessible over the web. Changing this location will modify all download paths and may cause unexpected problems on an existing site.'),
'#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
'#description' => t('Choose the <em>Public download</em> method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.')
);
return system_settings_form($form);
}
/**
* Form builder; Configure site image toolkit usage.
'#description' => t('A user-defined short date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_short_custom))),
'#description' => t('A user-defined medium date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_medium_custom))),
'#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_long_custom))),
);
$form = system_settings_form($form);
// We will call system_settings_form_submit() manually, so remove it for now.
unset($form['#submit']);
return $form;
}
/**
* Process system_date_time_settings form submissions.
*/
function system_date_time_settings_submit($form, &$form_state) {
if ($form_state['values']['date_format_short'] == 'custom') {
'#description' => t('When set to "Online", all visitors will be able to browse your site normally. When set to "Off-line", only users with the "administer site configuration" permission will be able to access your site to perform maintenance; all other visitors will see the site off-line message configured below. Authorized users can log in during "Off-line" mode directly via the <a href="@user-login">user login</a> page.', array('@user-login' => url('user'))),
);
$form['site_offline_message'] = array(
'#type' => 'textarea',
'#title' => t('Site off-line message'),
'#default_value' => variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
'#description' => t('Message to show visitors when the site is in off-line mode.')
);
return system_settings_form($form);
}
/**
* Form builder; Configure Clean URL settings.
*
* @ingroup forms
* @see system_settings_form()
*/
function system_clean_url_settings() {
$form['clean_url'] = array(
'#type' => 'radios',
'#title' => t('Clean URLs'),
'#default_value' => variable_get('clean_url', 0),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
$form['clean_url']['#description'] .= ' <span>'. t('Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information.', array('@handbook' => 'http://drupal.org/node/15365')) .'</span>';
$output .= '<p>'. t('The MySQL query cache can improve performance of your site by storing the result of queries. Then, if an identical query is received later, the MySQL server retrieves the result from the query cache rather than parsing and executing the statement again.') .'</p>';
$output .= _system_sql($data, array(
'Qcache_queries_in_cache' => t('The number of queries in the query cache.'),
'Qcache_hits' => t('The number of times MySQL found previous results in the cache.'),
'Qcache_inserts' => t('The number of times MySQL added a query to the cache (misses).'),
'Qcache_lowmem_prunes' => t('The number of times MySQL had to remove queries from the cache because it ran out of memory. Ideally should be zero.')
));
return $output;
}
/**
* Default page callback for batches.
*/
function system_batch_page() {
require_once './includes/batch.inc';
$output = _batch_page();
if ($output === FALSE) {
drupal_access_denied();
}
elseif (isset($output)) {
// Force a page without blocks or messages to
// display a list of collected messages later.
print theme('page', $output, FALSE, FALSE);
}
}
/**
* This function formats an administrative block for display.
*
* @param $block
* An array containing information about the block. It should
* include a 'title', a 'description' and a formatted 'content'.
* @ingroup themeable
*/
function theme_admin_block($block) {
// Don't display the block if it has no content to display.
if (empty($block['content'])) {
return '';
}
$output = <<< EOT
<div class="admin-panel">
<h3>
$block[title]
</h3>
<div class="body">
<p class="description">
$block[description]
</p>
$block[content]
</div>
</div>
EOT;
return $output;
}
/**
* This function formats the content of an administrative block.
*
* @param $block
* An array containing information about the block. It should
* include a 'title', a 'description' and a formatted 'content'.
if (isset($form['status']['#incompatible_modules_core'][$key])) {
unset($form['status'][$key]);
$status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
$description .= '<div class="incompatible">'. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'</div>';
$description .= '<div class="incompatible">'. t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) .'</div>';
* An associative array containing the structure of the form.
* @ingroup themeable
*/
function theme_system_themes_form($form) {
foreach (element_children($form) as $key) {
// Only look for themes
if (!isset($form[$key]['info'])) {
continue;
}
// Fetch info
$info = $form[$key]['info']['#value'];
// Localize theme description.
$description = t($info['description']);
// Make sure it is compatible and render the checkbox if so.
if (isset($form['status']['#incompatible_themes_core'][$key])) {
unset($form['status'][$key]);
$status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
$description .= '<div class="incompatible">'. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'</div>';
$description .= '<div class="incompatible">'. t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) .'</div>';