renderingoutput.class.inc.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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\Renderer;
  19. /**
  20. * Description of RenderingOutput
  21. *
  22. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  23. */
  24. class RenderingOutput
  25. {
  26. protected $sHtml;
  27. protected $sJsInline;
  28. protected $aJsFiles;
  29. protected $sCssInline;
  30. protected $aCssFiles;
  31. public function __construct()
  32. {
  33. $this->sHtml = '';
  34. $this->sJsInline = '';
  35. $this->aJsFiles = array();
  36. $this->sCssInline = '';
  37. $this->aCssFiles = array();
  38. }
  39. /**
  40. *
  41. * @return string
  42. */
  43. public function GetHtml()
  44. {
  45. return $this->sHtml;
  46. }
  47. /**
  48. *
  49. * @return string
  50. */
  51. public function GetJs()
  52. {
  53. return $this->sJsInline;
  54. }
  55. /**
  56. *
  57. * @return array
  58. */
  59. public function GetJsFiles()
  60. {
  61. return $this->aJsFiles;
  62. }
  63. /**
  64. *
  65. * @return string
  66. */
  67. public function GetCss()
  68. {
  69. return $this->sCssInline;
  70. }
  71. /**
  72. *
  73. * @return array
  74. */
  75. public function GetCssFiles()
  76. {
  77. return $this->aCssFiles;
  78. }
  79. /**
  80. *
  81. * @param string $sHtml
  82. * @return \Combodo\iTop\Renderer\RenderingOutput
  83. */
  84. public function AddHtml($sHtml)
  85. {
  86. $this->sHtml .= $sHtml;
  87. return $this;
  88. }
  89. /**
  90. *
  91. * @param string $sJs
  92. * @return \Combodo\iTop\Renderer\RenderingOutput
  93. */
  94. public function AddJs($sJs)
  95. {
  96. $this->sJsInline .= $sJs . "\n";
  97. return $this;
  98. }
  99. /**
  100. *
  101. * @param string $sFile
  102. * @return \Combodo\iTop\Renderer\RenderingOutput
  103. */
  104. public function AddJsFile($sFile)
  105. {
  106. if (!in_array($sFile, $this->aJsFiles))
  107. {
  108. $this->aJsFiles[] = $sFile;
  109. }
  110. return $this;
  111. }
  112. /**
  113. *
  114. * @param string $sFile
  115. * @return \Combodo\iTop\Renderer\RenderingOutput
  116. */
  117. public function RemoveJsFile($sFile)
  118. {
  119. if (in_array($sFile, $this->aJsFiles))
  120. {
  121. unset($this->aJsFiles[$sFile]);
  122. }
  123. return $this;
  124. }
  125. /**
  126. *
  127. * @param string $sCss
  128. * @return \Combodo\iTop\Renderer\RenderingOutput
  129. */
  130. public function AddCss($sCss)
  131. {
  132. $this->sCssInline .= $sCss . "\n";
  133. return $this;
  134. }
  135. /**
  136. *
  137. * @param string $sFile
  138. * @return \Combodo\iTop\Renderer\RenderingOutput
  139. */
  140. public function AddCssFile($sFile)
  141. {
  142. if (!in_array($sFile, $this->aCssFiles))
  143. {
  144. $this->aCssFiles[] = $sFile;
  145. }
  146. return $this;
  147. }
  148. /**
  149. *
  150. * @param string $sFile
  151. * @return \Combodo\iTop\Renderer\RenderingOutput
  152. */
  153. public function RemoveCssFile($sFile)
  154. {
  155. if (in_array($sFile, $this->aCssFiles))
  156. {
  157. unset($this->aCssFiles[$sFile]);
  158. }
  159. return $this;
  160. }
  161. }