You are here

class RulesI18nStringObjectWrapper in Rules 7.2

Custom I18nString object wrapper; registers custom properties per config.

Hierarchy

Expanded class hierarchy of RulesI18nStringObjectWrapper

1 string reference to 'RulesI18nStringObjectWrapper'
RulesI18nStringController::hook_object_info in rules_i18n/rules_i18n.i18n.inc
Overridden to customize i18n object info.

File

rules_i18n/rules_i18n.i18n.inc, line 43
Internationalization integration based upon the entity API i18n stuff.

View source
class RulesI18nStringObjectWrapper extends i18n_string_object_wrapper {

  /**
   * Get translatable properties.
   */
  protected function build_properties() {
    $strings = parent::build_properties();
    $properties = array();

    // Also add in the configuration label, as the i18n String UI requires
    // a String to be available always.
    $properties['label'] = array(
      'title' => t('Configuration name'),
      'string' => $this->object->label,
    );
    $this
      ->buildElementProperties($this->object, $properties);

    // Add in translations for all elements.
    foreach ($this->object
      ->elements() as $element) {
      $this
        ->buildElementProperties($element, $properties);
    }
    $strings[$this
      ->get_textgroup()]['rules_config'][$this->object->name] = $properties;
    return $strings;
  }

  /**
   * Adds in translatable properties of the given element.
   */
  protected function buildElementProperties($element, &$properties) {
    foreach ($element
      ->pluginParameterInfo() as $name => $info) {

      // Add in all directly provided input variables.
      if (!empty($info['translatable']) && isset($element->settings[$name])) {

        // If its an array of textual values, translate each value on its own.
        if (is_array($element->settings[$name])) {
          foreach ($element->settings[$name] as $i => $value) {
            $properties[$element
              ->elementId() . ':' . $name . ':' . $i] = array(
              'title' => t('@plugin "@label" (id @id), @parameter, Value @delta', array(
                '@plugin' => drupal_ucfirst($element
                  ->plugin()),
                '@label' => $element
                  ->label(),
                '@id' => $element
                  ->elementId(),
                '@parameter' => $info['label'],
                '@delta' => $i + 1,
              )),
              'string' => $value,
            );
          }
        }
        else {
          $properties[$element
            ->elementId() . ':' . $name] = array(
            'title' => t('@plugin "@label" (id @id), @parameter', array(
              '@plugin' => drupal_ucfirst($element
                ->plugin()),
              '@label' => $element
                ->label(),
              '@id' => $element
                ->elementId(),
              '@parameter' => $info['label'],
            )),
            'string' => $element->settings[$name],
          );
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
i18n_object_wrapper::$key protected property
i18n_object_wrapper::$object protected property
i18n_object_wrapper::$translations protected property
i18n_object_wrapper::$type protected property
i18n_object_wrapper::get_edit_path function Get edit path for object 2
i18n_object_wrapper::get_field function Get field value from object/array
i18n_object_wrapper::get_index function Get string numeric key for indexing.
i18n_object_wrapper::get_info public function Get object info
i18n_object_wrapper::get_key function Get key value from object/array
i18n_object_wrapper::get_langcode public function Get language code
i18n_object_wrapper::get_object public function Get real object or array.
i18n_object_wrapper::get_path public function Get link for item 2
i18n_object_wrapper::get_placeholders protected function Get menu placehoders for object
i18n_object_wrapper::get_string_info public function Get object string translation info
i18n_object_wrapper::get_title public function Get title from item 2
i18n_object_wrapper::get_translate_access function Menu access callback for mixed translation tab
i18n_object_wrapper::get_translation_info public function Get object translation set info
i18n_object_wrapper::get_tsid function Get translation set id if any
i18n_object_wrapper::get_type public function Get object type
i18n_object_wrapper::load_object function Load real object or array. 1
i18n_object_wrapper::localize function Localize object if localizable.
i18n_object_wrapper::path_replace protected function Replace path with placeholders
i18n_object_wrapper::set_field function Set field value to object/array
i18n_object_wrapper::set_tsid function Set translation set id
i18n_object_wrapper::translate_access protected function Translate access (translation sets) 2
i18n_object_wrapper::__construct public function Class constructor 2
i18n_string_object_wrapper::$properties protected property
i18n_string_object_wrapper::$textgroup protected property
i18n_string_object_wrapper::get_properties public function Get object translatable properties
i18n_string_object_wrapper::get_strings public function Get object strings for translation
i18n_string_object_wrapper::get_string_context public function Get string context 3
i18n_string_object_wrapper::get_textgroup public function Get textgroup name
i18n_string_object_wrapper::get_translate_context protected function Context to be pre-loaded before translation. 2
i18n_string_object_wrapper::get_translate_mode public function Translation mode for object Overrides i18n_object_wrapper::get_translate_mode 3
i18n_string_object_wrapper::get_translate_path public function Get translate path for object 2
i18n_string_object_wrapper::load_strings public function Load all existing strings for this object.
i18n_string_object_wrapper::localize_access protected function Translate access (localize strings) Overrides i18n_object_wrapper::localize_access
i18n_string_object_wrapper::strings_remove public function Remove all strings for this object.
i18n_string_object_wrapper::strings_update public function Update all strings for this object.
i18n_string_object_wrapper::textgroup protected function Get textgroup object
i18n_string_object_wrapper::translate public function Translate object. Overrides i18n_object_wrapper::translate
i18n_string_object_wrapper::translate_field protected function Translate object property. 2
i18n_string_object_wrapper::translate_object protected function Translate all properties for object.
RulesI18nStringObjectWrapper::buildElementProperties protected function Adds in translatable properties of the given element.
RulesI18nStringObjectWrapper::build_properties protected function Get translatable properties. Overrides i18n_string_object_wrapper::build_properties