linkedsetfield.class.inc.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 LinkedSetField
  22. *
  23. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  24. */
  25. class LinkedSetField extends Field
  26. {
  27. protected $sTargetClass;
  28. protected $sExtKeyToRemote;
  29. protected $bIndirect;
  30. protected $aAttributesToDisplay;
  31. protected $sSearchEndpoint;
  32. protected $sInformationEndpoint;
  33. public function __construct($sId, \Closure $onFinalizeCallback = null)
  34. {
  35. $this->sTargetClass = null;
  36. $this->sExtKeyToRemote = null;
  37. $this->bIndirect = false;
  38. $this->aAttributesToDisplay = array();
  39. $this->sSearchEndpoint = null;
  40. $this->sInformationEndpoint = null;
  41. parent::__construct($sId, $onFinalizeCallback);
  42. }
  43. /**
  44. *
  45. * @return string
  46. */
  47. public function GetTargetClass()
  48. {
  49. return $this->sTargetClass;
  50. }
  51. /**
  52. *
  53. * @param string $sTargetClass
  54. * @return \Combodo\iTop\Form\Field\LinkedSetField
  55. */
  56. public function SetTargetClass($sTargetClass)
  57. {
  58. $this->sTargetClass = $sTargetClass;
  59. return $sTargetClass;
  60. }
  61. /**
  62. *
  63. * @return string
  64. */
  65. public function GetExtKeyToRemote()
  66. {
  67. return $this->sExtKeyToRemote;
  68. }
  69. /**
  70. *
  71. * @param string $sExtKeyToRemote
  72. * @return \Combodo\iTop\Form\Field\LinkedSetField
  73. */
  74. public function SetExtKeyToRemote($sExtKeyToRemote)
  75. {
  76. $this->sExtKeyToRemote = $sExtKeyToRemote;
  77. return $sExtKeyToRemote;
  78. }
  79. /**
  80. *
  81. * @return boolean
  82. */
  83. public function IsIndirect()
  84. {
  85. return $this->bIndirect;
  86. }
  87. /**
  88. *
  89. * @param boolean $bIndirect
  90. * @return \Combodo\iTop\Form\Field\LinkedSetField
  91. */
  92. public function SetIndirect($bIndirect)
  93. {
  94. $this->bIndirect = $bIndirect;
  95. return $this;
  96. }
  97. /**
  98. * Returns a hash array of attributes to be displayed in the linkedset in the form $sAttCode => $sAttLabel
  99. *
  100. * @param $bAttCodesOnly If set to true, will return only the attcodes
  101. * @return array
  102. */
  103. public function GetAttributesToDisplay($bAttCodesOnly = false)
  104. {
  105. return ($bAttCodesOnly) ? array_keys($this->aAttributesToDisplay) : $this->aAttributesToDisplay;
  106. }
  107. /**
  108. *
  109. * @param array $aAttCodes
  110. * @return \Combodo\iTop\Form\Field\LinkedSetField
  111. */
  112. public function SetAttributesToDisplay(array $aAttributesToDisplay)
  113. {
  114. $this->aAttributesToDisplay = $aAttributesToDisplay;
  115. return $this;
  116. }
  117. public function GetSearchEndpoint()
  118. {
  119. return $this->sSearchEndpoint;
  120. }
  121. public function SetSearchEndpoint($sSearchEndpoint)
  122. {
  123. $this->sSearchEndpoint = $sSearchEndpoint;
  124. return $this;
  125. }
  126. public function GetInformationEndpoint()
  127. {
  128. return $this->sInformationEndpoint;
  129. }
  130. public function SetInformationEndpoint($sInformationEndpoint)
  131. {
  132. $this->sInformationEndpoint = $sInformationEndpoint;
  133. return $this;
  134. }
  135. }