You are here

function template_preprocess_simplenews_status in Simplenews 6.2

Same name and namespace in other branches
  1. 6 simplenews.admin.inc \template_preprocess_simplenews_status()

Process variables to format the simplenews status indication.

$variables contains:

  • $source
  • $status

See also

simplenews-status.tpl.php

theme_simplenews_status()

File

includes/simplenews.admin.inc, line 1407
Newsletter admin, subscription admin, simplenews settings

Code

function template_preprocess_simplenews_status(&$variables) {
  switch ($variables['source']) {
    case 'published':
      $images = array(
        0 => 'sn-saved.png',
        1 => 'sn-sent.png',
      );
      $title = array(
        0 => t('Not published'),
        1 => t('Published'),
      );
      break;
    case 'activated':
      $images = array(
        0 => 'sn-saved.png',
        1 => 'sn-sent.png',
      );
      $title = array(
        0 => t('Inactive: no newsletters will be sent'),
        1 => t('Active: user will receive newsletters'),
      );
      break;
    case 'sent':
      $images = array(
        SIMPLENEWS_STATUS_SEND_PENDING => 'sn-cron.png',
        SIMPLENEWS_STATUS_SEND_READY => 'sn-sent.png',
      );
      $title = array(
        SIMPLENEWS_STATUS_SEND_NOT => '-',
        SIMPLENEWS_STATUS_SEND_PENDING => $variables['already_sent'] . ' / ' . $variables['sent_subscriber_count'],
        SIMPLENEWS_STATUS_SEND_READY => $variables['sent_subscriber_count'],
      );
      $variables['trailer'] = $title[$variables['status']];
      break;
  }

  // Build the variables
  if (isset($images) && $images[$variables['status']]) {
    $variables['image'] = base_path() . drupal_get_path('module', 'simplenews') . '/' . $images[$variables['status']];
  }
  $variables['alt'] = $variables['title'] = $title[$variables['status']];
}