5.x-2.x branch
Provide support of CCK fields by adding corresponding mailvars.
| Name | Description |
|---|---|
| subscriptions_cck_form_alter | Implementation of hook_form_alter(). Add the !cck_... variable explanation to the Mail Editor forms. |
| subscriptions_cck_subscriptions_get_mailvars | Implementation of hook_subscriptions_add_mailvars(). Add the !cck... variables. |
- <?php
-
- /**
- * @file
- *
- * Provide support of CCK fields by adding corresponding mailvars.
- */
-
- /**
- * Implementation of hook_form_alter().
- * Add the !cck_... variable explanation to the Mail Editor forms.
- *
- * @ingroup hooks
- */
- function subscriptions_cck_form_alter($form_id, &$form) {
- if ($form_id == 'mail_edit_form' && substr($form['mailkey']['#value'], 0, 13) == 'subscriptions') {
- if (!isset($form['addon_help'])) {
- $form['addon_help'] = array(
- '#variables' => array(),
- '#theme' => 'mail_edit_variables',
- '#weight' => 35.5,
- );
- }
- $tr = 't';
- $variables = array('%fieldname' => '<fieldname>', '!content_type', $tr('content type'));
- $form['addon_help']['#variables'] += array(
- '!ccklabel_<fieldname>' => t('The label for the CCK field %fieldname, as defined for your !content_type.', $variables),
- '!cckvalue1_<fieldname>' => t('The value(s) of the CCK field %fieldname, as defined for your !content_type, comma-separated.', $variables),
- '!cckvalue2_<fieldname>' => t('The value(s) of the CCK field %fieldname, as defined for your !content_type, newline-separated.', $variables),
- );
- }
- }
-
- /**
- * Implementation of hook_subscriptions_add_mailvars().
- * Add the !cck... variables.
- *
- * @ingroup hooks
- */
- function subscriptions_cck_subscriptions_get_mailvars($node) {
- $mailvars = array();
- if (isset($node->type) && ($fields = content_fields(NULL, $node->type))) {
- foreach ($fields as $field_name => $field_info) {
- if (isset($node->$field_name)) {
- $values = $node->$field_name;
- $formatteds = array();
- foreach ($values as $value) {
- if (!($formatted = html_entity_decode( content_format($field_info, $value, 'plain'), ENT_QUOTES, 'UTF-8'))) {
- $formatted = content_format($field_info, $value, 'default');
- }
- $formatteds[] = $formatted;
- }
- $mailvars['!ccklabel_'. $field_name] = $field_info['widget']['label'];
- $mailvars['!cckvalue1_'. $field_name] = implode(', ', $formatteds);
- $mailvars['!cckvalue2_'. $field_name] = implode("\n", $formatteds);
- }
- }
- }
- return $mailvars;
- }
-
-
-