Commit b9f6051c authored by frjo's avatar frjo

Added token browser ui if the token module is installed, as in the Drupal 7 version.

parent 0fb008da
...@@ -176,16 +176,31 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl ...@@ -176,16 +176,31 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl
), ),
), ),
); );
$element['colorbox_token_gallery'] = array( if (\Drupal::moduleHandler()->moduleExists('token')) {
'#type' => 'fieldset', $element['colorbox_token_gallery'] = array(
'#title' => $this->t('Replacement patterns'), '#type' => 'fieldset',
'#description' => '<strong class="error">' . $this->t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>', '#title' => t('Replacement patterns'),
'#states' => array( '#theme' => 'token_tree_link',
'visible' => array( '#token_types' => array($form['#entity_type'], 'file'),
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'), '#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
),
), ),
), );
); }
else {
$element['colorbox_token_gallery'] = array(
'#type' => 'fieldset',
'#title' => $this->t('Replacement patterns'),
'#description' => '<strong class="error">' . $this->t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>',
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
),
),
);
}
$caption = array( $caption = array(
'auto' => $this->t('Automatic'), 'auto' => $this->t('Automatic'),
...@@ -212,16 +227,31 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl ...@@ -212,16 +227,31 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl
), ),
), ),
); );
$element['colorbox_token_caption'] = array( if (\Drupal::moduleHandler()->moduleExists('token')) {
'#type' => 'fieldset', $element['colorbox_token_caption'] = array(
'#title' => $this->t('Replacement patterns'), '#type' => 'fieldset',
'#description' => '<strong class="error">' . $this->t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>', '#title' => t('Replacement patterns'),
'#states' => array( '#theme' => 'token_tree_link',
'visible' => array( '#token_types' => array($form['#entity_type'], 'file'),
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'), '#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
),
), ),
), );
); }
else {
$element['colorbox_token_caption'] = array(
'#type' => 'fieldset',
'#title' => $this->t('Replacement patterns'),
'#description' => '<strong class="error">' . $this->t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>',
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
),
),
);
}
return $element; return $element;
} }
......
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