You are here

function _subscriptions_mail_mail_edit_form_extra in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 7 subscriptions_mail.mail_edit.inc \_subscriptions_mail_mail_edit_form_extra()

Implements hook_mail_edit_form_extra().

Customize Mail Editor's edit template page.

_state

Parameters

array $form:

$mailkey:

array $template:

1 call to _subscriptions_mail_mail_edit_form_extra()
subscriptions_mail_mail_edit_form_extra in subscriptions_mail/subscriptions_mail.module
Implements hook_mail_edit_form_extra().

File

subscriptions_mail/subscriptions_mail.mail_edit.inc, line 97
Subscriptions_mail module integration with Mail Editor module.

Code

function _subscriptions_mail_mail_edit_form_extra(array &$form, array &$form_state, $mailkey, array $template) {
  if ($mailkey == 'digest') {
    $form['mail']['body']['#description'] = t('The mail body contains a repeat loop that pulls in multiple items that are ready for sending. Recommended tokens: <ul><li>@t1 and @t2<br />Note: Accessing parts of an item requires casting the item to the correct item type, e.g. @t4.</li> <li>@t3</li></ul>', array(
      '@t1' => '[subs:items]',
      '@t2' => '[subs:manage-url]',
      '@t3' => '[current-user:*]',
      '@t4' => '[subs:items:index:#0:as-node:title]',
    ));
  }
  else {
    if ($mailkey == '.DEFAULT') {
      $form['explain_default'] = array(
        '#markup' => t('This template serves a double purpose for all other !Subscriptions templates (except for the %digest template):<ul><li>it is used as default template where no customized template exists, and</li><li>it serves as starting point for adding new templates.</li></ul>', array(
          '!Subscriptions' => 'Subscriptions',
          '%digest' => 'digest',
        )),
        '#weight' => -7,
      );
      $description = t('The mail body contains one node of unknown type.');
    }
    else {
      $description = t('The mail body contains one node of the named type.');
    }
    $description = $description . ' ' . t('Recommended tokens: <ul><li>@t1, except for @t2,</li> <li>@t3, @t4, and @t5,</li> <li>!t6, if comments should be included.</li></ul>', array(
      '@t1' => '[subs:*]',
      '@t2' => '[subs:items]',
      '@t3' => '[node:*]',
      '@t4' => '[node:author:*]',
      '@t5' => '[current-user:*]',
      '!t6' => '<code>{{[subs:comments:count]#...[subs:comments:value:#0]...}}</code>',
    ));
    $comment_description = t('This template formats one comment for inclusion in the @Body template above. Recommended tokens:<ul><li>@t1, @t2, @t3, @t4, and @t5, if available,</li> <li>@t6 and @t7.</li></ul>', array(
      '@Body' => t('Body'),
      '@t1' => '[subs:is-new]',
      '@t2' => '[subs:is-updated]',
      '@t3' => '[subs:is-published]',
      '@t4' => '[subs:type]',
      '@t5' => '[subs:files:field_FILES]',
      '@t6' => '[comment:*]',
      '@t7' => '[comment:author:*]',
    ));
    $node_type_id = 'subscriptions_mail_node-type-';
    if (strpos($form['id']['#value'], $node_type_id) === 0) {
      $content_type = substr($form['id']['#value'], strlen($node_type_id));
      $note = module_exists('field_ui') ? '' : ' (' . t('Requires the !Field_UI core module.', array(
        '!Field_UI' => 'Field UI',
      )) . ')';
      $description = $description . t('Alternatively, @t7 provides the entire rendered item as defined in the <a href="!link">display settings for the %Subscriptions view mode</a>.', array(
        '@t7' => '[subs:view]',
        '%Subscriptions' => t('Subscriptions'),
        '!link' => url("admin/structure/types/manage/{$content_type}/display"),
      )) . $note;
      $comment_description = $comment_description . t('Alternatively, @t8 provides the entire rendered comment as defined in the <a href="!link">comment display settings for the %Subscriptions view mode</a>.', array(
        '@t8' => '[subs:view]',
        '%Subscriptions' => t('Subscriptions'),
        '!link' => url("admin/structure/types/manage/{$content_type}/comment/display"),
      )) . $note;
    }
    $form['mail']['body']['#description'] = $description;
    if (isset($template['subscriptions_comment_body'])) {
      $form['mail']['subscriptions_comment_body'] = array(
        '#title' => module_exists('comment') ? t('Comment') : t('@Comment (unused because @Comment module is disabled on this site)', array(
          '@Comment' => t('Comment'),
        )),
        '#type' => 'textarea',
        '#default_value' => $template['subscriptions_comment_body'],
        '#rows' => 5,
        '#description' => $comment_description,
        '#weight' => 5,
      );
    }
  }
}