imagefield.class.inc.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // Copyright (C) 2010-2017 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 \utils;
  20. use \Dict;
  21. use \ormDocument;
  22. use \Combodo\iTop\Form\Field\BlobField;
  23. /**
  24. * Description of ImageField
  25. *
  26. * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
  27. */
  28. class ImageField extends BlobField
  29. {
  30. public function GetDisplayValue()
  31. {
  32. if ($this->currentValue->IsEmpty())
  33. {
  34. $sValue = Dict::S('Portal:File:None');
  35. }
  36. else
  37. {
  38. $sFilename = $this->currentValue->GetFileName();
  39. $iSize = utils::BytesToFriendlyFormat(strlen($this->currentValue->GetData()));
  40. $sOpenLink = $this->GetDisplayUrl();
  41. $sDownloadLink = $this->GetDownloadUrl();
  42. $sValue = Dict::Format('Portal:File:DisplayInfo+', $sFilename, $iSize, $sOpenLink, $sDownloadLink);
  43. }
  44. return $sValue;
  45. }
  46. }