PlaintextFormat.php 563 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Plaintext
  4. * Returns $this->items as raw php data.
  5. */
  6. class PlaintextFormat extends FormatAbstract {
  7. public function stringify(){
  8. $items = $this->getItems();
  9. $toReturn = print_r($items, true);
  10. // Remove invalid non-UTF8 characters
  11. ini_set('mbstring.substitute_character', 'none');
  12. $toReturn = mb_convert_encoding($toReturn, $this->getCharset(), 'UTF-8');
  13. return $toReturn;
  14. }
  15. public function display(){
  16. $this
  17. ->setContentType('text/plain; charset=' . $this->getCharset())
  18. ->callContentType();
  19. return parent::display();
  20. }
  21. }