function lang_dropdown_block_configure in Language Switcher Dropdown 7
Same name and namespace in other branches
- 7.2 lang_dropdown.module \lang_dropdown_block_configure()
Implements hook_block_configure().
File
- ./
lang_dropdown.module, line 43
Code
function lang_dropdown_block_configure($delta = '') {
$settings = _lang_dropdown_get_settings($delta);
$form = array();
$form['lang_dropdown'] = array(
'#type' => 'fieldset',
'#title' => t('Language switcher dropdown settings'),
'#weight' => 0,
);
$form['lang_dropdown']['showall'] = array(
'#type' => 'checkbox',
'#title' => t('Show all enabled languages'),
'#description' => t('Show all languages in the switcher no matter if there is a translation for the node or not. For languages without translation the switcher will redirect to homepage.'),
'#default_value' => $settings['showall'],
);
$form['lang_dropdown']['tohome'] = array(
'#type' => 'checkbox',
'#title' => t('Redirect to home on switch'),
'#description' => t('When you change language the switcher will redirect to homepage.'),
'#default_value' => $settings['tohome'],
);
$form['lang_dropdown']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width of dropdown element'),
'#size' => 5,
'#maxlength' => 3,
'#required' => TRUE,
'#field_suffix' => 'px',
'#default_value' => $settings['js_widget_settings']['width'],
);
$form['lang_dropdown']['js_widget'] = array(
'#type' => 'select',
'#title' => t('Output type'),
'#options' => array(
'0' => t('Simple HTML select'),
'1' => t('Marghoob Suleman Dropdown jquery library'),
'2' => t('Chosen jquery library'),
),
'#description' => t('This looks better with <a href="!href">Language icons</a> module.', array(
'!href' => 'http://drupal.org/project/languageicons',
)),
'#default_value' => $settings['js_widget'],
'#element_validate' => array(
'_lang_dropdown_validate_output_value',
),
);
$form['lang_dropdown']['mssettings'] = array(
'#type' => 'fieldset',
'#title' => t('Marghoob Suleman Dropdown Settings'),
'#weight' => 1,
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$num_rows = array(
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
);
$form['lang_dropdown']['mssettings']['visible_rows'] = array(
'#type' => 'select',
'#title' => t('Maximum number of visible rows'),
'#options' => array_combine($num_rows, $num_rows),
'#default_value' => $settings['js_widget_settings']['visible_rows'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$form['lang_dropdown']['mssettings']['rounded'] = array(
'#type' => 'checkbox',
'#title' => t('Rounded corners.'),
'#default_value' => $settings['js_widget_settings']['rounded'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$form['lang_dropdown']['mssettings']['animation'] = array(
'#type' => 'select',
'#title' => t('Animation style for dropdown'),
'#options' => array(
'slideDown' => t('Slide down'),
'fadeIn' => t('Fade in'),
'show' => t('Show'),
),
'#default_value' => $settings['js_widget_settings']['animation'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$form['lang_dropdown']['mssettings']['event'] = array(
'#type' => 'select',
'#title' => t('Event that opens the menu'),
'#options' => array(
'click' => t('Click'),
'mouseover' => t('Mouse Over'),
),
'#default_value' => $settings['js_widget_settings']['event'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$skinOptions = array();
foreach (_lang_dropdown_get_skins() as $key => $value) {
$skinOptions[$key] = $value['text'];
}
$form['lang_dropdown']['mssettings']['skin'] = array(
'#type' => 'select',
'#title' => t('Skin'),
'#options' => $skinOptions,
'#default_value' => $settings['js_widget_settings']['skin'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
),
),
);
$form['lang_dropdown']['mssettings']['custom_skin'] = array(
'#type' => 'textfield',
'#title' => t('Custom skin'),
'#size' => 80,
'#maxlength' => 55,
'#default_value' => $settings['js_widget_settings']['custom_skin'],
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 1,
),
':input[name="skin"]' => array(
'value' => 'custom',
),
),
),
);
$form['lang_dropdown']['languageicons'] = array(
'#type' => 'fieldset',
'#title' => t('Language icons settings'),
'#weight' => 1,
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 0,
),
),
),
);
if (module_exists('languageicons')) {
$form['lang_dropdown']['languageicons']['flag_position'] = array(
'#type' => 'select',
'#title' => t('Position of the flag when the dropdown is show just as a select'),
'#options' => array(
0 => t('Before'),
1 => t('After'),
),
'#default_value' => $settings['languageicons']['flag_position'],
);
}
else {
$form['lang_dropdown']['languageicons']['#description'] = t('Enable <a href="!href">Language icons</a> to enhance the Language dropdown widget.', array(
'!href' => 'http://drupal.org/project/languageicons',
));
}
$form['lang_dropdown']['chosen'] = array(
'#type' => 'fieldset',
'#title' => t('Chosen settings'),
'#weight' => 1,
'#states' => array(
'visible' => array(
':input[name="js_widget"]' => array(
'value' => 2,
),
),
),
);
if (module_exists('chosen')) {
$form['lang_dropdown']['chosen']['#description'] = t('If you are already using the chosen module you must just choose to output language dropdown as a simple HTML select and allow chosen module to turn it into a chosen style select.');
}
else {
if (_get_chosen_path()) {
$form['lang_dropdown']['chosen']['disable_search'] = array(
'#type' => 'checkbox',
'#title' => t('Disable select box'),
'#default_value' => $settings['chosen']['disable_search'],
);
$form['lang_dropdown']['chosen']['no_results_text'] = array(
'#type' => 'textfield',
'#title' => t('No Result Text'),
'#description' => t('Text to show when no result is found on search.'),
'#default_value' => $settings['chosen']['no_results_text'],
'#states' => array(
'visible' => array(
':input[name="disable_search"]' => array(
'checked' => FALSE,
),
),
),
);
}
else {
$form['lang_dropdown']['chosen']['#description'] = t('You need to download the !chosen and extract the entire contents of the archive into the %path directory on your server.', array(
'!chosen' => l(t('Chosen JavaScript file'), CHOSEN_WEB_URL),
'%path' => 'sites/all/libraries',
));
}
}
return $form;
}