| Versionen | |
|---|---|
| drupal6 – drupal7 | system_themes_form() |
Menu callback; displays a listing of all themes.
modules/
<?php
function system_themes_form() {
drupal_clear_css_cache();
$themes = system_theme_data();
uasort($themes, 'system_sort_modules_by_info_name');
$status = array();
$incompatible_core = array();
$incompatible_php = array();
foreach ($themes as $theme) {
$screenshot = NULL;
$theme_key = $theme->name;
while ($theme_key) {
if (file_exists($themes[$theme_key]->info['screenshot'])) {
$screenshot = $themes[$theme_key]->info['screenshot'];
break;
}
$theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
}
$screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
$form[$theme->name]['screenshot'] = array('#markup' => $screenshot);
$form[$theme->name]['info'] = array(
'#type' => 'value',
'#value' => $theme->info,
);
$options[$theme->name] = $theme->info['name'];
if (!empty($theme->status) || $theme->name == variable_get('admin_theme', 0)) {
$form[$theme->name]['operations'] = array('#markup' => l(t('configure'), 'admin/build/themes/settings/' . $theme->name) );
}
else {
// Dummy element for drupal_render. Cleaner than adding a check in the theme function.
$form[$theme->name]['operations'] = array();
}
if (!empty($theme->status)) {
$status[] = $theme->name;
}
else {
// Ensure this theme is compatible with this version of core.
// Require the 'content' region to make sure the main page
// content has a common place in all themes.
if (!isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']))) {
$incompatible_core[] = $theme->name;
}
if (version_compare(phpversion(), $theme->info['php']) < 0) {
$incompatible_php[$theme->name] = $theme->info['php'];
}
}
}
$form['status'] = array(
'#type' => 'checkboxes',
'#options' => array_fill_keys(array_keys($options), ''),
'#default_value' => $status,
'#incompatible_themes_core' => drupal_map_assoc($incompatible_core),
'#incompatible_themes_php' => $incompatible_php,
);
$form['theme_default'] = array(
'#type' => 'radios',
'#options' => array_fill_keys(array_keys($options), ''),
'#default_value' => variable_get('theme_default', 'garland'),
);
// Administration theme settings.
$form['admin_theme'] = array(
'#type' => 'fieldset',
'#title' => t('Administration theme'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['admin_theme']['admin_theme'] = array(
'#type' => 'select',
'#options' => array(0 => t('Default theme')) + $options,
'#title' => t('Administration theme'),
'#description' => t('Choose which theme the administration pages should display in. If you choose "Default theme" the administration pages will use the same theme as the rest of the site.'),
'#default_value' => variable_get('admin_theme', 0),
);
$form['admin_theme']['node_admin_theme'] = array(
'#type' => 'checkbox',
'#title' => t('Use administration theme for content editing'),
'#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
'#default_value' => variable_get('node_admin_theme', '0'),
);
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['buttons']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return $form;
}
?>
Kommentare
Kommentar hinzufügen