2001-06-23 11:09:40 +00:00
<?php
2001-10-20 18:57:09 +00:00
// $Id$
2001-06-23 11:09:40 +00:00
2004-08-21 06:42:38 +00:00
/**
* @file
* Configuration system that lets administrators modify the workings of the site.
*/
2007-01-15 12:03:50 +00:00
define('VERSION', '6.0-dev');
2006-06-05 08:53:05 +00:00
2007-03-26 06:26:45 +00:00
define('DRUPAL_MINIMUM_PHP', '4.3.3');
define('DRUPAL_MINIMUM_MYSQL', '4.1.0'); // If using MySQL
define('DRUPAL_MINIMUM_PGSQL', '7.4'); // If using PostgreSQL
define('DRUPAL_MINIMUM_APACHE', '1.3'); // If using Apache
2004-06-18 15:04:37 +00:00
/**
* Implementation of hook_help().
*/
function system_help($section) {
2006-04-23 06:07:59 +00:00
global $base_url;
2003-08-21 18:13:28 +00:00
switch ($section) {
2005-11-01 10:17:34 +00:00
case 'admin/help#system':
2007-02-27 12:29:22 +00:00
$output = '<p>'. t('The system module provides system-wide defaults such as running jobs at a particular time, and storing web pages to improve efficiency. The ability to run scheduled jobs makes administering the website more usable, as administrators do not have to manually start jobs. The storing of web pages, or caching, allows the site to efficiently re-use web pages and improve website performance. The settings module provides control over preferences, behaviours including visual and operational settings.') .'</p>';
2006-08-09 07:42:55 +00:00
$output .= '<p>'. t('Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). The aggregator module periodically updates feeds using cron. Ping periodically notifies services of new content on your site. Search periodically indexes the content on your site. Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution. Cron can, if necessary, also be run manually.') .'</p>';
2006-11-24 10:18:24 +00:00
$output .= '<p>'. t("There is a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, the system module does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by <em>anonymous</em> users are cached. In order to reduce server load and save bandwidth, the system module stores and sends cached pages compressed.") .'</p>';
2006-08-18 12:17:00 +00:00
$output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@system">System page</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
2005-11-01 10:17:34 +00:00
return $output;
2005-01-14 15:21:39 +00:00
case 'admin':
2006-11-26 23:10:29 +00:00
return '<p>'. t('Welcome to the administration section. Here you may control how your site functions.') .'</p>';
2006-10-03 20:38:07 +00:00
case 'admin/by-module':
2006-11-26 23:10:29 +00:00
return '<p>'. t('This page shows you all available administration tasks for each module.') .'</p>';
2006-07-31 11:25:55 +00:00
case 'admin/build/themes':
2006-11-26 23:10:29 +00:00
return '<p>'. t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternately, to override these settings in a specific theme, click the "configure" link for the corresponding theme. Note that different themes may have different regions available for rendering content like blocks. If you want consistency in what your users see, you may wish to enable only one theme.') .'</p>';
2006-07-31 11:25:55 +00:00
case 'admin/build/themes/settings':
2006-11-26 23:10:29 +00:00
return '<p>'. t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') .'</p>';
2007-02-15 07:31:59 +00:00
case 'admin/build/themes/settings/'. arg(4):
$reference = explode('.', arg(4), 2);
2005-09-08 19:46:05 +00:00
$theme = array_pop($reference);
2006-11-26 23:10:29 +00:00
return '<p>'. t('These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.', array('%template' => $theme, '@global' => url('admin/build/themes/settings'))) .'</p>';
2006-10-03 20:38:07 +00:00
case 'admin/build/modules':
2006-10-24 15:56:22 +00:00
return t('<p>Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new <a href="@permissions">permissions</a> might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by enabling the throttle.module and checking throttle. The auto-throttle functionality must be enabled on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p>
2006-11-13 20:26:00 +00:00
<p>It is important that <a href="@update-php">update.php</a> is run every time a module is updated to a newer version.</p><p>You can find all administration tasks belonging to a particular module on the <a href="@by-module">administration by module page</a>.</p>', array('@permissions' => url('admin/user/access'), '@throttle' => url('admin/settings/throttle'), '@update-php' => $base_url .'/update.php', '@by-module' => url('admin/by-module')));
2006-10-24 15:56:22 +00:00
case 'admin/build/modules/uninstall':
2006-11-26 23:10:29 +00:00
return '<p>'. t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it. Not all modules support this feature.') .'</p>';
2006-09-01 08:44:53 +00:00
case 'admin/logs/status':
2006-11-26 23:10:29 +00:00
return '<p>'. t("Here you can find a short overview of your Drupal site's parameters as well as any problems detected with your installation. It is useful to copy/paste this information when you need support.") .'</p>';
2003-08-21 18:13:28 +00:00
}
2002-02-07 19:59:37 +00:00
}
2007-04-06 13:27:23 +00:00
function system_theme() {
return array_merge(drupal_common_themes(), array(
'system_theme_select_form' => array(
'arguments' => array('form' => NULL),
),
'system_themes_form' => array(
'arguments' => array('form' => NULL),
),
'system_modules' => array(
'arguments' => array('form' => NULL),
),
'system_modules_uninstall' => array(
'arguments' => array('form' => NULL),
),
'status_report' => array(
'arguments' => array('requirements' => NULL),
),
'admin_page' => array(
'arguments' => array('blocks' => NULL),
),
'admin_block' => array(
'arguments' => array('block' => NULL),
),
'admin_block_content' => array(
'arguments' => array('content' => NULL),
),
'system_admin_by_module' => array(
'arguments' => array('menu_items' => NULL),
),
));
}
2004-06-18 15:04:37 +00:00
/**
* Implementation of hook_perm().
*/
2001-06-23 11:09:40 +00:00
function system_perm() {
2005-11-30 11:09:38 +00:00
return array('administer site configuration', 'access administration pages', 'select different theme');
2001-06-29 22:08:57 +00:00
}
2005-10-07 06:11:12 +00:00
/**
* Implementation of hook_elements().
*/
function system_elements() {
// Top level form
2006-03-28 01:45:41 +00:00
$type['form'] = array('#method' => 'post', '#action' => request_uri());
2005-10-07 06:11:12 +00:00
// Inputs
2005-10-11 19:44:35 +00:00
$type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
2006-04-25 20:46:57 +00:00
$type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
$type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
2005-11-12 11:26:16 +00:00
$type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
2007-01-31 15:49:26 +00:00
$type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
2007-05-14 13:43:38 +00:00
$type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm'));
2007-01-31 15:49:26 +00:00
$type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE);
2007-05-14 13:43:38 +00:00
$type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios'));
2007-01-31 15:49:26 +00:00
$type['radio'] = array('#input' => TRUE, '#default_value' => NULL);
2007-05-14 13:43:38 +00:00
$type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE);
2007-01-31 15:49:26 +00:00
$type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE);
2007-05-14 13:43:38 +00:00
$type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight'));
$type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#element_validate' => array('date_validate'));
2005-10-11 19:44:35 +00:00
$type['file'] = array('#input' => TRUE, '#size' => 60);
2005-10-07 06:11:12 +00:00
// Form structure
2007-01-31 15:49:26 +00:00
$type['item'] = array('#value' => '');
2005-10-11 19:44:35 +00:00
$type['hidden'] = array('#input' => TRUE);
$type['value'] = array('#input' => TRUE);
$type['markup'] = array('#prefix' => '', '#suffix' => '');
2007-01-31 15:49:26 +00:00
$type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL);
2007-01-24 07:51:53 +00:00
$type['token'] = array('#input' => TRUE);
2005-10-07 06:11:12 +00:00
return $type;
}
2004-04-21 13:56:38 +00:00
/**
2004-06-18 15:04:37 +00:00
* Implementation of hook_menu().
2004-04-21 13:56:38 +00:00
*/
2007-01-24 14:48:36 +00:00
function system_menu() {
$items['system/files'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'File download',
2007-01-24 14:48:36 +00:00
'page callback' => 'file_download',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['admin'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Administer',
2007-01-24 14:48:36 +00:00
'access arguments' => array('access administration pages'),
'page callback' => 'system_main_admin_page',
'weight' => 9,
2007-05-22 05:52:17 +00:00
'file' => 'system.admin.inc',
2007-01-24 14:48:36 +00:00
);
$items['admin/compact'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Compact mode',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_admin_compact_page',
'type' => MENU_CALLBACK,
);
$items['admin/by-task'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'By task',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_main_admin_page',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/by-module'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'By module',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_admin_by_module',
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
// menu items that are basically just menu blocks
$items['admin/settings'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Site configuration',
'description' => 'Adjust basic site configuration options.',
2007-01-24 14:48:36 +00:00
'position' => 'right',
'weight' => -5,
'page callback' => 'system_settings_overview',
'access arguments' => array('administer site configuration'),
);
$items['admin/build'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Site building',
'description' => 'Control how your site looks and feels.',
2007-01-24 14:48:36 +00:00
'position' => 'right',
'weight' => -10,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer site configuration'),
2007-05-22 05:52:17 +00:00
'file' => 'system.admin.inc',
2007-01-24 14:48:36 +00:00
);
$items['admin/settings/admin'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Administration theme',
'description' => 'Settings for how your administrative pages should look.',
2007-01-24 14:48:36 +00:00
'position' => 'left',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_admin_theme_settings'),
'block callback' => 'system_admin_theme_settings',
);
// Themes:
$items['admin/build/themes'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Themes',
'description' => 'Change which theme your site uses or allows users to set.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
2007-04-06 13:27:23 +00:00
'page arguments' => array('system_themes_form'),
2007-01-24 14:48:36 +00:00
);
$items['admin/build/themes/select'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'List',
'description' => 'Select the default theme.',
2007-01-24 14:48:36 +00:00
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
$items['admin/build/themes/settings'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Configure',
2007-01-24 14:48:36 +00:00
'page arguments' => array('system_theme_settings'),
'type' => MENU_LOCAL_TASK,
);
// Theme configuration subtabs
$items['admin/build/themes/settings/global'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Global settings',
2007-01-24 14:48:36 +00:00
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
2004-09-16 07:17:56 +00:00
2007-01-24 14:48:36 +00:00
foreach (list_themes() as $theme) {
if ($theme->status) {
$items['admin/build/themes/settings/'. $theme->name] = array(
2007-04-17 07:19:39 +00:00
'title' => $theme->info['name'],
2007-01-24 14:48:36 +00:00
'page arguments' => array('system_theme_settings', $theme->name),
'type' => MENU_LOCAL_TASK,
);
2004-09-16 07:17:56 +00:00
}
2001-06-29 22:08:57 +00:00
}
2006-08-14 07:17:37 +00:00
2007-01-24 14:48:36 +00:00
// Modules:
$items['admin/build/modules'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Modules',
'description' => 'Enable or disable add-on modules for your site.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_modules'),
);
$items['admin/build/modules/list'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'List',
2007-01-24 14:48:36 +00:00
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/build/modules/list/confirm'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'List',
2007-01-24 14:48:36 +00:00
'type' => MENU_CALLBACK,
);
$items['admin/build/modules/uninstall'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Uninstall',
2007-01-24 14:48:36 +00:00
'page arguments' => array('system_modules_uninstall'),
'type' => MENU_LOCAL_TASK,
);
$items['admin/build/modules/uninstall/confirm'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Uninstall',
2007-01-24 14:48:36 +00:00
'type' => MENU_CALLBACK,
);
2004-06-18 15:04:37 +00:00
2007-01-24 14:48:36 +00:00
// Settings:
$items['admin/settings/site-information'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Site information',
'description' => 'Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_site_information_settings'),
);
$items['admin/settings/error-reporting'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Error reporting',
'description' => 'Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_error_reporting_settings'),
);
2007-04-10 10:10:27 +00:00
$items['admin/settings/logging'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Logging and alerts',
'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destination, such as syslog, database, email, ...etc.",
2007-04-10 10:10:27 +00:00
'page callback' => 'system_logging_overview',
);
2007-01-24 14:48:36 +00:00
$items['admin/settings/performance'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Performance',
'description' => 'Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_performance_settings'),
);
$items['admin/settings/file-system'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'File system',
'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_file_system_settings'),
);
$items['admin/settings/image-toolkit'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Image toolkit',
'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_image_toolkit_settings'),
);
$items['admin/content/rss-publishing'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'RSS publishing',
'description' => 'Configure the number of items per feed and whether feeds should be titles/teasers/full-text.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_rss_feeds_settings'),
);
$items['admin/settings/date-time'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Date and time',
'description' => "Settings for how Drupal displays date and time, as well as the system's default timezone.",
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_date_time_settings'),
);
2007-05-14 16:22:26 +00:00
$items['admin/settings/date-time/lookup'] = array(
'title' => t('Date and time lookup'),
'type' => MENU_CALLBACK,
'page callback' => 'system_date_time_lookup',
);
2007-01-24 14:48:36 +00:00
$items['admin/settings/site-maintenance'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Site maintenance',
'description' => 'Take the site off-line for maintenance or bring it back online.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_site_maintenance_settings'),
);
$items['admin/settings/clean-urls'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Clean URLs',
'description' => 'Enable or disable clean URLs for your site.',
2007-01-24 14:48:36 +00:00
'page callback' => 'drupal_get_form',
'page arguments' => array('system_clean_url_settings'),
);
// Logs:
$items['admin/logs'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Logs',
'description' => 'View system logs and other status information.',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_admin_menu_block_page',
'weight' => 5,
'position' => 'left',
2007-05-22 05:52:17 +00:00
'file' => 'system.admin.inc',
2007-01-24 14:48:36 +00:00
);
$items['admin/logs/status'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Status report',
'description' => "Get a status report about your site's operation and any detected problems.",
2007-01-24 14:48:36 +00:00
'page callback' => 'system_status',
'weight' => 10,
'access arguments' => array('administer site configuration'),
);
$items['admin/logs/status/run-cron'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'Run cron',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_run_cron',
'type' => MENU_CALLBACK,
);
$items['admin/logs/status/php'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'PHP',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_php',
'type' => MENU_CALLBACK,
);
$items['admin/logs/status/sql'] = array(
2007-04-30 17:03:29 +00:00
'title' => 'SQL',
2007-01-24 14:48:36 +00:00
'page callback' => 'system_sql',
'type' => MENU_CALLBACK,
);
2007-05-04 09:41:37 +00:00
// Default page for batch operations
$items['batch'] = array(
'page callback' => 'system_batch_page',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
2004-06-18 15:04:37 +00:00
return $items;
2001-06-23 11:09:40 +00:00
}
2007-01-24 14:48:36 +00:00
function system_init() {
// Use the administrative theme if the user is looking at a page in the admin/* path.
if (arg(0) == 'admin') {
global $custom_theme;
$custom_theme = variable_get('admin_theme', '0');
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
}
// Add the CSS for this module.
drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
}
2004-06-18 15:04:37 +00:00
/**
* Implementation of hook_user().
*
* Allows users to individually set their theme and time zone.
*/
2004-06-27 19:10:52 +00:00
function system_user($type, $edit, &$user, $category = NULL) {
2006-04-17 20:48:26 +00:00
if ($type == 'form' && $category == 'account') {
2007-01-31 15:49:26 +00:00
$form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), isset($edit['theme']) ? $edit['theme'] : NULL, 2);
2006-04-17 20:48:26 +00:00
2004-07-09 00:25:10 +00:00
if (variable_get('configurable_timezones', 1)) {
2004-07-22 02:13:13 +00:00
$zones = _system_zonelist();
2007-01-11 03:32:56 +00:00
$form['timezone'] = array(
2007-04-13 08:56:59 +00:00
'#type' => 'fieldset',
2007-01-11 03:32:56 +00:00
'#title' => t('Locale settings'),
'#weight' => 6,
'#collapsible' => TRUE,
);
2006-01-17 17:35:47 +00:00
$form['timezone']['timezone'] = array(
2007-01-11 03:32:56 +00:00
'#type' => 'select',
'#title' => t('Time zone'),
'#default_value' => strlen($edit['timezone']) ? $edit['timezone'] : variable_get('date_default_timezone', 0),
'#options' => $zones,
'#description' => t('Select your current local time. Dates and times throughout this site will be displayed using this time zone.'),
2005-10-07 06:11:12 +00:00
);
2003-10-30 19:16:44 +00:00
}
2006-04-17 20:48:26 +00:00
2005-10-07 06:11:12 +00:00
return $form;
2004-02-07 16:59:34 +00:00
}
2003-09-30 21:48:32 +00:00
}
2006-07-31 11:25:55 +00:00
/**
* Provide a single block on the administration overview page.
*/
2007-03-12 13:01:10 +00:00
function system_admin_menu_block($item) {
2006-07-31 11:25:55 +00:00
$content = array();
2007-05-16 13:45:17 +00:00
if (!isset($item->mlid)) {
$item->mlid = db_result(db_query("SELECT mlid FROM {menu_links} ml WHERE ml.router_path = '%s' AND menu_name = 'navigation'", $item->path));
}
$result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path
WHERE ml.plid = '%s' AND ml.menu_name = 'navigation' ORDER BY m.weight, m.title", $item->mlid);
2007-03-12 13:01:10 +00:00
while ($item = db_fetch_object($result)) {
2007-05-16 13:45:17 +00:00
_menu_link_translate($item);
2007-03-12 13:01:10 +00:00
if (!$item->access) {
continue;
2006-07-31 11:25:55 +00:00
}
2007-03-12 13:01:10 +00:00
$content[] = (array)$item;
2006-07-31 11:25:55 +00:00
}
return $content;
}
function system_admin_compact_page($mode = 'off') {
global $user;
user_save($user, array('admin_compact_mode' => ($mode == 'on')));
drupal_goto('admin');
}
2006-08-07 19:35:41 +00:00
2006-07-31 11:25:55 +00:00
/**
2006-08-07 19:35:41 +00:00
* This function allows selection of the theme to show in administration sections.
2006-07-31 11:25:55 +00:00
*/
2006-08-07 19:35:41 +00:00
function system_admin_theme_settings() {
2006-07-31 11:25:55 +00:00
$themes = system_theme_data();
ksort($themes);
$options[0] = t('System default');
foreach ($themes as $theme) {
2007-04-17 07:19:39 +00:00
$options[$theme->name] = $theme->info['name'];
2006-07-31 11:25:55 +00:00
}
$form['admin_theme'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('Administration theme'),
2006-11-24 10:18:24 +00:00
'#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.'),
2006-10-03 23:18:18 +00:00
'#default_value' => variable_get('admin_theme', '0'),
2006-07-31 11:25:55 +00:00
);
2007-05-14 13:43:38 +00:00
$form['#submit'][] = 'system_admin_theme_submit';
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-31 11:25:55 +00:00
}
2007-05-14 13:43:38 +00:00
function system_admin_theme_submit($form_values, $form, &$form_state) {
2006-07-31 11:25:55 +00:00
// If we're changing themes, make sure the theme has its blocks initialized.
2006-10-03 23:18:18 +00:00
if ($form_values['admin_theme'] != variable_get('admin_theme', '0')) {
2006-07-31 11:25:55 +00:00
$result = db_query("SELECT status FROM {blocks} WHERE theme = '%s'", $form_values['admin_theme']);
if (!db_num_rows($result)) {
system_initialize_theme_blocks($form_values['admin_theme']);
}
}
}
2006-04-14 20:30:08 +00:00
/*
* Returns a fieldset containing the theme select form.
*
* @param $description
* description of the fieldset
* @param $default_value
* default value of theme radios
* @param $weight
* weight of the fieldset
* @return
* a form array
*/
function system_theme_select_form($description = '', $default_value = '', $weight = 0) {
if (user_access('select different theme')) {
2007-03-27 05:13:55 +00:00
$enabled = array();
2007-05-06 05:47:52 +00:00
$themes = list_themes();
foreach ($themes as $theme) {
2006-04-14 20:30:08 +00:00
if ($theme->status) {
$enabled[] = $theme;
}
}
if (count($enabled) > 1) {
ksort($enabled);
$form['themes'] = array(
2006-04-17 20:48:26 +00:00
'#type' => 'fieldset',
'#title' => t('Theme configuration'),
'#description' => $description,
'#collapsible' => TRUE,
2006-04-14 20:30:08 +00:00
'#theme' => 'system_theme_select_form'
);
foreach ($enabled as $info) {
// For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
2006-11-08 19:24:11 +00:00
$info->key = $info->name == variable_get('theme_default', 'garland') ? '' : $info->name;
2006-04-14 20:30:08 +00:00
2007-05-06 05:47:52 +00:00
$screenshot = NULL;
$theme_key = $info->name;
while ($theme_key) {
if (file_exists($themes[$theme_key]->info['screenshot'])) {
$screenshot = $themes[$theme_key]->info['screenshot'];
break;
}
$theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
}
$screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
2006-04-14 20:30:08 +00:00
2006-10-26 05:31:14 +00:00
$form['themes'][$info->key]['screenshot'] = array('#value' => $screenshot);
2006-11-26 02:20:01 +00:00
$form['themes'][$info->key]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'garland') ? '<br /> <em>'. t('(site default theme)') .'</em>' : ''));
2006-04-14 20:30:08 +00:00
$options[$info->key] = '';
}
$form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $default_value ? $default_value : '');
$form['#weight'] = $weight;
return $form;
}
}
}
function theme_system_theme_select_form($form) {
2005-10-11 19:44:35 +00:00
foreach (element_children($form) as $key) {
$row = array();
2007-01-31 15:49:26 +00:00
if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
2006-08-10 15:42:33 +00:00
$row[] = drupal_render($form[$key]['screenshot']);
$row[] = drupal_render($form[$key]['description']);
$row[] = drupal_render($form['theme'][$key]);
2005-10-11 19:44:35 +00:00
}
$rows[] = $row;
}
2005-10-22 14:17:11 +00:00
$header = array(t('Screenshot'), t('Name'), t('Selected'));
2005-10-11 19:44:35 +00:00
$output = theme('table', $header, $rows);
return $output;
}
2004-07-22 02:13:13 +00:00
function _system_zonelist() {
$timestamp = time();
$zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
$zones = array();
foreach ($zonelist as $offset) {
$zone = $offset * 3600;
2007-01-24 07:51:53 +00:00
$zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') .' O', $zone);
2004-07-22 02:13:13 +00:00
}
return $zones;
}
2006-07-10 19:27:52 +00:00
function system_site_information_settings() {
$form['site_name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
2006-10-22 08:28:47 +00:00
'#default_value' => variable_get('site_name', 'Drupal'),
2007-02-27 12:29:22 +00:00
'#description' => t('The name of this website.'),
2006-07-10 19:27:52 +00:00
'#required' => TRUE
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_mail'] = array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
2007-04-24 19:49:01 +00:00
'#description' => t('A valid e-mail address to be used as the "From" address by the auto-mailer during registration, new password requests, notifications, etc. To lessen the likelihood of e-mail being marked as spam, this e-mail address should use the same domain as the website.'),
'#required' => TRUE,
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_slogan'] = array(
'#type' => 'textfield',
'#title' => t('Slogan'),
'#default_value' => variable_get('site_slogan', ''),
2005-11-12 11:26:16 +00:00
'#description' => t('The slogan of this website. Some themes display a slogan when available.')
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_mission'] = array(
'#type' => 'textarea',
'#title' => t('Mission'),
'#default_value' => variable_get('site_mission', ''),
2005-11-12 11:26:16 +00:00
'#description' => t('Your site\'s mission statement or focus.')
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_footer'] = array(
'#type' => 'textarea',
'#title' => t('Footer message'),
'#default_value' => variable_get('site_footer', ''),
2006-05-07 00:08:36 +00:00
'#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['anonymous'] = array(
'#type' => 'textfield',
'#title' => t('Anonymous user'),
2006-11-24 09:01:57 +00:00
'#default_value' => variable_get('anonymous', t('Anonymous')),
2005-10-11 19:44:35 +00:00
'#description' => t('The name used to indicate anonymous users.')
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_frontpage'] = array(
'#type' => 'textfield',
'#title' => t('Default front page'),
'#default_value' => variable_get('site_frontpage', 'node'),
2006-09-07 08:03:08 +00:00
'#size' => 40,
'#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),
2007-02-15 11:40:19 +00:00
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
2005-10-07 06:11:12 +00:00
);
2004-11-02 12:47:10 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
function system_clean_url_settings() {
$form['clean_url'] = array(
2006-05-01 09:30:13 +00:00
'#type' => 'radios',
'#title' => t('Clean URLs'),
'#default_value' => variable_get('clean_url', 0),
'#options' => array(t('Disabled'), t('Enabled')),
2007-02-13 07:33:33 +00:00
'#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
2006-05-01 09:30:13 +00:00
);
2005-10-07 06:11:12 +00:00
2006-05-01 08:45:29 +00:00
if (!variable_get('clean_url', 0)) {
if (strpos(request_uri(), '?q=') !== FALSE) {
2007-02-13 07:33:33 +00:00
drupal_add_js(array('cleanURL' => array('success' => t('Your server has been successfully tested to support this feature.'), 'failure' => t('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => t('Testing clean URLs...'))), 'setting');
drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
$(document).ready(function() {
Drupal.cleanURLsSettingsCheck();
});
}', 'inline');
$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>';
2006-08-27 12:54:01 +00:00
$form['clean_url']['#disabled'] = TRUE;
2007-02-13 07:33:33 +00:00
$form['clean_url']['#prefix'] = '<div id="clean-url">';
$form['clean_url']['#suffix'] = '<p>'. t('<a href="@clean_url">Run the clean url test</a>.', array('@clean_url' => base_path() .'admin/settings/clean-urls')) .'</p></div>';
2006-05-01 08:45:29 +00:00
}
else {
2007-02-13 07:33:33 +00:00
$form['clean_url']['#description'] .= ' '. t('Your server has been successfully tested to support this feature.');
2006-05-01 08:45:29 +00:00
}
}
2004-10-04 22:04:07 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
function system_error_reporting_settings() {
2006-09-01 06:24:10 +00:00
$form['site_403'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'textfield',
2006-09-01 06:24:10 +00:00
'#title' => t('Default 403 (access denied) page'),
2006-07-10 19:27:52 +00:00
'#default_value' => variable_get('site_403', ''),
2006-09-07 08:03:08 +00:00
'#size' => 40,
'#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
2007-02-15 11:40:19 +00:00
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
2005-10-07 06:11:12 +00:00
);
2006-09-01 06:24:10 +00:00
$form['site_404'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'textfield',
2006-09-01 06:24:10 +00:00
'#title' => t('Default 404 (not found) page'),
2006-07-10 19:27:52 +00:00
'#default_value' => variable_get('site_404', ''),
2006-09-07 08:03:08 +00:00
'#size' => 40,
'#description' => t('This page is displayed when no other content matches the requested document. If unsure, specify nothing.'),
2007-02-15 11:40:19 +00:00
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
2005-10-07 06:11:12 +00:00
);
2006-09-01 06:24:10 +00:00
$form['error_level'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
'#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
2006-09-01 06:24:10 +00:00
'#description' => t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.')
2005-10-07 06:11:12 +00:00
);
2006-09-01 06:24:10 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
2001-06-23 11:09:40 +00:00
2006-12-10 09:54:35 +00:00
function system_performance_settings() {
2005-10-07 06:11:12 +00:00
2006-08-31 18:40:04 +00:00
$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 (init) 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>';
$problem_modules = array_unique(array_merge(module_implements('init'), module_implements('exit')));
sort($problem_modules);
if (count($problem_modules) > 0) {
2006-11-24 10:18:24 +00:00
$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>';
2006-08-31 18:40:04 +00:00
}
else {
2006-11-24 10:18:24 +00:00
$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>';
2006-08-31 18:40:04 +00:00
}
2006-12-10 09:54:35 +00:00
$form['page_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Page cache'),
'#description' => t('Enabling the 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 someone wants to view it.'),
);
2006-12-10 20:34:03 +00:00
2006-12-10 09:54:35 +00:00
$form['page_cache']['cache'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'radios',
2006-08-31 18:40:04 +00:00
'#title' => t('Caching mode'),
2006-07-10 19:27:52 +00:00
'#default_value' => variable_get('cache', CACHE_DISABLED),
2006-08-31 18:40:04 +00:00
'#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended, no side effects)'), CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)')),
'#description' => $description
2005-10-07 06:11:12 +00:00
);
2005-08-22 05:09:01 +00:00
$period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
$period[0] = t('none');
2006-12-10 09:54:35 +00:00
$form['page_cache']['cache_lifetime'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'select',
'#title' => t('Minimum cache lifetime'),
'#default_value' => variable_get('cache_lifetime', 0),
'#options' => $period,
2006-08-31 18:40:04 +00:00
'#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
2005-10-07 06:11:12 +00:00
);
2006-12-10 20:34:03 +00:00
2006-12-10 09:54:35 +00:00
$form['bandwidth_optimizations'] = array(
'#type' => 'fieldset',
'#title' => t('Bandwidth optimizations'),
'#description' => t('These options can help reduce both the size and number of requests made to your website. This can reduce the server load, the bandwidth used, and the average page loading time for your visitors.')
);
2006-12-10 20:34:03 +00:00
2006-12-10 09:54:35 +00:00
$directory = file_directory_path();
2006-12-10 20:34:03 +00:00
$is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
2006-12-10 09:54:35 +00:00
$form['bandwidth_optimizations']['preprocess_css'] = array(
'#type' => 'radios',
'#title' => t('Aggregate and compress CSS files'),
'#default_value' => variable_get('preprocess_css', FALSE) && $is_writable,
'#disabled' => !$is_writable,
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t("Some Drupal modules include their own CSS files. When these modules are enabled, each module's CSS file adds an additional HTTP request to the page, which can increase the load time of each page. These HTTP requests can also slightly increase server load. It is recommended to only turn this option on when your site is in production, as it can interfere with theme development. This option is disabled if you have not set up your files directory, or if your download method is set to private."),
);
2007-05-25 15:04:42 +00:00
$form['reverse_proxy'] = array(
'#type' => 'fieldset',
'#title' => t('Reverse proxy'),
'#description' => t('Proper extraction of client IP addresses when Drupal is behind a reverse proxy.'),
);
$form['reverse_proxy']['reverse_proxy'] = array(
'#type' => 'radios',
'#title' => t('Reverse proxy'),
'#default_value' => variable_get('reverse_proxy', FALSE),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t('Enable this setting to determine the correct IP address of the remote client by examining information stored in the X-Forwarded-For headers. X-Forwarded-For headers are a standard mechanism for identifying client systems connecting through a reverse proxy server, such as Squid or Pound. Reverse proxy servers are often used to enhance the performance of heavily visited sites and may also provide other site caching, security or encryption benefits. If this Drupal installation operates behind a reverse proxy, this setting should be enabled so that correct IP address information is captured in Drupal\'s session management, logging, statistics and access management systems; if you are unsure about this setting, do not have a reverse proxy, or Drupal operates in a shared hosting environment, this setting should be set to disabled.'),
);
2007-05-14 13:43:38 +00:00
$form['#submit'][] = 'drupal_clear_css_cache';
2003-11-18 19:44:36 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
2001-06-30 20:23:33 +00:00
2006-07-10 19:27:52 +00:00
function system_file_system_settings() {
2005-10-07 06:11:12 +00:00
2006-07-10 19:27:52 +00:00
$form['file_directory_path'] = array(
2005-11-13 07:57:11 +00:00
'#type' => 'textfield',
'#title' => t('File system path'),
'#default_value' => file_directory_path(),
'#maxlength' => 255,
2006-09-01 07:32:58 +00:00
'#description' => t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to the Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'),
2006-04-20 07:11:37 +00:00
'#after_build' => array('system_check_directory'),
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['file_directory_temp'] = array(
2005-11-13 07:57:11 +00:00
'#type' => 'textfield',
'#title' => t('Temporary directory'),
'#default_value' => file_directory_temp(),
'#maxlength' => 255,
'#description' => t('Location where uploaded files will be kept during previews. Relative paths will be resolved relative to the Drupal installation directory.'),
2006-04-20 07:11:37 +00:00
'#after_build' => array('system_check_directory'),
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['file_downloads'] = array(
'#type' => 'radios',
'#title' => t('Download method'),
'#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC),
2006-09-01 07:32:58 +00:00
'#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
2005-10-11 19:44:35 +00:00
'#description' => t('If you want any sort of access control on the downloading of files, this needs to be set to <em>private</em>. You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.')
2005-10-07 06:11:12 +00:00
);
2003-04-15 19:10:02 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
function system_image_toolkit_settings() {
2005-02-01 16:27:43 +00:00
$toolkits_available = image_get_available_toolkits();
if (count($toolkits_available) > 1) {
2006-07-10 19:27:52 +00:00
$form['image_toolkit'] = array(
'#type' => 'radios',
'#title' => t('Select an image processing toolkit'),
'#default_value' => variable_get('image_toolkit', image_get_toolkit()),
'#options' => $toolkits_available
2005-10-07 06:11:12 +00:00
);
2005-02-01 16:27:43 +00:00
}
2006-07-10 19:27:52 +00:00
else {
2006-12-26 14:01:41 +00:00
$form['image_toolkit'] = array('#value' => '<p>'. t("No image toolkits found. Drupal will use PHP's built-in GD library for image handling.") .'</p>');
2006-07-10 19:27:52 +00:00
}
2006-12-26 14:01:41 +00:00
$form['image_toolkit_settings'] = image_toolkit_invoke('settings');
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
function system_rss_feeds_settings() {
2005-02-01 16:27:43 +00:00
2006-07-10 19:27:52 +00:00
$form['feed_default_items'] = array(
'#type' => 'select',
'#title' => t('Number of items per feed'),
'#default_value' => variable_get('feed_default_items', 10),
2005-10-11 19:44:35 +00:00
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
'#description' => t('The default number of items to include in a feed.')
2005-10-07 06:11:12 +00:00
);
2006-07-10 19:27:52 +00:00
$form['feed_item_length'] = array(
'#type' => 'select',
'#title' => t('Display of XML feed items'),
2007-01-24 07:51:53 +00:00
'#default_value' => variable_get('feed_item_length', 'teaser'),
2005-10-11 19:44:35 +00:00
'#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
'#description' => t('Global setting for the length of XML feed items that are output by default.')
2005-10-07 06:11:12 +00:00
);
2005-09-18 10:37:57 +00:00
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
function system_date_time_settings() {
2007-05-14 16:22:26 +00:00
drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
drupal_add_js(array('dateTime' => array('lookup' => url('admin/settings/date-time/lookup'))), 'setting');
drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
$(document).ready(Drupal.dateTimeAutoAttach);
}', 'inline');
2005-03-27 23:37:20 +00:00
// Date settings:
2004-07-22 02:13:13 +00:00
$zones = _system_zonelist();
2004-02-08 21:42:59 +00:00
2005-03-27 23:37:20 +00:00
// Date settings: possible date formats
2007-05-14 16:22:26 +00:00
$date_short = array('Y-m-d H:i', 'm/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
2006-04-04 01:40:41 +00:00
'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
2004-06-18 15:04:37 +00:00
'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
2007-05-14 16:22:26 +00:00
$date_medium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
2004-09-22 17:50:55 +00:00
'D, Y/m/d - H:i', 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
2004-06-18 15:04:37 +00:00
'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
2006-04-02 09:19:56 +00:00
'F j, Y - g:ia', 'j F Y - g:ia', 'Y, F j - g:ia', 'j. F Y - G:i');
2007-05-14 16:22:26 +00:00
$date_long = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
2006-04-02 09:19:56 +00:00
'l, F j, Y - g:ia', 'l, j F Y - g:ia', 'l, Y, F j - g:ia', 'l, j. F Y - G:i');
2003-02-09 17:39:40 +00:00
2005-03-27 23:37:20 +00:00
// Date settings: construct choices for user
2007-05-14 16:22:26 +00:00
foreach ($date_short as $f) {
$date_short_choices[$f] = format_date(time(), 'custom', $f);
2003-02-09 17:39:40 +00:00
}
2007-05-14 16:22:26 +00:00
foreach ($date_medium as $f) {
$date_medium_choices[$f] = format_date(time(), 'custom', $f);
2003-02-09 17:39:40 +00:00
}
2007-05-14 16:22:26 +00:00
foreach ($date_long as $f) {
$date_long_choices[$f] = format_date(time(), 'custom', $f);
2003-02-09 17:39:40 +00:00
}
2007-05-14 16:22:26 +00:00
$date_long_choices['custom'] = $date_medium_choices['custom'] = $date_short_choices['custom'] = t('Custom format');
2007-05-17 07:28:42 +00:00
$form['locale'] = array(
'#type' => 'fieldset',
'#title' => t('Locale settings'),
);
$form['locale']['date_default_timezone'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'select',
'#title' => t('Default time zone'),
'#default_value' => variable_get('date_default_timezone', 0),
'#options' => $zones,
'#description' => t('Select the default site time zone.')
2005-10-07 06:11:12 +00:00
);
2007-05-17 07:28:42 +00:00
$form['locale']['configurable_timezones'] = array(
2006-07-10 19:27:52 +00:00
'#type' => 'radios',
2007-05-17 07:28:42 +00:00
'#title' => t('User-configurable time zones'),
2006-07-10 19:27:52 +00:00
'#default_value' => variable_get('configurable_timezones', 1),
'#options' => array(t('Disabled'), t('Enabled')),
2007-05-17 07:28:42 +00:00
'#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.')
);
$form['locale']['date_first_day'] = array(
'#type' => 'select',
'#title' => t('First day of week'),
'#default_value' => variable_get('date_first_day', 0),
'#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
'#description' => t('The first day of the week for calendar views.')
);
$form['date_formats'] = array(
'#type' => 'fieldset',
'#title' => t('Formatting'),
2005-10-07 06:11:12 +00:00
);
2007-05-14 16:22:26 +00:00
$date_format_short = variable_get('date_format_short', $date_short[1]);
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_short'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="date-container"><div>',
'#suffix' => '</div>',
2006-07-10 19:27:52 +00:00
'#type' => 'select',
'#title' => t('Short date format'),
2007-05-14 16:22:26 +00:00
'#attributes' => array('class' => 'date-format'),
'#default_value' => (isset($date_short_choices[$date_format_short]) ? $date_format_short : 'custom'),
'#options' => $date_short_choices,
'#description' => t('The short format of date display.'),
2005-10-07 06:11:12 +00:00
);
2007-05-14 16:22:26 +00:00
$default_short_custom = variable_get('date_format_short_custom', (isset($date_short_choices[$date_format_short]) ? $date_format_short : ''));
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_short_custom'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="custom-container">',
'#suffix' => '</div></div>',
'#type' => 'textfield',
'#title' => t('Custom short date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_short_custom,
'#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))),
);
$date_format_medium = variable_get('date_format_medium', $date_medium[1]);
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_medium'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="date-container"><div>',
'#suffix' => '</div>',
2006-07-10 19:27:52 +00:00
'#type' => 'select',
'#title' => t('Medium date format'),
2007-05-14 16:22:26 +00:00
'#attributes' => array('class' => 'date-format'),
'#default_value' => (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : 'custom'),
'#options' => $date_medium_choices,
'#description' => t('The medium sized date display.'),
);
$default_medium_custom = variable_get('date_format_medium_custom', (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : ''));
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_medium_custom'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="custom-container">',
'#suffix' => '</div></div>',
'#type' => 'textfield',
'#title' => t('Custom medium date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_medium_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))),
2005-10-07 06:11:12 +00:00
);
2007-05-14 16:22:26 +00:00
$date_format_long = variable_get('date_format_long', $date_long[0]);
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_long'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="date-container"><div>',
'#suffix' => '</div>',
2006-07-10 19:27:52 +00:00
'#type' => 'select',
'#title' => t('Long date format'),
2007-05-14 16:22:26 +00:00
'#attributes' => array('class' => 'date-format'),
'#default_value' => (isset($date_long_choices[$date_format_long]) ? $date_format_long : 'custom'),
'#options' => $date_long_choices,
2006-07-10 19:27:52 +00:00
'#description' => t('Longer date format used for detailed display.')
2005-10-07 06:11:12 +00:00
);
2007-05-14 16:22:26 +00:00
$default_long_custom = variable_get('date_format_long_custom', (isset($date_long_choices[$date_format_long]) ? $date_format_long : ''));
2007-05-17 07:28:42 +00:00
$form['date_formats']['date_format_long_custom'] = array(
2007-05-14 16:22:26 +00:00
'#prefix' => '<div class="custom-container">',
'#suffix' => '</div></div>',
'#type' => 'textfield',
'#title' => t('Custom long date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_long_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.
2007-05-17 07:28:42 +00:00
unset($form['#submit']);
2007-05-14 16:22:26 +00:00
return $form;
}
2003-06-04 18:24:39 +00:00
2007-05-17 07:28:42 +00:00
function system_date_time_settings_submit($form_values, $form, &$form_state) {
2007-05-14 16:22:26 +00:00
if ($form_values['date_format_short'] == 'custom') {
$form_values['date_format_short'] = $form_values['date_format_short_custom'];
}
if ($form_values['date_format_medium'] == 'custom') {
$form_values['date_format_medium'] = $form_values['date_format_medium_custom'];
}
if ($form_values['date_format_long'] == 'custom') {
$form_values['date_format_long'] = $form_values['date_format_long_custom'];
}
2007-05-17 07:28:42 +00:00
return system_settings_form_submit($form_values, $form, $form_state);
2007-05-14 16:22:26 +00:00
}
/**
* Return the date for a given format string via Ajax.
*/
function system_date_time_lookup() {
$result = format_date(time(), 'custom', $_GET['format']);
echo drupal_to_js($result);
exit;
2006-07-10 19:27:52 +00:00
}
2001-06-23 11:09:40 +00:00
2006-09-01 08:44:53 +00:00
function system_site_maintenance_settings() {
2005-10-08 12:38:20 +00:00
2006-07-10 19:27:52 +00:00
$form['site_offline'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'radios',
2006-10-14 10:14:06 +00:00
'#title' => t('Site status'),
2005-10-11 19:44:35 +00:00
'#default_value' => variable_get('site_offline', 0),
2006-01-22 07:51:06 +00:00
'#options' => array(t('Online'), t('Off-line')),
2006-08-18 12:17:00 +00:00
'#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'))),
2005-10-08 12:38:20 +00:00
);
2006-07-10 19:27:52 +00:00
$form['site_offline_message'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'textarea',
2006-01-22 07:51:06 +00:00
'#title' => t('Site off-line message'),
2006-11-25 09:04:22 +00:00
'#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')))),
2006-01-22 07:51:06 +00:00
'#description' => t('Message to show visitors when the site is in off-line mode.')
2005-10-08 12:38:20 +00:00
);
2006-08-18 18:58:47 +00:00
return system_settings_form($form);
2006-07-10 19:27:52 +00:00
}
2005-11-13 07:57:11 +00:00
/**
* Checks the existence of the directory specified in $form_element. This
2006-07-10 19:27:52 +00:00
* function is called from the system_settings form to check both the
2005-11-13 07:57:11 +00:00
* file_directory_path and file_directory_temp directories. If validation
* fails, the form element is flagged with an error from within the
* file_check_directory function.
*
* @param $form_element
* The form element containing the name of the directory to check.
*/
2005-11-21 18:10:26 +00:00
function system_check_directory($form_element) {
2005-11-13 07:57:11 +00:00
file_check_directory($form_element['#value'], FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
return $form_element;
}
2004-08-20 07:51:27 +00:00
/**
* Retrieves the current status of an array of files in the system table.
*/
function system_get_files_database(&$files, $type) {
2002-11-08 13:19:12 +00:00
// Extract current files from database.
2006-02-27 14:32:38 +00:00
$result = db_query("SELECT filename, name, type, status, throttle, schema_version FROM {system} WHERE type = '%s'", $type);
2002-11-08 13:19:12 +00:00
while ($file = db_fetch_object($result)) {
2005-05-21 11:33:03 +00:00
if (isset($files[$file->name]) && is_object($files[$file->name])) {
2006-02-27 14:32:38 +00:00
$file->old_filename = $file->filename;
2002-11-08 13:19:12 +00:00
foreach ($file as $key => $value) {
2005-05-21 11:33:03 +00:00
if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) {
2004-11-24 22:44:01 +00:00
$files[$file->name]->$key = $value;
}
2002-11-08 13:19:12 +00:00
}
2002-04-14 19:34:04 +00:00
}
2001-06-23 11:09:40 +00:00
}
2004-08-20 07:51:27 +00:00
}
2001-06-23 11:09:40 +00:00
2007-04-17 07:19:39 +00:00
function system_theme_default() {
// Prepare defaults for themes.
return array(
'regions' => array(
'left' => 'Left sidebar',
'right' => 'Right sidebar',
'content' => 'Content',
'header' => 'Header',
'footer' => 'Footer',
),
'description' => '',
'features' => array(
'comment_user_picture',
'favicon',
'mission',
'logo',
'name',
'node_user_picture',
'search',
'slogan'
),
2007-05-06 05:47:52 +00:00
'stylesheet' => 'style.css',
'screenshot' => 'screenshot.png',
2007-04-17 07:19:39 +00:00
);
}
2004-08-20 07:51:27 +00:00
/**
* Collect data about all currently available themes
*/
2004-11-24 22:44:01 +00:00
function system_theme_data() {
// Find themes
2007-05-06 05:47:52 +00:00
$themes = drupal_system_listing('\.info$', 'themes');
2004-11-24 22:44:01 +00:00
2004-08-20 07:51:27 +00:00
// Find theme engines
2006-10-23 06:45:17 +00:00
$engines = drupal_system_listing('\.engine$', 'themes/engines');
2004-11-24 22:44:01 +00:00
// Remove all theme engines from the system table
db_query("DELETE FROM {system} WHERE type = 'theme_engine'");
2004-08-20 07:51:27 +00:00
foreach ($engines as $engine) {
2004-11-25 06:17:03 +00:00
// Insert theme engine into system table
2004-11-24 22:44:01 +00:00
drupal_get_filename('theme_engine', $engine->name, $engine->filename);
drupal_load('theme_engine', $engine->name);
db_query("INSERT INTO {system} (name, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', %d, %d, %d)", $engine->name, 'theme_engine', $engine->filename, 1, 0, 0);
2007-05-06 05:47:52 +00:00
}
2004-11-24 22:44:01 +00:00
2007-05-06 05:47:52 +00:00
$defaults = system_theme_default();
2005-08-16 18:06:18 +00:00
2007-05-06 05:47:52 +00:00
$sub_themes = array();
// Read info files for each theme
foreach ($themes as $key => $theme) {
$themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
if (!empty($themes[$key]->info['base theme'])) {
$sub_themes[] = $key;
}
if (empty($themes[$key]->info['engine'])) {
$filename = dirname($themes[$key]->filename) .'/'. $themes[$key]->name .'.theme';
if (file_exists($filename)) {
$themes[$key]->owner = $filename;
$themes[$key]->prefix = $key;
2004-11-25 06:17:03 +00:00
}
2004-08-20 07:51:27 +00:00
}
2007-05-06 05:47:52 +00:00
else {
$engine = $themes[$key]->info['engine'];
if (isset($engines[$engine])) {
$themes[$key]->owner = $engines[$engine]->filename;
$themes[$key]->prefix = $engines[$engine]->name;
$themes[$key]->template = TRUE;
}
}
// Give the stylesheet proper path information.
if (!empty($themes[$key]->info['stylesheet'])) {
$themes[$key]->info['stylesheet'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['stylesheet'];
}
// Give the screenshot proper path information.
if (!empty($themes[$key]->info['screenshot'])) {
$themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['screenshot'];
}
2004-08-20 07:51:27 +00:00
}
2007-05-06 05:47:52 +00:00
// Now that we've established all our master themes, go back and fill in
// data for subthemes.
foreach ($sub_themes as $key) {
$base_key = system_find_base_theme($themes, $key);
if (!$base_key) {
continue;
}
// Copy the 'owner' and 'engine' over if the top level theme uses a
// theme engine.
if (isset($themes[$base_key]->owner)) {
if (isset($themes[$base_key]->info['engine'])) {
$themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
$themes[$key]->owner = $themes[$base_key]->owner;
$themes[$key]->prefix = $themes[$base_key]->prefix;
}
else {
$themes[$key]->prefix = $key;
2004-08-20 07:51:27 +00:00
}
}
2003-11-20 22:10:42 +00:00
}
2004-08-20 07:51:27 +00:00
// Extract current files from database.
2004-11-24 22:44:01 +00:00
system_get_files_database($themes, 'theme');
db_query("DELETE FROM {system} WHERE type = 'theme'");
2004-08-20 07:51:27 +00:00
2004-11-24 22:44:01 +00:00
foreach ($themes as $theme) {
2007-05-06 05:47:52 +00:00
if (!isset($theme->owner)) {
$theme->owner = '';
}
2007-04-17 07:19:39 +00:00
db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0);
2004-11-24 22:44:01 +00:00
}
return $themes;
}
2007-05-06 05:47:52 +00:00
/**
* Recursive function to find the top level base theme. Themes can inherit
* templates and function implementations from earlier themes; this function
* finds the top level parent that has no ancestor, or returns NULL if there
* isn't a valid parent.
*/
function system_find_base_theme($themes, $key, $used_keys = array()) {
$base_key = $themes[$key]->info['base theme'];
// Does the base theme exist?
if (!isset($themes[$base_key])) {
return NULL;
}
// Is the base theme itself a child of another theme?
if (isset($themes[$base_key]->info['base theme'])) {
// Prevent loops.
if ($used_keys[$base_key]) {
return NULL;
}
$used_keys[$base_key] = TRUE;
return system_find_base_theme($themes, $base_key, $used_keys);
}
// If we get here, then this is our parent theme.
return $base_key;
}
2005-08-16 18:06:18 +00:00
/**
* Get a list of available regions from a specified theme.
*
2005-08-28 18:17:47 +00:00
* @param $theme_key
2005-08-16 18:06:18 +00:00
* The name of a theme.
* @return
* An array of regions in the form $region['name'] = 'description'.
*/
2005-08-28 18:17:47 +00:00
function system_region_list($theme_key) {
2005-08-16 18:06:18 +00:00
static $list = array();
2005-10-22 15:14:46 +00:00
if (!array_key_exists($theme_key, $list)) {
2007-04-17 07:19:39 +00:00
$info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key)));
$list[$theme_key] = array_map('t', $info['regions']);
2005-08-16 18:06:18 +00:00
}
2005-08-28 18:17:47 +00:00
return $list[$theme_key];
2005-08-16 18:06:18 +00:00
}
/**
* Get the name of the default region for a given theme.
*
* @param $theme
* The name of a theme.
* @return
* A string that is the region name.
*/
function system_default_region($theme) {
$regions = array_keys(system_region_list($theme));
2007-03-27 05:13:55 +00:00
return isset($regions[0]) ? $regions[0] : '';
2005-08-16 18:06:18 +00:00
}
2004-08-20 07:51:27 +00:00
/**
2005-10-07 06:11:12 +00:00
* Assign an initial, default set of blocks for a theme.
*
2006-05-07 00:08:36 +00:00
* This function is called the first time a new theme is enabled. The new theme
2005-10-07 06:11:12 +00:00
* gets a copy of the default theme's blocks, with the difference that if a
* particular region isn't available in the new theme, the block is assigned
* to the new theme's default region.
*
* @param $theme
* The name of a theme.
*/
function system_initialize_theme_blocks($theme) {
// Initialize theme's blocks if none already registered.
if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
2006-11-08 19:24:11 +00:00
$default_theme = variable_get('theme_default', 'garland');
2005-10-07 06:11:12 +00:00
$regions = system_region_list($theme);
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
2007-01-02 05:05:38 +00:00
while ($block = db_fetch_array($result)) {
2005-10-07 06:11:12 +00:00
// If the region isn't supported by the theme, assign the block to the theme's default region.
if (!array_key_exists($block['region'], $regions)) {
$block['region'] = system_default_region($theme);
}
db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)",
$block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
}
}
}
2006-08-18 18:58:47 +00:00
/**
* Add default buttons to a form and set its prefix
*/
function system_settings_form($form) {
2005-10-11 19:44:35 +00:00
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
2005-10-07 06:11:12 +00:00
2005-10-08 12:21:47 +00:00
if (!empty($_POST) && form_get_errors()) {
2005-10-08 12:38:20 +00:00
drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
2005-10-08 12:21:47 +00:00
}
2007-05-14 13:43:38 +00:00
$form['#submit'][] = 'system_settings_form_submit';
$form['#validate'][] = 'system_settings_form_validate';
2007-03-17 18:30:14 +00:00
$form['#theme'] = 'system_settings_form';
2006-08-18 18:58:47 +00:00
return $form;
2005-10-07 06:11:12 +00:00
}
2007-05-14 13:43:38 +00:00
function system_theme_settings_submit($form_values, $form, &$form_state) {
2005-10-26 01:24:09 +00:00
$op = isset($_POST['op']) ? $_POST['op'] : '';
2006-09-08 16:33:02 +00:00
$key = $form_values['var'];
2005-10-26 01:24:09 +00:00
2006-04-25 10:00:57 +00:00
// Exclude unnecessary elements.
2006-09-08 16:33:02 +00:00
unset($form_values['var'], $form_values['submit'], $form_values['reset'], $form_values['form_id']);
2006-04-25 10:00:57 +00:00
2005-10-26 01:24:09 +00:00
if ($op == t('Reset to defaults')) {
variable_del($key);
drupal_set_message(t('The configuration options have been reset to their default values.'));
}
else {
2006-09-08 16:33:02 +00:00
variable_set($key, $form_values);
2005-10-26 01:24:09 +00:00
drupal_set_message(t('The configuration options have been saved.'));
}
2006-11-10 09:22:07 +00:00
cache_clear_all();
2005-10-26 01:24:09 +00:00
}
2005-10-07 06:11:12 +00:00
/**
* Execute the system_settings_form.
*
2005-10-13 10:02:31 +00:00
* If you want node type configure style handling of your checkboxes,
* add an array_filter value to your form.
*
2005-10-07 06:11:12 +00:00
*/
2007-05-14 13:43:38 +00:00
function system_settings_form_submit($form_values, $form, &$form_state) {
2006-09-17 19:14:16 +00:00
$op = isset($form_values['op']) ? $form_values['op'] : '';
2005-10-07 06:11:12 +00:00
2006-04-25 10:00:57 +00:00
// Exclude unnecessary elements.
2006-11-29 23:12:41 +00:00
unset($form_values['submit'], $form_values['reset'], $form_values['form_id'], $form_values['op'], $form_values['form_token']);
2006-04-25 10:00:57 +00:00
2006-09-08 16:33:02 +00:00
foreach ($form_values as $key => $value) {
2005-10-07 06:11:12 +00:00
if ($op == t('Reset to defaults')) {
variable_del($key);
}
else {
2006-09-08 16:33:02 +00:00
if (is_array($value) && isset($form_values['array_filter'])) {
2005-10-07 06:11:12 +00:00
$value = array_keys(array_filter($value));
}
variable_set($key, $value);
}
}
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The configuration options have been reset to their default values.'));
2005-10-22 15:14:46 +00:00
}
else {
2005-10-07 06:11:12 +00:00
drupal_set_message(t('The configuration options have been saved.'));
}
2006-12-10 09:54:35 +00:00
2007-04-06 13:27:23 +00:00
drupal_rebuild_theme_registry();
2005-10-07 06:11:12 +00:00
}
/**
* Menu callback; displays a listing of all themes.
*/
2007-04-06 13:27:23 +00:00
function system_themes_form() {
2006-12-10 09:54:35 +00:00
drupal_clear_css_cache();
2004-11-24 22:44:01 +00:00
$themes = system_theme_data();
2004-08-20 07:51:27 +00:00
ksort($themes);
2007-03-27 05:13:55 +00:00
$status = array();
2004-08-20 07:51:27 +00:00
2007-04-17 07:19:39 +00:00
foreach ($themes as $theme) {
2007-05-06 05:47:52 +00:00
$screenshot = NULL;
$theme_key = $theme->name;
while ($theme_key) {
if (file_exists($themes[$theme_key]->info['screenshot'])) {
$screenshot = $themes[$theme_key]->info['screenshot'];
break;
}
$theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
}
$screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
2007-04-17 07:19:39 +00:00
$form[$theme->name]['screenshot'] = array('#value' => $screenshot);
$form[$theme->name]['info'] = array('#type' => 'value', '#value' => $theme->info);
$options[$theme->name] = '';
if (!empty($theme->status)) {
$status[] = $theme->name;
2005-10-07 06:11:12 +00:00
}
2007-04-17 07:19:39 +00:00
if (!empty($theme->status)) {
$form[$theme->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/'. $theme->name) );
2004-08-20 07:51:27 +00:00
}
else {
2006-08-10 15:42:33 +00:00
// Dummy element for drupal_render. Cleaner than adding a check in the theme function.
2007-04-17 07:19:39 +00:00
$form[$theme->name]['operations'] = array();
2005-10-07 06:11:12 +00:00
}
}
2005-10-11 19:44:35 +00:00
$form['status'] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $status);
2006-11-08 19:24:11 +00:00
$form['theme_default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('theme_default', 'garland'));
2005-10-11 19:44:35 +00:00
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
2005-10-07 06:11:12 +00:00
2006-08-18 18:58:47 +00:00
return $form;
2005-10-07 06:11:12 +00:00
}
2007-04-06 13:27:23 +00:00
function theme_system_themes_form($form) {
2005-10-07 06:11:12 +00:00
foreach (element_children($form) as $key) {
2007-04-17 07:19:39 +00:00
// Only look for themes
if (!isset($form[$key]['info'])) {
continue;
}
// Fetch info
$info = $form[$key]['info']['#value'];
// Style theme info
$theme = '<div class="theme-info"><h2>'. $info['name'] .'</h2><div class="description">'. $info['description'] .'</div></div>';
// Build rows
2005-10-07 06:11:12 +00:00
$row = array();
2007-04-17 07:19:39 +00:00
$row[] = drupal_render($form[$key]['screenshot']);
$row[] = $theme;
2007-04-20 08:44:01 +00:00
$row[] = $info['version'];
2007-04-17 07:19:39 +00:00
$row[] = array('data' => drupal_render($form['status'][$key]), 'align' => 'center');
if ($form['theme_default']) {
$row[] = array('data' => drupal_render($form['theme_default'][$key]), 'align' => 'center');
$row[] = array('data' => drupal_render($form[$key]['operations']), 'align' => 'center');
2004-08-20 07:51:27 +00:00
}
$rows[] = $row;
}
2007-04-20 08:44:01 +00:00
$header = array(t('Screenshot'), t('Name'), t('Version'), t('Enabled'), t('Default'), t('Operations'));
2005-10-07 06:11:12 +00:00
$output = theme('table', $header, $rows);
2006-08-10 15:42:33 +00:00
$output .= drupal_render($form);
2004-08-20 07:51:27 +00:00
return $output;
}
2005-10-07 06:11:12 +00:00
2007-05-14 13:43:38 +00:00
function system_themes_form_submit($form_values, $form, &$form_state) {
2005-10-07 06:11:12 +00:00
2007-05-21 10:56:05 +00:00
// Store list of previously enabled themes and disable all themes
$old_theme_list = $new_theme_list = array();
foreach (list_themes() as $theme) {
if ($theme->status) {
$old_theme_list[] = $theme->name;
}
}
2005-10-07 06:11:12 +00:00
db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
2006-09-17 19:14:16 +00:00
if ($form_values['op'] == t('Save configuration')) {
2006-09-08 16:33:02 +00:00
if (is_array($form_values['status'])) {
foreach ($form_values['status'] as $key => $choice) {
2005-11-14 22:19:14 +00:00
// Always enable the default theme, despite its status checkbox being checked:
2006-09-08 16:33:02 +00:00
if ($choice || $form_values['theme_default'] == $key) {
2006-12-31 13:44:33 +00:00
system_initialize_theme_blocks($key);
2007-05-21 10:56:05 +00:00
$new_theme_list[] = $key;
2005-10-07 06:11:12 +00:00
db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key);
}
}
}
2006-11-10 08:16:51 +00:00
if (($admin_theme = variable_get('admin_theme', '0')) != '0' && $admin_theme != $form_values['theme_default']) {
2006-10-03 23:18:18 +00:00
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(
'!admin_theme_page' => url('admin/settings/admin'),
'%admin_theme' => $admin_theme,
2006-11-10 08:16:51 +00:00
'%selected_theme' => $form_values['theme_default'],
2006-10-03 23:18:18 +00:00
)));
}
2006-09-08 16:33:02 +00:00
variable_set('theme_default', $form_values['theme_default']);
2005-10-07 06:11:12 +00:00
}
else {
2007-05-21 10:56:05 +00:00
// Revert to defaults: only Garland is enabled.
2005-10-07 06:11:12 +00:00
variable_del('theme_default');
2006-11-08 19:24:11 +00:00
db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'");
2007-05-21 10:56:05 +00:00
$new_theme_list = array('garland');
2005-10-07 06:11:12 +00:00
}
2007-04-06 14:31:51 +00:00
list_themes(TRUE);
2005-11-29 02:52:20 +00:00
menu_rebuild();
2005-10-07 06:11:12 +00:00
drupal_set_message(t('The configuration options have been saved.'));
2007-05-14 13:43:38 +00:00
$form_state['redirect'] = 'admin/build/themes';
2007-05-22 05:52:17 +00:00
2007-05-21 10:56:05 +00:00
// Notify locale module about new themes being enabled, so translations can
// be imported. This might start a batch, and only return to the redirect
// path after that.
module_invoke('locale', 'system_update', array_diff($new_theme_list, $old_theme_list));
2007-05-22 05:52:17 +00:00
2007-05-14 13:43:38 +00:00
return;
2005-10-07 06:11:12 +00:00
}
2004-08-20 07:51:27 +00:00
/**
2006-10-02 16:49:08 +00:00
* Menu callback; provides module enable/disable interface.
*
* Modules can be enabled or disabled and set for throttling if the throttle module is enabled.
* The list of modules gets populated by module.info files, which contain each module's name,
* description and dependencies.
2007-04-18 20:42:23 +00:00
* @sa drupal_parse_info_file for information on module.info descriptors.
2006-10-02 16:49:08 +00:00
*
* Dependency checking is performed to ensure that a module cannot be enabled if the module has
* disabled dependencies and also to ensure that the module cannot be disabled if the module has
* enabled dependents.
*
* @return
* The form array.
2004-08-20 07:51:27 +00:00
*/
2007-05-14 13:43:38 +00:00
function system_modules($form_state = array()) {
2006-10-02 16:49:08 +00:00
// Get current list of modules.
2006-08-03 01:02:51 +00:00
$files = module_rebuild_cache();
2007-05-14 13:43:38 +00:00
if (!empty($form_state['storage'])) {
return system_modules_confirm_form($files, $form_state['storage']);
2006-10-02 16:49:08 +00:00
}
2007-05-14 13:43:38 +00:00
$dependencies = array();
2006-10-02 16:49:08 +00:00
// Store module list for validation callback.
$form['validation_modules'] = array('#type' => 'value', '#value' => $files);
2004-08-20 07:51:27 +00:00
2006-10-02 16:49:08 +00:00
// Create storage for disabled modules as browser will disable checkboxes.
$form['disabled_modules'] = array('#type' => 'value', '#value' => array());
// Array for disabling checkboxes in callback system_module_disable.
$disabled = array();
2007-01-31 15:49:26 +00:00
$throttle = array();
2006-10-02 16:49:08 +00:00
// Traverse the files retrieved and build the form.
2002-11-08 13:19:12 +00:00
foreach ($files as $filename => $file) {
2006-10-02 16:49:08 +00:00
$form['name'][$filename] = array('#value' => $file->info['name']);
2006-11-21 20:55:36 +00:00
$form['version'][$filename] = array('#value' => $file->info['version']);
2006-10-02 16:49:08 +00:00
$form['description'][$filename] = array('#value' => t($file->info['description']));
$options[$filename] = '';
2005-10-07 06:11:12 +00:00
if ($file->status) {
$status[] = $file->name;
}
if ($file->throttle) {
$throttle[] = $file->name;
}
2006-10-02 16:49:08 +00:00
$dependencies = array();
// Check for missing dependencies.
if (is_array($file->info['dependencies'])) {
foreach ($file->info['dependencies'] as $dependency) {
if (!isset($files[$dependency]) || !$files[$dependency]->status) {
if (isset($files[$dependency])) {
$dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
}
else {
$dependencies[] = drupal_ucfirst($dependency) . t(' (<span class="admin-missing">missing</span>)');
$disabled[] = $filename;
$form['disabled_modules']['#value'][$filename] = FALSE;
}
}
else {
$dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
}
}
// Add text for dependencies.
if (!empty($dependencies)) {
$form['description'][$filename]['dependencies'] = array(
'#value' => t('Depends on: !dependencies', array('!dependencies' => implode(', ', $dependencies))),
'#prefix' => '<div class="admin-dependencies">',
'#suffix' => '</div>',
);
}
}
// Mark dependents disabled so user can not remove modules being depended on.
$dependents = array();
2007-01-31 15:49:26 +00:00
foreach ($file->info['dependents'] as $dependent) {
if ($files[$dependent]->status == 1) {
$dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
$disabled[] = $filename;
$form['disabled_modules']['#value'][$filename] = TRUE;
}
else {
$dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
2006-10-02 16:49:08 +00:00
}
}
// Add text for enabled dependents.
2007-01-24 07:51:53 +00:00
if (!empty($dependents)) {
2006-10-02 16:49:08 +00:00
$form['description'][$filename]['required'] = array(
'#value' => t('Required by: !required', array('!required' => implode(', ', $dependents))),
'#prefix' => '<div class="admin-required">',
'#suffix' => '</div>',
);
}
2002-04-14 19:34:04 +00:00
}
2002-12-29 16:08:05 +00:00
2007-03-27 05:13:55 +00:00
$modules_required = drupal_required_modules();
2006-10-02 16:49:08 +00:00
// Merge in required modules.
2007-03-27 05:13:55 +00:00
foreach ($modules_required as $required) {
2006-10-02 16:49:08 +00:00
$disabled[] = $required;
$form['disabled_modules']['#value'][$required] = TRUE;
2005-10-07 06:11:12 +00:00
}
2004-11-24 22:44:01 +00:00
2006-10-02 16:49:08 +00:00
// Handle status checkboxes, including overriding
// the generated checkboxes for required modules.
$form['status'] = array(
'#type' => 'checkboxes',
'#default_value' => $status,
'#options' => $options,
'#process' => array(
2007-05-14 13:43:38 +00:00
'expand_checkboxes',
'system_modules_disable',
2006-10-02 16:49:08 +00:00
),
2007-05-14 13:43:38 +00:00
'#disabled_modules' => $disabled,
2006-10-02 16:49:08 +00:00
);
// Handle throttle checkboxes, including overriding the
// generated checkboxes for required modules.
2006-08-20 05:57:41 +00:00
if (module_exists('throttle')) {
2006-10-02 16:49:08 +00:00
$form['throttle'] = array(
'#type' => 'checkboxes',
'#default_value' => $throttle,
'#options' => $options,
'#process' => array(
2007-05-14 13:43:38 +00:00
'expand_checkboxes',
'system_modules_disable',
2006-10-02 16:49:08 +00:00
),
2007-05-14 13:43:38 +00:00
'#disabled_modules' => array_merge($modules_required, array('throttle')),
2006-10-02 16:49:08 +00:00
);
2005-10-07 06:11:12 +00:00
}
2004-01-05 19:19:05 +00:00
2006-10-02 16:49:08 +00:00
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
2006-10-24 15:56:22 +00:00
$form['#action'] = url('admin/build/modules/list/confirm');
2004-01-05 19:19:05 +00:00
2006-08-18 18:58:47 +00:00
return $form;
2004-01-05 19:19:05 +00:00
}
2005-10-07 06:11:12 +00:00
2006-10-02 16:49:08 +00:00
/**
* Form process callback function to disable check boxes.
*/
2007-05-14 13:43:38 +00:00
function system_modules_disable($form, $edit) {
foreach ($form['#disabled_modules'] as $key) {
2006-10-02 16:49:08 +00:00
$form[$key]['#attributes']['disabled'] = 'disabled';
}
return $form;
}
2005-10-07 06:11:12 +00:00
2007-05-21 10:56:05 +00:00
/**
* Display confirmation form for dependencies.
*
* @param $modules
* Array of module file objects as returned from module_rebuild_cache().
* @param $storage
* The contents of $form_state['storage']; an array with two
* elements: the list of dependencies and the list of status
* form field values from the previous screen.
*/
function system_modules_confirm_form($modules, $storage) {
2006-10-02 16:49:08 +00:00
$form = array();
$items = array();
2007-05-21 10:56:05 +00:00
list($dependencies, $status) = $storage;
2007-05-14 13:43:38 +00:00
$form['validation_modules'] = array('#type' => 'value', '#value' => $modules);
$form['status']['#tree'] = TRUE;
2007-05-21 10:56:05 +00:00
// Remember list of modules selected on the module listing page already.
foreach ($status as $key => $choice) {
$form['status'][$key] = array('#type' => 'value', '#value' => $choice);
}
2007-05-14 13:43:38 +00:00
foreach ($dependencies as $name => $missing_dependencies) {
$form['status'][$name] = array('#type' => 'hidden', '#value' => 1);
foreach ($missing_dependencies as $k => $dependency) {
$form['status'][$dependency] = array('#type' => 'hidden', '#value' => 1);
$info = $modules[$dependency]->info;
$missing_dependencies[$k] = $info['name'] ? $info['name'] : drupal_ucfirst($dependency);
2005-08-16 18:06:18 +00:00
}
2007-05-14 13:43:38 +00:00
$t_argument = array(
'@module' => $modules[$name]->info['name'],
'@dependencies' => implode(', ', $missing_dependencies),
);
$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);
2005-10-07 06:11:12 +00:00
}
2007-05-14 13:43:38 +00:00
$form['text'] = array('#value' => theme('item_list', $items));
2004-01-05 19:19:05 +00:00
2006-10-02 16:49:08 +00:00
if ($form) {
// Set some default form values
$form = confirm_form(
$form,
t('Some required modules must be enabled'),
2006-10-03 20:38:07 +00:00
'admin/build/modules',
2006-10-02 16:49:08 +00:00
t('Would you like to continue with enabling the above?'),
t('Continue'),
t('Cancel'));
return $form;
}
2004-01-05 19:19:05 +00:00
}
2006-10-02 16:49:08 +00:00
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;
}
2003-03-04 06:20:18 +00:00
2006-10-02 16:49:08 +00:00
/**
* Submit callback; handles modules form submission.
*/
2007-05-14 13:43:38 +00:00
function system_modules_submit($form_values, $form, &$form_state) {
2006-08-03 01:02:51 +00:00
include_once './includes/install.inc';
2005-12-08 08:40:10 +00:00
$new_modules = array();
2006-09-01 08:44:53 +00:00
2007-05-14 13:43:38 +00:00
// If we are coming from the confirm form...
if (!isset($form_state['storage'])) {
// Merge in disabled active modules since they should be enabled.
// They don't appear because disabled checkboxes are not submitted
// by browsers.
$form_values['status'] = array_merge($form_values['status'], $form_values['disabled_modules']);
// Check values for dependency that we can't install.
if ($dependencies = system_module_build_dependencies($form_values['validation_modules'], $form_values)) {
// These are the modules that depend on existing modules.
foreach (array_keys($dependencies) as $name) {
$form_values['status'][$name] = 0;
}
2006-10-02 16:49:08 +00:00
}
}
2007-05-14 13:43:38 +00:00
else {
$dependencies = NULL;
}
2006-10-02 16:49:08 +00:00
2007-05-21 10:56:05 +00:00
// Update throttle settings, if present
if (isset($form_values['throttle'])) {
foreach ($form_values['throttle'] as $key => $choice) {
db_query("UPDATE {system} SET throttle = %d WHERE type = 'module' and name = '%s'", $choice ? 1 : 0, $key);
}
}
2007-05-16 13:45:17 +00:00
// Temporarily disable menu module while it's broken.
unset($form_values['status']['menu']);
2007-05-21 10:56:05 +00:00
// If there where unmet dependencies and they haven't confirmed don't process
// the submission yet. Store the form submission data needed later.
if ($dependencies) {
if (!isset($form_values['confirm'])) {
$form_state['storage'] = array($dependencies, $form_values['status']);
return;
}
else {
$form_values['status'] = array_merge($form_values['status'], $form_storage[1]);
}
}
// If we have no dependencies, or the dependencies are confirmed
// to be installed, we don't need the temporary storage anymore.
unset($form_state['storage']);
2006-11-16 08:28:08 +00:00
$enable_modules = array();
2006-11-27 23:15:41 +00:00
$disable_modules = array();
2006-09-08 16:33:02 +00:00
foreach ($form_values['status'] as $key => $choice) {
2005-10-07 06:11:12 +00:00
if ($choice) {
2006-08-03 01:02:51 +00:00
if (drupal_get_installed_schema_version($key) == SCHEMA_UNINSTALLED) {
2005-12-08 08:40:10 +00:00
$new_modules[] = $key;
}
2006-08-03 01:02:51 +00:00
else {
2006-11-16 08:28:08 +00:00
$enable_modules[] = $key;
2006-08-03 01:02:51 +00:00
}
2004-01-05 19:19:05 +00:00
}
2006-08-03 01:02:51 +00:00
else {
2006-11-27 23:15:41 +00:00
$disable_modules[] = $key;
2006-08-03 01:02:51 +00:00
}
}
2006-12-31 13:44:33 +00:00
$old_module_list = module_list();
2006-11-16 08:28:08 +00:00
if (!empty($enable_modules)) {
module_enable($enable_modules);
}
2006-11-27 23:15:41 +00:00
if (!empty($disable_modules)) {
module_disable($disable_modules);
}
2006-11-16 08:28:08 +00:00
2006-10-02 16:49:08 +00:00
// Install new modules.
2006-11-16 08:28:08 +00:00
foreach ($new_modules as $key => $module) {
if (!drupal_check_module($module)) {
unset($new_modules[$key]);
2006-09-01 08:44:53 +00:00
}
2004-01-05 19:19:05 +00:00
}
2006-11-16 08:28:08 +00:00
drupal_install_modules($new_modules);
2005-10-07 06:11:12 +00:00
2006-10-02 16:49:08 +00:00
$current_module_list = module_list(TRUE, FALSE);
if ($old_module_list != $current_module_list) {
2007-04-06 13:27:23 +00:00
drupal_rebuild_theme_registry();
2006-10-02 16:49:08 +00:00
node_types_rebuild();
2007-05-16 13:45:17 +00:00
menu_rebuild();
2006-10-02 16:49:08 +00:00
drupal_set_message(t('The configuration options have been saved.'));
}
2006-04-20 16:43:28 +00:00
2006-12-10 09:54:35 +00:00
drupal_clear_css_cache();
2007-05-14 13:43:38 +00:00
$form_state['redirect'] = 'admin/build/modules';
2007-05-21 10:56:05 +00:00
// Notify locale module about module changes, so translations can be
// imported. This might start a batch, and only return to the redirect
// path after that.
module_invoke('locale', 'system_update', $new_modules);
2007-05-14 13:43:38 +00:00
return;
2004-06-18 15:04:37 +00:00
}
2006-10-02 16:49:08 +00:00
/**
* Theme call back for the modules form.
*/
function theme_system_modules($form) {
if (isset($form['confirm'])) {
return drupal_render($form);
}
2006-10-05 15:47:57 +00:00
// Individual table headers.
2006-10-02 16:49:08 +00:00
$header = array(t('Enabled'));
if (module_exists('throttle')) {
$header[] = t('Throttle');
}
$header[] = t('Name');
2006-11-21 20:55:36 +00:00
$header[] = t('Version');
2006-10-02 16:49:08 +00:00
$header[] = t('Description');
2006-10-05 15:47:57 +00:00
// Pull package information from module list and start grouping modules.
$modules = $form['validation_modules']['#value'];
foreach ($modules as $module) {
2006-12-12 09:42:14 +00:00
if (!isset($module->info['package']) || !$module->info['package']) {
2007-02-01 21:43:07 +00:00
$module->info['package'] = t('Other');
2006-10-05 15:47:57 +00:00
}
$packages[$module->info['package']][$module->name] = $module->info;
}
ksort($packages);
// Display packages.
$output = '';
foreach ($packages as $package => $modules) {
$rows = array();
foreach ($modules as $key => $module) {
$row = array();
$row[] = array('data' => drupal_render($form['status'][$key]), 'align' => 'center');
if (module_exists('throttle')) {
$row[] = array('data' => drupal_render($form['throttle'][$key]), 'align' => 'center');
}
$row[] = '<strong>'. drupal_render($form['name'][$key]) .'</strong>';
2006-11-21 20:55:36 +00:00
$row[] = drupal_render($form['version'][$key]);
2006-10-05 15:47:57 +00:00
$row[] = array('data' => drupal_render($form['description'][$key]), 'class' => 'description');
$rows[] = $row;
}
2006-11-13 20:26:00 +00:00
$fieldset = array(
2006-11-12 20:18:57 +00:00
'#title' => t($package),
'#collapsible' => TRUE,
2006-11-13 20:26:00 +00:00
'#collapsed' => ($package == 'Core - required'),
'#value' => theme('table', $header, $rows, array('class' => 'package')),
2006-11-12 20:18:57 +00:00
);
$output .= theme('fieldset', $fieldset);
2006-10-05 15:47:57 +00:00
}
2006-10-02 16:49:08 +00:00
$output .= drupal_render($form);
return $output;
}
2006-10-23 20:59:56 +00:00
/**
* Uninstall functions
*/
/**
* Builds a form of currently disabled modules.
*
* @param
* $form_values Submitted form values.
* @return
* A form array representing the currently disabled modules.
*/
2007-05-14 13:43:38 +00:00
function system_modules_uninstall($form_state = NULL) {
2006-10-23 20:59:56 +00:00
// Make sure the install API is available.
include_once './includes/install.inc';
// Display the confirm form if any modules have been submitted.
2007-05-14 13:43:38 +00:00
if (isset($form_state) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
2006-10-23 20:59:56 +00:00
return $confirm_form;
}
$form = array();
// Pull all disabled modules from the system table.
2007-04-17 07:19:39 +00:00
$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);
2006-10-23 20:59:56 +00:00
while ($module = db_fetch_object($disabled_modules)) {
2007-04-17 07:19:39 +00:00
// Grab the module info
$info = unserialize($module->info);
2006-10-23 20:59:56 +00:00
// Load the .install file, and check for an uninstall hook.
// If the hook exists, the module can be uninstalled.
module_load_install($module->name);
if (module_hook($module->name, 'uninstall')) {
$form['modules'][$module->name]['name'] = array('#value' => $info['name'] ? $info['name'] : $module->name);
$form['modules'][$module->name]['description'] = array('#value' => t($info['description']));
$options[$module->name] = '';
}
}
// Only build the rest of the form if there are any modules available to uninstall.
2007-01-31 15:49:26 +00:00
if (!empty($options)) {
2006-10-23 20:59:56 +00:00
$form['uninstall'] = array(
'#type' => 'checkboxes',
'#options' => $options,
);
$form['buttons']['submit'] = array(
2007-05-14 13:43:38 +00:00
'#type' => 'submit',
2006-10-23 20:59:56 +00:00
'#value' => t('Uninstall'),
);
2006-10-24 15:56:22 +00:00
$form['#action'] = url('admin/build/modules/uninstall/confirm');
2006-10-23 20:59:56 +00:00
}
2007-01-31 15:49:26 +00:00
else {
$form['modules'] = array();
}
2006-10-23 20:59:56 +00:00
return $form;
}
/**
* Confirm uninstall of selected modules.
*
* @param
* $form_values Submitted form values.
* @return
* A form array representing modules to confirm.
*/
2007-05-14 13:43:38 +00:00
function system_modules_uninstall_confirm_form($storage) {
2006-10-23 20:59:56 +00:00
// Nothing to build.
2007-05-14 13:43:38 +00:00
if (!isset($storage)) {
2006-10-23 20:59:56 +00:00
return;
}
// Construct the hidden form elements and list items.
2007-05-14 13:43:38 +00:00
foreach (array_filter($storage['uninstall']) as $module => $value) {
2007-04-18 20:42:23 +00:00
$info = drupal_parse_info_file(dirname(drupal_get_filename('module', $module)) .'/'. $module .'.info');
2006-10-23 20:59:56 +00:00
$uninstall[] = $info['name'];
$form['uninstall'][$module] = array('#type' => 'hidden',
'#value' => 1,
);
}
// Display a confirm form if modules have been selected.
if (isset($uninstall)) {
2007-05-14 13:43:38 +00:00
$form['#confirmed'] = TRUE;
2006-10-23 20:59:56 +00:00
$form['uninstall']['#tree'] = TRUE;
2006-10-24 15:56:22 +00:00
$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));
2006-10-23 20:59:56 +00:00
$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;
}
}
/**
* Themes a table of currently disabled modules.
*
* @param
* $form The form array representing the currently disabled modules.
* @return
* An HTML string representing the table.
*/
function theme_system_modules_uninstall($form) {
// No theming for the confirm form.
if (isset($form['confirm'])) {
return drupal_render($form);
}
// Table headers.
$header = array(t('Uninstall'),
t('Name'),
t('Description'),
);
// Display table.
$rows = array();
foreach (element_children($form['modules']) as $module) {
$rows[] = array(
array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'),
'<strong>'. drupal_render($form['modules'][$module]['name']) .'</strong>',
array('data' => drupal_render($form['modules'][$module]['description']), 'class' => 'description'),
);
}
// Only display table if there are modules that can be uninstalled.
2007-01-31 15:49:26 +00:00
if (empty($rows)) {
2006-10-23 20:59:56 +00:00
$rows[] = array(array('data' => t('No modules are available to uninstall.'), 'colspan' => '3', 'align' => 'center', 'class' => 'message'));
}
$output = theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
}
/**
* Validates the submitted uninstall form.
*
* @param
* $form_id The form ID.
* @param
* $form_values Submitted form values.
*/
2007-05-14 13:43:38 +00:00
function system_modules_uninstall_validate($form_values, $form, &$form_state) {
2006-10-23 20:59:56 +00:00
// Form submitted, but no modules selected.
if (!count(array_filter($form_values['uninstall']))) {
drupal_set_message(t('No modules selected.'), 'error');
drupal_goto('admin/build/modules/uninstall');
}
}
/**
* Processes the submitted uninstall form.
*
* @param
* $form_id The form ID.
* @param
* $form_values Submitted form values.
*/
2007-05-14 13:43:38 +00:00
function system_modules_uninstall_submit($form_values, $form, &$form_state) {
2006-10-23 20:59:56 +00:00
// Make sure the install API is available.
include_once './includes/install.inc';
2007-05-14 13:43:38 +00:00
if (!empty($form['#confirmed'])) {
// Call the uninstall routine for each selected module.
foreach (array_filter($form_values['uninstall']) as $module => $value) {
drupal_uninstall_module($module);
}
drupal_set_message(t('The selected modules have been uninstalled.'));
unset($form_state['storage']);
$form_state['redirect'] = 'admin/build/modules/uninstall';
}
else {
$form_state['storage'] = $form_values;
2006-10-23 20:59:56 +00:00
}
}
2006-09-01 08:44:53 +00:00
/**
* Menu callback: run cron manually.
*/
function system_run_cron() {
// Run cron manually
if (drupal_cron_run()) {
drupal_set_message(t('Cron ran successfully'));
}
else {
drupal_set_message(t('Cron run failed'));
}
drupal_goto('admin/logs/status');
}
/**
* Menu callback: return information about PHP.
*/
function system_php() {
phpinfo(INFO_GENERAL | INFO_CONFIGURATION);
exit();
}
function _system_sql($data, $keys) {
$rows = array();
foreach ($keys as $key => $explanation) {
if (isset($data[$key])) {
$rows[] = array(check_plain($key), check_plain($data[$key]), $explanation);
}
}
return theme('table', array(t('Variable'), t('Value'), t('Description')), $rows);
}
/**
* Menu callback: return information about PHP.
*/
function system_sql() {
$result = db_query("SHOW STATUS");
while ($entry = db_fetch_object($result)) {
$data[$entry->Variable_name] = $entry->Value;
}
$output = '<h2>'. t('Command counters') .'</h2>';
$output .= _system_sql($data, array(
'Com_select' => t('The number of <code>SELECT</code>-statements.'),
'Com_insert' => t('The number of <code>INSERT</code>-statements.'),
'Com_update' => t('The number of <code>UPDATE</code>-statements.'),
'Com_delete' => t('The number of <code>DELETE</code>-statements.'),
'Com_lock_tables' => t('The number of table locks.'),
'Com_unlock_tables' => t('The number of table unlocks.')
));
$output .= '<h2>'. t('Query performance') .'</h2>';
$output .= _system_sql($data, array(
2007-01-08 12:07:42 +00:00
'Select_full_join' => t('The number of joins without an index; should be zero.'),
2006-09-01 08:44:53 +00:00
'Select_range_check' => t('The number of joins without an index; should be zero.'),
'Sort_scan' => t('The number of sorts done without using an index; should be zero.'),
'Table_locks_immediate' => t('The number of times a lock could be acquired immediately.'),
'Table_locks_waited' => t('The number of times the server had to wait for a lock.')
));
$output .= '<h2>'. t('Query cache information') .'</h2>';
$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 that MySQL found previous results in the cache.'),
'Qcache_inserts' => t('The number of times that MySQL added a query to the cache (misses).'),
'Qcache_lowmem_prunes' => t('The number of times that MySQL had to remove queries from the cache because it ran out of memory. Ideally should be zero.')
));
return $output;
}
/**
* Menu callback: displays the site status report. Can also be used as a pure check.
*
* @param $check
* If true, only returns a boolean whether there are system status errors.
*/
function system_status($check = FALSE) {
// Load .install files
include_once './includes/install.inc';
drupal_load_updates();
// Check run-time requirements and status information
$requirements = module_invoke_all('requirements', 'runtime');
2006-10-29 15:13:01 +00:00
usort($requirements, '_system_sort_requirements');
2006-09-01 08:44:53 +00:00
if ($check) {
return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
}
return theme('status_report', $requirements);
}
2006-10-29 15:13:01 +00:00
/**
* Helper function to sort requirements.
*/
function _system_sort_requirements($a, $b) {
2007-03-27 05:13:55 +00:00
if (!isset($a['weight'])) {
if (!isset($b['weight'])) {
return strcmp($a['title'], $b['title']);
}
return -$b['weight'];
}
return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
2006-10-29 15:13:01 +00:00
}
2006-09-01 08:44:53 +00:00
/**
* Theme status report
*/
function theme_status_report(&$requirements) {
2006-09-08 23:13:00 +00:00
$i = 0;
2006-09-01 08:44:53 +00:00
$output = '<table class="system-status-report">';
foreach ($requirements as $requirement) {
2007-01-31 15:49:26 +00:00
if (empty($requirement['#type'])) {
2006-10-29 08:37:48 +00:00
$class = ++$i % 2 == 0 ? 'even' : 'odd';
2006-09-01 08:44:53 +00:00
$classes = array(
2006-09-01 09:23:45 +00:00
REQUIREMENT_INFO => 'info',
2006-09-01 08:44:53 +00:00
REQUIREMENT_OK => 'ok',
REQUIREMENT_WARNING => 'warning',
REQUIREMENT_ERROR => 'error',
);
2007-01-31 15:49:26 +00:00
$class = $classes[isset($requirement['severity']) ? (int)$requirement['severity'] : 0] .' '. $class;
2006-09-01 08:44:53 +00:00
// Output table row(s)
2007-03-15 15:10:38 +00:00
if (!empty($requirement['description'])) {
2006-09-01 08:44:53 +00:00
$output .= '<tr class="'. $class .' merge-down"><th>'. $requirement['title'] .'</th><td>'. $requirement['value'] .'</td></tr>';
$output .= '<tr class="'. $class .' merge-up"><td colspan="2">'. $requirement['description'] .'</td></tr>';
}
else {
$output .= '<tr class="'. $class .'"><th>'. $requirement['title'] .'</th><td>'. $requirement['value'] .'</td></tr>';
}
}
}
$output .= '</table>';
return $output;
}
2004-06-18 15:04:37 +00:00
2004-08-14 17:19:30 +00:00
/**
2004-08-20 07:51:27 +00:00
* Menu callback; displays a module's settings page.
2004-08-14 17:19:30 +00:00
*/
2006-07-10 19:27:52 +00:00
function system_settings_overview() {
2006-07-31 11:25:55 +00:00
// Check database setup if necessary
if (function_exists('db_check_setup') && empty($_POST)) {
db_check_setup();
}
2006-07-10 19:27:52 +00:00
2007-03-12 13:01:10 +00:00
$item = menu_get_item('admin/settings');
$content = system_admin_menu_block($item);
2006-07-10 19:27:52 +00:00
2006-07-31 11:25:55 +00:00
$output = theme('admin_block_content', $content);
2004-08-14 17:19:30 +00:00
2006-07-31 11:25:55 +00:00
return $output;
2004-08-14 17:19:30 +00:00
}
2007-04-10 10:10:27 +00:00
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;
}
2004-06-18 15:04:37 +00:00
/**
2004-08-20 07:51:27 +00:00
* Menu callback; display theme configuration for entire site and individual themes.
2004-06-18 15:04:37 +00:00
*/
2005-03-16 19:41:12 +00:00
function system_theme_settings($key = '') {
2005-11-12 09:23:50 +00:00
$directory_path = file_directory_path();
2005-10-07 06:11:12 +00:00
file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
2005-03-16 19:41:12 +00:00
// Default settings are defined in theme_get_settings() in includes/theme.inc
2004-08-20 07:51:27 +00:00
if ($key) {
2004-08-20 17:21:37 +00:00
$settings = theme_get_settings($key);
2004-08-20 07:51:27 +00:00
$var = str_replace('/', '_', 'theme_'. $key .'_settings');
2004-11-24 22:44:01 +00:00
$themes = system_theme_data();
2007-04-17 07:19:39 +00:00
$features = $themes[$key]->info['features'];
2004-06-18 15:04:37 +00:00
}
else {
2004-08-20 17:21:37 +00:00
$settings = theme_get_settings('');
2004-08-20 07:51:27 +00:00
$var = 'theme_settings';
}
2005-10-11 19:44:35 +00:00
$form['var'] = array('#type' => 'hidden', '#value' => $var);
2005-10-07 06:11:12 +00:00
2004-09-21 18:33:51 +00:00
// Check for a new uploaded logo, and use that instead.
if ($file = file_check_upload('logo_upload')) {
2005-02-01 16:27:43 +00:00
if ($info = image_get_info($file->filepath)) {
2004-09-21 18:33:51 +00:00
$parts = pathinfo($file->filename);
2007-01-24 07:51:53 +00:00
$filename = ($key) ? str_replace('/', '_', $key) .'_logo.'. $parts['extension'] : 'logo.'. $parts['extension'];
2004-09-21 18:33:51 +00:00
if ($file = file_save_upload('logo_upload', $filename, 1)) {
2006-08-29 09:12:03 +00:00
$_POST['default_logo'] = 0;
$_POST['logo_path'] = $file->filepath;
$_POST['toggle_logo'] = 1;
2004-09-21 18:33:51 +00:00
}
}
else {
form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.'));
}
}
2005-05-25 06:03:18 +00:00
// Check for a new uploaded favicon, and use that instead.
if ($file = file_check_upload('favicon_upload')) {
$parts = pathinfo($file->filename);
2007-01-24 07:51:53 +00:00
$filename = ($key) ? str_replace('/', '_', $key) .'_favicon.'. $parts['extension'] : 'favicon.'. $parts['extension'];
2005-05-25 06:03:18 +00:00
if ($file = file_save_upload('favicon_upload', $filename, 1)) {
2006-08-29 09:12:03 +00:00
$_POST['default_favicon'] = 0;
$_POST['favicon_path'] = $file->filepath;
$_POST['toggle_favicon'] = 1;
2005-05-25 06:03:18 +00:00
}
}
2004-09-21 18:33:51 +00:00
2006-04-04 23:36:18 +00:00
// Toggle settings
$toggles = array(
2007-04-17 07:19:39 +00:00
'logo' => t('Logo'),
'name' => t('Site name'),
'slogan' => t('Site slogan'),
'mission' => t('Mission statement'),
'node_user_picture' => t('User pictures in posts'),
'comment_user_picture' => t('User pictures in comments'),
'search' => t('Search box'),
'favicon' => t('Shortcut icon')
2006-04-04 23:36:18 +00:00
);
// Some features are not always available
$disabled = array();
if (!variable_get('user_pictures', 0)) {
2006-07-05 11:45:51 +00:00
$disabled['toggle_node_user_picture'] = TRUE;
$disabled['toggle_comment_user_picture'] = TRUE;
2006-04-04 23:36:18 +00:00
}
2006-08-20 05:57:41 +00:00
if (!module_exists('search')) {
2006-07-05 11:45:51 +00:00
$disabled['toggle_search'] = TRUE;
2006-04-04 23:36:18 +00:00
}
$form['theme_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Toggle display'),
'#description' => t('Enable or disable the display of certain page elements.'),
);
foreach ($toggles as $name => $title) {
if ((!$key) || in_array($name, $features)) {
// disable search box if search.module is disabled
2007-04-17 07:19:39 +00:00
$form['theme_settings']['toggle_'. $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => $settings['toggle_'. $name]);
2006-04-04 23:36:18 +00:00
if (isset($disabled[$name])) {
2007-04-17 07:19:39 +00:00
$form['theme_settings']['toggle_'. $name]['#disabled'] = TRUE;
2006-04-04 23:36:18 +00:00
}
}
}
// System wide only settings.
if (!$key) {
// Create neat 2-column layout for the toggles
$form['theme_settings'] += array(
'#prefix' => '<div class="theme-settings-left">',
'#suffix' => '</div>',
);
// Toggle node display.
2006-08-06 23:00:42 +00:00
$node_types = node_get_types('names');
2006-04-04 23:36:18 +00:00
if ($node_types) {
$form['node_info'] = array(
'#type' => 'fieldset',
'#title' => t('Display post information on'),
'#description' => t('Enable or disable the <em>submitted by Username on date</em> text when displaying posts of the following type.'),
'#prefix' => '<div class="theme-settings-right">',
'#suffix' => '</div>',
);
foreach ($node_types as $type => $name) {
$form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => $name, '#default_value' => $settings["toggle_node_info_$type"]);
}
}
}
2004-08-20 07:51:27 +00:00
// Logo settings
2007-04-17 07:19:39 +00:00
if ((!$key) || in_array('logo', $features)) {
2006-04-04 23:36:18 +00:00
$form['logo'] = array(
'#type' => 'fieldset',
'#title' => t('Logo image settings'),
'#description' => t('If toggled on, the following logo will be displayed.'),
'#attributes' => array('class' => 'theme-settings-bottom'),
);
2005-10-07 06:11:12 +00:00
$form['logo']["default_logo"] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'checkbox',
'#title' => t('Use the default logo'),
'#default_value' => $settings['default_logo'],
'#tree' => FALSE,
2005-10-11 19:44:35 +00:00
'#description' => t('Check here if you want the theme to use the logo supplied with it.')
2005-10-07 06:11:12 +00:00
);
$form['logo']['logo_path'] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'textfield',
'#title' => t('Path to custom logo'),
'#default_value' => $settings['logo_path'],
2005-10-11 19:44:35 +00:00
'#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'));
2005-10-07 06:11:12 +00:00
$form['logo']['logo_upload'] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'file',
'#title' => t('Upload logo image'),
'#maxlength' => 40,
2005-10-11 19:44:35 +00:00
'#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
2005-10-07 06:11:12 +00:00
);
2005-05-25 06:03:18 +00:00
}
2007-04-17 07:19:39 +00:00
if ((!$key) || in_array('favicon', $features)) {
2007-04-13 08:50:36 +00:00
$form['favicon'] = array(
'#type' => 'fieldset',
'#title' => t('Shortcut icon settings'),
'#description' => t("Your shortcut icon or 'favicon' is displayed in the address bar and bookmarks of most browsers.")
);
2005-10-07 06:11:12 +00:00
$form['favicon']['default_favicon'] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'checkbox',
'#title' => t('Use the default shortcut icon.'),
'#default_value' => $settings['default_favicon'],
2005-10-11 19:44:35 +00:00
'#description' => t('Check here if you want the theme to use the default shortcut icon.')
2005-10-07 06:11:12 +00:00
);
$form['favicon']['favicon_path'] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'textfield',
'#title' => t('Path to custom icon'),
'#default_value' => $settings['favicon_path'],
2005-10-11 19:44:35 +00:00
'#description' => t('The path to the image file you would like to use as your custom shortcut icon.')
2005-10-07 06:11:12 +00:00
);
$form['favicon']['favicon_upload'] = array(
2005-12-16 19:57:41 +00:00
'#type' => 'file',
'#title' => t('Upload icon image'),
'#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
2005-10-07 06:11:12 +00:00
);
2004-08-20 07:51:27 +00:00
}
if ($key) {
// Template-specific settings
2004-08-21 06:34:59 +00:00
$function = $themes[$key]->prefix .'_settings';
2004-08-20 07:51:27 +00:00
if (function_exists($function)) {
2004-11-25 06:17:03 +00:00
if ($themes[$key]->template) {
// file is a template or a style of a template
2005-10-11 19:44:35 +00:00
$form['specific'] = array('#type' => 'fieldset', '#title' => t('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)));
2004-08-20 07:51:27 +00:00
}
else {
2004-11-25 06:17:03 +00:00
// file is a theme or a style of a theme
2005-10-11 19:44:35 +00:00
$form['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]->prefix)));
2004-08-20 07:51:27 +00:00
}
2005-10-07 06:11:12 +00:00
$group = $function();
$form['specific'] = array_merge($form['specific'], (is_array($group) ? $group : array()));
2004-08-20 07:51:27 +00:00
}
2004-06-18 15:04:37 +00:00
}
2005-10-11 19:44:35 +00:00
$form['#attributes'] = array('enctype' => 'multipart/form-data');
2004-09-21 18:33:51 +00:00
2007-05-23 08:00:46 +00:00
$form = system_settings_form($form);
// We don't want to call system_settings_form_submit(), so change #submit.
$form['#submit'] = array('system_theme_settings_submit');
return $form;
2001-06-23 11:09:40 +00:00
}
2001-11-01 11:00:51 +00:00
2006-11-27 01:55:45 +00:00
/**
* Implementation of hook_node_type().
*
* Updates theme settings after a node type change.
*/
function system_node_type($op, $info) {
if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
$old = 'toggle_node_info_'. $info->old_type;
$new = 'toggle_node_info_'. $info->type;
$theme_settings = variable_get('theme_settings', array());
if (isset($theme_settings[$old])) {
$theme_settings[$new] = $theme_settings[$old];
unset($theme_settings[$old]);
variable_set('theme_settings', $theme_settings);
}
}
}
2005-10-07 06:11:12 +00:00
/**
* Output a confirmation form
*
2006-08-18 18:58:47 +00:00
* This function returns a complete form for confirming an action. A link is
2005-10-07 06:11:12 +00:00
* offered to go back to the item that is being changed in case the user changes
* his/her mind.
*
2006-08-29 09:12:03 +00:00
* You can check for the existence of $_POST[$name] (where $name
2006-08-18 18:58:47 +00:00
* is usually 'confirm') to check if the confirmation was successful or
* use the regular submit model.
2005-10-07 06:11:12 +00:00
*
* @param $form
* Additional elements to inject into the form, for example hidden elements.
* @param $question
* The question to ask the user (e.g. "Are you sure you want to delete the
* block <em>foo</em>?").
2006-11-24 10:57:20 +00:00
* @param $path
2005-10-07 06:11:12 +00:00
* The page to go to if the user denies the action.
2006-12-12 09:48:47 +00:00
* Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'.
2005-10-07 06:11:12 +00:00
* @param $description
* Additional text to display (defaults to "This action cannot be undone.").
* @param $yes
* A caption for the button which confirms the action (e.g. "Delete",
* "Replace", ...).
* @param $no
* A caption for the link which denies the action (e.g. "Cancel").
* @param $name
* The internal name used to refer to the confirmation item.
* @return
2006-08-18 18:58:47 +00:00
* The form.
2005-10-07 06:11:12 +00:00
*/
2006-11-24 10:57:20 +00:00
function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
2006-12-26 10:20:37 +00:00
$description = isset($description) ? $description : t('This action cannot be undone.');
2006-12-12 09:48:47 +00:00
// Prepare cancel link
$query = $fragment = NULL;
if (is_array($path)) {
$query = isset($path['query']) ? $path['query'] : NULL;
$fragment = isset($path['fragment']) ? $path['fragment'] : NULL;
$path = isset($path['path']) ? $path['path'] : NULL;
}
2007-02-15 11:40:19 +00:00
$cancel = l($no ? $no : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment));
2006-12-12 09:48:47 +00:00
2005-10-07 06:11:12 +00:00
drupal_set_title($question);
2007-03-13 13:41:39 +00:00
// Confirm form fails duplication check, as the form values rarely change -- so skip it.
$form['#skip_duplicate_check'] = TRUE;
2005-10-11 19:44:35 +00:00
$form['#attributes'] = array('class' => 'confirmation');
$form['description'] = array('#value' => $description);
$form[$name] = array('#type' => 'hidden', '#value' => 1);
2005-10-07 06:11:12 +00:00
2005-10-11 19:44:35 +00:00
$form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
2006-12-12 09:48:47 +00:00
$form['actions']['cancel'] = array('#value' => $cancel);
2007-03-17 18:30:14 +00:00
$form['#theme'] = 'confirm_form';
2006-08-18 18:58:47 +00:00
return $form;
2005-10-07 06:11:12 +00:00
}
2006-07-31 11:25:55 +00:00
/**
* Determine if a user is in compact mode.
*/
function system_admin_compact_mode() {
global $user;
return (isset($user->admin_compact_mode)) ? $user->admin_compact_mode : variable_get('admin_compact_mode', FALSE);
}
/**
* This function formats an administrative page for viewing.
*
* @param $blocks
* An array of blocks to display. Each array should include a
* 'title', a 'description', a formatted 'content' and a
* 'position' which will control which container it will be
* in. This is usually 'left' or 'right'.
* @themeable
*/
function theme_admin_page($blocks) {
2006-09-08 23:13:00 +00:00
$stripe = 0;
2007-01-25 22:14:06 +00:00
$container = array();
2006-12-27 21:59:32 +00:00
2006-07-31 11:25:55 +00:00
foreach ($blocks as $block) {
if ($block_output = theme('admin_block', $block)) {
2007-03-12 13:01:10 +00:00
if (empty($block['position'])) {
2006-07-31 11:25:55 +00:00
// perform automatic striping.
2007-03-12 13:01:10 +00:00
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
2006-07-31 11:25:55 +00:00
}
2007-03-27 05:13:55 +00:00
if (!isset($container[$block['position']])) {
$container[$block['position']] = '';
}
2006-07-31 11:25:55 +00:00
$container[$block['position']] .= $block_output;
}
}
2006-11-24 09:28:38 +00:00
$output = '<div class="admin clear-block">';
2006-07-31 11:25:55 +00:00
$output .= '<div class="compact-link">';
if (system_admin_compact_mode()) {
2006-10-12 20:31:36 +00:00
$output .= l(t('Show descriptions'), 'admin/compact/off', array('title' => t('Produce a less compact layout that includes descriptions.')));
2006-07-31 11:25:55 +00:00
}
else {
2006-11-24 10:18:24 +00:00
$output .= l(t('Hide descriptions'), 'admin/compact/on', array('title' => t("Produce a more compact layout that doesn't include descriptions.")));
2006-07-31 11:25:55 +00:00
}
$output .= '</div>';
foreach ($container as $id => $data) {
2006-08-27 07:44:55 +00:00
$output .= '<div class="'. $id .' clear-block">';
2006-07-31 11:25:55 +00:00
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
return $output;
}
/**
* 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'.
* @themeable
*/
function theme_admin_block($block) {
// Don't display the block if it has no content to display.
2007-03-12 13:01:10 +00:00
if (empty($block['content'])) {
2006-07-31 11:25:55 +00:00
return '';
}
$output = <<< EOT
2006-08-27 07:44:55 +00:00
<div class="admin-panel">
<h3>
2006-07-31 11:25:55 +00:00
$block[title]
2006-08-27 07:44:55 +00:00
</h3>
2006-07-31 11:25:55 +00:00
<div class="body">
2006-08-27 07:44:55 +00:00
<p class="description">
2006-07-31 11:25:55 +00:00
$block[description]
2006-08-27 07:44:55 +00:00
</p>
2006-07-31 11:25:55 +00:00
$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'.
* @themeable
*/
function theme_admin_block_content($content) {
if (!$content) {
return '';
}
if (system_admin_compact_mode()) {
$output = '<ul class="menu">';
foreach ($content as $item) {
2007-03-12 13:01:10 +00:00
if (empty($item['attributes'])) {
$item['attributes'] = array();
}
$item['attributes'] += array('title' => $item['description']);
2007-05-16 13:45:17 +00:00
$output .= '<li class="leaf">'. l($item['title'], $item['href'], $item['options']) .'</li>';
2006-07-31 11:25:55 +00:00
}
$output .= '</ul>';
}
else {
$output = '<dl class="admin-list">';
foreach ($content as $item) {
2007-05-16 13:45:17 +00:00
$output .= '<dt>'. l($item['title'], $item['href'], $item['options']) .'</dt>';
2006-07-31 11:25:55 +00:00
$output .= '<dd>'. $item['description'] .'</dd>';
}
$output .= '</dl>';
}
return $output;
}
2006-10-03 20:38:07 +00:00
/**
* Menu callback; prints a listing of admin tasks for each installed module.
*/
function system_admin_by_module() {
2007-01-24 14:48:36 +00:00
return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
2006-10-03 20:38:07 +00:00
$modules = module_rebuild_cache();
$menu_items = array();
foreach ($modules as $file) {
$module = $file->name;
if ($module == 'help') {
continue;
}
2006-11-21 20:14:19 +00:00
$admin_tasks = system_get_module_admin_tasks($module);
2006-10-03 20:38:07 +00:00
2006-11-29 20:36:30 +00:00
// Only display a section if there are any available tasks.
if (count($admin_tasks)) {
// Check for help links.
if (module_invoke($module, 'help', "admin/help#$module")) {
$admin_tasks[100] = l(t('Get help'), "admin/help/$module");
}
2006-10-03 20:38:07 +00:00
2006-11-29 20:36:30 +00:00
// Sort.
ksort($admin_tasks);
$menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks);
}
2006-10-03 20:38:07 +00:00
}
return theme('system_admin_by_module', $menu_items);
}
2006-11-21 20:14:19 +00:00
function system_get_module_admin_tasks($module) {
2007-01-24 14:48:36 +00:00
return array(); // TODO: this needs to be rewritten for the new menu system.
2006-11-21 20:14:19 +00:00
$admin_access = user_access('administer access control');
$menu = menu_get_menu();
$admin_tasks = array();
// Check for permissions.
if (module_hook($module, 'perm') && $admin_access) {
2007-02-15 11:40:19 +00:00
$admin_tasks[-1] = l(t('Configure permissions'), 'admin/user/access', array('fragment' => 'module-'. $module));
2006-11-21 20:14:19 +00:00
}
// Check for menu items that are admin links.
if ($items = module_invoke($module, 'menu', TRUE)) {
foreach ($items as $item) {
$parts = explode('/', $item['path']);
$n = count($parts);
if ((!isset($item['type']) || ($item['type'] & MENU_VISIBLE_IN_TREE)) && ($parts[0] == 'admin') && ($n >= 3) && _menu_item_is_accessible($menu['path index'][$item['path']])) {
$admin_tasks[$item['title']] = l($item['title'], $item['path']);
}
}
}
return $admin_tasks;
}
2006-10-03 20:38:07 +00:00
/**
* Theme output of the dashboard page.
*/
function theme_system_admin_by_module($menu_items) {
$stripe = 0;
$output = '';
2007-01-25 22:14:06 +00:00
$container = array();
2006-10-03 20:38:07 +00:00
// Iterate over all modules
foreach ($menu_items as $module => $block) {
list($description, $items) = $block;
// Output links
if (count($items)) {
$block = array();
$block['title'] = $module;
$block['content'] = theme('item_list', $items);
2006-12-15 07:56:36 +00:00
$block['description'] = t($description);
2006-10-03 20:38:07 +00:00
if ($block_output = theme('admin_block', $block)) {
2007-01-25 22:14:06 +00:00
if (!$block['position']) {
2006-10-03 20:38:07 +00:00
// Perform automatic striping.
2006-10-26 22:07:03 +00:00
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
2006-10-03 20:38:07 +00:00
}
$container[$block['position']] .= $block_output;
}
}
}
$output = '<div class="admin">';
foreach ($container as $id => $data) {
$output .= '<div class="'. $id .' clear-block">';
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
return $output;
}
2007-04-10 10:10:27 +00:00
/**
* Implementation of hook_cron().
*
* Remove older rows from flood table
*/
function system_cron() {
// Cleanup the flood
db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600);
2007-05-04 09:41:37 +00:00
// Cleanup the batch table
db_query('DELETE FROM {batch} WHERE timestamp < %d', time() - 864000);
2007-04-10 10:10:27 +00:00
}
2007-05-04 09:41:37 +00:00
/**
* Default page callback for batches.
*/
function system_batch_page() {
require_once './includes/batch.inc';
$output = _batch_page();
if ($output === FALSE) {
drupal_access_denied();
}
else {
// Force a page without blocks or messages to
// display a list of collected messages later.
print theme('page', $output, FALSE, FALSE);
}
}