protected function GeshiFilterFilter::perLanguageSettings in GeSHi Filter for syntax highlighting 8
Same name and namespace in other branches
- 8.2 src/Plugin/Filter/GeshiFilterFilter.php \Drupal\geshifilter\Plugin\Filter\GeshiFilterFilter::perLanguageSettings()
Function for generating a form table for per language settings.
Parameters
string $view: Which languages to show:
- enabled Show only enabled languages.
- disabled Show only disabled languages.
- all Show all languages.
bool $add_checkbox: When add(TRUE) or not a checkbox to enable languages.
bool $add_tag_option: When add(TRUE) or not a textbox to set the tags for a language.
Return value
array An array with form elements for languages.
1 call to GeshiFilterFilter::perLanguageSettings()
- GeshiFilterFilter::settingsForm in src/
Plugin/ Filter/ GeshiFilterFilter.php - Create the settings form for the filter.
File
- src/
Plugin/ Filter/ GeshiFilterFilter.php, line 582
Class
- GeshiFilterFilter
- Provides a base filter for Geshi Filter.
Namespace
Drupal\geshifilter\Plugin\FilterCode
protected function perLanguageSettings($view, $add_checkbox, $add_tag_option) {
$form = [];
$header = [
$this
->t('Language'),
$this
->t('GeSHi language code'),
];
if ($add_tag_option) {
$header[] = $this
->t('Tag/language attribute value');
}
$form['language'] = [
'#type' => 'table',
'#header' => $header,
'#empty' => $this
->t('Nome language is available.'),
];
// Table body.
$languages = GeshiFilter::getAvailableLanguages();
foreach ($languages as $language => $language_data) {
$enabled = $this->config
->get("language.{$language}.enabled", FALSE);
// Skip items to hide.
if ($view == 'enabled' && !$enabled || $view == 'disabled' && $enabled) {
continue;
}
// Build language row.
$form['language'][$language] = [];
// Add enable/disable checkbox.
if ($add_checkbox) {
$form['language'][$language]['enabled'] = [
'#type' => 'checkbox',
'#default_value' => $enabled,
'#title' => $language_data['fullname'],
];
}
else {
$form['language'][$language]['fullname'] = [
'#type' => 'markup',
'#markup' => $language_data['fullname'],
];
}
// Language code.
$form['language'][$language]['name'] = [
'#type' => 'markup',
'#markup' => $language,
];
// Add a textfield for tags.
if ($add_tag_option) {
$form['language'][$language]['tags'] = [
'#type' => 'textfield',
'#default_value' => $this->settings['per_language_settings']['table']['language'][$language]['tags'],
'#size' => 20,
];
}
}
return $form;
}