i18n_block.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Blocks textgroup handler
  4. */
  5. /**
  6. * Block object
  7. */
  8. class i18n_block_object extends i18n_string_object_wrapper {
  9. /**
  10. * Load a block object.
  11. *
  12. * @param $object
  13. * An array with module and delta.
  14. */
  15. function load_object($object) {
  16. $this->object = call_user_func_array($this->get_info('load callback'), $object);
  17. return $this->get_object();
  18. }
  19. /**
  20. * Get base keys for translating this object
  21. */
  22. public function get_string_context() {
  23. return array($this->object->module, $this->object->delta);
  24. }
  25. /**
  26. * Get object strings for translation
  27. */
  28. protected function build_properties() {
  29. if ($this->object->module == 'block' && !isset($this->object->body)) {
  30. $block = (object) block_custom_block_get($this->object->delta);
  31. $this->object->body = $block->body;
  32. $this->object->format = $block->format;
  33. }
  34. $properties = parent::build_properties();
  35. // Body is available only for custom blocks.
  36. if ($this->object->module != 'block') {
  37. unset($properties[$this->get_textgroup()][$this->object->module][$this->object->delta]['body']);
  38. }
  39. return $properties;
  40. }
  41. /**
  42. * Translation mode for object
  43. */
  44. public function get_translate_mode() {
  45. return !empty($this->object->i18n_mode) ? I18N_MODE_LOCALIZE : I18N_MODE_NONE;
  46. }
  47. }