You are here

protected function MailchimpI18nStringObjectWrapper::build_properties in Mailchimp 7.4

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_i18n/mailchimp_i18n.i18n.inc \MailchimpI18nStringObjectWrapper::build_properties()

Get translatable properties.

Overrides i18n_string_object_wrapper::build_properties

File

modules/mailchimp_i18n/mailchimp_i18n.i18n.inc, line 36
i18n_string integration based upon the Entity API i18n.

Class

MailchimpI18nStringObjectWrapper
Custom I18n String object wrapper.

Code

protected function build_properties() {
  $strings = parent::build_properties();
  $properties = array();
  $title_mapping = array(
    'description' => t('Description'),
    'submit_button' => t('Submit Button Label'),
    'confirmation_message' => t('Confirmation Message'),
  );

  // Add in translations for all settings and mergefields.
  foreach ($this->object->settings as $settings_key => $setting) {
    if (is_array($setting)) {
      $mergefields = array_filter($setting);
      foreach ($mergefields as $tag => $mergefield_settings) {
        $properties['mergefield:' . $tag] = array(
          'title' => $mergefield_settings->name,
          'string' => $mergefield_settings->name,
        );
      }
    }
    if (isset($title_mapping[$settings_key])) {
      $properties[$settings_key] = array(
        'title' => $title_mapping[$settings_key],
        'string' => $setting,
      );
    }
  }
  if (!isset($strings[$this
    ->get_textgroup()]['mailchimp_signup'][$this->object->name])) {
    $strings[$this
      ->get_textgroup()]['mailchimp_signup'][$this->object->name] = array();
  }
  if (!empty($this->object->settings['include_interest_groups'])) {
    $lists = mailchimp_get_lists($this->object->mc_lists);
    if (!empty($lists)) {
      foreach ($lists as $list) {
        foreach ($list->intgroups as $intgroup) {
          $properties['intgroup_' . $intgroup->id] = array(
            'title' => $intgroup->title,
            'string' => $intgroup->title,
          );
          if (!empty($intgroup->interests)) {
            foreach ($intgroup->interests as $interest) {
              $properties['intgroup_' . $intgroup->id . '_interest_' . $interest->id] = array(
                'title' => $interest->name,
                'string' => $interest->name,
              );
            }
          }
        }
      }
    }
  }
  $strings[$this
    ->get_textgroup()]['mailchimp_signup'][$this->object->name] += $properties;
  return $strings;
}