csv_writer.class.php 931 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Glossary;
  3. use Chamilo;
  4. /**
  5. * Write glossary 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 \Glossary\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. 'name' => 'name',
  28. 'description' => 'description'
  29. );
  30. parent::__construct($stream, $map, $delimiter, $enclosure);
  31. }
  32. function get_path()
  33. {
  34. return $this->path;
  35. }
  36. }