contrib modules updates

This commit is contained in:
2019-02-27 10:39:59 +01:00
parent 04a4b8895d
commit e3cf889820
579 changed files with 18343 additions and 4076 deletions
@@ -9,11 +9,62 @@ use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Random;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Asset\LibraryDiscovery;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Messenger\Messenger;
use Drupal\Core\Logger\LoggerChannelFactoryInterface ;
/**
* Base class for audiofield plugins. Includes global functions.
*/
abstract class AudioFieldPluginBase extends PluginBase {
abstract class AudioFieldPluginBase extends PluginBase implements ContainerFactoryPluginInterface {
/**
* Library discovery service.
*
* @var Drupal\Core\Asset\LibraryDiscovery
*/
protected $libraryDiscovery;
/**
* Messenger service.
*
* @var Drupal\Core\Messenger\Messenger
*/
protected $messenger;
/**
* Messenger service.
*
* @var Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $loggerFactory;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, Messenger $messenger, LoggerChannelFactoryInterface $logger_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->libraryDiscovery = $library_discovery;
$this->messenger = $messenger;
$this->loggerFactory = $logger_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('library.discovery'),
$container->get('messenger'),
$container->get('logger.factory')
);
}
/**
* Renders the player.
@@ -68,7 +119,7 @@ abstract class AudioFieldPluginBase extends PluginBase {
*/
public function getPluginLibrary() {
// Get the main library for this plugin.
return \Drupal::service('library.discovery')->getLibraryByName('audiofield', 'audiofield.' . $this->getPluginLibraryName());
return $this->libraryDiscovery->getLibraryByName('audiofield', 'audiofield.' . $this->getPluginLibraryName());
}
/**
@@ -170,8 +221,8 @@ abstract class AudioFieldPluginBase extends PluginBase {
'%command' => 'drush audiofield-update',
'@status_report' => Link::createFromRoute('status report', 'system.status')->toString(),
];
\Drupal::logger('audiofield')->warning('Warning: @plugin library is out of date. You should upgrade from version @version to version @newversion. You can manually download the required version here: @download-link or you can install automatically by running the command %command. See the @status_report for more information', $message_data);
drupal_set_message(t('Warning: @plugin library is out of date. You should upgrade from version @version to version @newversion. You can manually download the required version here: @download-link or you can install automatically by running the command %command. See the @status_report for more information', $message_data), 'warning');
$this->loggerFactory->get('audiofield')->warning('Warning: @plugin library is out of date. You should upgrade from version @version to version @newversion. You can manually download the required version here: @download-link or you can install automatically by running the command %command. See the @status_report for more information', $message_data);
$this->messenger->addWarning(t('Warning: @plugin library is out of date. You should upgrade from version @version to version @newversion. You can manually download the required version here: @download-link or you can install automatically by running the command %command. See the @status_report for more information', $message_data));
}
return FALSE;
}
@@ -186,8 +237,8 @@ abstract class AudioFieldPluginBase extends PluginBase {
'@library_name' => $this->getPluginLibraryName(),
'@status_report' => Link::createFromRoute('status report', 'system.status')->toString(),
];
\Drupal::logger('audiofield')->error('Error: @library_name library is not currently installed! See the @status_report for more information.', $message_data);
drupal_set_message(t('Error: @library_name library is not currently installed! See the @status_report for more information.', $message_data), 'error');
$this->loggerFactory->get('audiofield')->error('Error: @library_name library is not currently installed! See the @status_report for more information.', $message_data);
$this->messenger->addWarning(t('Error: @library_name library is not currently installed! See the @status_report for more information.', $message_data));
}
/**
@@ -208,8 +259,8 @@ abstract class AudioFieldPluginBase extends PluginBase {
'@player' => $this->getPluginLibraryName(),
'%extensions' => implode(', ', $this->pluginDefinition["fileTypes"]),
];
\Drupal::logger('audiofield')->error('Error playing file %filename: currently selected audio player only supports the following extensions: %extensions', $message_data);
drupal_set_message(t('Error playing file %filename: currently selected audio player only supports the following extensions: %extensions', $message_data), 'error');
$this->loggerFactory->get('audiofield')->error('Error playing file %filename: currently selected audio player only supports the following extensions: %extensions', $message_data);
$this->messenger->addWarning(t('Error playing file %filename: currently selected audio player only supports the following extensions: %extensions', $message_data));
return FALSE;
}
return TRUE;
@@ -232,8 +283,8 @@ abstract class AudioFieldPluginBase extends PluginBase {
$message_data = [
'%link' => $link->toString(),
];
\Drupal::logger('audiofield')->error('Error playing file: invalid link: %link', $message_data);
drupal_set_message(t('Error playing file: invalid link: %link', $message_data), 'error');
$this->loggerFactory->get('audiofield')->error('Error playing file: invalid link: %link', $message_data);
$this->messenger->addWarning(t('Error playing file: invalid link: %link', $message_data));
return FALSE;
}
return TRUE;
@@ -366,20 +417,19 @@ abstract class AudioFieldPluginBase extends PluginBase {
* The source URL of an entity.
*/
private function getAudioSource($item) {
$source_url = '';
if ($this->getClassType($item) == 'FileItem') {
// Load the associated file.
$file = $this->loadFileFromItem($item);
// Get the file URL.
$source_url = Url::fromUri(file_create_url($file->getFileUri()));
return Url::fromUri(file_create_url($file->getFileUri()));
}
// Handle Link entity.
elseif ($this->getClassType($item) == 'LinkItem') {
// Get the file URL.
$source_url = $item->getUrl();
return $item->getUrl();
}
return $source_url;
return '';
}
/**
@@ -392,7 +442,6 @@ abstract class AudioFieldPluginBase extends PluginBase {
* The description of an entity.
*/
private function getAudioDescription($item) {
$entity_description = '';
if ($this->getClassType($item) == 'FileItem') {
// Get the file description - use the filename if it doesn't exist.
$entity_description = $item->get('description')->getString();
@@ -400,19 +449,20 @@ abstract class AudioFieldPluginBase extends PluginBase {
// Load the associated file.
$file = $this->loadFileFromItem($item);
$entity_description = $file->getFilename();
return $file->getFilename();
}
return $entity_description;
}
// Handle Link entity.
elseif ($this->getClassType($item) == 'LinkItem') {
// Get the file description - use the filename if it doesn't exist.
$entity_description = $item->get('title')->getString();
if (empty($entity_description)) {
$entity_description = $item->getUrl()->toString();
return $item->getUrl()->toString();
}
return $entity_description;
}
return $entity_description;
return '';
}
/**
@@ -476,51 +526,29 @@ abstract class AudioFieldPluginBase extends PluginBase {
* A render array containing download links.
*/
public function createDownloadList($items, array $settings) {
$download_links = [];
// Check if download links are turned on.
if ($settings['download_link']) {
// Loop over each item.
foreach ($items as $item) {
// Get the source URL for this item.
$source_url = $this->getAudioSource($item);
// Get the entity description for this item.
$entity_description = $this->getAudioDescription($item);
// Add the link.
$download_links[] = [
'#markup' => Link::fromTextAndUrl($entity_description, $source_url)->toString(),
'#wrapper_attributes' => [
'class' => [
'audiofield-download-link',
],
],
];
}
// Check if download links are turned on and there are items.
if (!$settings['download_link'] || count($items) == 0) {
return [];
}
// Render links if we have them.
$download_render_array = [];
if (count($download_links) > 0) {
$download_render_array = [
'#theme' => 'item_list',
'#list_type' => 'ul',
'#title' => t('Download files:'),
'#wrapper_attributes' => [
'class' => [
'audiofield-downloads',
],
],
'#attributes' => [],
'#empty' => '',
'#items' => $download_links,
$links = [];
// Loop over each item.
foreach ($items as $item) {
// Get the source URL for this item.
$source_url = $this->getAudioSource($item);
// Get the entity description for this item.
$entity_description = $this->getAudioDescription($item);
// Add the link.
$links[] = [
'link' => Link::fromTextAndUrl($entity_description, $source_url)->toString(),
];
}
return [
'#theme' => 'audiofield_download_links',
'#links' => $download_render_array,
'#links' => $links,
];
}
@@ -0,0 +1,268 @@
<?php
namespace Drupal\audiofield\Commands;
use Drush\Commands\DrushCommands;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Drupal\audiofield\AudioFieldPlayerManager;
/**
* A Drush commandfile for Audiofield module.
*/
class AudiofieldCommands extends DrushCommands {
/**
* Library discovery service.
*
* @var Drupal\audiofield\AudioFieldPlayerManager
*/
protected $playerManager;
/**
* {@inheritdoc}
*/
public function __construct(AudioFieldPlayerManager $player_manager) {
$this->playerManager = $player_manager;
}
/**
* Downloads the suggested Audiofield libraries from their remote repos.
*
* @param string $installLibrary
* The name of the library. If omitted, all libraries will be installed.
* @param bool $print_messages
* Flag indicating if messages should be displayed.
*
* @command audiofield:download
* @aliases audiofield-download
*/
public function download($installLibrary = '', $print_messages = TRUE) {
// Declare filesystem container.
$fs = new Filesystem();
// Get a list of the audiofield plugins.
$pluginList = $this->playerManager->getDefinitions();
// If there is an argument, check to make sure its valid.
if (!empty($installLibrary)) {
if (!isset($pluginList[$installLibrary . '_audio_player'])) {
$this->logger()->error(dt('Error: @library is not a valid Audiofield library.', [
'@library' => $installLibrary,
], 'error'));
return;
}
// If the argument is valid, we only want to install that plugin.
$pluginList = [$installLibrary . '_audio_player' => $pluginList[$installLibrary . '_audio_player']];
}
// Loop over each plugin and make sure it's library is installed.
foreach ($pluginList as $pluginName => $plugin) {
// Create an instance of this plugin.
$pluginInstance = $this->playerManager->createInstance($pluginName);
// Only check install if there is a library for the plugin.
if (!$pluginInstance->getPluginLibrary()) {
continue;
}
// Skip if the plugin is installed.
if ($pluginInstance->checkInstalled()) {
if ($print_messages) {
$this->logger()->notice(dt('Audiofield library for @library is already installed at @location', [
'@library' => $pluginInstance->getPluginTitle(),
'@location' => $pluginInstance->getPluginLibraryPath(),
], 'success'));
}
continue;
}
// Get the library install path.
$path = DRUPAL_ROOT . $pluginInstance->getPluginLibraryPath();
// Create the install directory if it does not exist.
if (!is_dir($path)) {
$fs->mkdir($path);
}
// Download the file.
$client = new Client();
$destination = tempnam(sys_get_temp_dir(), 'file.') . "tar.gz";
try {
$client->get($pluginInstance->getPluginRemoteSource(), ['save_to' => $destination]);
}
catch (RequestException $e) {
// Remove the directory.
$fs->remove($path);
$this->logger()->error(dt('Error: unable to download @library. @exception', [
'@library' => $pluginInstance->getPluginTitle(),
'@exception' => $e->getMessage(),
], 'error'));
continue;
}
$fs->rename($destination, $path . '/audiofield-dl.zip');
if (!file_exists($path . '/audiofield-dl.zip')) {
// Remove the directory where we tried to install.
$fs->remove($path);
if ($print_messages) {
$this->logger()->error(dt('Error: unable to download Audiofield library @library', [
'@library' => $pluginInstance->getPluginTitle(),
], 'error'));
continue;
}
}
// Unzip the file.
$zip = new \ZipArchive();
$res = $zip->open($path . '/audiofield-dl.zip');
if ($res === TRUE) {
$zip->extractTo($path);
$zip->close();
}
else {
// Remove the directory.
$fs->remove($path);
$this->logger()->error(dt('Error: unable to unzip @library.', [
'@library' => $pluginInstance->getPluginTitle(),
], 'error'));
continue;
}
// Remove the downloaded zip file.
$fs->remove($path . '/audiofield-dl.zip');
// If the library still is not installed, we need to move files.
if (!$pluginInstance->checkInstalled()) {
// Find all folders in this directory and move their
// subdirectories up to the parent directory.
$directories = Finder::create()
->directories()
->depth('< 1')
->in($path)
->ignoreDotFiles(TRUE)
->ignoreVCS(TRUE);
foreach ($directories as $dirName) {
$fs->mirror($dirName, $path, NULL, ['override' => TRUE]);
$fs->remove($dirName);
}
// Projekktor source files need to be installed.
if ($pluginInstance->getPluginId() == 'projekktor_audio_player') {
drush_op('chdir', '..');
drush_op('chdir', $path);
drush_shell_exec('npm install');
drush_shell_exec('grunt --force');
}
}
if ($pluginInstance->checkInstalled()) {
if ($print_messages) {
$this->logger()->notice(dt('Audiofield library for @library has been successfully installed at @location', [
'@library' => $pluginInstance->getPluginTitle(),
'@location' => $pluginInstance->getPluginLibraryPath(),
], 'success'));
}
}
else {
// Remove the directory where we tried to install.
$fs->remove($path);
if ($print_messages) {
$this->logger()->error(dt('Error: unable to install Audiofield library @library', [
'@library' => $pluginInstance->getPluginTitle(),
], 'error'));
}
}
}
}
/**
* Updates Audiofield libraries from their remote repos if out of date.
*
* @param string $updateLibrary
* The name of the library. If omitted, all libraries will be updated.
* @param bool $print_messages
* Flag indicating if messages should be displayed.
*
* @command audiofield:update
* @aliases audiofield-update
*/
public function update($updateLibrary = '', $print_messages = TRUE) {
// Declare filesystem container.
$fs = new Filesystem();
// Get a list of the audiofield plugins.
$pluginList = $this->playerManager->getDefinitions();
// If there is an argument, check to make sure its valid.
if (!empty($updateLibrary)) {
if (!isset($pluginList[$updateLibrary . '_audio_player'])) {
$this->logger()->error(dt('Error: @library is not a valid Audiofield library.', [
'@library' => $updateLibrary,
], 'error'));
return;
}
// If the argument is valid, we only want to install that plugin.
$pluginList = [$updateLibrary . '_audio_player' => $pluginList[$updateLibrary . '_audio_player']];
}
// Loop over each plugin and make sure it's library is installed.
foreach ($pluginList as $pluginName => $plugin) {
// Create an instance of this plugin.
$pluginInstance = $this->playerManager->createInstance($pluginName);
// Only check install if there is a library for the plugin.
if (!$pluginInstance->getPluginLibrary()) {
continue;
}
// Get the library install path.
$path = DRUPAL_ROOT . $pluginInstance->getPluginLibraryPath();
// If the library isn't installed at all we just run the install.
if (!$pluginInstance->checkInstalled(FALSE)) {
$this->download($pluginInstance->getPluginLibraryName());
continue;
}
// Don't updating the library if its up to date.
if ($pluginInstance->checkVersion(FALSE)) {
$this->logger()->notice(dt('Audiofield library for @library is already up to date', [
'@library' => $pluginInstance->getPluginTitle(),
], 'success'));
continue;
}
// Move the current installation to the temp directory.
$fs->rename($path, file_directory_temp() . '/temp_audiofield', TRUE);
// If the directory failed to move, just delete it.
if (is_dir($path)) {
$fs->remove($path);
}
// Run the install command now to get the latest version.
$this->download($updateLibrary, FALSE);
// Check if library has been properly installed.
if ($pluginInstance->checkInstalled()) {
// Remove the temporary directory.
$fs->remove(file_directory_temp() . '/temp_audiofield');
$this->logger()->notice(dt('Audiofield library for @library has been successfully updated at @location', [
'@library' => $pluginInstance->getPluginTitle(),
'@location' => $pluginInstance->getPluginLibraryPath(),
], 'success'));
}
else {
// Remove the directory where we tried to install.
$fs->remove($path);
$this->logger()->error(dt('Error: unable to update Audiofield library @library', [
'@library' => $pluginInstance->getPluginTitle(),
], 'error'));
// Restore the original install since we failed to update.
$fs->rename(file_directory_temp() . '/temp_audiofield', $path, TRUE);
}
}
}
}
@@ -45,6 +45,18 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase {
'volume' => ($settings['audio_player_initial_volume'] / 10),
'playertype' => ($settings['audio_player_wavesurfer_combine_files'] ? 'playlist' : 'default'),
'files' => [],
'audioRate' => $settings['audio_player_wavesurfer_audiorate'],
'autoCenter' => $settings['audio_player_wavesurfer_autocenter'],
'barGap' => $settings['audio_player_wavesurfer_bargap'],
'barHeight' => $settings['audio_player_wavesurfer_barheight'],
'barWidth' => $settings['audio_player_wavesurfer_barwidth'],
'cursorColor' => $settings['audio_player_wavesurfer_cursorcolor'],
'cursorWidth' => $settings['audio_player_wavesurfer_cursorwidth'],
'forceDecode' => $settings['audio_player_wavesurfer_forcedecode'],
'normalize' => $settings['audio_player_wavesurfer_normalize'],
'progressColor' => $settings['audio_player_wavesurfer_progresscolor'],
'responsive' => $settings['audio_player_wavesurfer_responsive'],
'waveColor' => $settings['audio_player_wavesurfer_wavecolor'],
'autoplay' => $settings['audio_player_autoplay'],
];
@@ -138,6 +138,140 @@ class AudioFieldFieldFormatter extends FormatterBase implements ContainerFactory
],
],
];
// Settings for WaveSurfer.
$elements['audio_player_wavesurfer_audiorate'] = [
'#type' => 'number',
'#title' => $this->t('Audio Rate'),
'#description' => $this->t("Speed at which to play audio. Lower number is slower."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_audiorate'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_autocenter'] = [
'#type' => 'checkbox',
'#title' => $this->t('Auto Center'),
'#description' => $this->t("If a scrollbar is present, center the waveform around the progress."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_autocenter'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_bargap'] = [
'#type' => 'number',
'#title' => $this->t('Bar Gap'),
'#description' => $this->t("The optional spacing between bars of the wave."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_bargap'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_barheight'] = [
'#type' => 'number',
'#title' => $this->t('Bar Height'),
'#description' => $this->t("Height of the waveform bars. Higher number than 1 will increase the waveform bar heights."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_barheight'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_barwidth'] = [
'#type' => 'number',
'#title' => $this->t('Bar Width'),
'#description' => $this->t("If specified, the waveform will be drawn like this: ▁ ▂ ▇ ▃ ▅ ▂"),
'#default_value' => $this->getSetting('audio_player_wavesurfer_barwidth'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_cursorcolor'] = [
'#type' => 'color',
'#title' => $this->t('Cursor Color'),
'#description' => $this->t("The fill color of the cursor indicating the playhead position."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_cursorcolor'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_cursorwidth'] = [
'#type' => 'number',
'#title' => $this->t('Cursor Width'),
'#description' => $this->t("Width of the cursor indicating the playhead position. Measured in pixels."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_cursorwidth'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_forcedecode'] = [
'#type' => 'checkbox',
'#title' => $this->t('Force Decode'),
'#description' => $this->t("Force decoding of audio using web audio when zooming to get a more detailed waveform."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_forcedecode'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_normalize'] = [
'#type' => 'checkbox',
'#title' => $this->t('Normalize'),
'#description' => $this->t("If checked, normalize by the maximum peak instead of 1.0."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_normalize'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_progresscolor'] = [
'#type' => 'color',
'#title' => $this->t('Progress Color'),
'#description' => $this->t("The fill color of the part of the waveform behind the cursor."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_progresscolor'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_responsive'] = [
'#type' => 'checkbox',
'#title' => $this->t('Responsive'),
'#description' => $this->t("If checked, resize the waveform, when the window is resized. This is debounced with a 100ms timeout by default."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_responsive'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
$elements['audio_player_wavesurfer_wavecolor'] = [
'#type' => 'color',
'#title' => $this->t('Wave Color'),
'#description' => $this->t("The fill color of the waveform after the cursor."),
'#default_value' => $this->getSetting('audio_player_wavesurfer_wavecolor'),
'#states' => [
'visible' => [
[':input[name="fields[' . $fieldname . '][settings_edit_form][settings][audio_player]"]' => ['value' => 'wavesurfer_audio_player']],
],
],
];
// Settings for WordPress.
// Only show when WordPress is the selected audio player.
$elements['audio_player_wordpress_combine_files'] = [
@@ -291,6 +425,42 @@ class AudioFieldFieldFormatter extends FormatterBase implements ContainerFactory
$summary[] = $this->t('Combine files into single player? <strong>@combine</strong>', [
'@combine' => ($settings['audio_player_wavesurfer_combine_files'] ? 'Yes' : 'No'),
]);
$summary[] = $this->t('Audio Rate: <strong>@value</strong>', [
'@value' => $settings['audio_player_wavesurfer_audiorate'],
]);
$summary[] = $this->t('Auto Center? <strong>@value</strong>', [
'@value' => ($settings['audio_player_wavesurfer_autocenter'] ? 'Yes' : 'No'),
]);
$summary[] = $this->t('Bar Gap: <strong>@value</strong>', [
'@value' => $settings['audio_player_wavesurfer_bargap'],
]);
$summary[] = $this->t('Bar Height: <strong>@value</strong>', [
'@value' => $settings['audio_player_wavesurfer_barheight'],
]);
$summary[] = $this->t('Bar Width: <strong>@value</strong>', [
'@value' => $settings['audio_player_wavesurfer_barwidth'],
]);
$summary[] = $this->t('Cursor Color: <span style="border:1px solid black;height:10px;width:10px;display:inline-block;background:@value;"></span>', [
'@value' => $settings['audio_player_wavesurfer_cursorcolor'],
]);
$summary[] = $this->t('Cursor Width: <strong>@value</strong>', [
'@value' => $settings['audio_player_wavesurfer_cursorwidth'],
]);
$summary[] = $this->t('Force Decode? <strong>@value</strong>', [
'@value' => ($settings['audio_player_wavesurfer_forcedecode'] ? 'Yes' : 'No'),
]);
$summary[] = $this->t('Normalize? <strong>@value</strong>', [
'@value' => ($settings['audio_player_wavesurfer_normalize'] ? 'Yes' : 'No'),
]);
$summary[] = $this->t('Progress Color: <span style="border:1px solid black;height:10px;width:10px;display:inline-block;background:@value;"></span>', [
'@value' => $settings['audio_player_wavesurfer_progresscolor'],
]);
$summary[] = $this->t('Responsive? <strong>@value</strong>', [
'@value' => ($settings['audio_player_wavesurfer_responsive'] ? 'Yes' : 'No'),
]);
$summary[] = $this->t('Wave Color: <span style="border:1px solid black;height:10px;width:10px;display:inline-block;background:@value;"></span>', [
'@value' => $settings['audio_player_wavesurfer_wavecolor'],
]);
}
// If this is wordpress, add those settings.
elseif ($settings['audio_player'] == 'wordpress_audio_player') {
@@ -384,6 +554,18 @@ class AudioFieldFieldFormatter extends FormatterBase implements ContainerFactory
'audio_player' => 'default_mp3_player',
'audio_player_jplayer_theme' => 'none',
'audio_player_wavesurfer_combine_files' => FALSE,
'audio_player_wavesurfer_audiorate' => 1,
'audio_player_wavesurfer_autocenter' => TRUE,
'audio_player_wavesurfer_bargap' => 0,
'audio_player_wavesurfer_barheight' => 1,
'audio_player_wavesurfer_barwidth' => NULL,
'audio_player_wavesurfer_cursorcolor' => '#333',
'audio_player_wavesurfer_cursorwidth' => 1,
'audio_player_wavesurfer_forcedecode' => FALSE,
'audio_player_wavesurfer_normalize' => FALSE,
'audio_player_wavesurfer_progresscolor' => '#555',
'audio_player_wavesurfer_responsive' => FALSE,
'audio_player_wavesurfer_wavecolor' => '#999',
'audio_player_wordpress_combine_files' => FALSE,
'audio_player_wordpress_animation' => TRUE,
'audio_player_soundmanager_theme' => 'default',