textareafield.class.inc.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. // Copyright (C) 2010-2016 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. namespace Combodo\iTop\Form\Field;
  19. use \Closure;
  20. use \DBObject;
  21. use \Combodo\iTop\Form\Field\TextField;
  22. /**
  23. * Description of TextAreaField
  24. *
  25. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  26. */
  27. class TextAreaField extends TextField
  28. {
  29. const ENUM_FORMAT_TEXT = 'text';
  30. const ENUM_FORMAT_HTML = 'html';
  31. const DEFAULT_FORMAT = 'html';
  32. protected $sFormat;
  33. protected $oObject;
  34. protected $sTransactionId;
  35. public function __construct($sId, Closure $onFinalizeCallback = null, DBObject $oObject = null)
  36. {
  37. parent::__construct($sId, $onFinalizeCallback);
  38. $this->sFormat = static::DEFAULT_FORMAT;
  39. $this->oObject = $oObject;
  40. $this->sTransactionId = null;
  41. }
  42. /**
  43. *
  44. * @return string
  45. */
  46. public function GetFormat()
  47. {
  48. return $this->sFormat;
  49. }
  50. /**
  51. *
  52. * @param string $sFormat
  53. * @return \Combodo\iTop\Form\Field\TextAreaField
  54. */
  55. public function SetFormat($sFormat)
  56. {
  57. $this->sFormat = $sFormat;
  58. return $this;
  59. }
  60. /**
  61. *
  62. * @return DBObject
  63. */
  64. public function GetObject()
  65. {
  66. return $this->oObject;
  67. }
  68. /**
  69. *
  70. * @param DBObject $oObject
  71. * @return \Combodo\iTop\Form\Field\TextAreaField
  72. */
  73. public function SetObject(DBObject $oObject)
  74. {
  75. $this->oObject = $oObject;
  76. return $this;
  77. }
  78. /**
  79. * Returns the transaction id for the field. This is usally used/setted when using a html format that allows upload of files/images
  80. *
  81. * @return string
  82. */
  83. public function GetTransactionId()
  84. {
  85. return $this->sTransactionId;
  86. }
  87. /**
  88. *
  89. * @param string $sTransactionId
  90. * @return \Combodo\iTop\Form\Field\TextAreaField
  91. */
  92. public function SetTransactionId($sTransactionId)
  93. {
  94. $this->sTransactionId = $sTransactionId;
  95. return $this;
  96. }
  97. }