FusionDirectory
 All Data Structures Files Functions Variables
class_cvsExporter.inc
Go to the documentation of this file.
1 <?php
2 
3 /*
4  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
5  Copyright (C) 2003-2010 Cajus Pollmeier
6  Copyright (C) 2011-2016 FusionDirectory
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
32 {
33  var $result;
34 
46  function __construct($headline, $header, $entries, $columns = array())
47  {
48  // If no preset, render all columns
49  if (!count($columns)) {
50  foreach ($header as $index => $dummy) {
51  $columns[] = $index;
52  }
53  }
54 
55  // Generate header
56  $this->result = "#";
57  foreach ($columns as $index) {
58  if (isset($header[$index])) {
59  $this->result .= trim(html_entity_decode($header[$index], ENT_QUOTES, 'UTF-8').";");
60  } else {
61  $this->result .= ";";
62  }
63  }
64  $this->result = preg_replace('/;$/', '', $this->result)."\n";
65 
66  // Append entries
67  foreach ($entries as $row) {
68  foreach ($columns as $index) {
69  if (isset($row["_sort$index"])) {
70  $this->result .= trim(html_entity_decode($row["_sort$index"], ENT_QUOTES, 'UTF-8')).";";
71  } else {
72  $this->result .= ";";
73  }
74  }
75  $this->result = preg_replace('/;$/', '', $this->result)."\n";
76  }
77  }
78 
82  function query()
83  {
84  return $this->result;
85  }
86 
87 
91  static function getInfo()
92  {
93  return array("exportCSV" => array( "label" => _("CSV"), "image" => "geticon.php?context=mimetypes&icon=text-csv&size=16", "class" => "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" ));
94  }
95 
96 }
97 
98 ?>
query()
Get the result.
static getInfo()
Get Informations.
__construct($headline, $header, $entries, $columns=array())
Create a cvsExporter.
This class contains all the functions needed for cvs export.