public function sweaver_plugin_themesettings::sweaver_form in Sweaver 6
Same name and namespace in other branches
- 7 plugins/sweaver_plugin_themesettings/sweaver_plugin_themesettings.inc \sweaver_plugin_themesettings::sweaver_form()
Frontend form.
Overrides sweaver_plugin::sweaver_form
File
- plugins/
sweaver_plugin_themesettings/ sweaver_plugin_themesettings.inc, line 28 - Theme settings plugin.
Class
- sweaver_plugin_themesettings
- @file Theme settings plugin.
Code
public function sweaver_form() {
$form = array();
$form['#popups'] = array();
// Get theme settings form.
$themesettings = array();
$sweaver = Sweaver::get_instance();
$sweaver_style = $sweaver
->get_current_style();
if (isset($sweaver_style->themesettings) && !empty($sweaver_style->themesettings)) {
$themesettings = unserialize($sweaver_style->themesettings);
}
$form = $this
->sweaver_get_theme_settings_form($sweaver
->get_theme_key(), $themesettings);
// Add extra property for theme settings which need to be saved also.
// Form alters on the theme settings form must be put those keys in this array.
$form['#sweaver_other_themesettings'] = array();
// Let other modules alter the form.
$form_state = array();
drupal_prepare_form('system_theme_settings', $form, $form_state);
// We need to unset the #type, otherwise a nested form is created, which breaks in IE7.
unset($form['#type']);
// Convert all fieldsets to buttons. The content of those fieldsets
// will be moved into the Sweaver popup.
$i = 1;
$weight = -100;
foreach (element_children($form) as $key) {
if (isset($form[$key]['#type']) && $form[$key]['#type'] == 'fieldset') {
// Skip fieldsets which the user doesn't have access to.
if (isset($form[$key]['#access']) && $form[$key]['#access'] === FALSE) {
continue;
}
$title = $form[$key]['#title'];
$form['item_' . $i] = array(
'#type' => 'markup',
'#value' => '<div class="popup-link"><a href="#" id="theme-settings-link-' . $i . '">' . check_plain($title) . '</a></div>',
'#weight' => $weight++,
);
if (isset($form[$key]['#prefix'])) {
$form[$key]['#prefix'] .= '<div style="display:none" id="theme-settings-data-' . $i . '">';
}
else {
$form[$key]['#prefix'] = '<div style="display:none"id="theme-settings-data-' . $i . '">';
}
if (isset($form[$key]['#suffix'])) {
$form[$key]['#suffix'] = '</div>' . $form[$key]['#suffix'];
}
else {
$form[$key]['#suffix'] = '</div>';
}
unset($form[$key]['#collapsible']);
unset($form[$key]['#collapsed']);
unset($form[$key]['#attributes']);
// Add to popups.
$form['#popups'][] = $key;
$i++;
}
}
// Deny access to the buttons and add our own.
$form['buttons']['#access'] = FALSE;
$form['theme_settings_apply'] = array(
'#type' => 'submit',
'#value' => t('Apply theme settings'),
'#prefix' => '<div class="clear-block"></div>',
);
return $form;
}