function omega_tools_form_alter in Omega Tools 7.2
Same name and namespace in other branches
- 6 omega_tools.module \omega_tools_form_alter()
- 7 omega_tools.module \omega_tools_form_alter()
Implementation of hook_form_alter() Functionality:
- system_theme_settings form For this form the form_alter organizes the form a bit better, adding fieldsets to the default items, making them collapsible, and changing the default size of the file uploads for logo and favicon
File
- ./
omega_tools.module, line 30
Code
function omega_tools_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'system_theme_settings':
$theme = arg(3);
$themes = list_themes();
// if we have an active theme settings page, not the default one
if (isset($theme) && $theme != 'templates') {
// we have a specific theme settings page defined, so we are going to render
// a custom fieldset and submit button/handler that will allow a user to reset
// the theme settings stored in the system.
if (isset($themes[$theme]->base_theme)) {
$base_themes = system_find_base_themes($themes, $theme, $used_keys = array());
$omega_base = in_array('Omega', $base_themes) ? TRUE : FALSE;
}
else {
$omega_base = FALSE;
}
//krumo($themes);
if ($omega_base || $themes[$theme]->name == 'omega') {
$form['omega_general']['omega_tools_reset'] = array(
'#type' => 'fieldset',
'#title' => t('Revert Theme Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => '<p><strong>Use this feature with caution!!!</strong></p><p>Using this feature will allow you to revert your theme settings to anything that is in code, and erase the database stored settings in the <em>system</em> table. This is accomplished by removing the record in the table, and then re-enabling the theme. All settings from the .info file will be used rather than any stored changes in the database.</p><p>If you would like to save the theme settings you have now, and put them in code, use the export feature, and paste the settings[] array in your .info file replacing the current values for that array. Then it will be safe to revert without destroying changes made to the theme settings for your subtheme.</p><p>If you have manually edited the settings in the .info file, and are unconcerned with the settings in the database, or the settings in the database are out of date, then it is also safe to revert.</p>',
'#weight' => 50,
);
$form['omega_general']['omega_tools_reset']['theme_reset'] = array(
'#markup' => l('Revert Theme Settings for ' . $theme, 'admin/appearance/settings/' . $theme . '/reset'),
);
$form['omega_general']['omega_tools_export'] = array(
'#type' => 'fieldset',
'#title' => t('Export Theme Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => '<p>This feature will dump the settings[] array for your .info file, so you may safely paste this data over the appropriate section in your themes .info, and then use the revert feature without actually using your settings <strong></theme-export-awesomesauce></strong>.</p>',
'#weight' => 49,
);
// gather theme information
$overwritten_settings = variable_get('theme_' . $theme . '_settings', FALSE);
if ($overwritten_settings) {
$form['omega_general']['omega_tools_export']['theme_settings_status'] = array(
'#markup' => 'Current Theme Settings status: <strong>Overwritten</strong>',
);
$s = $overwritten_settings;
unset($s['toggle_logo'], $s['toggle_name'], $s['toggle_slogan'], $s['toggle_node_user_picture'], $s['toggle_comment_user_picture'], $s['toggle_comment_user_verification'], $s['toggle_favicon'], $s['toggle_main_menu'], $s['toggle_secondary_menu'], $s['default_logo'], $s['logo_path'], $s['logo_upload'], $s['default_favicon'], $s['favicon_path'], $s['favicon_upload'], $s['theme_settings_export_code']);
$export_vars = '';
foreach ($s as $key => $val) {
if (isset($val) && !empty($val)) {
if (is_array($val)) {
foreach ($val as $k => $v) {
$export_vars .= "settings[" . $key . "][{$k}] = '" . $v . "'\n";
}
}
else {
$export_vars .= "settings[" . $key . "] = '" . $val . "'\n";
}
}
else {
$export_vars .= "settings[" . $key . "] = ''\n";
}
}
$form['omega_general']['omega_tools_export']['theme_settings_export_code'] = array(
'#type' => 'textarea',
'#title' => t('Export Code'),
'#default_value' => $export_vars,
'#description' => 'You will want to paste this code in the .info file of your subtheme and overwrite the entire settings[] section to properly export this code.',
);
}
else {
$form['omega_general']['omega_tools_export']['theme_settings_status'] = array(
'#markup' => 'Current Theme Settings status: <strong>In Code (.info)</strong>',
);
}
}
}
break;
}
}