i18n_taxonomy.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Internationalization (i18n) module - Translation set
  5. */
  6. /**
  7. * @file
  8. * Internationalization (i18n) module - Translation set
  9. */
  10. class i18n_taxonomy_translation_set extends i18n_translation_set {
  11. /**
  12. * Load all term translations
  13. */
  14. public function load_translations() {
  15. return i18n_translation_set_index(taxonomy_term_load_multiple(array(), array('i18n_tsid' => $this->tsid)));
  16. }
  17. /**
  18. * Get placeholder values for path replacement
  19. */
  20. function get_path_placeholders($op = 'list') {
  21. $values = parent::get_path_placeholders($op);
  22. if (!empty($this->bundle)) {
  23. $values['%taxonomy_vocabulary_machine_name'] = $this->bundle;
  24. }
  25. return $values;
  26. }
  27. }
  28. /**
  29. * Taxonomy textgroup handler
  30. */
  31. class i18n_taxonomy_term extends i18n_string_object_wrapper {
  32. /**
  33. * Translation mode for object
  34. */
  35. public function get_translate_mode() {
  36. $mode = i18n_taxonomy_vocabulary_mode($this->object->vid);
  37. if ($this->get_langcode()) {
  38. return $mode & I18N_MODE_TRANSLATE;
  39. }
  40. else {
  41. return $mode & I18N_MODE_LOCALIZE;
  42. }
  43. }
  44. /**
  45. * Access to object translation. This should check object properties and permissions
  46. */
  47. protected function translate_access() {
  48. return taxonomy_term_edit_access($this->object) && $this->get_langcode() && user_access('translate interface');
  49. }
  50. }