[ 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 'title' => 'Tehtävänimike', 34 'n_given' => 'Etunimi', 35 'n_middle' => 'Toinen nimi', 36 'n_family' => 'Sukunimi', 37 'n_suffix' => 'Jälkiliite', 38 'org_name' => 'Yritys', 39 'org_unit' => 'Osasto', 40 'adr_one_street' => 'Lähiosoite (työ)', 41 'Business Street 2' => 'Lähiosoite (työ) 2', 42 'Business Street 3' => 'Lähiosoite (työ) 3', 43 'Business City' => 'Postitoimipaikka (työ)', 44 'Business State' => 'Sijaintitiedot (työ)', 45 'Business Postal Code' => 'Postinumero (työ)', 46 'Business Country' => 'Maa (työ)', 47 'Home Street' => 'Lähiosoite (koti)', 48 'Home City' => 'Postitoimipaikka (koti)', 49 'Home State' => 'Sijaintitiedot (koti)', 50 'Home Postal Code' => 'Postinumero (koti)', 51 'Home Country' => 'Maa (koti)', 52 'Business Fax' => 'Työfaksi', 53 'Business Phone' => 'Työpuhelin', 54 "Assistant's Phone" => 'Avustajan puhelinnumero', 55 'Car Phone' => 'Autopuhelin', 56 'ISDN' => 'ISDN', 57 'Home Phone' => 'Kotipuhelin', 58 'Mobile Phone' => 'Matkapuhelin', 59 'Pager' => 'Hakulaite', 60 'Business Phone 2' => 'Työpuhelin 2', 61 'Birthday' => 'Syntymäpäivä', 62 'E-mail Address' => 'Sähköpostiosoite', 63 'E-mail Address 2' => 'Säköpostiosoite 2',// Note! Typo error in Finnish Outlook 2003 export addressbook to csv-file! 64 'Web Page' => 'Web-sivu', 65 'Notes' => 'Muistilaput' 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 ?>
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 |