bssimplefieldrenderer.class.inc.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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\Bootstrap\FieldRenderer;
  19. use \utils;
  20. use \Dict;
  21. use \UserRights;
  22. use \AttributeDateTime;
  23. use \InlineImage;
  24. use \Combodo\iTop\Renderer\FieldRenderer;
  25. use \Combodo\iTop\Renderer\RenderingOutput;
  26. use \Combodo\iTop\Form\Field\TextAreaField;
  27. /**
  28. * Description of BsSimpleFieldRenderer
  29. *
  30. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  31. */
  32. class BsSimpleFieldRenderer extends FieldRenderer
  33. {
  34. /**
  35. * Returns a RenderingOutput for the FieldRenderer's Field
  36. *
  37. * @return \Combodo\iTop\Renderer\RenderingOutput
  38. */
  39. public function Render()
  40. {
  41. $oOutput = new RenderingOutput();
  42. $sFieldClass = get_class($this->oField);
  43. $sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
  44. // Rendering field in edition mode
  45. if (!$this->oField->GetReadOnly() && !$this->oField->GetHidden())
  46. {
  47. switch ($sFieldClass)
  48. {
  49. case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
  50. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  51. if ($this->oField->GetLabel() !== '')
  52. {
  53. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  54. }
  55. $oOutput->AddHtml('<div class="help-block"></div>');
  56. $oOutput->AddHtml('<div class="input-group date" id="datepicker_' . $this->oField->GetGlobalId() . '">');
  57. $oOutput->AddHtml('<input type="text" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('" class="form-control" maxlength="255" />');
  58. $oOutput->AddHtml('<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>');
  59. $oOutput->AddHtml('</div>');
  60. $oOutput->AddHtml('</div>');
  61. $sJSFormat = json_encode($this->oField->GetJSDateTimeFormat());
  62. $oOutput->AddJs(
  63. <<<EOF
  64. $('#datepicker_{$this->oField->GetGlobalId()}').datetimepicker({format: $sJSFormat});
  65. EOF
  66. );
  67. break;
  68. case 'Combodo\\iTop\\Form\\Field\\PasswordField':
  69. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  70. if ($this->oField->GetLabel() !== '')
  71. {
  72. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  73. }
  74. $oOutput->AddHtml('<div class="help-block"></div>');
  75. $oOutput->AddHtml('<input type="password" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" autocomplete="off" />');
  76. $oOutput->AddHtml('</div>');
  77. break;
  78. case 'Combodo\\iTop\\Form\\Field\\StringField':
  79. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  80. if ($this->oField->GetLabel() !== '')
  81. {
  82. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  83. }
  84. $oOutput->AddHtml('<div class="help-block"></div>');
  85. $oOutput->AddHtml('<input type="text" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" maxlength="255" />');
  86. $oOutput->AddHtml('</div>');
  87. break;
  88. case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
  89. case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
  90. $bRichEditor = ($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML);
  91. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  92. if ($this->oField->GetLabel() !== '')
  93. {
  94. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  95. }
  96. $oOutput->AddHtml('<div class="help-block"></div>');
  97. // First the edition area
  98. $oOutput->AddHtml('<div>');
  99. $oOutput->AddHtml('<textarea id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" class="form-control" rows="8">' . $this->oField->GetCurrentValue() . '</textarea>');
  100. $oOutput->AddHtml('</div>');
  101. // Then the previous entries if necessary
  102. if ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\CaseLogField')
  103. {
  104. $this->PreparingCaseLogEntries($oOutput);
  105. }
  106. $oOutput->AddHtml('</div>');
  107. // Some additional stuff if we are displaying it with a rich editor
  108. if ($bRichEditor)
  109. {
  110. $sEditorLanguage = strtolower(trim(UserRights::GetUserLanguage()));
  111. $oOutput->AddJs(
  112. <<<EOF
  113. $('#{$this->oField->GetGlobalId()}').addClass('htmlEditor');
  114. $('#{$this->oField->GetGlobalId()}').ckeditor(function(){}, {language: '$sEditorLanguage', contentsLanguage: '$sEditorLanguage'});
  115. EOF
  116. );
  117. if (($this->oField->GetObject() !== null) && ($this->oField->GetTransactionId() !== null))
  118. {
  119. $oOutput->AddJs(InlineImage::EnableCKEditorImageUpload($this->oField->GetObject(), utils::GetUploadTempId($this->oField->GetTransactionId())));
  120. }
  121. }
  122. break;
  123. case 'Combodo\\iTop\\Form\\Field\\SelectField':
  124. case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
  125. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  126. if ($this->oField->GetLabel() !== '')
  127. {
  128. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  129. }
  130. $oOutput->AddHtml('<div class="help-block"></div>');
  131. $oOutput->AddHtml('<select id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" ' . ( ($this->oField->GetMultipleValuesEnabled()) ? 'multiple' : '' ) . ' class="form-control">');
  132. foreach ($this->oField->GetChoices() as $sChoice => $sLabel)
  133. {
  134. // Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
  135. $sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
  136. $oOutput->AddHtml('<option value="' . $sChoice . '" ' . $sSelectedAtt . ' >')->AddHtml($sLabel)->AddHtml('</option>');
  137. }
  138. $oOutput->AddHtml('</select>');
  139. $oOutput->AddHtml('</div>');
  140. break;
  141. case 'Combodo\\iTop\\Form\\Field\\RadioField':
  142. case 'Combodo\\iTop\\Form\\Field\\CheckboxField':
  143. $sFieldType = ($sFieldClass === 'Combodo\\iTop\\Form\\Field\\RadioField') ? 'radio' : 'checkbox';
  144. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '" id="' . $this->oField->GetGlobalId() . '">');
  145. if ($this->oField->GetLabel() !== '')
  146. {
  147. $oOutput->AddHtml('<div><label class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label></div>');
  148. }
  149. $oOutput->AddHtml('<div class="help-block"></div>');
  150. $oOutput->AddHtml('<div class="btn-group" data-toggle="buttons">');
  151. $i = 0;
  152. foreach ($this->oField->GetChoices() as $sChoice => $sLabel)
  153. {
  154. // Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
  155. $sCheckedAtt = ($this->oField->IsAmongValues($sChoice)) ? 'checked' : '';
  156. $sCheckedClass = ($this->oField->IsAmongValues($sChoice)) ? 'active' : '';
  157. $oOutput->AddHtml('<label class="btn btn-default ' . $sCheckedClass . '"><input type="' . $sFieldType . '" name="' . $this->oField->GetId() . '" id="' . $this->oField->GetId() . $i . '" value="' . $sChoice . '" ' . $sCheckedAtt . ' />' . $sLabel . '</label>');
  158. $i++;
  159. }
  160. $oOutput->AddHtml('</div>');
  161. $oOutput->AddHtml('</div>');
  162. break;
  163. case 'Combodo\\iTop\\Form\\Field\\HiddenField':
  164. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
  165. break;
  166. }
  167. }
  168. // ... and in read-only mode (or hidden)
  169. else
  170. {
  171. // ... specific rendering for fields with multiple values
  172. if (($this->oField instanceof Combodo\iTop\Form\Field\MultipleChoicesField) && ($this->oField->GetMultipleValuesEnabled()))
  173. {
  174. // TODO
  175. }
  176. // ... clasic rendering for fields with only one value
  177. else
  178. {
  179. switch ($sFieldClass)
  180. {
  181. case 'Combodo\\iTop\\Form\\Field\\LabelField':
  182. $oOutput->AddHtml('<div class="form-group">');
  183. // Showing label / value only if read-only but not hidden
  184. if (!$this->oField->GetHidden())
  185. {
  186. if ($this->oField->GetLabel() !== '')
  187. {
  188. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  189. }
  190. $oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('</div>');
  191. }
  192. $oOutput->AddHtml('</div>');
  193. break;
  194. case 'Combodo\\iTop\\Form\\Field\\StringField':
  195. case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
  196. $oOutput->AddHtml('<div class="form-group">');
  197. // Showing label / value only if read-only but not hidden
  198. if (!$this->oField->GetHidden())
  199. {
  200. if ($this->oField->GetLabel() !== '')
  201. {
  202. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  203. }
  204. if($sFieldClass === 'Combodo\\iTop\\Form\\Field\\TextAreaField')
  205. {
  206. $bEncodeHtmlEntities = false;
  207. if($this->oField->GetFormat() === TextAreaField::ENUM_FORMAT_HTML)
  208. {
  209. $sDisplayValue = $this->oField->GetCurrentValue();
  210. }
  211. else
  212. {
  213. $sDisplayValue = utils::TextToHtml($this->oField->GetCurrentValue());
  214. }
  215. }
  216. else
  217. {
  218. $bEncodeHtmlEntities = true;
  219. $sDisplayValue = $this->oField->GetCurrentValue();
  220. }
  221. $oOutput->AddHtml('<div class="form-control-static">')->AddHtml($sDisplayValue, $bEncodeHtmlEntities)->AddHtml('</div>');
  222. }
  223. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
  224. $oOutput->AddHtml('</div>');
  225. break;
  226. case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
  227. $oOutput->AddHtml('<div class="form-group ' . $sFieldMandatoryClass . '">');
  228. if ($this->oField->GetLabel() !== '')
  229. {
  230. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  231. }
  232. // Entries if necessary
  233. $this->PreparingCaseLogEntries($oOutput);
  234. $oOutput->AddHtml('</div>');
  235. break;
  236. case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
  237. $oOutput->AddHtml('<div class="form-group">');
  238. // Showing label / value only if read-only but not hidden
  239. if (!$this->oField->GetHidden())
  240. {
  241. if ($this->oField->GetLabel() !== '')
  242. {
  243. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  244. }
  245. $oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('</div>');
  246. }
  247. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('" class="form-control" />');
  248. $oOutput->AddHtml('</div>');
  249. break;
  250. case 'Combodo\\iTop\\Form\\Field\\DurationField':
  251. $oOutput->AddHtml('<div class="form-group">');
  252. // Showing label / value only if read-only but not hidden
  253. if (!$this->oField->GetHidden())
  254. {
  255. if ($this->oField->GetLabel() !== '')
  256. {
  257. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  258. }
  259. $oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('</div>');
  260. }
  261. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
  262. $oOutput->AddHtml('</div>');
  263. break;
  264. case 'Combodo\\iTop\\Form\\Field\\RadioField':
  265. case 'Combodo\\iTop\\Form\\Field\\SelectField':
  266. case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
  267. $aFieldChoices = $this->oField->GetChoices();
  268. $sFieldValue = (isset($aFieldChoices[$this->oField->GetCurrentValue()])) ? $aFieldChoices[$this->oField->GetCurrentValue()] : Dict::S('UI:UndefinedObject');
  269. $oOutput->AddHtml('<div class="form-group">');
  270. // Showing label / value only if read-only but not hidden
  271. if (!$this->oField->GetHidden())
  272. {
  273. if ($this->oField->GetLabel() !== '')
  274. {
  275. $oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label">')->AddHtml($this->oField->GetLabel(), true)->AddHtml('</label>');
  276. }
  277. $oOutput->AddHtml('<div class="form-control-static">' . $sFieldValue . '</div>');
  278. }
  279. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="' . $this->oField->GetCurrentValue() . '" class="form-control" />');
  280. $oOutput->AddHtml('</div>');
  281. break;
  282. case 'Combodo\\iTop\\Form\\Field\\HiddenField':
  283. $oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('"/>');
  284. break;
  285. }
  286. }
  287. }
  288. // JS FieldChange trigger (:input are not always at the same depth)
  289. switch ($sFieldClass)
  290. {
  291. case 'Combodo\\iTop\\Form\\Field\\PasswordField':
  292. case 'Combodo\\iTop\\Form\\Field\\StringField':
  293. case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
  294. case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
  295. case 'Combodo\\iTop\\Form\\Field\\SelectField':
  296. case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
  297. case 'Combodo\\iTop\\Form\\Field\\HiddenField':
  298. $oOutput->AddJs(
  299. <<<EOF
  300. $("#{$this->oField->GetGlobalId()}").off("change keyup").on("change keyup", function(){
  301. var me = this;
  302. $(this).closest(".field_set").trigger("field_change", {
  303. id: $(me).attr("id"),
  304. name: $(me).closest(".form_field").attr("data-field-id"),
  305. value: $(me).val()
  306. });
  307. });
  308. EOF
  309. );
  310. break;
  311. case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
  312. // We need the focusout event has the datepicker widget seems to override the change event
  313. $oOutput->AddJs(
  314. <<<EOF
  315. $("#{$this->oField->GetGlobalId()}").off("change keyup focusout").on("change keyup focusout", function(){
  316. var me = this;
  317. $(this).closest(".field_set").trigger("field_change", {
  318. id: $(me).attr("id"),
  319. name: $(me).closest(".form_field").attr("data-field-id"),
  320. value: $(me).val()
  321. });
  322. });
  323. EOF
  324. );
  325. break;
  326. case 'Combodo\\iTop\\Form\\Field\\RadioField':
  327. case 'Combodo\\iTop\\Form\\Field\\CheckboxField':
  328. $oOutput->AddJs(
  329. <<<EOF
  330. $("#{$this->oField->GetGlobalId()} input").off("change").on("change", function(){
  331. var me = this;
  332. $(this).closest(".field_set").trigger("field_change", {
  333. id: $(me).closest("#{$this->oField->GetGlobalId()}").attr("id"),
  334. name: $(me).attr("name"),
  335. value: $(me).val()
  336. });
  337. });
  338. EOF
  339. );
  340. break;
  341. }
  342. // JS Form field widget construct
  343. $aValidators = array();
  344. foreach ($this->oField->GetValidators() as $oValidator)
  345. {
  346. $aValidators[$oValidator::GetName()] = array(
  347. 'reg_exp' => $oValidator->GetRegExp(),
  348. 'message' => Dict::S($oValidator->GetErrorMessage())
  349. );
  350. }
  351. $sFormFieldOptions = json_encode(array(
  352. 'validators' => $aValidators
  353. ));
  354. switch ($sFieldClass)
  355. {
  356. case 'Combodo\\iTop\\Form\\Field\\PasswordField':
  357. case 'Combodo\\iTop\\Form\\Field\\StringField':
  358. case 'Combodo\\iTop\\Form\\Field\\SelectField':
  359. case 'Combodo\\iTop\\Form\\Field\\MultipleSelectField':
  360. case 'Combodo\\iTop\\Form\\Field\\HiddenField':
  361. case 'Combodo\\iTop\\Form\\Field\\RadioField':
  362. case 'Combodo\\iTop\\Form\\Field\\CheckboxField':
  363. case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
  364. $oOutput->AddJs(
  365. <<<EOF
  366. $("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field($sFormFieldOptions);
  367. EOF
  368. );
  369. break;
  370. case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
  371. case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
  372. // Overloading $sFormFieldOptions to include the set_current_value_callback. It would have been nicer to refactor the variable for all field types, but as this is a fix for a maintenance release, we rather be safe.
  373. $sValidators = json_encode($aValidators);
  374. $oOutput->AddJs(
  375. <<<EOF
  376. $("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html({
  377. validators: $sValidators,
  378. set_current_value_callback: function(me, oEvent, oData){ $(me.element).find('textarea').val(oData); }
  379. });
  380. EOF
  381. );
  382. // MagnificPopup on images
  383. $oOutput->AddJs(InlineImage::FixImagesWidth());
  384. break;
  385. }
  386. return $oOutput;
  387. }
  388. protected function PreparingCaseLogEntries(RenderingOutput &$oOutput)
  389. {
  390. $aEntries = $this->oField->GetEntries();
  391. if (count($aEntries) > 0)
  392. {
  393. $oOutput->AddHtml('<div>');
  394. for ($i = 0; $i < count($aEntries); $i++)
  395. {
  396. $sEntryDate = AttributeDateTime::GetFormat()->Format($aEntries[$i]['date']);
  397. $sEntryUser = $aEntries[$i]['user_login'];
  398. $sEntryHeader = Dict::Format('UI:CaseLog:Header_Date_UserName', $sEntryDate, $sEntryUser);
  399. // Only the last 2 entries are expanded by default
  400. $sEntryContentExpanded = ($i < 2) ? 'true' : 'false';
  401. $sEntryHeaderButtonClass = ($i < 2) ? '' : 'collapsed';
  402. $sEntryContentClass = ($i < 2) ? 'in' : '';
  403. $sEntryContentId = 'caselog_field_entry_content-' . $this->oField->GetGlobalId() . '-' . $i;
  404. // Note : We use CKEditor stylesheet to format this
  405. $oOutput->AddHtml(
  406. <<<EOF
  407. <div class="caselog_field_entry cke_inner">
  408. <div class="caselog_field_entry_header">
  409. {$sEntryHeader}
  410. <div class="pull-right">
  411. <span class="caselog_field_entry_button {$sEntryHeaderButtonClass}" data-toggle="collapse" href="#{$sEntryContentId}" aria-expanded="{$sEntryContentExpanded}" aria-controls="{$sEntryContentId}"></span>
  412. </div>
  413. </div>
  414. <div class="caselog_field_entry_content collapse {$sEntryContentClass}" id="{$sEntryContentId}">
  415. {$aEntries[$i]['message_html']}
  416. </div>
  417. </div>
  418. EOF
  419. );
  420. }
  421. $oOutput->AddHtml('</div>');
  422. }
  423. }
  424. }