| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
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' => 'Anrede', 34 'n_given' => 'Vorname', 35 'n_middle' => 'Weitere Vornamen', 36 'n_family' => 'Nachname', 37 'n_suffix' => 'Suffix', 38 'org_name' => 'Firma', 39 'org_unit' => 'Abteilung', 40 'title' => 'Position', 41 'adr_one_street' => 'Straße geschäftlich', 42 'address2' => 'Straße geschäftlich 2', 43 'address3' => 'Straße geschäftlich 3', 44 'adr_one_locality' => 'Ort geschäftlich', 45 'adr_one_region' => 'Region geschäftlich', 46 'adr_one_postalcode' => 'Postleitzahl geschäftlich', 47 'adr_one_countryname' => 'Land geschäftlich', 48 'adr_two_street' => 'Straße privat', 49 'adr_two_locality' => 'Ort privat', 50 'adr_two_region' => 'Region privat', 51 'adr_two_postalcode' => 'Postleitzahl privat', 52 'adr_two_countryname' => 'Land privat', 53 'tel_fax' => 'Fax geschäftlich', 54 'tel_work' => 'Telefon geschäftlich', 55 'tel_msg' => 'Telefon Assistent', 56 'tel_car' => 'Autotelefon', 57 'tel_isdn' => 'ISDN', 58 'tel_home' => 'Telefon privat', 59 'tel_cell' => 'Mobiltelefon', 60 'tel_pager' => 'Pager', 61 'ophone' => 'Telefon geschäftlich 2', 62 'bday' => 'Geburtstag', 63 'email' => 'E-Mail-Adresse', 64 'email_home' => 'E-Mail 2: Adresse', 65 'url' => 'Webseite', 66 'note' => 'Notizen' 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 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |