[ 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_-_English (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              'n_prefix'            => 'Title',
  34              'n_given'             => 'First Name',
  35              'n_middle'            => 'Middle Name',
  36              'n_family'            => 'Last Name',
  37              'n_suffix'            => 'Suffix',
  38              'org_name'            => 'Company',
  39              'org_unit'            => 'Department',
  40              'title'               => 'Job Title',
  41              'adr_one_street'      => 'Business Street',
  42              'address2'            => 'Business Street 2',
  43              'address3'            => 'Business Street 3',
  44              'adr_one_locality'    => 'Business City',
  45              'adr_one_region'      => 'Business State',
  46              'adr_one_postalcode'  => 'Business Postal Code',
  47              'adr_one_countryname' => 'Business Country',
  48              'adr_two_street'      => 'Home Street',
  49              'adr_two_locality'    => 'Home City',
  50              'adr_two_region'      => 'Home State',
  51              'adr_two_postalcode'  => 'Home Postal Code',
  52              'adr_two_countryname' => 'Home Country',
  53              'tel_fax'             => 'Business Fax',
  54              'tel_work'            => 'Business Phone',
  55              'tel_msg'             => "Assistant's Phone",
  56              'tel_car'             => 'Car Phone',
  57              'tel_isdn'            => 'ISDN',
  58              'tel_home'            => 'Home Phone',
  59              'tel_cell'            => 'Mobile Phone',
  60              'tel_pager'           => 'Pager',
  61              'ophone'              => 'Business Phone 2',
  62              'bday'                => 'Birthday',
  63              'email'               => 'E-mail Address',
  64              'email_home'          => 'E-mail Address 2',
  65              'url'                 => 'Web Page',
  66              'note'                => 'Notes'
  67          );
  68  
  69          // This will store the contacts object
  70          var $contacts = '';
  71  
  72  		function export_start_file($buffer,$ncat_id='')
  73          {
  74              $this->id=-1;
  75              if ($ncat_id)
  76              {
  77                  $filter = 'tid=n,cat_id='.$ncat_id;
  78              }
  79              else
  80              {
  81                  $filter = 'tid=n';
  82              }
  83              $this->contacts = CreateObject('phpgwapi.contacts');
  84  
  85              $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
  86              for ($i=0;$i<count($tmp);$i++)
  87              {
  88                  $this->ids[$i] = $tmp[$i]['id'];
  89              }
  90              // $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
  91              // $buffer is still empty
  92              return $buffer;
  93          }
  94  
  95          // Read each entry
  96  		function export_start_record($buffer)
  97          {
  98              $this->id++;
  99              $top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
 100              $this->currentrecord = $top[0];
 101              return $buffer;
 102          }
 103  
 104          // Read each attribute, populate buffer
 105          // name/value are the fields from the export array above
 106  		function export_new_attrib($buffer,$name,$value)
 107          {
 108              if ($this->export[$name])
 109              {
 110                  $buffer[$this->id][$this->export[$name]] = $value;
 111                  //echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
 112              }
 113              return $buffer;
 114          }
 115  
 116          // Tack on some extra values
 117  		function export_end_record($buffer)
 118          {
 119              return $buffer;
 120          }
 121  
 122  		function export_end_file($buffer)
 123          {
 124              // Build the header for the file (field list)
 125              reset($this->export);
 126              while (list($name,$value)=each($this->export))
 127              {
 128                  $entries .= $value . ',';
 129              }
 130              $entries = substr($entries,0,-1);
 131              $entries .= "\r\n";
 132  
 133              // Now add all the data
 134              reset($this->ids);
 135              for ($i=0;$i<count($this->ids);$i++)
 136              {
 137                  reset($this->export);
 138                  while (list($name,$value)=each($this->export))
 139                  {
 140                      $entries .= $buffer[$i][$value] . ',';
 141                  }
 142                  $entries = substr($entries,0,-1);
 143                  $entries .= "\r\n";
 144              }
 145              $buffer = $entries;
 146              return $buffer;
 147          }
 148      }
 149  ?>


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