RenderText.php 879 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ V6M2gIA9HZy47f/3KeqWMZXbmDV0AMuzew76i18BHts=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.2
  11. */
  12. /**
  13. * processes an input value and renders it as forced text
  14. * applies nl2br as well
  15. */
  16. namespace Cube\View\Helper;
  17. class RenderText extends AbstractHelper
  18. {
  19. /**
  20. *
  21. * output formatted string
  22. *
  23. * @param string $string
  24. * @param bool $nl2br
  25. *
  26. * @return string
  27. */
  28. public function renderText($string, $nl2br = false)
  29. {
  30. $output = trim(str_ireplace(
  31. array("'", '"', '<', '>'), array('&#039;', '&quot;', '&lt;', '&gt;'),
  32. stripslashes(rawurldecode($string))));
  33. return ($nl2br) ? nl2br($output) : $output;
  34. }
  35. }