Commit 76b3f7de authored by catch's avatar catch

Issue #2077979 by cilefen, plopesc: Modernize filter.module forms: use $this->t().

parent ba16dfb8
......@@ -24,7 +24,7 @@ public function form(array $form, array &$form_state) {
*/
public function submit(array $form, array &$form_state) {
parent::submit($form, $form_state);
drupal_set_message(t('Added text format %format.', array('%format' => $this->entity->label())));
drupal_set_message($this->t('Added text format %format.', array('%format' => $this->entity->label())));
return $this->entity;
}
......
......@@ -33,7 +33,7 @@ public function form(array $form, array &$form_state) {
*/
public function submit(array $form, array &$form_state) {
parent::submit($form, $form_state);
drupal_set_message(t('The text format %format has been updated.', array('%format' => $this->entity->label())));
drupal_set_message($this->t('The text format %format has been updated.', array('%format' => $this->entity->label())));
return $this->entity;
}
......
......@@ -56,7 +56,7 @@ public function form(array $form, array &$form_state) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#title' => $this->t('Name'),
'#default_value' => $format->label(),
'#required' => TRUE,
'#weight' => -30,
......@@ -77,13 +77,13 @@ public function form(array $form, array &$form_state) {
// Add user role access selection.
$form['roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#title' => $this->t('Roles'),
'#options' => array_map('\Drupal\Component\Utility\String::checkPlain', user_role_names()),
'#disabled' => $is_fallback,
'#weight' => -10,
);
if ($is_fallback) {
$form['roles']['#description'] = t('All roles for this text format must be enabled and cannot be changed.');
$form['roles']['#description'] = $this->t('All roles for this text format must be enabled and cannot be changed.');
}
if (!$format->isNew()) {
// If editing an existing text format, pre-select its current permissions.
......@@ -103,7 +103,7 @@ public function form(array $form, array &$form_state) {
// When a filter is missing, it is replaced by the null filter. Remove it
// here, so that saving the form will remove the missing filter.
if ($filter instanceof FilterNull) {
drupal_set_message(t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
drupal_set_message($this->t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
$filters->removeInstanceID($filter_id);
}
}
......@@ -111,7 +111,7 @@ public function form(array $form, array &$form_state) {
// Filter status.
$form['filters']['status'] = array(
'#type' => 'item',
'#title' => t('Enabled filters'),
'#title' => $this->t('Enabled filters'),
'#prefix' => '<div id="filters-status-wrapper">',
'#suffix' => '</div>',
// This item is used as a pure wrapping container with heading. Ignore its
......@@ -124,7 +124,7 @@ public function form(array $form, array &$form_state) {
'#type' => 'table',
// For filter.admin.js
'#attributes' => array('id' => 'filter-order'),
'#title' => t('Filter processing order'),
'#title' => $this->t('Filter processing order'),
'#tabledrag' => array(
array(
'action' => 'order',
......@@ -139,7 +139,7 @@ public function form(array $form, array &$form_state) {
// Filter settings.
$form['filter_settings'] = array(
'#type' => 'vertical_tabs',
'#title' => t('Filter settings'),
'#title' => $this->t('Filter settings'),
);
foreach ($filters as $name => $filter) {
......@@ -159,7 +159,7 @@ public function form(array $form, array &$form_state) {
);
$form['filters']['order'][$name]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $filter->getLabel())),
'#title' => $this->t('Weight for @title', array('@title' => $filter->getLabel())),
'#title_display' => 'invisible',
'#delta' => 50,
'#default_value' => $filter->weight,
......@@ -267,7 +267,7 @@ public function submit(array $form, array &$form_state) {
*/
protected function actions(array $form, array &$form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = t('Save configuration');
$actions['submit']['#value'] = $this->t('Save configuration');
return $actions;
}
......
......@@ -82,8 +82,8 @@ public function load() {
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = t('Name');
$header['roles'] = t('Roles');
$header['label'] = $this->t('Name');
$header['roles'] = $this->t('Roles');
return $header + parent::buildHeader();
}
......@@ -98,16 +98,16 @@ public function buildRow(EntityInterface $entity) {
$fallback_choice = $this->configFactory->get('filter.settings')->get('always_show_fallback_choice');
if ($fallback_choice) {
$roles_markup = String::placeholder(t('All roles may use this format'));
$roles_markup = String::placeholder($this->t('All roles may use this format'));
}
else {
$roles_markup = String::placeholder(t('This format is shown when no other formats are available'));
$roles_markup = String::placeholder($this->t('This format is shown when no other formats are available'));
}
}
else {
$row['label'] = $this->getLabel($entity);
$roles = array_map('\Drupal\Component\Utility\String::checkPlain', filter_get_roles_by_format($entity));
$roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format');
$roles_markup = $roles ? implode(', ', $roles) : $this->t('No roles may use this format');
}
$row['roles'] = !empty($this->weightKey) ? array('#markup' => $roles_markup) : $roles_markup;
......@@ -122,7 +122,7 @@ public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['title'] = t('Configure');
$operations['edit']['title'] = $this->t('Configure');
}
// The fallback format may not be disabled.
......@@ -138,7 +138,7 @@ public function getDefaultOperations(EntityInterface $entity) {
*/
public function buildForm(array $form, array &$form_state) {
$form = parent::buildForm($form, $form_state);
$form['actions']['submit']['#value'] = t('Save changes');
$form['actions']['submit']['#value'] = $this->t('Save changes');
return $form;
}
/**
......@@ -148,7 +148,7 @@ public function submitForm(array &$form, array &$form_state) {
parent::submitForm($form, $form_state);
filter_formats_reset();
drupal_set_message(t('The text format ordering has been saved.'));
drupal_set_message($this->t('The text format ordering has been saved.'));
}
}
......@@ -19,7 +19,7 @@ class FilterDisableForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
return t('Are you sure you want to disable the text format %format?', array('%format' => $this->entity->label()));
return $this->t('Are you sure you want to disable the text format %format?', array('%format' => $this->entity->label()));
}
/**
......@@ -33,14 +33,14 @@ public function getCancelRoute() {
* {@inheritdoc}
*/
public function getConfirmText() {
return t('Disable');
return $this->t('Disable');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.');
return $this->t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.');
}
/**
......@@ -48,7 +48,7 @@ public function getDescription() {
*/
public function submit(array $form, array &$form_state) {
$this->entity->disable()->save();
drupal_set_message(t('Disabled text format %format.', array('%format' => $this->entity->label())));
drupal_set_message($this->t('Disabled text format %format.', array('%format' => $this->entity->label())));
$form_state['redirect_route'] = $this->getCancelRoute();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment