Overview

Packages

  • Hermes
  • Horde
    • Data
  • Kronolith
  • None

Classes

  • Hermes_Data_Hermescsv
  • Hermes_Data_Hermestsv
  • Hermes_Data_Hermesxls
  • Hermes_Data_Iif
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Hermes_Data_Hermescsv class extends Horde's CSV Data class with
 4:  * Hermes-specific handling.
 5:  *
 6:  * See the enclosed file LICENSE for license information (BSD). If you
 7:  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 8:  *
 9:  * @author Chuck Hagenbuch <chuck@horde.org>
10:  * @package Horde_Data
11:  */
12: class Hermes_Data_Hermescsv extends Horde_Data_Csv
13: {
14:     public function exportData(
15:         $data, $header = true, $export_mapping = array())
16:     {
17:         return parent::exportData($this->_map($data), $header, $export_mapping);
18:     }
19: 
20:     protected function _map($data)
21:     {
22:         $count = count($data);
23:         for ($i = 0; $i < $count; $i++) {
24:             $data[$i] = $data[$i]->toArray();
25:             $data[$i]['description'] = str_replace(array("\r", "\n"), array('', ' '), $data[$i]['description']);
26:             $data[$i]['note'] = str_replace(array("\r", "\n"), array('', ' '), $data[$i]['note']);
27:             $data[$i]['timestamp'] = $data[$i]['date'];
28:             $data[$i]['date'] = date('m/d/y', $data[$i]['date']);
29:             $data[$i]['duration'] = date('H:i', mktime(0, $data[$i]['hours'] * 60));
30:             $data[$i]['billable'] = $data[$i]['billable'] == 2 ? '' : $data[$i]['billable'];
31:         }
32: 
33:         return $data;
34:     }
35: 
36: }
37: 
API documentation generated by ApiGen