csv_writer.class.php 915 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Notebook;
  3. use Chamilo;
  4. /**
  5. * Write notebook entries to a file in CSV format.
  6. *
  7. * @license /licence.txt
  8. * @author Laurent Opprecht <laurent@opprecht.info>
  9. */
  10. class CsvWriter extends \CsvObjectWriter
  11. {
  12. /**
  13. *
  14. * @return \Notebook\CsvWriter
  15. */
  16. public static function create($path = '', $delimiter = ';', $enclosure = '"')
  17. {
  18. return new self($path, $delimiter, $enclosure);
  19. }
  20. protected $path = '';
  21. function __construct($path = '', $delimiter = ';', $enclosure = '"')
  22. {
  23. $path = $path ? $path : Chamilo::temp_file();
  24. $this->path = $path;
  25. $stream = new \FileWriter($path);
  26. $map = array(
  27. 'title' => 'title',
  28. 'description' => 'description'
  29. );
  30. parent::__construct($stream, $map, $delimiter, $enclosure);
  31. }
  32. function get_path()
  33. {
  34. return $this->path;
  35. }
  36. }