00001 <?php
00002
00003
00012 function system_main_admin_page($arg = NULL) {
00013
00014
00015
00016 if (isset($arg) && substr($arg, 0, 3) != 'by-') {
00017 return drupal_not_found();
00018 }
00019
00020
00021 if (system_status(TRUE) && user_access('administer site configuration')) {
00022 drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
00023 }
00024 $blocks = array();
00025 if ($admin = db_fetch_array(db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin' AND module = 'system'"))) {
00026 $result = db_query("
00027 SELECT m.*, ml.*
00028 FROM {menu_links} ml
00029 INNER JOIN {menu_router} m ON ml.router_path = m.path
00030 WHERE ml.link_path != 'admin/help' AND menu_name = '%s' AND ml.plid = %d AND hidden = 0", $admin);
00031 while ($item = db_fetch_array($result)) {
00032 _menu_link_translate($item);
00033 if (!$item['access']) {
00034 continue;
00035 }
00036
00037
00038 if (!empty($item['localized_options']['attributes']['title'])) {
00039 $item['description'] = $item['localized_options']['attributes']['title'];
00040 }
00041 $block = $item;
00042 $block['content'] = '';
00043 if ($item['block_callback'] && function_exists($item['block_callback'])) {
00044 $function = $item['block_callback'];
00045 $block['content'] .= $function();
00046 }
00047 $block['content'] .= theme('admin_block_content', system_admin_menu_block($item));
00048
00049
00050 $blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block;
00051 }
00052 }
00053 if ($blocks) {
00054 ksort($blocks);
00055 return theme('admin_page', $blocks);
00056 }
00057 else {
00058 return t('You do not have any administrative items.');
00059 }
00060 }
00061
00062
00073 function system_admin_menu_block_page() {
00074 $item = menu_get_item();
00075 if ($content = system_admin_menu_block($item)) {
00076 $output = theme('admin_block_content', $content);
00077 }
00078 else {
00079 $output = t('You do not have any administrative items.');
00080 }
00081 return $output;
00082 }
00083
00087 function system_admin_by_module() {
00088
00089 $modules = module_rebuild_cache();
00090 $menu_items = array();
00091 $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
00092
00093 foreach ($modules as $file) {
00094 $module = $file->name;
00095 if ($module == 'help') {
00096 continue;
00097 }
00098
00099 $admin_tasks = system_get_module_admin_tasks($module);
00100
00101
00102 if (count($admin_tasks)) {
00103
00104
00105 if ($help_arg && module_invoke($module, 'help', "admin/help#$module", $help_arg)) {
00106 $admin_tasks[100] = l(t('Get help'), "admin/help/$module");
00107 }
00108
00109
00110 ksort($admin_tasks);
00111
00112 $menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks);
00113 }
00114 }
00115 return theme('system_admin_by_module', $menu_items);
00116 }
00117
00121 function system_settings_overview() {
00122
00123 if (function_exists('db_check_setup') && empty($_POST)) {
00124 db_check_setup();
00125 }
00126
00127 $item = menu_get_item('admin/settings');
00128 $content = system_admin_menu_block($item);
00129
00130 $output = theme('admin_block_content', $content);
00131
00132 return $output;
00133 }
00134
00141 function system_admin_theme_settings() {
00142 $themes = system_theme_data();
00143
00144 uasort($themes, 'system_sort_modules_by_info_name');
00145
00146 $options[0] = '<' . t('System default') . '>';
00147 foreach ($themes as $theme) {
00148 $options[$theme->name] = $theme->info['name'];
00149 }
00150
00151 $form['admin_theme'] = array(
00152 '#type' => 'select',
00153 '#options' => $options,
00154 '#title' => t('Administration theme'),
00155 '#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.'),
00156 '#default_value' => variable_get('admin_theme', '0'),
00157 );
00158
00159 $form['node_admin_theme'] = array(
00160 '#type' => 'checkbox',
00161 '#title' => t('Use administration theme for content editing'),
00162 '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
00163 '#default_value' => variable_get('node_admin_theme', '0'),
00164 );
00165
00166 $form['#submit'][] = 'system_admin_theme_submit';
00167 return system_settings_form($form);
00168 }
00169
00176 function system_themes_form() {
00177
00178 drupal_clear_css_cache();
00179 $themes = system_theme_data();
00180
00181 uasort($themes, 'system_sort_modules_by_info_name');
00182
00183 $status = array();
00184 $incompatible_core = array();
00185 $incompatible_php = array();
00186
00187 foreach ($themes as $theme) {
00188 $screenshot = NULL;
00189 $theme_key = $theme->name;
00190 while ($theme_key) {
00191 if (file_exists($themes[$theme_key]->info['screenshot'])) {
00192 $screenshot = $themes[$theme_key]->info['screenshot'];
00193 break;
00194 }
00195 $theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
00196 }
00197 $screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
00198
00199 $form[$theme->name]['screenshot'] = array('#value' => $screenshot);
00200 $form[$theme->name]['info'] = array(
00201 '#type' => 'value',
00202 '#value' => $theme->info,
00203 );
00204 $options[$theme->name] = '';
00205
00206 if (!empty($theme->status) || $theme->name == variable_get('admin_theme', '0')) {
00207 $form[$theme->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/' . $theme->name) );
00208 }
00209 else {
00210
00211 $form[$theme->name]['operations'] = array();
00212 }
00213 if (!empty($theme->status)) {
00214 $status[] = $theme->name;
00215 }
00216 else {
00217
00218 if (!isset($theme->info['core']) || $theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
00219 $incompatible_core[] = $theme->name;
00220 }
00221 if (version_compare(phpversion(), $theme->info['php']) < 0) {
00222 $incompatible_php[$theme->name] = $theme->info['php'];
00223 }
00224 }
00225 }
00226
00227 $form['status'] = array(
00228 '#type' => 'checkboxes',
00229 '#options' => $options,
00230 '#default_value' => $status,
00231 '#incompatible_themes_core' => drupal_map_assoc($incompatible_core),
00232 '#incompatible_themes_php' => $incompatible_php,
00233 );
00234 $form['theme_default'] = array(
00235 '#type' => 'radios',
00236 '#options' => $options,
00237 '#default_value' => variable_get('theme_default', 'garland'),
00238 );
00239 $form['buttons']['submit'] = array(
00240 '#type' => 'submit',
00241 '#value' => t('Save configuration'),
00242 );
00243 $form['buttons']['reset'] = array(
00244 '#type' => 'submit',
00245 '#value' => t('Reset to defaults'),
00246 );
00247 return $form;
00248 }
00249
00253 function system_themes_form_submit($form, &$form_state) {
00254
00255
00256 $old_theme_list = $new_theme_list = array();
00257 foreach (list_themes() as $theme) {
00258 if ($theme->status) {
00259 $old_theme_list[] = $theme->name;
00260 }
00261 }
00262 db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
00263
00264 if ($form_state['values']['op'] == t('Save configuration')) {
00265 if (is_array($form_state['values']['status'])) {
00266 foreach ($form_state['values']['status'] as $key => $choice) {
00267
00268 if ($choice || $form_state['values']['theme_default'] == $key) {
00269 system_initialize_theme_blocks($key);
00270 $new_theme_list[] = $key;
00271 db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key);
00272 }
00273 }
00274 }
00275 if (($admin_theme = variable_get('admin_theme', '0')) != '0' && $admin_theme != $form_state['values']['theme_default']) {
00276 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(
00277 '!admin_theme_page' => url('admin/settings/admin'),
00278 '%admin_theme' => $admin_theme,
00279 '%selected_theme' => $form_state['values']['theme_default'],
00280 )));
00281 }
00282 variable_set('theme_default', $form_state['values']['theme_default']);
00283 }
00284 else {
00285
00286 variable_del('theme_default');
00287 db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'");
00288 $new_theme_list = array('garland');
00289 }
00290
00291 list_themes(TRUE);
00292 menu_rebuild();
00293 drupal_rebuild_theme_registry();
00294 drupal_set_message(t('The configuration options have been saved.'));
00295 $form_state['redirect'] = 'admin/build/themes';
00296
00297
00298
00299
00300 module_invoke('locale', 'system_update', array_diff($new_theme_list, $old_theme_list));
00301
00302 return;
00303 }
00304
00315 function system_theme_settings(&$form_state, $key = '') {
00316 $directory_path = file_directory_path();
00317 file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
00318
00319
00320 if ($key) {
00321 $settings = theme_get_settings($key);
00322 $var = str_replace('/', '_', 'theme_' . $key . '_settings');
00323 $themes = system_theme_data();
00324 $features = $themes[$key]->info['features'];
00325 }
00326 else {
00327 $settings = theme_get_settings('');
00328 $var = 'theme_settings';
00329 }
00330
00331 $form['var'] = array('#type' => 'hidden', '#value' => $var);
00332
00333
00334 if ($file = file_save_upload('logo_upload', array('file_validate_is_image' => array()))) {
00335 $parts = pathinfo($file->filename);
00336 $filename = ($key) ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension'];
00337
00338
00339
00340
00341 if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
00342 $_POST['default_logo'] = 0;
00343 $_POST['logo_path'] = $file->filepath;
00344 $_POST['toggle_logo'] = 1;
00345 }
00346 }
00347
00348
00349 if ($file = file_save_upload('favicon_upload')) {
00350 $parts = pathinfo($file->filename);
00351 $filename = ($key) ? str_replace('/', '_', $key) . '_favicon.' . $parts['extension'] : 'favicon.' . $parts['extension'];
00352
00353
00354
00355
00356 if (file_copy($file, $filename)) {
00357 $_POST['default_favicon'] = 0;
00358 $_POST['favicon_path'] = $file->filepath;
00359 $_POST['toggle_favicon'] = 1;
00360 }
00361 }
00362
00363
00364 $toggles = array(
00365 'logo' => t('Logo'),
00366 'name' => t('Site name'),
00367 'slogan' => t('Site slogan'),
00368 'mission' => t('Mission statement'),
00369 'node_user_picture' => t('User pictures in posts'),
00370 'comment_user_picture' => t('User pictures in comments'),
00371 'search' => t('Search box'),
00372 'favicon' => t('Shortcut icon'),
00373 'primary_links' => t('Primary links'),
00374 'secondary_links' => t('Secondary links'),
00375 );
00376
00377
00378 $disabled = array();
00379 if (!variable_get('user_pictures', 0)) {
00380 $disabled['toggle_node_user_picture'] = TRUE;
00381 $disabled['toggle_comment_user_picture'] = TRUE;
00382 }
00383 if (!module_exists('search')) {
00384 $disabled['toggle_search'] = TRUE;
00385 }
00386
00387 $form['theme_settings'] = array(
00388 '#type' => 'fieldset',
00389 '#title' => t('Toggle display'),
00390 '#description' => t('Enable or disable the display of certain page elements.'),
00391 );
00392 foreach ($toggles as $name => $title) {
00393 if ((!$key) || in_array($name, $features)) {
00394 $form['theme_settings']['toggle_' . $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => $settings['toggle_' . $name]);
00395
00396 if (isset($disabled['toggle_' . $name])) {
00397 $form['theme_settings']['toggle_' . $name]['#disabled'] = TRUE;
00398 }
00399 }
00400 }
00401
00402
00403 if (!$key) {
00404
00405 $form['theme_settings'] += array(
00406 '#prefix' => '<div class="theme-settings-left">',
00407 '#suffix' => '</div>',
00408 );
00409
00410
00411 $node_types = node_get_types('names');
00412 if ($node_types) {
00413 $form['node_info'] = array(
00414 '#type' => 'fieldset',
00415 '#title' => t('Display post information on'),
00416 '#description' => t('Enable or disable the <em>submitted by Username on date</em> text when displaying posts of the following type.'),
00417 '#prefix' => '<div class="theme-settings-right">',
00418 '#suffix' => '</div>',
00419 );
00420 foreach ($node_types as $type => $name) {
00421 $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => check_plain($name), '#default_value' => $settings["toggle_node_info_$type"]);
00422 }
00423 }
00424 }
00425 elseif (!element_children($form['theme_settings'])) {
00426
00427
00428 $form['theme_settings']['#access'] = FALSE;
00429 }
00430
00431
00432 if ((!$key) || in_array('logo', $features)) {
00433 $form['logo'] = array(
00434 '#type' => 'fieldset',
00435 '#title' => t('Logo image settings'),
00436 '#description' => t('If toggled on, the following logo will be displayed.'),
00437 '#attributes' => array('class' => 'theme-settings-bottom'),
00438 );
00439 $form['logo']["default_logo"] = array(
00440 '#type' => 'checkbox',
00441 '#title' => t('Use the default logo'),
00442 '#default_value' => $settings['default_logo'],
00443 '#tree' => FALSE,
00444 '#description' => t('Check here if you want the theme to use the logo supplied with it.')
00445 );
00446 $form['logo']['logo_path'] = array(
00447 '#type' => 'textfield',
00448 '#title' => t('Path to custom logo'),
00449 '#default_value' => $settings['logo_path'],
00450 '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'));
00451
00452 $form['logo']['logo_upload'] = array(
00453 '#type' => 'file',
00454 '#title' => t('Upload logo image'),
00455 '#maxlength' => 40,
00456 '#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
00457 );
00458 }
00459
00460 if ((!$key) || in_array('favicon', $features)) {
00461 $form['favicon'] = array(
00462 '#type' => 'fieldset',
00463 '#title' => t('Shortcut icon settings'),
00464 '#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers.")
00465 );
00466 $form['favicon']['default_favicon'] = array(
00467 '#type' => 'checkbox',
00468 '#title' => t('Use the default shortcut icon.'),
00469 '#default_value' => $settings['default_favicon'],
00470 '#description' => t('Check here if you want the theme to use the default shortcut icon.')
00471 );
00472 $form['favicon']['favicon_path'] = array(
00473 '#type' => 'textfield',
00474 '#title' => t('Path to custom icon'),
00475 '#default_value' => $settings['favicon_path'],
00476 '#description' => t('The path to the image file you would like to use as your custom shortcut icon.')
00477 );
00478
00479 $form['favicon']['favicon_upload'] = array(
00480 '#type' => 'file',
00481 '#title' => t('Upload icon image'),
00482 '#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
00483 );
00484 }
00485
00486 if ($key) {
00487
00488 $filename = './' . str_replace("/$key.info", '', $themes[$key]->filename) . '/theme-settings.php';
00489 if (!file_exists($filename) and !empty($themes[$key]->info['base theme'])) {
00490
00491 $base = $themes[$key]->info['base theme'];
00492 $filename = './' . str_replace("/$base.info", '', $themes[$base]->filename) . '/theme-settings.php';
00493 }
00494 if (file_exists($filename)) {
00495 require_once $filename;
00496 }
00497
00498
00499 $function = $themes[$key]->prefix . '_engine_settings';
00500 if (function_exists($function)) {
00501 $group = $function($settings);
00502 if (!empty($group)) {
00503 $form['engine_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-engine-specific settings'), '#description' => t('These settings only exist for all the templates and styles based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)));
00504 $form['engine_specific'] = array_merge($form['engine_specific'], $group);
00505 }
00506 }
00507
00508 $function = $key . '_settings';
00509 if (!function_exists($function)) {
00510 $function = $themes[$key]->prefix . '_settings';
00511 }
00512 if (function_exists($function)) {
00513 $group = $function($settings);
00514 if (!empty($group)) {
00515 $form['theme_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-specific settings'), '#description' => t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $themes[$key]->info['name'])));
00516 $form['theme_specific'] = array_merge($form['theme_specific'], $group);
00517 }
00518 }
00519 }
00520 $form['#attributes'] = array('enctype' => 'multipart/form-data');
00521
00522 $form = system_settings_form($form);
00523
00524 $form['#submit'] = array('system_theme_settings_submit');
00525 return $form;
00526 }
00527
00531 function system_theme_settings_submit($form, &$form_state) {
00532 $values = $form_state['values'];
00533 $key = $values['var'];
00534
00535 if ($values['op'] == t('Reset to defaults')) {
00536 variable_del($key);
00537 drupal_set_message(t('The configuration options have been reset to their default values.'));
00538 }
00539 else {
00540
00541 unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']);
00542 variable_set($key, $values);
00543 drupal_set_message(t('The configuration options have been saved.'));
00544 }
00545
00546 cache_clear_all();
00547 }
00548
00561 function _system_is_incompatible(&$incompatible, $files, $file) {
00562 static $seen;
00563
00564 if (isset($seen[$file->name])) {
00565 return isset($incompatible[$file->name]);
00566 }
00567 $seen[$file->name] = TRUE;
00568 if (isset($incompatible[$file->name])) {
00569 return TRUE;
00570 }
00571
00572
00573
00574 if (!is_array($file->info['dependencies'])) {
00575 $file->info['dependencies'] = array();
00576 $incompatible[$file->name] = TRUE;
00577 return TRUE;
00578 }
00579
00580 foreach ($file->info['dependencies'] as $dependency) {
00581 if (isset($files[$dependency]) && _system_is_incompatible($incompatible, $files, $files[$dependency])) {
00582 $incompatible[$file->name] = TRUE;
00583 return TRUE;
00584 }
00585 }
00586 }
00587
00607 function system_modules($form_state = array()) {
00608 drupal_rebuild_theme_registry();
00609 node_types_rebuild();
00610 menu_rebuild();
00611 cache_clear_all('schema', 'cache');
00612
00613 $files = module_rebuild_cache();
00614
00615 uasort($files, 'system_sort_modules_by_info_name');
00616
00617 if (!empty($form_state['storage'])) {
00618 return system_modules_confirm_form($files, $form_state['storage']);
00619 }
00620 $dependencies = array();
00621
00622
00623 $form['validation_modules'] = array('#type' => 'value', '#value' => $files);
00624
00625
00626 $form['disabled_modules'] = array('#type' => 'value', '#value' => array());
00627
00628
00629 $incompatible_core = array();
00630 $incompatible_php = array();
00631 foreach ($files as $filename => $file) {
00632
00633 if (!isset($file->info['core']) || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
00634 $incompatible_core[$file->name] = $file->name;
00635 }
00636
00637 if (version_compare(phpversion(), $file->info['php']) < 0) {
00638 $incompatible_php[$file->name] = $file->info['php'];
00639 }
00640 }
00641
00642
00643 $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
00644
00645 $disabled = array();
00646
00647 foreach ($files as $filename => $file) {
00648 $form['name'][$filename] = array('#value' => $file->info['name']);
00649 $form['version'][$filename] = array('#value' => $file->info['version']);
00650 $form['description'][$filename] = array('#value' => t($file->info['description']));
00651
00652
00653 if ($help_arg && module_hook($filename, 'help')) {
00654 if (module_invoke($filename, 'help', "admin/help#$filename", $help_arg)) {
00655
00656 $form['help'][$filename] = array('#value' => theme('more_help_link', url("admin/help/$filename")));
00657 }
00658 }
00659
00660 $options[$filename] = '';
00661
00662 if (_system_is_incompatible($incompatible_core, $files, $file) || _system_is_incompatible($incompatible_php, $files, $file)) {
00663 $disabled[] = $file->name;
00664
00665 continue;
00666 }
00667 if ($file->status) {
00668 $status[] = $file->name;
00669 }
00670
00671 $dependencies = array();
00672
00673 if (is_array($file->info['dependencies'])) {
00674 foreach ($file->info['dependencies'] as $dependency) {
00675 if (!isset($files[$dependency]) || !$files[$dependency]->status) {
00676 if (isset($files[$dependency])) {
00677 $dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
00678 }
00679 else {
00680 $dependencies[] = drupal_ucfirst($dependency) . t(' (<span class="admin-missing">missing</span>)');
00681 $disabled[] = $filename;
00682 $form['disabled_modules']['#value'][$filename] = FALSE;
00683 }
00684 }
00685 else {
00686 $dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
00687 }
00688 }
00689
00690
00691 if (!empty($dependencies)) {
00692 $form['description'][$filename]['dependencies'] = array(
00693 '#value' => t('Depends on: !dependencies', array('!dependencies' => implode(', ', $dependencies))),
00694 '#prefix' => '<div class="admin-dependencies">',
00695 '#suffix' => '</div>',
00696 );
00697 }
00698 }
00699
00700
00701 $dependents = array();
00702 foreach ($file->info['dependents'] as $dependent) {
00703 if ($files[$dependent]->status == 1) {
00704 $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
00705 $disabled[] = $filename;
00706 $form['disabled_modules']['#value'][$filename] = TRUE;
00707 }
00708 else {
00709 $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
00710 }
00711 }
00712
00713
00714 if (!empty($dependents)) {
00715 $form['description'][$filename]['required'] = array(
00716 '#value' => t('Required by: !required', array('!required' => implode(', ', $dependents))),
00717 '#prefix' => '<div class="admin-required">',
00718 '#suffix' => '</div>',
00719 );
00720 }
00721 }
00722
00723 $modules_required = drupal_required_modules();
00724
00725 foreach ($modules_required as $required) {
00726 $disabled[] = $required;
00727 $form['disabled_modules']['#value'][$required] = TRUE;
00728 }
00729
00730
00731
00732 $form['status'] = array(
00733 '#type' => 'checkboxes',
00734 '#default_value' => $status,
00735 '#options' => $options,
00736 '#process' => array(
00737 'expand_checkboxes',
00738 'system_modules_disable',
00739 ),
00740 '#disabled_modules' => $disabled,
00741 '#incompatible_modules_core' => $incompatible_core,
00742 '#incompatible_modules_php' => $incompatible_php,
00743 );
00744
00745 $form['buttons']['submit'] = array(
00746 '#type' => 'submit',
00747 '#value' => t('Save configuration'),
00748 );
00749 $form['#action'] = url('admin/build/modules/list/confirm');
00750
00751 return $form;
00752 }
00753
00757 function system_sort_modules_by_info_name($a, $b) {
00758 return strcasecmp($a->info['name'], $b->info['name']);
00759 }
00760
00772 function system_modules_disable($form, $edit) {
00773 foreach ($form['#disabled_modules'] as $key) {
00774 $form[$key]['#attributes']['disabled'] = 'disabled';
00775 }
00776 return $form;
00777 }
00778
00790 function system_modules_confirm_form($modules, $storage) {
00791 $form = array();
00792 $items = array();
00793
00794 list($dependencies, $status) = $storage;
00795 $form['validation_modules'] = array('#type' => 'value', '#value' => $modules);
00796 $form['status']['#tree'] = TRUE;
00797
00798 foreach ($status as $key => $choice) {
00799 $form['status'][$key] = array('#type' => 'value', '#value' => $choice);
00800 }
00801 foreach ($dependencies as $name => $missing_dependencies) {
00802 $form['status'][$name] = array('#type' => 'hidden', '#value' => 1);
00803 foreach ($missing_dependencies as $k => $dependency) {
00804 $form['status'][$dependency] = array('#type' => 'hidden', '#value' => 1);
00805 $info = $modules[$dependency]->info;
00806 $missing_dependencies[$k] = $info['name'] ? $info['name'] : drupal_ucfirst($dependency);
00807 }
00808 $t_argument = array(
00809 '@module' => $modules[$name]->info['name'],
00810 '@dependencies' => implode(', ', $missing_dependencies),
00811 );
00812 $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);
00813 }
00814 $form['text'] = array('#value' => theme('item_list', $items));
00815
00816 if ($form) {
00817
00818 $form = confirm_form(
00819 $form,
00820 t('Some required modules must be enabled'),
00821 'admin/build/modules',
00822 t('Would you like to continue with enabling the above?'),
00823 t('Continue'),
00824 t('Cancel'));
00825 return $form;
00826 }
00827 }
00828
00832 function system_modules_submit($form, &$form_state) {
00833 include_once './includes/install.inc';
00834 $new_modules = array();
00835
00836
00837 if (!isset($form_state['storage'])) {
00838
00839
00840
00841 $form_state['values']['status'] = array_merge($form_state['values']['status'], $form_state['values']['disabled_modules']);
00842
00843
00844 if ($dependencies = system_module_build_dependencies($form_state['values']['validation_modules'], $form_state['values'])) {
00845
00846 foreach (array_keys($dependencies) as $name) {
00847 $form_state['values']['status'][$name] = 0;
00848 }
00849 }
00850 }
00851 else {
00852 $dependencies = NULL;
00853 }
00854
00855
00856
00857 if ($dependencies) {
00858 if (!isset($form_state['values']['confirm'])) {
00859 $form_state['storage'] = array($dependencies, $form_state['values']['status']);
00860 return;
00861 }
00862 else {
00863 $form_state['values']['status'] = array_merge($form_state['values']['status'], $form_storage[1]);
00864 }
00865 }
00866
00867
00868 unset($form_state['storage']);
00869
00870 $enable_modules = array();
00871 $disable_modules = array();
00872 foreach ($form_state['values']['status'] as $key => $choice) {
00873 if ($choice) {
00874 if (drupal_get_installed_schema_version($key) == SCHEMA_UNINSTALLED) {
00875 $new_modules[] = $key;
00876 }
00877 else {
00878 $enable_modules[] = $key;
00879 }
00880 }
00881 else {
00882 $disable_modules[] = $key;
00883 }
00884 }
00885
00886 $old_module_list = module_list();
00887
00888 if (!empty($enable_modules)) {
00889 module_enable($enable_modules);
00890 }
00891 if (!empty($disable_modules)) {
00892 module_disable($disable_modules);
00893 }
00894
00895
00896 foreach ($new_modules as $key => $module) {
00897 if (!drupal_check_module($module)) {
00898 unset($new_modules[$key]);
00899 }
00900 }
00901 drupal_install_modules($new_modules);
00902
00903 $current_module_list = module_list(TRUE, FALSE);
00904 if ($old_module_list != $current_module_list) {
00905 drupal_set_message(t('The configuration options have been saved.'));
00906 }
00907
00908 drupal_clear_css_cache();
00909 drupal_clear_js_cache();
00910
00911 $form_state['redirect'] = 'admin/build/modules';
00912
00913
00914
00915
00916 module_invoke('locale', 'system_update', $new_modules);
00917
00918
00919 actions_synchronize();
00920
00921 return;
00922 }
00923
00924
00935 function system_module_build_dependencies($modules, $form_values) {
00936 static $dependencies;
00937
00938 if (!isset($dependencies) && isset($form_values)) {
00939 $dependencies = array();
00940 foreach ($modules as $name => $module) {
00941
00942 if (!$module->status && $form_values['status'][$name] && isset($module->info['dependencies'])) {
00943 foreach ($module->info['dependencies'] as $dependency) {
00944 if (!$form_values['status'][$dependency] && isset($modules[$dependency])) {
00945 if (!isset($dependencies[$name])) {
00946 $dependencies[$name] = array();
00947 }
00948 $dependencies[$name][] = $dependency;
00949 }
00950 }
00951 }
00952 }
00953 }
00954 return $dependencies;
00955 }
00956
00972 function system_modules_uninstall($form_state = NULL) {
00973
00974 include_once './includes/install.inc';
00975
00976
00977 if (isset($form_state) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
00978 return $confirm_form;
00979 }
00980
00981 $form = array();
00982
00983
00984 $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);
00985 while ($module = db_fetch_object($disabled_modules)) {
00986
00987
00988 $info = unserialize($module->info);
00989
00990
00991
00992 module_load_install($module->name);
00993 if (module_hook($module->name, 'uninstall')) {
00994 $form['modules'][$module->name]['name'] = array('#value' => $info['name'] ? $info['name'] : $module->name);
00995 $form['modules'][$module->name]['description'] = array('#value' => t($info['description']));
00996 $options[$module->name] = '';
00997 }
00998 }
00999
01000
01001 if (!empty($options)) {
01002 $form['uninstall'] = array(
01003 '#type' => 'checkboxes',
01004 '#options' => $options,
01005 );
01006 $form['buttons']['submit'] = array(
01007 '#type' => 'submit',
01008 '#value' => t('Uninstall'),
01009 );
01010 $form['#action'] = url('admin/build/modules/uninstall/confirm');
01011 }
01012 else {
01013 $form['modules'] = array();
01014 }
01015
01016 return $form;
01017 }
01018
01028 function system_modules_uninstall_confirm_form($storage) {
01029
01030 if (!isset($storage)) {
01031 return;
01032 }
01033
01034
01035 foreach (array_filter($storage['uninstall']) as $module => $value) {
01036 $info = drupal_parse_info_file(dirname(drupal_get_filename('module', $module)) . '/' . $module . '.info');
01037 $uninstall[] = $info['name'];
01038 $form['uninstall'][$module] = array('#type' => 'hidden',
01039 '#value' => 1,
01040 );
01041 }
01042
01043
01044 if (isset($uninstall)) {
01045 $form['#confirmed'] = TRUE;
01046 $form['uninstall']['#tree'] = TRUE;
01047 $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));
01048 $form = confirm_form(
01049 $form,
01050 t('Confirm uninstall'),
01051 'admin/build/modules/uninstall',
01052 t('Would you like to continue with uninstalling the above?'),
01053 t('Uninstall'),
01054 t('Cancel'));
01055 return $form;
01056 }
01057 }
01058
01062 function system_modules_uninstall_validate($form, &$form_state) {
01063
01064 if (!count(array_filter($form_state['values']['uninstall']))) {
01065 drupal_set_message(t('No modules selected.'), 'error');
01066 drupal_goto('admin/build/modules/uninstall');
01067 }
01068 }
01069
01073 function system_modules_uninstall_submit($form, &$form_state) {
01074
01075 include_once './includes/install.inc';
01076
01077 if (!empty($form['#confirmed'])) {
01078
01079 foreach (array_filter($form_state['values']['uninstall']) as $module => $value) {
01080 drupal_uninstall_module($module);
01081 }
01082 drupal_set_message(t('The selected modules have been uninstalled.'));
01083
01084 unset($form_state['storage']);
01085 $form_state['redirect'] = 'admin/build/modules/uninstall';
01086 }
01087 else {
01088 $form_state['storage'] = $form_state['values'];
01089 }
01090 }
01091
01095 function system_ip_blocking() {
01096 $output = '';
01097 $rows = array();
01098 $header = array(t('IP address'), t('Operations'));
01099 $result = db_query('SELECT * FROM {blocked_ips}');
01100 while ($ip = db_fetch_object($result)) {
01101 $rows[] = array(
01102 $ip->ip,
01103 l(t('delete'), "admin/settings/ip-blocking/delete/$ip->iid"),
01104 );
01105 }
01106
01107 $output .= drupal_get_form('system_ip_blocking_form');
01108
01109 $output .= theme('table', $header, $rows);
01110
01111 return $output;
01112 }
01113
01121 function system_ip_blocking_form($form_state) {
01122 $form['ip'] = array(
01123 '#title' => t('IP address'),
01124 '#type' => 'textfield',
01125 '#size' => 64,
01126 '#maxlength' => 32,
01127 '#default_value' => arg(3),
01128 '#description' => t('Enter a valid IP address.'),
01129 );
01130 $form['submit'] = array(
01131 '#type' => 'submit',
01132 '#value' => t('Save'),
01133 );
01134 $form['#submit'][] = 'system_ip_blocking_form_submit';
01135 $form['#validate'][] = 'system_ip_blocking_form_validate';
01136 return $form;
01137 }
01138
01139 function system_ip_blocking_form_validate($form, &$form_state) {
01140 $ip = trim($form_state['values']['ip']);
01141 if (db_result(db_query("SELECT * FROM {blocked_ips} WHERE ip = '%s'", $ip))) {
01142 form_set_error('ip', t('This IP address is already blocked.'));
01143 }
01144 else if ($ip == ip_address()) {
01145 form_set_error('ip', t('You may not block your own IP address.'));
01146 }
01147 else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
01148 form_set_error('ip', t('Please enter a valid IP address.'));
01149 }
01150 }
01151
01152 function system_ip_blocking_form_submit($form, &$form_state) {
01153 $ip = trim($form_state['values']['ip']);
01154 db_query("INSERT INTO {blocked_ips} (ip) VALUES ('%s')", $ip);
01155 drupal_set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip)));
01156 $form_state['redirect'] = 'admin/settings/ip-blocking';
01157 return;
01158 }
01159
01165 function system_ip_blocking_delete(&$form_state, $iid) {
01166 $form['blocked_ip'] = array(
01167 '#type' => 'value',
01168 '#value' => $iid,
01169 );
01170 return confirm_form($form, t('Are you sure you want to delete %ip?', array('%ip' => $iid['ip'])), 'admin/settings/ip-blocking', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
01171 }
01172
01176 function system_ip_blocking_delete_submit($form, &$form_state) {
01177 $blocked_ip = $form_state['values']['blocked_ip'];
01178 db_query("DELETE FROM {blocked_ips} WHERE iid = %d", $blocked_ip['iid']);
01179 watchdog('user', 'Deleted %ip', array('%ip' => $blocked_ip['ip']));
01180 drupal_set_message(t('The IP address %ip was deleted.', array('%ip' => $blocked_ip['ip'])));
01181 $form_state['redirect'] = 'admin/settings/ip-blocking';
01182 }
01183
01190 function system_site_information_settings() {
01191 $form['site_name'] = array(
01192 '#type' => 'textfield',
01193 '#title' => t('Name'),
01194 '#default_value' => variable_get('site_name', 'Drupal'),
01195 '#description' => t('The name of this website.'),
01196 '#required' => TRUE
01197 );
01198 $form['site_mail'] = array(
01199 '#type' => 'textfield',
01200 '#title' => t('E-mail address'),
01201 '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
01202 '#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
01203 '#required' => TRUE,
01204 );
01205 $form['site_slogan'] = array(
01206 '#type' => 'textfield',
01207 '#title' => t('Slogan'),
01208 '#default_value' => variable_get('site_slogan', ''),
01209 '#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site).")
01210 );
01211 $form['site_mission'] = array(
01212 '#type' => 'textarea',
01213 '#title' => t('Mission'),
01214 '#default_value' => variable_get('site_mission', ''),
01215 '#description' => t("Your site's mission or focus statement (often prominently displayed on the front page).")
01216 );
01217 $form['site_footer'] = array(
01218 '#type' => 'textarea',
01219 '#title' => t('Footer message'),
01220 '#default_value' => variable_get('site_footer', ''),
01221 '#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')
01222 );
01223 $form['anonymous'] = array(
01224 '#type' => 'textfield',
01225 '#title' => t('Anonymous user'),
01226 '#default_value' => variable_get('anonymous', t('Anonymous')),
01227 '#description' => t('The name used to indicate anonymous users.'),
01228 '#required' => TRUE,
01229 );
01230 $form['site_frontpage'] = array(
01231 '#type' => 'textfield',
01232 '#title' => t('Default front page'),
01233 '#default_value' => variable_get('site_frontpage', 'node'),
01234 '#size' => 40,
01235 '#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),
01236 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
01237 '#required' => TRUE,
01238 );
01239 $form['#validate'][] = 'system_site_information_settings_validate';
01240
01241 return system_settings_form($form);
01242 }
01243
01247 function system_site_information_settings_validate($form, &$form_state) {
01248
01249 if ($error = user_validate_mail($form_state['values']['site_mail'])) {
01250 form_set_error('site_mail', $error);
01251 }
01252
01253 $item = array('link_path' => $form_state['values']['site_frontpage']);
01254 $normal_path = drupal_get_normal_path($item['link_path']);
01255 if ($item['link_path'] != $normal_path) {
01256 drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
01257 $item['link_path'] = $normal_path;
01258 }
01259 if (!empty($item) && !menu_valid_path($item)) {
01260 form_set_error('site_frontpage', t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $item['link_path'])));
01261 }
01262 }
01263
01270 function system_error_reporting_settings() {
01271
01272 $form['site_403'] = array(
01273 '#type' => 'textfield',
01274 '#title' => t('Default 403 (access denied) page'),
01275 '#default_value' => variable_get('site_403', ''),
01276 '#size' => 40,
01277 '#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
01278 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
01279 );
01280
01281 $form['site_404'] = array(
01282 '#type' => 'textfield',
01283 '#title' => t('Default 404 (not found) page'),
01284 '#default_value' => variable_get('site_404', ''),
01285 '#size' => 40,
01286 '#description' => t('This page is displayed when no other content matches the requested document. If unsure, specify nothing.'),
01287 '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
01288 );
01289
01290 $form['error_level'] = array(
01291 '#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
01292 '#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
01293 '#description' => t('Specify where Drupal, PHP and SQL errors are logged. While it is recommended that a site running in a production environment write errors to the log only, in a development or testing environment it may be helpful to write errors both to the log and to the screen.')
01294 );
01295
01296 return system_settings_form($form);
01297 }
01298
01302 function system_logging_overview() {
01303 $item = menu_get_item('admin/settings/logging');
01304 $content = system_admin_menu_block($item);
01305
01306 $output = theme('admin_block_content', $content);
01307
01308 return $output;
01309 }
01310
01317 function system_performance_settings() {
01318
01319 $description = '<p>' . t("The normal cache mode is suitable for most sites and does not cause any side effects. The aggressive cache mode causes Drupal to skip the loading (boot) and unloading (exit) of enabled modules when serving a cached page. This results in an additional performance boost but can cause unwanted side effects.") . '</p>';
01320
01321 $problem_modules = array_unique(array_merge(module_implements('boot'), module_implements('exit')));
01322 sort($problem_modules);
01323
01324 if (count($problem_modules) > 0) {
01325 $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>';
01326 }
01327 else {
01328 $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>';
01329 }
01330 $form['page_cache'] = array(
01331 '#type' => 'fieldset',
01332 '#title' => t('Page cache'),
01333 '#description' => t('Enabling the page cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time it is viewed.'),
01334 );
01335
01336 $form['page_cache']['cache'] = array(
01337 '#type' => 'radios',
01338 '#title' => t('Caching mode'),
01339 '#default_value' => variable_get('cache', CACHE_DISABLED),
01340 '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended for production sites, no side effects)'), CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)')),
01341 '#description' => $description
01342 );
01343
01344 $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
01345 $period[0] = '<' . t('none') . '>';
01346 $form['page_cache']['cache_lifetime'] = array(
01347 '#type' => 'select',
01348 '#title' => t('Minimum cache lifetime'),
01349 '#default_value' => variable_get('cache_lifetime', 0),
01350 '#options' => $period,
01351 '#description' => t('On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
01352 );
01353 $form['page_cache']['page_compression'] = array(
01354 '#type' => 'radios',
01355 '#title' => t('Page compression'),
01356 '#default_value' => variable_get('page_compression', TRUE),
01357 '#options' => array(t('Disabled'), t('Enabled')),
01358 '#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression."),
01359 );
01360
01361 $form['block_cache'] = array(
01362 '#type' => 'fieldset',
01363 '#title' => t('Block cache'),
01364 '#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on each page load. If the page cache is also enabled, performance increases from enabling the block cache will mainly benefit authenticated users.'),
01365 );
01366
01367 $form['block_cache']['block_cache'] = array(
01368 '#type' => 'radios',
01369 '#title' => t('Block cache'),
01370 '#default_value' => variable_get('block_cache', CACHE_DISABLED),
01371 '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Enabled (recommended)')),
01372 '#disabled' => count(module_implements('node_grants')),
01373 '#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
01374 );
01375
01376 $form['bandwidth_optimizations'] = array(
01377 '#type' => 'fieldset',
01378 '#title' => t('Bandwidth optimizations'),
01379 '#description' => '<p>' . t('Drupal can automatically optimize external resources like CSS and JavaScript, which can reduce both the size and number of requests made to your website. CSS files can be aggregated and compressed into a single file, while JavaScript files are aggregated (but not compressed). These optional optimizations may reduce server load, bandwidth requirements, and page loading times.') . '</p><p>' . t('These options are disabled if you have not set up your files directory, or if your download method is set to private.') . '</p>'
01380 );
01381
01382 $directory = file_directory_path();
01383 $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
01384 $form['bandwidth_optimizations']['preprocess_css'] = array(
01385 '#type' => 'radios',
01386 '#title' => t('Optimize CSS files'),
01387 '#default_value' => intval(variable_get('preprocess_css', 0) && $is_writable),
01388 '#disabled' => !$is_writable,
01389 '#options' => array(t('Disabled'), t('Enabled')),
01390 '#description' => t('This option can interfere with theme development and should only be enabled in a production environment.'),
01391 );
01392 $form['bandwidth_optimizations']['preprocess_js'] = array(
01393 '#type' => 'radios',
01394 '#title' => t('Optimize JavaScript files'),
01395 '#default_value' => intval(variable_get('preprocess_js', 0) && $is_writable),
01396 '#disabled' => !$is_writable,
01397 '#options' => array(t('Disabled'), t('Enabled')),
01398 '#description' => t('This option can interfere with module development and should only be enabled in a production environment.'),
01399 );
01400
01401 $form['clear_cache'] = array(
01402 '#type' => 'fieldset',
01403 '#title' => t('Clear cached data'),
01404 '#description' => t('Caching data improves performance, but may cause problems while troubleshooting new modules, themes, or translations, if outdated information has been cached. To refresh all cached data on your site, click the button below. <em>Warning: high-traffic sites will experience performance slowdowns while cached data is rebuilt.</em>'),
01405 );
01406
01407 $form['clear_cache']['clear'] = array(
01408 '#type' => 'submit',
01409 '#value' => t('Clear cached data'),
01410 '#submit' => array('system_clear_cache_submit'),
01411 );
01412
01413 $form['#submit'][] = 'drupal_clear_css_cache';
01414 $form['#submit'][] = 'drupal_clear_js_cache';
01415
01416 return system_settings_form($form);
01417 }
01418
01424 function system_clear_cache_submit(&$form_state, $form) {
01425 drupal_flush_all_caches();
01426 drupal_set_message(t('Caches cleared.'));
01427 }
01428
01435 function system_file_system_settings() {
01436
01437 $form['file_directory_path'] = array(
01438 '#type' => 'textfield',
01439 '#title' => t('File system path'),
01440 '#default_value' => file_directory_path(),
01441 '#maxlength' => 255,
01442 '#description' => t('A file system path where the files will be stored. This directory must exist and be writable by Drupal. If the download method is set to public, this directory must be relative to the Drupal installation directory and be accessible over the web. If the download method is set to private, this directory should not be accessible over the web. Changing this location will modify all download paths and may cause unexpected problems on an existing site.'),
01443 '#after_build' => array('system_check_directory'),
01444 );
01445
01446 $form['file_directory_temp'] = array(
01447 '#type' => 'textfield',
01448 '#title' => t('Temporary directory'),
01449 '#default_value' => file_directory_temp(),
01450 '#maxlength' => 255,
01451 '#description' => t('A file system path where uploaded files will be stored during previews.'),
01452 '#after_build' => array('system_check_directory'),
01453 );
01454
01455 $form['file_downloads'] = array(
01456 '#type' => 'radios',
01457 '#title' => t('Download method'),
01458 '#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC),
01459 '#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
01460 '#description' => t('Choose the <em>Public download</em> method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.')
01461 );
01462
01463 return system_settings_form($form);
01464 }
01465
01472 function system_image_toolkit_settings() {
01473 $toolkits_available = image_get_available_toolkits();
01474 if (count($toolkits_available) > 1) {
01475 $form['image_toolkit'] = array(
01476 '#type' => 'radios',
01477 '#title' => t('Select an image processing toolkit'),
01478 '#default_value' => variable_get('image_toolkit', image_get_toolkit()),
01479 '#options' => $toolkits_available
01480 );
01481 }
01482 elseif (count($toolkits_available) == 1) {
01483 variable_set('image_toolkit', key($toolkits_available));
01484 }
01485
01486 $form['image_toolkit_settings'] = image_toolkit_invoke('settings');
01487
01488 return system_settings_form($form);
01489 }
01490
01497 function system_rss_feeds_settings() {
01498
01499 $form['feed_default_items'] = array(
01500 '#type' => 'select',
01501 '#title' => t('Number of items in each feed'),
01502 '#default_value' => variable_get('feed_default_items', 10),
01503 '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
01504 '#description' => t('Default number of items to include in each feed.')
01505 );
01506 $form['feed_item_length'] = array(
01507 '#type' => 'select',
01508 '#title' => t('Feed content'),
01509 '#default_value' => variable_get('feed_item_length', 'teaser'),
01510 '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
01511 '#description' => t('Global setting for the default display of content items in each feed.')
01512 );
01513
01514 return system_settings_form($form);
01515 }
01516
01524 function system_date_time_settings() {
01525 drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
01526 drupal_add_js(array('dateTime' => array('lookup' => url('admin/settings/date-time/lookup'))), 'setting');
01527
01528
01529 $zones = _system_zonelist();
01530
01531
01532 $date_short = array('Y-m-d H:i', 'm/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
01533 'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
01534 'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
01535 'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
01536 $date_medium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
01537 'D, Y/m/d - H:i', 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
01538 'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
01539 'F j, Y - g:ia', 'j F Y - g:ia', 'Y, F j - g:ia', 'j. F Y - G:i');
01540 $date_long = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
01541 'l, F j, Y - g:ia', 'l, j F Y - g:ia', 'l, Y, F j - g:ia', 'l, j. F Y - G:i');
01542
01543
01544 foreach ($date_short as $f) {
01545 $date_short_choices[$f] = format_date(time(), 'custom', $f);
01546 }
01547 foreach ($date_medium as $f) {
01548 $date_medium_choices[$f] = format_date(time(), 'custom', $f);
01549 }
01550 foreach ($date_long as $f) {
01551 $date_long_choices[$f] = format_date(time(), 'custom', $f);
01552 }
01553
01554 $date_long_choices['custom'] = $date_medium_choices['custom'] = $date_short_choices['custom'] = t('Custom format');
01555
01556 $form['locale'] = array(
01557 '#type' => 'fieldset',
01558 '#title' => t('Locale settings'),
01559 );
01560
01561 $form['locale']['date_default_timezone'] = array(
01562 '#type' => 'select',
01563 '#title' => t('Default time zone'),
01564 '#default_value' => variable_get('date_default_timezone', 0),
01565 '#options' => $zones,
01566 '#description' => t('Select the default site time zone.')
01567 );
01568
01569 $form['locale']['configurable_timezones'] = array(
01570 '#type' => 'radios',
01571 '#title' => t('User-configurable time zones'),
01572 '#default_value' => variable_get('configurable_timezones', 1),
01573 '#options' => array(t('Disabled'), t('Enabled')),
01574 '#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.')
01575 );
01576
01577 $form['locale']['date_first_day'] = array(
01578 '#type' => 'select',
01579 '#title' => t('First day of week'),
01580 '#default_value' => variable_get('date_first_day', 0),
01581 '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
01582 '#description' => t('The first day of the week for calendar views.')
01583 );
01584
01585 $form['date_formats'] = array(
01586 '#type' => 'fieldset',
01587 '#title' => t('Formatting'),
01588 );
01589
01590 $date_format_short = variable_get('date_format_short', $date_short[1]);
01591 $form['date_formats']['date_format_short'] = array(
01592 '#prefix' => '<div class="date-container"><div class="select-container">',
01593 '#suffix' => '</div>',
01594 '#type' => 'select',
01595 '#title' => t('Short date format'),
01596 '#attributes' => array('class' => 'date-format'),
01597 '#default_value' => (isset($date_short_choices[$date_format_short]) ? $date_format_short : 'custom'),
01598 '#options' => $date_short_choices,
01599 '#description' => t('The short format of date display.'),
01600 );
01601
01602 $default_short_custom = variable_get('date_format_short_custom', (isset($date_short_choices[$date_format_short]) ? $date_format_short : ''));
01603 $form['date_formats']['date_format_short_custom'] = array(
01604 '#prefix' => '<div class="custom-container">',
01605 '#suffix' => '</div></div>',
01606 '#type' => 'textfield',
01607 '#title' => t('Custom short date format'),
01608 '#attributes' => array('class' => 'custom-format'),
01609 '#default_value' => $default_short_custom,
01610 '#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))),
01611 );
01612
01613 $date_format_medium = variable_get('date_format_medium', $date_medium[1]);
01614 $form['date_formats']['date_format_medium'] = array(
01615 '#prefix' => '<div class="date-container"><div class="select-container">',
01616 '#suffix' => '</div>',
01617 '#type' => 'select',
01618 '#title' => t('Medium date format'),
01619 '#attributes' => array('class' => 'date-format'),
01620 '#default_value' => (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : 'custom'),
01621 '#options' => $date_medium_choices,
01622 '#description' => t('The medium sized date display.'),
01623 );
01624
01625 $default_medium_custom = variable_get('date_format_medium_custom', (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : ''));
01626 $form['date_formats']['date_format_medium_custom'] = array(
01627 '#prefix' => '<div class="custom-container">',
01628 '#suffix' => '</div></div>',
01629 '#type' => 'textfield',
01630 '#title' => t('Custom medium date format'),
01631 '#attributes' => array('class' => 'custom-format'),
01632 '#default_value' => $default_medium_custom,
01633 '#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))),
01634 );
01635
01636 $date_format_long = variable_get('date_format_long', $date_long[0]);
01637 $form['date_formats']['date_format_long'] = array(
01638 '#prefix' => '<div class="date-container"><div class="select-container">',
01639 '#suffix' => '</div>',
01640 '#type' => 'select',
01641 '#title' => t('Long date format'),
01642 '#attributes' => array('class' => 'date-format'),
01643 '#default_value' => (isset($date_long_choices[$date_format_long]) ? $date_format_long : 'custom'),
01644 '#options' => $date_long_choices,
01645 '#description' => t('Longer date format used for detailed display.')
01646 );
01647
01648 $default_long_custom = variable_get('date_format_long_custom', (isset($date_long_choices[$date_format_long]) ? $date_format_long : ''));
01649 $form['date_formats']['date_format_long_custom'] = array(
01650 '#prefix' => '<div class="custom-container">',
01651 '#suffix' => '</div></div>',
01652 '#type' => 'textfield',
01653 '#title' => t('Custom long date format'),
01654 '#attributes' => array('class' => 'custom-format'),
01655 '#default_value' => $default_long_custom,
01656 '#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))),
01657 );
01658
01659 $form = system_settings_form($form);
01660
01661 unset($form['#submit']);
01662 return $form;
01663 }
01664
01668 function system_date_time_settings_submit($form, &$form_state) {
01669 if ($form_state['values']['date_format_short'] == 'custom') {
01670 $form_state['values']['date_format_short'] = $form_state['values']['date_format_short_custom'];
01671 }
01672 if ($form_state['values']['date_format_medium'] == 'custom') {
01673 $form_state['values']['date_format_medium'] = $form_state['values']['date_format_medium_custom'];
01674 }
01675 if ($form_state['values']['date_format_long'] == 'custom') {
01676 $form_state['values']['date_format_long'] = $form_state['values']['date_format_long_custom'];
01677 }
01678 return system_settings_form_submit($form, $form_state);
01679 }
01680
01684 function system_date_time_lookup() {
01685 $result = format_date(time(), 'custom', $_GET['format']);
01686 echo drupal_to_js($result);
01687 exit;
01688 }
01689
01696 function system_site_maintenance_settings() {
01697
01698 $form['site_offline'] = array(
01699 '#type' => 'radios',
01700 '#title' => t('Site status'),
01701 '#default_value' => variable_get('site_offline', 0),
01702 '#options' => array(t('Online'), t('Off-line')),
01703 '#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'))),
01704 );
01705
01706 $form['site_offline_message'] = array(
01707 '#type' => 'textarea',
01708 '#title' => t('Site off-line message'),
01709 '#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')))),
01710 '#description' => t('Message to show visitors when the site is in off-line mode.')
01711 );
01712
01713 return system_settings_form($form);
01714 }
01715
01722 function system_clean_url_settings() {
01723 $form['clean_url'] = array(
01724 '#type' => 'radios',
01725 '#title' => t('Clean URLs'),
01726 '#default_value' => variable_get('clean_url', 0),
01727 '#options' => array(t('Disabled'), t('Enabled')),
01728 '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
01729 );
01730
01731 if (!variable_get('clean_url', 0)) {
01732 if (strpos(request_uri(), '?q=') !== FALSE) {
01733 drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
01734
01735 $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>';
01736
01737 $form['clean_url']['#disabled'] = TRUE;
01738 $form['clean_url']['#prefix'] = '<div id="clean-url">';
01739 $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>';
01740 }
01741 else {
01742 $form['clean_url']['#description'] .= ' <div class="ok">' . t('Your server has been successfully tested to support this feature.') . '</div>';
01743 }
01744 }
01745
01746 return system_settings_form($form);
01747 }
01748
01755 function system_status($check = FALSE) {
01756
01757 include_once './includes/install.inc';
01758 drupal_load_updates();
01759
01760
01761 $requirements = module_invoke_all('requirements', 'runtime');
01762 usort($requirements, '_system_sort_requirements');
01763
01764 if ($check) {
01765 return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
01766 }
01767
01768
01769 db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0");
01770
01771 return theme('status_report', $requirements);
01772 }
01773
01777 function system_run_cron() {
01778
01779 if (drupal_cron_run()) {
01780 drupal_set_message(t('Cron ran successfully.'));
01781 }
01782 else {
01783 drupal_set_message(t('Cron run failed.'), 'error');
01784 }
01785
01786 drupal_goto('admin/reports/status');
01787 }
01788
01792 function system_php() {
01793 phpinfo(INFO_ALL);
01794 exit();
01795 }
01796
01807 function _system_sql($data, $keys) {
01808 $rows = array();
01809 foreach ($keys as $key => $explanation) {
01810 if (isset($data[$key])) {
01811 $rows[] = array(check_plain($key), check_plain($data[$key]), $explanation);
01812 }
01813 }
01814
01815 return theme('table', array(t('Variable'), t('Value'), t('Description')), $rows);
01816 }
01817
01821 function system_sql() {
01822
01823 $result = db_query("SHOW STATUS");
01824 while ($entry = db_fetch_object($result)) {
01825
01826
01827 $data[$entry->Variable_name] = $entry->Value;
01828 }
01829
01830 $output = '<h2>' . t('Command counters') . '</h2>';
01831 $output .= _system_sql($data, array(
01832 'Com_select' => t('The number of <code>SELECT</code>-statements.'),
01833 'Com_insert' => t('The number of <code>INSERT</code>-statements.'),
01834 'Com_update' => t('The number of <code>UPDATE</code>-statements.'),
01835 'Com_delete' => t('The number of <code>DELETE</code>-statements.'),
01836 'Com_lock_tables' => t('The number of table locks.'),
01837 'Com_unlock_tables' => t('The number of table unlocks.')
01838 ));
01839
01840 $output .= '<h2>' . t('Query performance') . '</h2>';
01841 $output .= _system_sql($data, array(
01842 'Select_full_join' => t('The number of joins without an index; should be zero.'),
01843 'Select_range_check' => t('The number of joins without keys that check for key usage after each row; should be zero.'),
01844 'Sort_scan' => t('The number of sorts done without using an index; should be zero.'),
01845 'Table_locks_immediate' => t('The number of times a lock could be acquired immediately.'),
01846 'Table_locks_waited' => t('The number of times the server had to wait for a lock.')
01847 ));
01848
01849 $output .= '<h2>' . t('Query cache information') . '</h2>';
01850 $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>';
01851 $output .= _system_sql($data, array(
01852 'Qcache_queries_in_cache' => t('The number of queries in the query cache.'),
01853 'Qcache_hits' => t('The number of times MySQL found previous results in the cache.'),
01854 'Qcache_inserts' => t('The number of times MySQL added a query to the cache (misses).'),
01855 'Qcache_lowmem_prunes' => t('The number of times MySQL had to remove queries from the cache because it ran out of memory. Ideally should be zero.')
01856 ));
01857
01858 return $output;
01859 }
01860
01864 function system_batch_page() {
01865 require_once './includes/batch.inc';
01866 $output = _batch_page();
01867 if ($output === FALSE) {
01868 drupal_access_denied();
01869 }
01870 elseif (isset($output)) {
01871
01872
01873 print theme('page', $output, FALSE, FALSE);
01874 }
01875 }
01876
01885 function theme_admin_block($block) {
01886
01887 if (empty($block['content'])) {
01888 return '';
01889 }
01890
01891 $output = <<< EOT
01892 <div class="admin-panel">
01893 <h3>
01894 $block[title]
01895 </h3>
01896 <div class="body">
01897 <p class="description">
01898 $block[description]
01899 </p>
01900 $block[content]
01901 </div>
01902 </div>
01903 EOT;
01904 return $output;
01905 }
01906
01915 function theme_admin_block_content($content) {
01916 if (!$content) {
01917 return '';
01918 }
01919
01920 if (system_admin_compact_mode()) {
01921 $output = '<ul class="menu">';
01922 foreach ($content as $item) {
01923 $output .= '<li class="leaf">' . l($item['title'], $item['href'], $item['localized_options']) . '</li>';
01924 }
01925 $output .= '</ul>';
01926 }
01927 else {
01928 $output = '<dl class="admin-list">';
01929 foreach ($content as $item) {
01930 $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
01931 $output .= '<dd>' . $item['description'] . '</dd>';
01932 }
01933 $output .= '</dl>';
01934 }
01935 return $output;
01936 }
01937
01948 function theme_admin_page($blocks) {
01949 $stripe = 0;
01950 $container = array();
01951
01952 foreach ($blocks as $block) {
01953 if ($block_output = theme('admin_block', $block)) {
01954 if (empty($block['position'])) {
01955
01956 $block['position'] = ++$stripe % 2 ? 'left' : 'right';
01957 }
01958 if (!isset($container[$block['position']])) {
01959 $container[$block['position']] = '';
01960 }
01961 $container[$block['position']] .= $block_output;
01962 }
01963 }
01964
01965 $output = '<div class="admin clear-block">';
01966 $output .= theme('system_compact_link');
01967
01968 foreach ($container as $id => $data) {
01969 $output .= '<div class="' . $id . ' clear-block">';
01970 $output .= $data;
01971 $output .= '</div>';
01972 }
01973 $output .= '</div>';
01974 return $output;
01975 }
01976
01984 function theme_system_admin_by_module($menu_items) {
01985 $stripe = 0;
01986 $output = '';
01987 $container = array('left' => '', 'right' => '');
01988 $flip = array('left' => 'right', 'right' => 'left');
01989 $position = 'left';
01990
01991
01992 foreach ($menu_items as $module => $block) {
01993 list($description, $items) = $block;
01994
01995
01996 if (count($items)) {
01997 $block = array();
01998 $block['title'] = $module;
01999 $block['content'] = theme('item_list', $items);
02000 $block['description'] = t($description);
02001
02002 if ($block_output = theme('admin_block', $block)) {
02003 if (!isset($block['position'])) {
02004
02005 $block['position'] = $position;
02006 $position = $flip[$position];
02007 }
02008 $container[$block['position']] .= $block_output;
02009 }
02010 }
02011 }
02012
02013 $output = '<div class="admin clear-block">';
02014 foreach ($container as $id => $data) {
02015 $output .= '<div class="' . $id . ' clear-block">';
02016 $output .= $data;
02017 $output .= '</div>';
02018 }
02019 $output .= '</div>';
02020
02021 return $output;
02022 }
02023
02031 function theme_status_report(&$requirements) {
02032 $i = 0;
02033 $output = '<table class="system-status-report">';
02034 foreach ($requirements as $requirement) {
02035 if (empty($requirement['#type'])) {
02036 $class = ++$i % 2 == 0 ? 'even' : 'odd';
02037
02038 $classes = array(
02039 REQUIREMENT_INFO => 'info',
02040 REQUIREMENT_OK => 'ok',
02041 REQUIREMENT_WARNING => 'warning',
02042 REQUIREMENT_ERROR => 'error',
02043 );
02044 $class = $classes[isset($requirement['severity']) ? (int)$requirement['severity'] : 0] . ' ' . $class;
02045
02046
02047 if (!empty($requirement['description'])) {
02048 $output .= '<tr class="' . $class . ' merge-down"><th>' . $requirement['title'] . '</th><td>' . $requirement['value'] . '</td></tr>';
02049 $output .= '<tr class="' . $class . ' merge-up"><td colspan="2">' . $requirement['description'] . '</td></tr>';
02050 }
02051 else {
02052 $output .= '<tr class="' . $class . '"><th>' . $requirement['title'] . '</th><td>' . $requirement['value'] . '</td></tr>';
02053 }
02054 }
02055 }
02056
02057 $output .= '</table>';
02058 return $output;
02059 }
02060
02068 function theme_system_modules($form) {
02069 if (isset($form['confirm'])) {
02070 return drupal_render($form);
02071 }
02072
02073
02074 $header = array();
02075 $header[] = array('data' => t('Enabled'), 'class' => 'checkbox');
02076 $header[] = t('Name');
02077 $header[] = t('Version');
02078 $header[] = t('Description');
02079
02080
02081 $modules = $form['validation_modules']['#value'];
02082 foreach ($modules as $module) {
02083 if (!isset($module->info['package']) || !$module->info['package']) {
02084 $module->info['package'] = t('Other');
02085 }
02086 $packages[$module->info['package']][$module->name] = $module->info;
02087 }
02088 ksort($packages);
02089
02090
02091 $output = '';
02092 foreach ($packages as $package => $modules) {
02093 $rows = array();
02094 foreach ($modules as $key => $module) {
02095 $row = array();
02096 $description = '';
02097 if (isset($form['help'][$key])) {
02098 $description = '<div class="module-help">'. drupal_render($form['help'][$key]) .'</div>';
02099 }
02100 $description .= drupal_render($form['description'][$key]);
02101 if (isset($form['status']['#incompatible_modules_core'][$key])) {
02102 unset($form['status'][$key]);
02103 $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
02104 $description .= '<div class="incompatible">' . t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) . '</div>';
02105 }
02106 elseif (isset($form['status']['#incompatible_modules_php'][$key])) {
02107 unset($form['status'][$key]);
02108 $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
02109 $php_required = $form['status']['#incompatible_modules_php'][$key];
02110 if (substr_count($php_required, '.') < 2) {
02111 $php_required .= '.*';
02112 }
02113 $description .= '<div class="incompatible">' . t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) . '</div>';
02114 }
02115 else {
02116 $status = drupal_render($form['status'][$key]);
02117 }
02118 $row[] = array('data' => $status, 'class' => 'checkbox');
02119
02120
02121 if (isset($form['status'][$key])) {
02122 $row[] = '<strong><label for="' . $form['status'][$key]['#id'] . '">' . drupal_render($form['name'][$key]) . '</label></strong>';
02123 }
02124 else {
02125 $row[] = '<strong>' . drupal_render($form['name'][$key]) . '</strong>';
02126 }
02127
02128 $row[] = array('data' => drupal_render($form['version'][$key]), 'class' => 'version');
02129 $row[] = array('data' => $description, 'class' => 'description');
02130 $rows[] = $row;
02131 }
02132 $fieldset = array(
02133 '#title' => t($package),
02134 '#collapsible' => TRUE,
02135 '#collapsed' => ($package == 'Core - required'),
02136 '#value' => theme('table', $header, $rows, array('class' => 'package')),
02137 );
02138 $output .= theme('fieldset', $fieldset);
02139 }
02140
02141 $output .= drupal_render($form);
02142 return $output;
02143 }
02144
02154 function theme_system_modules_uninstall($form) {
02155
02156 if (isset($form['confirm'])) {
02157 return drupal_render($form);
02158 }
02159
02160
02161 $header = array(t('Uninstall'),
02162 t('Name'),
02163 t('Description'),
02164 );
02165
02166
02167 $rows = array();
02168 foreach (element_children($form['modules']) as $module) {
02169 $rows[] = array(
02170 array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'),
02171 '<strong><label for="' . $form['uninstall'][$module]['#id'] . '">' . drupal_render($form['modules'][$module]['name']) . '</label></strong>',
02172 array('data' => drupal_render($form['modules'][$module]['description']), 'class' => 'description'),
02173 );
02174 }
02175
02176
02177 if (empty($rows)) {
02178 $rows[] = array(array('data' => t('No modules are available to uninstall.'), 'colspan' => '3', 'align' => 'center', 'class' => 'message'));
02179 }
02180
02181 $output = theme('table', $header, $rows);
02182 $output .= drupal_render($form);
02183
02184 return $output;
02185 }
02186
02193 function theme_system_theme_select_form($form) {
02194 foreach (element_children($form) as $key) {
02195 $row = array();
02196 if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
02197 $row[] = drupal_render($form[$key]['screenshot']);
02198 $row[] = drupal_render($form[$key]['description']);
02199 $row[] = drupal_render($form['theme'][$key]);
02200 }
02201 $rows[] = $row;
02202 }
02203
02204 $header = array(t('Screenshot'), t('Name'), t('Selected'));
02205 $output = theme('table', $header, $rows);
02206 return $output;
02207 }
02208
02216 function theme_system_themes_form($form) {
02217 foreach (element_children($form) as $key) {
02218
02219 if (!isset($form[$key]['info'])) {
02220 continue;
02221 }
02222
02223
02224 $info = $form[$key]['info']['#value'];
02225
02226 $description = t($info['description']);
02227
02228 if (isset($form['status']['#incompatible_themes_core'][$key])) {
02229 unset($form['status'][$key]);
02230 $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
02231 $description .= '<div class="incompatible">' . t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) . '</div>';
02232 }
02233 elseif (isset($form['status']['#incompatible_themes_php'][$key])) {
02234 unset($form['status'][$key]);
02235 $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
02236 $php_required = $form['status']['#incompatible_themes_php'][$key];
02237 if (substr_count($php_required, '.') < 2) {
02238 $php_required .= '.*';
02239 }
02240 $description .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) . '</div>';
02241 }
02242 else {
02243 $status = drupal_render($form['status'][$key]);
02244 }
02245
02246
02247 $theme = '<div class="theme-info"><h2>' . $info['name'] . '</h2><div class="description">' . $description . '</div></div>';
02248
02249
02250 $row = array();
02251 $row[] = drupal_render($form[$key]['screenshot']);
02252 $row[] = $theme;
02253 $row[] = isset($info['version']) ? $info['version'] : '';
02254 $row[] = array('data' => $status, 'align' => 'center');
02255 if ($form['theme_default']) {
02256 $row[] = array('data' => drupal_render($form['theme_default'][$key]), 'align' => 'center');
02257 $row[] = array('data' => drupal_render($form[$key]['operations']), 'align' => 'center');
02258 }
02259 $rows[] = $row;
02260 }
02261
02262 $header = array(t('Screenshot'), t('Name'), t('Version'), t('Enabled'), t('Default'), t('Operations'));
02263 $output = theme('table', $header, $rows);
02264 $output .= drupal_render($form);
02265 return $output;
02266 }