fileuploadfield.class.inc.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 \Combodo\iTop\Form\Field\Field;
  20. /**
  21. * Description of FileUploadField
  22. *
  23. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  24. */
  25. class FileUploadField extends Field
  26. {
  27. const DEFAULT_ALLOW_DELETE = true;
  28. protected $sTransactionId;
  29. protected $oObject;
  30. protected $sUploadEndpoint;
  31. protected $sDownloadEndpoint;
  32. protected $bAllowDelete;
  33. public function __construct($sId, \Closure $onFinalizeCallback = null)
  34. {
  35. $this->sTransactionId = null;
  36. $this->oObject = null;
  37. $this->sUploadEndpoint = null;
  38. $this->sDownloadEndpoint = null;
  39. $this->bAllowDelete = static::DEFAULT_ALLOW_DELETE;
  40. parent::__construct($sId, $onFinalizeCallback);
  41. }
  42. /**
  43. * Returns the transaction id for the field.
  44. *
  45. * @return string
  46. */
  47. public function GetTransactionId()
  48. {
  49. return $this->sTransactionId;
  50. }
  51. /**
  52. *
  53. * @param string $sTransactionId
  54. * @return \Combodo\iTop\Form\Field\FileUploadField
  55. */
  56. public function SetTransactionId($sTransactionId)
  57. {
  58. $this->sTransactionId = $sTransactionId;
  59. return $this;
  60. }
  61. public function GetObject()
  62. {
  63. return $this->oObject;
  64. }
  65. public function SetObject($oObject)
  66. {
  67. $this->oObject = $oObject;
  68. return $this;
  69. }
  70. public function GetUploadEndpoint()
  71. {
  72. return $this->sUploadEndpoint;
  73. }
  74. public function SetUploadEndpoint($sUploadEndpoint)
  75. {
  76. $this->sUploadEndpoint = $sUploadEndpoint;
  77. return $this;
  78. }
  79. public function GetDownloadEndpoint()
  80. {
  81. return $this->sDownloadEndpoint;
  82. }
  83. public function SetDownloadEndpoint($sDownloadEndpoint)
  84. {
  85. $this->sDownloadEndpoint = $sDownloadEndpoint;
  86. return $this;
  87. }
  88. public function GetAllowDelete()
  89. {
  90. return $this->bAllowDelete;
  91. }
  92. public function SetAllowDelete($bAllowDelete)
  93. {
  94. $this->bAllowDelete = (boolean) $bAllowDelete;
  95. return $this;
  96. }
  97. }