Projet

Général

Profil

Paste
Télécharger (1,31 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / i18n / i18n_block / i18n_block.inc @ 76df55b7

1
<?php
2
/**
3
 * Blocks textgroup handler
4
 */
5

    
6
/**
7
 * Block object
8
 */
9
class i18n_block_object extends i18n_string_object_wrapper {
10

    
11
  /**
12
   * Load a block object.
13
   *
14
   * @param $object
15
   *  An array with module and delta.
16
   */
17
  function load_object($object) {
18
    $this->object = call_user_func_array($this->get_info('load callback'), $object);
19
    return $this->get_object();
20
  }
21

    
22
  /**
23
   * Get base keys for translating this object
24
   */
25
  public function get_string_context() {
26
    return array($this->object->module, $this->object->delta);
27
  }
28

    
29
  /**
30
   * Get object strings for translation
31
   */
32
  protected function build_properties() {
33
    if ($this->object->module == 'block' && !isset($this->object->body)) {
34
      $block = (object) block_custom_block_get($this->object->delta);
35
      $this->object->body = $block->body;
36
      $this->object->format = $block->format;
37
    }
38
    $properties = parent::build_properties();
39
    // Body is available only for custom blocks.
40
    if ($this->object->module != 'block') {
41
      unset($properties[$this->get_textgroup()][$this->object->module][$this->object->delta]['body']);
42
    }
43
    return $properties;
44
  }
45

    
46
  /**
47
   * Translation mode for object
48
   */
49
  public function get_translate_mode() {
50
    return !empty($this->object->i18n_mode) ? I18N_MODE_LOCALIZE : I18N_MODE_NONE;
51
  }
52
}