SourceString.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @file
  4. * Definition of SourceString.
  5. */
  6. /**
  7. * Defines the locale source string object.
  8. *
  9. * This class represents a module-defined string value that is to be translated.
  10. * This string must at least contain a 'source' field, which is the raw source
  11. * value, and is assumed to be in English language.
  12. */
  13. class SourceString extends StringBase {
  14. /**
  15. * Implements StringInterface::getParentId().
  16. */
  17. public function getParentId() {
  18. // Source strings don't have a parent; Translations do.
  19. return 0;
  20. }
  21. /**
  22. * Implements StringInterface::isSource().
  23. */
  24. public function isSource() {
  25. return isset($this->source);
  26. }
  27. /**
  28. * Implements StringInterface::isTranslation().
  29. */
  30. public function isTranslation() {
  31. return FALSE;
  32. }
  33. /**
  34. * Implements LocaleString::getString().
  35. */
  36. public function getString() {
  37. return isset($this->source) ? $this->source : '';
  38. }
  39. /**
  40. * Implements LocaleString::setString().
  41. */
  42. public function setString($string) {
  43. $this->source = $string;
  44. return $this;
  45. }
  46. /**
  47. * Implements LocaleString::isNew().
  48. */
  49. public function isNew() {
  50. return empty($this->lid);
  51. }
  52. }