You are here

public function boxes_i18n::render in Boxes translation 7

Same name and namespace in other branches
  1. 6 plugins/boxes/boxes_i18n.inc \boxes_i18n::render()

Implements boxes_content::render().

Overrides boxes_simple::render

File

plugins/boxes/boxes_i18n.inc, line 83

Class

boxes_i18n
Simple translatable custom text box.

Code

public function render() {
  global $language;

  // Get the filtered rendered data from boxes_simple.
  $block = parent::render();

  // Handle any multilingual settings.
  if (!empty($this->options['i18n_boxes']['language'])) {
    if ($this->options['i18n_boxes']['language'] == I18N_BOXES_LOCALIZE) {

      // This box is available to translate.
      $block['content'] = i18n_string_text(array(
        'boxes',
        $this->plugin_key,
        $this->delta,
        'body',
      ), $block['content'], array(
        'format' => $this->options['body']['format'],
      ));

      // Also translate the title.
      $block['subject'] = i18n_string_plain(array(
        'boxes',
        $this->plugin_key,
        $this->delta,
        'title',
      ), $block['subject']);
      $block['title'] = $block['subject'];
    }
    elseif ($this->options['i18n_boxes']['language'] != $language->language) {

      // This box does not share the language of the user, so do not display.
      $block = NULL;
    }
  }
  return $block;
}