2 // $Id: system.module 144 2007-03-28 07:52:20Z thierry $
6 * Configuration system that lets administrators modify the workings of the site.
9 define('VERSION', '4.7.3');
12 * Implementation of hook_help().
14 function system_help($section) {
18 case 'admin/help#system':
19 $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 web site 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 web site performance. The settings module provides control over preferences, behaviours including visual and operational settings.') .'</p>';
20 $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.') .'</p>';
21 $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>';
22 $output .= t('<p>You can</p>
24 <li>activate your cron job on the cron page <a href="%file-cron">cron.php</a>.</li>
25 <li>read how to <a href="%external-http-drupal-org-cron">configure cron jobs</a>.</li>
26 <li>administer cache settings in <a href="%admin-settings">administer >> settings</a>.</li>
28 ', array('%file-cron' => 'cron.php', '%external-http-drupal-org-cron' => 'http://drupal.org/cron', '%admin-settings' => url('admin/settings')));
29 $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>';
31 case 'admin/modules#description':
32 return t('Handles general site configuration for administrators.');
34 return t('<p>Welcome to the administration section. Below are the most recent system events.</p>');
35 case 'admin/settings':
36 return t('<p>General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.</p>');
38 return t('<p>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>');
39 case 'admin/themes/settings':
40 return t('<p>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>');
41 case 'admin/themes/settings/'. arg(3):
42 $reference = explode('.', arg(3), 2);
43 $theme = array_pop($reference);
44 return t('<p>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.</p>', array('%template' => $theme, '%global' => url('admin/themes/settings')));
46 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>
47 <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>', array('%permissions' => url('admin/access/permissions'), '%throttle' => url('admin/settings/throttle'), '%update-php' => $base_url .'/update.php'));
52 * Implementation of hook_perm().
54 function system_perm() {
55 return array('administer site configuration', 'access administration pages', 'select different theme');
59 * Implementation of hook_elements().
61 function system_elements() {
63 $type['form'] = array('#method' => 'post', '#action' => request_uri());
66 $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
67 $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
68 $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
69 $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
70 $type['password'] = array('#input' => TRUE, '#size' => 30);
71 $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm' => array()));
72 $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5);
73 $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios' => array()));
74 $type['radio'] = array('#input' => TRUE);
75 $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE);
76 $type['select'] = array('#input' => TRUE);
77 $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0);
78 $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#validate' => array('date_validate' => array()));
79 $type['file'] = array('#input' => TRUE, '#size' => 60);
82 $type['item'] = array();
83 $type['hidden'] = array('#input' => TRUE);
84 $type['value'] = array('#input' => TRUE);
85 $type['markup'] = array('#prefix' => '', '#suffix' => '');
86 $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE);
91 * Implementation of hook_menu().
93 function system_menu($may_cache) {
97 $items[] = array('path' => 'system/files', 'title' => t('file download'),
98 'callback' => 'file_download',
100 'type' => MENU_CALLBACK);
102 $access = user_access('administer site configuration');
104 $items[] = array('path' => 'admin', 'title' => t('administer'),
105 'access' => user_access('access administration pages'),
106 'callback' => 'watchdog_overview',
110 $items[] = array('path' => 'admin/themes', 'title' => t('themes'),
111 'callback' => 'system_themes', 'access' => $access);
113 $items[] = array('path' => 'admin/themes/select', 'title' => t('list'),
114 'callback' => 'system_themes', 'access' => $access,
115 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
117 $items[] = array('path' => 'admin/themes/settings', 'title' => t('configure'),
118 'callback' => 'system_theme_settings', 'access' => $access,
119 'type' => MENU_LOCAL_TASK);
121 // Theme configuration subtabs
122 $items[] = array('path' => 'admin/themes/settings/global', 'title' => t('global settings'),
123 'callback' => 'system_theme_settings', 'access' => $access,
124 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
126 foreach (list_themes() as $theme) {
127 if ($theme->status) {
128 $items[] = array('path' => 'admin/themes/settings/'. $theme->name, 'title' => $theme->name,
129 'callback' => 'system_theme_settings', 'callback arguments' => array($theme->name), 'access' => $access,
130 'type' => MENU_LOCAL_TASK);
135 $items[] = array('path' => 'admin/settings', 'title' => t('settings'),
136 'callback' => 'system_site_settings', 'access' => $access);
137 foreach (module_list() as $name) {
138 if (module_hook($name, 'settings')) {
139 $items[] = array('path' => 'admin/settings/'. $name, 'title' => t($name));
142 $items[] = array('path' => 'admin/modules', 'title' => t('modules'),
143 'callback' => 'system_modules', 'access' => $access);
150 * Implementation of hook_user().
152 * Allows users to individually set their theme and time zone.
154 function system_user($type, $edit, &$user, $category = NULL) {
155 if ($type == 'form' && $category == 'account') {
156 $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), $edit['theme'], 2);
158 if (variable_get('configurable_timezones', 1)) {
159 $zones = _system_zonelist();
160 $form['timezone'] = array('#type'=>'fieldset', '#title' => t('Locale settings'), '#weight' => 6);
161 $form['timezone']['timezone'] = array(
162 '#type' => 'select', '#title' => t('Time zone'), '#default_value' => strlen($edit['timezone']) ? $edit['timezone'] : variable_get('date_default_timezone', 0),
163 '#options' => $zones, '#description' => t('Select your current local time. Dates and times throughout this site will be displayed using this time zone.')
172 * Returns a fieldset containing the theme select form.
174 * @param $description
175 * description of the fieldset
176 * @param $default_value
177 * default value of theme radios
179 * weight of the fieldset
183 function system_theme_select_form($description = '', $default_value = '', $weight = 0) {
184 if (user_access('select different theme')) {
185 foreach (list_themes() as $theme) {
186 if ($theme->status) {
191 if (count($enabled) > 1) {
194 $form['themes'] = array(
195 '#type' => 'fieldset',
196 '#title' => t('Theme configuration'),
197 '#description' => $description,
198 '#collapsible' => TRUE,
199 '#theme' => 'system_theme_select_form'
202 foreach ($enabled as $info) {
203 // For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
204 $info->key = $info->name == variable_get('theme_default', 'bluemarine') ? '' : $info->name;
206 $info->screenshot = dirname($info->filename) . '/screenshot.png';
207 $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');
209 $form['themes'][$info->key]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
210 $form['themes'][$info->key]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'bluemarine') ? t('<br /> <em>(site default theme)</em>') : ''));
211 $options[$info->key] = '';
214 $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $default_value ? $default_value : '');
215 $form['#weight'] = $weight;
221 function theme_system_theme_select_form($form) {
222 foreach (element_children($form) as $key) {
224 if (is_array($form[$key]['description'])) {
225 $row[] = form_render($form[$key]['screenshot']);
226 $row[] = form_render($form[$key]['description']);
227 $row[] = form_render($form['theme'][$key]);
232 $header = array(t('Screenshot'), t('Name'), t('Selected'));
233 $output = theme('table', $header, $rows);
237 function _system_zonelist() {
239 $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);
241 foreach ($zonelist as $offset) {
242 $zone = $offset * 3600;
243 $zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone);
248 function system_view_general() {
250 $form['general'] = array(
251 '#type' => 'fieldset', '#title' => t('General settings'),
252 '#collapsible' => TRUE, '#collapsed' => TRUE
254 $form['general']['site_name'] = array(
255 '#type' => 'textfield', '#title' => t('Name'), '#default_value' => variable_get('site_name', 'drupal'),
256 '#description' => t('The name of this web site.'), '#required' => TRUE
258 $form['general']['site_mail'] = array(
259 '#type' => 'textfield', '#title' => t('E-mail address'), '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
260 '#description' => t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.')
262 $form['general']['site_slogan'] = array(
263 '#type' => 'textfield', '#title' => t('Slogan'), '#default_value' => variable_get('site_slogan', ''),
264 '#description' => t('The slogan of this website. Some themes display a slogan when available.')
267 $form['general']['site_mission'] = array(
268 '#type' => 'textarea', '#title' => t('Mission'), '#default_value' => variable_get('site_mission', ''),
269 '#description' => t('Your site\'s mission statement or focus.')
271 $form['general']['site_footer'] = array(
272 '#type' => 'textarea', '#title' => t('Footer message'), '#default_value' => variable_get('site_footer', ''),
273 '#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')
275 $form['general']['anonymous'] = array(
276 '#type' => 'textfield', '#title' => t('Anonymous user'), '#default_value' => variable_get('anonymous', 'Anonymous'),
277 '#description' => t('The name used to indicate anonymous users.')
279 $form['general']['site_frontpage'] = array(
280 '#type' => 'textfield', '#title' => t('Default front page'), '#default_value' => variable_get('site_frontpage', 'node'),
281 '#description' => t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".')
284 // We check for clean URL support using an image on the client side.
285 $form['general']['clean_url'] = array(
287 '#title' => t('Clean URLs'),
288 '#default_value' => variable_get('clean_url', 0),
289 '#options' => array(t('Disabled'), t('Enabled')),
290 '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL.)'),
293 if (!variable_get('clean_url', 0)) {
294 if (strpos(request_uri(), '?q=') !== FALSE) {
295 $form['general']['clean_url']['#description'] .= 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. %run-test', array('%handbook' => 'http://drupal.org/node/15365', '%run-test' => '<a href ="'. base_path() . 'admin/settings">'. t('Run the clean URL test') .'</a>'));
296 $form['general']['clean_url']['#attributes'] = array('disabled' => 'disabled');
299 $form['general']['clean_url']['#description'] .= t(' You have successfully demonstrated that clean URLs work on your server. You are welcome to enable/disable them as you wish.');
300 $form['general']['#collapsed'] = FALSE;
306 $form['errors'] = array( '#type' => 'fieldset', '#title' =>t('Error handling'), '#collapsible' => TRUE, '#collapsed' => TRUE );
307 $form['errors']['site_403'] = array(
308 '#type' => 'textfield', '#title' => t('Default 403 (access denied) page'), '#default_value' => variable_get('site_403', ''),
309 '#description' => t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')
312 $form['errors']['site_404'] = array(
313 '#type' => 'textfield', '#title' => t('Default 404 (not found) page'), '#default_value' => variable_get('site_404', ''),
314 '#description' => t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')
317 $form['errors']['error_level'] = array(
318 '#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
319 '#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
320 '#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.')
323 $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
324 $period['1000000000'] = t('Never');
325 $form['errors']['watchdog_clear'] = array(
326 '#type' => 'select', '#title' => t('Discard log entries older than'), '#default_value' => variable_get('watchdog_clear', 604800), '#options' => $period,
327 '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.')
332 $form['cache'] = array('#type' => 'fieldset', '#title' => t('Cache settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
334 $form['cache']['cache'] = array(
335 '#type' => 'radios', '#title' => t('Page cache'), '#default_value' => variable_get('cache', CACHE_DISABLED),
336 '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_ENABLED => t('Enabled')),
337 '#description' => t("Drupal has a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, Drupal 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 \"anonymous\" users are cached. In order to reduce server load and save bandwidth, Drupal stores and sends compressed cached pages.")
340 $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
341 $period[0] = t('none');
342 $form['cache']['cache_lifetime'] = array(
343 '#type' => 'select', '#title' => t('Minimum cache lifetime'), '#default_value' => variable_get('cache_lifetime', 0), '#options' => $period,
344 '#description' => t('Enabling the cache will offer a sufficient performance boost for most low-traffic and medium-traffic sites. 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.')
349 $form['files'] = array('#type' => 'fieldset', '#title' => t('File system settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
351 $form['files']['file_directory_path'] = array(
352 '#type' => 'textfield',
353 '#title' => t('File system path'),
354 '#default_value' => file_directory_path(),
356 '#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 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.'),
357 '#after_build' => array('system_check_directory'),
360 $form['files']['file_directory_temp'] = array(
361 '#type' => 'textfield',
362 '#title' => t('Temporary directory'),
363 '#default_value' => file_directory_temp(),
365 '#description' => t('Location where uploaded files will be kept during previews. Relative paths will be resolved relative to the Drupal installation directory.'),
366 '#after_build' => array('system_check_directory'),
369 $form['files']['file_downloads'] = array(
370 '#type' => 'radios', '#title' => t('Download method'), '#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC),
371 '#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
372 '#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.')
376 $toolkits_available = image_get_available_toolkits();
377 if (count($toolkits_available) > 1) {
378 $form['image'] = array('#type' => 'fieldset', '#title' => t('Image handling'), '#collapsible' => TRUE, '#collapsed' => true);
379 $form['image']['image_toolkit'] = array(
380 '#type' => 'radios', '#title' => t('Select an image processing toolkit'),
381 '#default_value' => variable_get('image_toolkit', image_get_toolkit()), '#options' => $toolkits_available
386 $form['feed'] = array('#type' => 'fieldset', '#title' => t('RSS feed settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
387 $form['feed']['feed_default_items'] = array(
388 '#type' => 'select', '#title' => t('Number of items per feed'), '#default_value' => variable_get('feed_default_items', 10),
389 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
390 '#description' => t('The default number of items to include in a feed.')
392 $form['feed']['feed_item_length'] = array(
393 '#type' => 'select', '#title' => t('Display of XML feed items'), '#default_value' => variable_get('feed_item_length','teaser'),
394 '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
395 '#description' => t('Global setting for the length of XML feed items that are output by default.')
399 $zones = _system_zonelist();
401 // Date settings: possible date formats
402 $dateshort = array('Y-m-d H:i','m/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
403 'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
404 'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
405 'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
406 $datemedium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
407 'D, Y/m/d - H:i', 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
408 'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
409 'F j, Y - g:ia', 'j F Y - g:ia', 'Y, F j - g:ia', 'j. F Y - G:i');
410 $datelong = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
411 'l, F j, Y - g:ia', 'l, j F Y - g:ia', 'l, Y, F j - g:ia', 'l, j. F Y - G:i');
413 // Date settings: construct choices for user
414 foreach ($dateshort as $f) {
415 $dateshortchoices[$f] = format_date(time(), 'custom', $f);
417 foreach ($datemedium as $f) {
418 $datemediumchoices[$f] = format_date(time(), 'custom', $f);
420 foreach ($datelong as $f) {
421 $datelongchoices[$f] = format_date(time(), 'custom', $f);
424 $form['dates'] = array('#type' => 'fieldset', '#title' => t('Date settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
425 $form['dates']['date_default_timezone'] = array(
426 '#type' => 'select', '#title' => t('Default time zone'), '#default_value' => variable_get('date_default_timezone', 0),
427 '#options' => $zones, '#description' => t('Select the default site time zone.')
430 $form['dates']['configurable_timezones'] = array(
431 '#type' => 'radios', '#title' => t('Configurable time zones'), '#default_value' => variable_get('configurable_timezones', 1), '#options' => array(t('Disabled'), t('Enabled')),
432 '#description' => t('Enable or disable user-configurable time zones. When enabled, users can set their own time zone and dates will be updated accordingly.')
435 $form['dates']['date_format_short'] = array(
436 '#type' => 'select', '#title' => t('Short date format'), '#default_value' => variable_get('date_format_short', $dateshort[0]),
437 '#options' => $dateshortchoices, '#description' => t('The short format of date display.')
440 $form['dates']['date_format_medium'] = array(
441 '#type' => 'select', '#title' => t('Medium date format'), '#default_value' => variable_get('date_format_medium', $datemedium[0]),
442 '#options' => $datemediumchoices, '#description' => t('The medium sized date display.')
445 $form['dates']['date_format_long'] = array(
446 '#type' => 'select', '#title' => t('Long date format'), '#default_value' => variable_get('date_format_long', $datelong[0]),
447 '#options' => $datelongchoices, '#description' => t('Longer date format used for detailed display.')
450 $form['dates']['date_first_day'] = array(
451 '#type' => 'select', '#title' => t('First day of week'), '#default_value' => variable_get('date_first_day', 0),
452 '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
453 '#description' => t('The first day of the week for calendar views.')
457 // Site off-line/maintenance settings
458 $form['site_status'] = array(
459 '#type' => 'fieldset',
460 '#title' => t('Site maintenance'),
461 '#collapsible' => TRUE,
462 '#collapsed' => TRUE);
464 $form['site_status']['site_offline'] = array(
466 '#title' => t('Site status'),
467 '#default_value' => variable_get('site_offline', 0),
468 '#options' => array(t('Online'), t('Off-line')),
469 '#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'))),
472 $form['site_status']['site_offline_message'] = array(
473 '#type' => 'textarea',
474 '#title' => t('Site off-line message'),
475 '#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', t('This Drupal site'))))),
476 '#description' => t('Message to show visitors when the site is in off-line mode.')
479 // String handling: report status and errors.
480 $form['strings'] = array('#type' => 'fieldset', '#title' => t('String handling'), '#collapsible' => TRUE, '#collapsed' => TRUE);
481 $form['strings'] = array_merge($form['strings'], unicode_settings());
483 // Cron: report status and errors.
484 $form['cron'] = array('#type' => 'fieldset', '#title' => t('Cron jobs'), '#collapsible' => TRUE, '#collapsed' => TRUE);
485 $form['cron'] = array_merge($form['cron'], system_cron_settings());
487 // Check database setup if necessary
488 if (function_exists('db_check_setup') && empty($_POST)) {
495 * Checks the existence of the directory specified in $form_element. This
496 * function is called from the system_view_general form to check both the
497 * file_directory_path and file_directory_temp directories. If validation
498 * fails, the form element is flagged with an error from within the
499 * file_check_directory function.
501 * @param $form_element
502 * The form element containing the name of the directory to check.
504 function system_check_directory($form_element) {
505 file_check_directory($form_element['#value'], FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
506 return $form_element;
510 * Return the cron status and errors for admin/settings.
512 function system_cron_settings() {
513 $cron_last = variable_get('cron_last', NULL);
515 if (is_numeric($cron_last)) {
516 $status = t('Cron is running. The last cron job ran %time ago.', array('%time' => format_interval(time() - $cron_last)));
519 $status = t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for <a href="%url">configuring cron jobs</a>.', array('%url' => 'http://drupal.org/cron'));
522 $form['settings'] = array('#type' => 'item', '#value' => $status);
527 * Retrieves the current status of an array of files in the system table.
529 function system_get_files_database(&$files, $type) {
530 // Extract current files from database.
531 $result = db_query("SELECT filename, name, type, status, throttle, schema_version FROM {system} WHERE type = '%s'", $type);
532 while ($file = db_fetch_object($result)) {
533 if (isset($files[$file->name]) && is_object($files[$file->name])) {
534 $file->old_filename = $file->filename;
535 foreach ($file as $key => $value) {
536 if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) {
537 $files[$file->name]->$key = $value;
545 * Collect data about all currently available themes
547 function system_theme_data() {
549 $themes = system_listing('\.theme$', 'themes');
551 // Find theme engines
552 $engines = system_listing('\.engine$', 'themes/engines');
554 // can't iterate over array itself as it uses a copy of the array items
555 foreach (array_keys($themes) as $key) {
556 drupal_get_filename('theme', $themes[$key]->name, $themes[$key]->filename);
557 drupal_load('theme', $themes[$key]->name);
558 $themes[$key]->owner = $themes[$key]->filename;
559 $themes[$key]->prefix = $key;
562 // Remove all theme engines from the system table
563 db_query("DELETE FROM {system} WHERE type = 'theme_engine'");
565 foreach ($engines as $engine) {
566 // Insert theme engine into system table
567 drupal_get_filename('theme_engine', $engine->name, $engine->filename);
568 drupal_load('theme_engine', $engine->name);
569 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);
571 // Add templates to the site listing
572 foreach (call_user_func($engine->name . '_templates') as $template) {
573 // Do not double-insert templates with theme files in their directory,
574 // but do register their engine data.
575 if (array_key_exists($template->name, $themes)) {
576 $themes[$template->name]->template = TRUE;
577 $themes[$template->name]->owner = $engine->filename;
578 $themes[$template->name]->prefix = $engine->name;
581 $template->template = TRUE;
582 $template->name = basename(dirname($template->filename));
583 $template->owner = $engine->filename;
584 $template->prefix = $engine->name;
586 $themes[$template->name] = $template;
591 // Find styles in each theme's directory.
592 foreach ($themes as $theme) {
593 foreach (file_scan_directory(dirname($theme->filename), 'style.css$') as $style) {
594 $style->style = TRUE;
595 $style->template = isset($theme->template) ? $theme->template : FALSE;
596 $style->name = basename(dirname($style->filename));
597 $style->owner = $theme->filename;
598 $style->prefix = $theme->template ? $theme->prefix : $theme->name;
599 // do not double-insert styles with theme files in their directory
600 if (array_key_exists($style->name, $themes)) {
603 $themes[$style->name] = $style;
607 // Extract current files from database.
608 system_get_files_database($themes, 'theme');
610 db_query("DELETE FROM {system} WHERE type = 'theme'");
612 foreach ($themes as $theme) {
613 db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, 'theme', $theme->filename, $theme->status, 0, 0);
620 * Get a list of available regions from a specified theme.
623 * The name of a theme.
625 * An array of regions in the form $region['name'] = 'description'.
627 function system_region_list($theme_key) {
628 static $list = array();
630 if (!array_key_exists($theme_key, $list)) {
631 $theme = db_fetch_object(db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key));
633 // Stylesheets can't have regions; use its theme.
634 if (strpos($theme->filename, '.css')) {
635 return system_region_list(basename(dirname($theme->description)));
638 // If this is a custom theme, load it in before moving on.
639 if (file_exists($file = dirname($theme->filename) .'/' . $theme_key . '.theme')) {
640 include_once "./$file";
645 // This theme has defined its own regions.
646 if (function_exists($theme_key . '_regions')) {
647 $regions = call_user_func($theme_key . '_regions');
649 // File is an engine; include its regions.
650 else if (strpos($theme->description, '.engine')) {
651 include_once './' . $theme->description;
652 $theme_engine = basename($theme->description, '.engine');
653 $regions = function_exists($theme_engine . '_regions') ? call_user_func($theme_engine . '_regions') : array();
656 $list[$theme_key] = $regions;
659 return $list[$theme_key];
663 * Get the name of the default region for a given theme.
666 * The name of a theme.
668 * A string that is the region name.
670 function system_default_region($theme) {
671 $regions = array_keys(system_region_list($theme));
676 * Returns an array of files objects of the given type from both the
677 * site-wide directory (i.e. modules/) and site-specific directory
678 * (i.e. sites/somesite/modules/). The returned array will be keyed
679 * using the key specified (name, basename, filename). Using name or
680 * basename will cause site-specific files to shadow files in the
681 * default directories. That is, if a file with the same name appears
682 * in both location, only the site-specific version will be included.
685 * The regular expression of the files to find.
687 * The subdirectory name in which the files are found. For example,
688 * 'modules' will search in both modules/ and
689 * sites/somesite/modules/.
691 * The key to be passed to file_scan_directory().
693 * Minimum depth of directories to return files from.
696 * An array of file objects of the specified type.
698 function system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
699 $config = conf_path();
700 $searchdir = array($directory);
703 if (file_exists("$config/$directory")) {
704 $searchdir[] = "$config/$directory";
707 // Get current list of items
708 foreach ($searchdir as $dir) {
709 $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth));
716 * Assign an initial, default set of blocks for a theme.
718 * This function is called the first time a new theme is enabled. The new theme
719 * gets a copy of the default theme's blocks, with the difference that if a
720 * particular region isn't available in the new theme, the block is assigned
721 * to the new theme's default region.
724 * The name of a theme.
726 function system_initialize_theme_blocks($theme) {
727 // Initialize theme's blocks if none already registered.
728 if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
729 $default_theme = variable_get('theme_default', 'bluemarine');
730 $regions = system_region_list($theme);
731 $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
732 while($block = db_fetch_array($result)) {
733 // If the region isn't supported by the theme, assign the block to the theme's default region.
734 if (!array_key_exists($block['region'], $regions)) {
735 $block['region'] = system_default_region($theme);
737 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)",
738 $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
743 // Add the submit / reset buttons and run drupal_get_form()
744 function system_settings_form($form_id, $form) {
745 $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
746 $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
748 if (!empty($_POST) && form_get_errors()) {
749 drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
752 return drupal_get_form($form_id, $form, 'system_settings_form');
755 function system_theme_settings_submit($form_id, $values) {
756 $op = isset($_POST['op']) ? $_POST['op'] : '';
757 $key = $values['var'];
759 // Exclude unnecessary elements.
760 unset($values['var'], $values['submit'], $values['reset'], $values['form_id']);
762 if ($op == t('Reset to defaults')) {
764 drupal_set_message(t('The configuration options have been reset to their default values.'));
767 variable_set($key, $values);
768 drupal_set_message(t('The configuration options have been saved.'));
773 * Execute the system_settings_form.
775 * If you want node type configure style handling of your checkboxes,
776 * add an array_filter value to your form.
779 function system_settings_form_submit($form_id, $values) {
780 $op = isset($_POST['op']) ? $_POST['op'] : '';
782 // Exclude unnecessary elements.
783 unset($values['submit'], $values['reset'], $values['form_id']);
785 foreach ($values as $key => $value) {
786 if ($op == t('Reset to defaults')) {
790 if (is_array($value) && isset($values['array_filter'])) {
791 $value = array_keys(array_filter($value));
793 variable_set($key, $value);
796 if ($op == t('Reset to defaults')) {
797 drupal_set_message(t('The configuration options have been reset to their default values.'));
800 drupal_set_message(t('The configuration options have been saved.'));
806 * Menu callback; displays a listing of all themes.
808 function system_themes() {
809 $themes = system_theme_data();
812 foreach ($themes as $info) {
813 $info->screenshot = dirname($info->filename) . '/screenshot.png';
814 $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');
816 $form[$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
817 $form[$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename));
818 $options[$info->name] = '';
820 $status[] = $info->name;
822 if ($info->status && (function_exists($info->prefix . '_settings') || function_exists($info->prefix . '_features'))) {
823 $form[$info->name]['operations'] = array('#type' => 'markup', '#value' => l(t('configure'), 'admin/themes/settings/' . $info->name) );
826 // Dummy element for form_render. Cleaner than adding a check in the theme function.
827 $form[$info->name]['operations'] = array();
831 $form['status'] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $status);
832 $form['theme_default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('theme_default', 'bluemarine'));
833 $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
834 $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
836 return drupal_get_form('system_themes', $form);
839 function theme_system_themes($form) {
840 foreach (element_children($form) as $key) {
842 if (is_array($form[$key]['description'])) {
843 $row[] = form_render($form[$key]['screenshot']);
844 $row[] = form_render($form[$key]['description']);
845 $row[] = array('data' => form_render($form['status'][$key]), 'align' => 'center');
846 if ($form['theme_default']) {
847 $row[] = array('data' => form_render($form['theme_default'][$key]), 'align' => 'center');
848 $row[] = array('data' => form_render($form[$key]['operations']), 'align' => 'center');
854 $header = array(t('Screenshot'), t('Name'), t('Enabled'), t('Default'), t('Operations'));
855 $output = theme('table', $header, $rows);
856 $output .= form_render($form);
861 function system_themes_submit($form_id, $values) {
863 db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
865 if ($_POST['op'] == t('Save configuration')) {
866 if (is_array($values['status'])) {
867 foreach ($values['status'] as $key => $choice) {
868 // Always enable the default theme, despite its status checkbox being checked:
869 if ($choice || $values['theme_default'] == $key) {
870 // If theme status is being set to 1 from 0, initialize block data for this theme if necessary.
871 if (db_num_rows(db_query("SELECT status FROM {system} WHERE type = 'theme' AND name = '%s' AND status = 0", $key))) {
872 system_initialize_theme_blocks($key);
874 db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key);
878 variable_set('theme_default', $values['theme_default']);
881 variable_del('theme_default');
882 db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'bluemarine'");
886 drupal_set_message(t('The configuration options have been saved.'));
887 return 'admin/themes';
891 * Menu callback; displays a listing of all modules.
893 function system_modules() {
894 // Get current list of modules
895 $files = system_listing('\.module$', 'modules', 'name', 0);
897 // Extract current files from database.
898 system_get_files_database($files, 'module');
902 foreach ($files as $filename => $file) {
903 drupal_get_filename('module', $file->name, $file->filename);
904 drupal_load('module', $file->name);
906 $file->description = module_invoke($file->name, 'help', 'admin/modules#description');
908 $form['name'][$file->name] = array('#value' => $file->name);
909 $form['description'][$file->name] = array('#value' => $file->description);
910 $options[$file->name] = '';
912 $status[] = $file->name;
914 if ($file->throttle) {
915 $throttle[] = $file->name;
918 // log the critical hooks implemented by this module
920 foreach (bootstrap_hooks() as $hook) {
921 if (module_hook($file->name, $hook)) {
927 // Update the contents of the system table:
928 if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) {
929 db_query("UPDATE {system} SET description = '%s', name = '%s', bootstrap = %d, filename = '%s' WHERE filename = '%s'", $file->description, $file->name, $bootstrap, $file->filename, $file->old_filename);
932 // This is a new module.
933 db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->description, 'module', $file->filename, $file->status, $file->throttle, $bootstrap);
938 // Handle status checkboxes, including overriding the generated
939 // checkboxes for required modules.
940 $form['status'] = array('#type' => 'checkboxes', '#default_value' => $status, '#options' => $options);
941 $required = array('block', 'filter', 'node', 'system', 'user', 'watchdog');
942 foreach ($required as $require) {
943 $form['status'][$require] = array('#type' => 'hidden', '#value' => 1, '#suffix' => t('required'));
947 * Handle throttle checkboxes, including overriding the generated checkboxes for required modules.
949 if (module_exist('throttle')) {
950 $form['throttle'] = array('#type' => 'checkboxes', '#default_value' => $throttle, '#options' => $options);
951 $throttle_required = array_merge($required, array('throttle'));
952 foreach ($throttle_required as $require) {
953 $form['throttle'][$require] = array('#type' => 'hidden', '#value' => 0, '#suffix' => t('required'));
957 $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
959 return drupal_get_form('system_modules', $form);
962 function theme_system_modules($form) {
963 foreach (element_children($form['name']) as $key) {
965 $row[] = form_render($form['name'][$key]);
966 $row[] = form_render($form['description'][$key]);
967 $row[] = array('data' => form_render($form['status'][$key]), 'align' => 'center');
969 if (module_exist('throttle')) {
970 $row[] = array('data' => form_render($form['throttle'][$key]), 'align' => 'center');
975 $header = array(t('Name'), t('Description'), t('Enabled'));
976 if (module_exist('throttle')) {
977 $header[] = t('Throttle');
980 $output = theme('table', $header, $rows);
981 $output .= form_render($form);
986 function system_modules_submit($form_id, $edit) {
987 db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module'");
989 $new_modules = array();
990 foreach ($edit['status'] as $key => $choice) {
992 db_query("UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '%s'", $key);
993 if (!module_exist($key)) {
994 $new_modules[] = $key;
999 if (is_array($edit['throttle'])) {
1000 foreach ($edit['throttle'] as $key => $choice) {
1002 db_query("UPDATE {system} SET throttle = 1 WHERE type = 'module' and name = '%s'", $key);
1007 module_list(TRUE, FALSE);
1009 include './includes/install.inc';
1010 foreach ($new_modules as $module) {
1011 // Set the installed schema version for newly-enabled modules
1012 $versions = drupal_get_schema_versions($module);
1013 if (drupal_get_installed_schema_version($module) == SCHEMA_UNINSTALLED) {
1014 drupal_set_installed_schema_version($module, $versions ? max($versions) : SCHEMA_INSTALLED);
1015 module_invoke($module, 'install');
1021 drupal_set_message(t('The configuration options have been saved.'));
1022 return 'admin/modules';
1027 * Menu callback; displays a module's settings page.
1029 function system_site_settings($module = NULL) {
1032 $form = module_invoke($module, 'settings');
1035 $form = system_view_general();
1039 return system_settings_form($module . '_settings_form', $form);
1043 * Menu callback; display theme configuration for entire site and individual themes.
1045 function system_theme_settings($key = '') {
1046 $directory_path = file_directory_path();
1047 file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
1049 // Default settings are defined in theme_get_settings() in includes/theme.inc
1051 $settings = theme_get_settings($key);
1052 $var = str_replace('/', '_', 'theme_'. $key .'_settings');
1053 $themes = system_theme_data();
1054 $features = function_exists($themes[$key]->prefix . '_features') ? call_user_func($themes[$key]->prefix . '_features') : array();
1057 $settings = theme_get_settings('');
1058 $var = 'theme_settings';
1061 $form['var'] = array('#type' => 'hidden', '#value' => $var);
1063 // Check for a new uploaded logo, and use that instead.
1064 if ($file = file_check_upload('logo_upload')) {
1065 if ($info = image_get_info($file->filepath)) {
1066 $parts = pathinfo($file->filename);
1067 $filename = ($key) ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension'];
1069 if ($file = file_save_upload('logo_upload', $filename, 1)) {
1070 $_POST['edit']['default_logo'] = 0;
1071 $_POST['edit']['logo_path'] = $file->filepath;
1072 $_POST['edit']['toggle_logo'] = 1;
1076 form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.'));
1080 // Check for a new uploaded favicon, and use that instead.
1081 if ($file = file_check_upload('favicon_upload')) {
1082 $parts = pathinfo($file->filename);
1083 $filename = ($key) ? str_replace('/', '_', $key) . '_favicon.' . $parts['extension'] : 'favicon.' . $parts['extension'];
1085 if ($file = file_save_upload('favicon_upload', $filename, 1)) {
1086 $_POST['edit']['default_favicon'] = 0;
1087 $_POST['edit']['favicon_path'] = $file->filepath;
1088 $_POST['edit']['toggle_favicon'] = 1;
1094 'toggle_logo' => t('Logo'),
1095 'toggle_name' => t('Site name'),
1096 'toggle_slogan' => t('Site slogan'),
1097 'toggle_mission' => t('Mission statement'),
1098 'toggle_node_user_picture' => t('User pictures in posts'),
1099 'toggle_comment_user_picture' => t('User pictures in comments'),
1100 'toggle_search' => t('Search box'),
1101 'toggle_favicon' => t('Shortcut icon')
1104 // Some features are not always available
1105 $disabled = array();
1106 if (!variable_get('user_pictures', 0)) {
1107 $disabled['toggle_node_user_picture'] = true;
1108 $disabled['toggle_comment_user_picture'] = true;
1110 if (!module_exist('search')) {
1111 $disabled['toggle_search'] = true;
1114 $form['theme_settings'] = array(
1115 '#type' => 'fieldset',
1116 '#title' => t('Toggle display'),
1117 '#description' => t('Enable or disable the display of certain page elements.'),
1119 foreach ($toggles as $name => $title) {
1120 if ((!$key) || in_array($name, $features)) {
1121 // disable search box if search.module is disabled
1122 $form['theme_settings'][$name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => $settings[$name]);
1123 if (isset($disabled[$name])) {
1124 $form['theme_settings'][$name]['#attributes'] = array('disabled' => 'disabled');
1129 // System wide only settings.
1131 // Create neat 2-column layout for the toggles
1132 $form['theme_settings'] += array(
1133 '#prefix' => '<div class="theme-settings-left">',
1134 '#suffix' => '</div>',
1137 // Toggle node display.
1138 $node_types = module_invoke('node', 'get_types');
1140 $form['node_info'] = array(
1141 '#type' => 'fieldset',
1142 '#title' => t('Display post information on'),
1143 '#description' => t('Enable or disable the <em>submitted by Username on date</em> text when displaying posts of the following type.'),
1144 '#prefix' => '<div class="theme-settings-right">',
1145 '#suffix' => '</div>',
1147 foreach ($node_types as $type => $name) {
1148 $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => $name, '#default_value' => $settings["toggle_node_info_$type"]);
1154 if ((!$key) || in_array('toggle_logo', $features)) {
1155 $form['logo'] = array(
1156 '#type' => 'fieldset',
1157 '#title' => t('Logo image settings'),
1158 '#description' => t('If toggled on, the following logo will be displayed.'),
1159 '#attributes' => array('class' => 'theme-settings-bottom'),
1161 $form['logo']["default_logo"] = array(
1162 '#type' => 'checkbox',
1163 '#title' => t('Use the default logo'),
1164 '#default_value' => $settings['default_logo'],
1166 '#description' => t('Check here if you want the theme to use the logo supplied with it.')
1168 $form['logo']['logo_path'] = array(
1169 '#type' => 'textfield',
1170 '#title' => t('Path to custom logo'),
1171 '#default_value' => $settings['logo_path'],
1172 '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'));
1174 $form['logo']['logo_upload'] = array(
1176 '#title' => t('Upload logo image'),
1178 '#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
1183 if ((!$key) || in_array('toggle_favicon', $features)) {
1184 $form['favicon'] = array('#type' => 'fieldset', '#title' => t('Shortcut icon settings'));
1185 $form['favicon']['text'] = array('#value' => t('Your shortcut icon or \'favicon\' is displayed in the address bar and bookmarks of most browsers.'));
1186 $form['favicon']['default_favicon'] = array(
1187 '#type' => 'checkbox',
1188 '#title' => t('Use the default shortcut icon.'),
1189 '#default_value' => $settings['default_favicon'],
1190 '#description' => t('Check here if you want the theme to use the default shortcut icon.')
1192 $form['favicon']['favicon_path'] = array(
1193 '#type' => 'textfield',
1194 '#title' => t('Path to custom icon'),
1195 '#default_value' => $settings['favicon_path'],
1196 '#description' => t('The path to the image file you would like to use as your custom shortcut icon.')
1199 $form['favicon']['favicon_upload'] = array(
1201 '#title' => t('Upload icon image'),
1202 '#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
1207 // Template-specific settings
1208 $function = $themes[$key]->prefix .'_settings';
1209 if (function_exists($function)) {
1210 if ($themes[$key]->template) {
1211 // file is a template or a style of a template
1212 $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)));
1215 // file is a theme or a style of a theme
1216 $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)));
1218 $group = $function();
1219 $form['specific'] = array_merge($form['specific'], (is_array($group) ? $group : array()));
1222 $form['#attributes'] = array('enctype' => 'multipart/form-data');
1224 return system_settings_form('system_theme_settings', $form);
1229 * Output a confirmation form
1231 * This function outputs a complete form for confirming an action. A link is
1232 * offered to go back to the item that is being changed in case the user changes
1235 * You should use $GLOBALS['values']['edit'][$name] (where $name is usually 'confirm') to
1236 * check if the confirmation was successful.
1239 * The unique form identifier. Used by the form API to construct the theme.
1241 * Additional elements to inject into the form, for example hidden elements.
1243 * The question to ask the user (e.g. "Are you sure you want to delete the
1244 * block <em>foo</em>?").
1246 * The page to go to if the user denies the action.
1247 * @param $description
1248 * Additional text to display (defaults to "This action cannot be undone.").
1250 * A caption for the button which confirms the action (e.g. "Delete",
1253 * A caption for the link which denies the action (e.g. "Cancel").
1255 * The internal name used to refer to the confirmation item.
1257 * A themed HTML string representing the form.
1260 function confirm_form($form_id, $form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
1262 $description = ($description) ? $description : t('This action cannot be undone.');
1263 drupal_set_title($question);
1264 $form['#attributes'] = array('class' => 'confirmation');
1265 $form['description'] = array('#value' => $description);
1266 $form[$name] = array('#type' => 'hidden', '#value' => 1);
1268 $form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
1269 $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
1270 $form['actions']['cancel'] = array('#value' => l($no ? $no : t('Cancel'), $path));
1271 return drupal_get_form($form_id, $form, 'confirm_form');