[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/addressbook/inc/export/ -> Outlook_CSV_-_French (source)

   1  <?php
   2  // This file defines a set of functions and an associative array.
   3  // The key of the array corresponds to a header in the source
   4  // export file and the value of the array item will be used in
   5  // the creation of the output file.
   6  //
   7  // An exported Outlook file looks like this:
   8  //
   9  // Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
  10  // <tab>Patrick<tab><tab>Walsh<tab>...
  11  //
  12  // Where the first line explains each optional field.  This is what
  13  // will be looked up in the key.
  14  //
  15  // The array need not be in any order and any fields not defined will
  16  // not be transferred.  If the val='+', the value will be appended to
  17  // the previous field and any text after the '+' will be appended 
  18  // before the value.  For example, the following would add a comma and
  19  // a space between LastName and FirstName and store it in FullName:
  20  //
  21  //    array("LastName" => "FullName","FirstName" => "+, ");
  22  //
  23  // Also start with a '#' symbol and a comma separated list will be
  24  // turned into a number of the same entries.
  25  
  26      class export_conv
  27      {
  28          var $currentrecord = array(); //used for buffering to allow uid lines to go first
  29          var $id;
  30          var $type = 'csv';
  31  
  32          var $export = array(
  33              'title'               => 'Fonction',
  34              'n_given'             => 'Prénom',
  35              'n_middle'            => 'Deuxième prénom',
  36              'n_family'            => 'Nom',
  37              'n_suffix'            => 'Suffixe',
  38              'org_name'            => 'Société',
  39              'org_unit'            => 'Service',
  40              'adr_one_street'      => 'Rue (bureau)',
  41              'address2'            => 'Rue (bureau) 2',
  42              'address3'            => 'Rue (bureau) 3',
  43              'adr_one_locality'    => 'Ville (bureau)',
  44              'adr_one_region'      => 'État/Prov (bureau)',
  45              'adr_one_postalcode'  => 'Code postal (bureau)',
  46              'adr_one_countryname' => 'Pays (bureau)',
  47              'adr_two_street'      => 'Rue (domicile)',
  48              'adr_two_locality'    => 'Ville (domicile)',
  49              'adr_two_region'      => 'État/Prov (domicile)',
  50              'adr_two_postalcode'  => 'Code postal (domicile)',
  51              'adr_two_countryname' => 'Pays (domicile)',
  52              'tel_fax'             => 'Télécopie (bureau)',
  53              'tel_work'            => 'Téléphone (bureau)',
  54              'tel_msg'             => "Téléphone de l'assistant(e)",
  55              'tel_car'             => 'Téléphone (voiture)',
  56              'tel_isdn'            => 'RNIS',
  57              'tel_home'            => 'Téléphone (domicile)',
  58              'tel_cell'            => 'Tél. mobile',
  59              'tel_pager'           => 'Récepteur de radiomessagerie',
  60              'ophone'              => 'Téléphone 2 (bureau)',
  61              'bday'                => 'Anniversaire',
  62              'email'               => 'Adresse e-mail',
  63              'email_home'          => 'Adresse e-mail 2',
  64              'url'                 => 'Page Web',
  65              'note'                => 'Notes'
  66          );
  67  
  68          // This will store the contacts object
  69          var $contacts = '';
  70  
  71  		function export_start_file($buffer,$ncat_id='')
  72          {
  73              $this->id=-1;
  74              if ($ncat_id)
  75              {
  76                  $filter = 'tid=n,cat_id='.$ncat_id;
  77              }
  78              else
  79              {
  80                  $filter = 'tid=n';
  81              }
  82              $this->contacts = CreateObject('phpgwapi.contacts');
  83  
  84              $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
  85              for ($i=0;$i<count($tmp);$i++)
  86              {
  87                  $this->ids[$i] = $tmp[$i]['id'];
  88              }
  89              // $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
  90              // $buffer is still empty
  91              return $buffer;
  92          }
  93  
  94          // Read each entry
  95  		function export_start_record($buffer)
  96          {
  97              $this->id++;
  98              $top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
  99              $this->currentrecord = $top[0];
 100              return $buffer;
 101          }
 102  
 103          // Read each attribute, populate buffer
 104          // name/value are the fields from the export array above
 105  		function export_new_attrib($buffer,$name,$value)
 106          {
 107              if ($this->export[$name])
 108              {
 109                  $buffer[$this->id][$this->export[$name]] = $value;
 110                  //echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
 111              }
 112              return $buffer;
 113          }
 114  
 115          // Tack on some extra values
 116  		function export_end_record($buffer)
 117          {
 118              return $buffer;
 119          }
 120  
 121  		function export_end_file($buffer)
 122          {
 123              // Build the header for the file (field list)
 124              reset($this->export);
 125              while (list($name,$value)=each($this->export))
 126              {
 127                  $entries .= $value . ',';
 128              }
 129              $entries = substr($entries,0,-1);
 130              $entries .= "\r\n";
 131  
 132              // Now add all the data
 133              reset($this->ids);
 134              for ($i=0;$i<count($this->ids);$i++)
 135              {
 136                  reset($this->export);
 137                  while (list($name,$value)=each($this->export))
 138                  {
 139                      $entries .= $buffer[$i][$value] . ',';
 140                  }
 141                  $entries = substr($entries,0,-1);
 142                  $entries .= "\r\n";
 143              }
 144              $buffer = $entries;
 145              return $buffer;
 146          }
 147      }
 148  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7