diff --git a/modules/media_internet/media_internet.module b/modules/media_internet/media_internet.module
index 90c1231..856e4c5 100644
--- a/modules/media_internet/media_internet.module
+++ b/modules/media_internet/media_internet.module
@@ -48,6 +48,18 @@ function media_internet_permission() {
}
/**
+ * Implements hook_theme().
+ */
+function media_internet_theme() {
+ return array(
+ // media_internet.pages.inc.
+ 'media_internet_embed_help' => array(
+ 'variables' => array('description' => NULL, 'supported_providers' => NULL),
+ ),
+ );
+}
+
+/**
* Gets the list of providers.
*
* A "Provider" is a bit of meta-data like a title and a logo and a class which
@@ -101,3 +113,30 @@ function media_internet_get_provider($embed_string) {
}
throw new MediaInternetNoHandlerException(t('Unable to handle the provided embed string or URL.'));
}
+
+/**
+ * Returns HTML for help text based on supported internet media providers.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - description: The normal description for this field, specified by the
+ * user.
+ * - supported_providers: A string of supported providers.
+ *
+ * @ingroup themeable
+ */
+function theme_media_internet_embed_help($variables) {
+ $description = $variables['description'];
+ $supported_providers = $variables['supported_providers'];
+
+ $descriptions = array();
+
+ if (strlen($description)) {
+ $descriptions[] = $description;
+ }
+ if (!empty($supported_providers)) {
+ $descriptions[] = t('Supported internet media providers: !providers.', array('!providers' => '' . $supported_providers . ''));
+ }
+
+ return implode('
', $descriptions);
+}
diff --git a/modules/media_internet/media_internet.pages.inc b/modules/media_internet/media_internet.pages.inc
index 2ec2307..9ef347b 100644
--- a/modules/media_internet/media_internet.pages.inc
+++ b/modules/media_internet/media_internet.pages.inc
@@ -29,30 +29,19 @@ function media_internet_add($form, &$form_state = array(), $types = NULL) {
// Determine if there are any visible providers.
foreach (media_internet_get_providers() as $key => $provider) {
if (empty($provider['hidden']) || $provider['hidden'] != TRUE) {
- $providers[] = array(
- 'data' => check_plain($provider['title']),
- 'class' => array(drupal_html_class($provider['title'])),
- );
+ $providers[] = check_plain($provider['title']);
}
}
+ $form['#providers'] = $providers;
+
// Notify the user of any available providers.
if ($providers) {
// If any providers are enabled it is assumed that some kind of embed is supported.
$form['embed_code']['#title'] = t('File URL or media resource');
$form['embed_code']['#description'] = t('Enter a URL to a file or media resource. Many media providers also support identifying media via the embed code used to embed the media into external websites.');
- // Providers are displayed in an unordered list below the embed input.
- // Providers can easily style their own listing by targeting the unique
- // class assigned to each list item.
- $form['providers'] = array(
- '#theme' => 'item_list',
- '#title' => t('Supported providers'),
- '#items' => $providers,
- '#attributes' => array(
- 'class' => array('media-internet-providers'),
- ),
- );
+ $form['embed_code']['#description'] = theme('media_internet_embed_help', array('description' => $form['embed_code']['#description'], 'supported_providers' => implode(' ', $providers)));
}
$form['#validators'] = array();