HtmlExport.class.php 895 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once(__DIR__.SLASH.'TextExport.class.php');
  3. class HtmlExport extends TextExport{
  4. public static $mime = 'text/html';
  5. public static $extension = 'html';
  6. public static $description = 'Fichier page web HTML';
  7. public static function sample($dataset){
  8. $stream = '<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"></head><body>';
  9. foreach($dataset as $macro => $infos)
  10. $stream .= ($infos['type']=='list') ? '{{#'.$macro.'}}{{/'.$macro.'}} : '.$infos['desc'].'<br>' : '{{'.$macro.'}} : '.$infos['desc'].'<br>'.PHP_EOL;
  11. $stream .= '</body></html>';
  12. return $stream;
  13. }
  14. public static function from_template($source, $data, $return, $isHtml=true){
  15. $htmlRaw = TextExport::from_template($source, $data, $return, $isHtml);
  16. $stream = $return=='stream' ? $htmlRaw : file_get_contents($htmlRaw);
  17. if($return!='stream') return $htmlRaw;
  18. return $stream;
  19. }
  20. }
  21. ?>