1 | <?php |
---|
2 | /* |
---|
3 | * Created on 11 juil. 2011 |
---|
4 | * |
---|
5 | * To change the template for this generated file go to |
---|
6 | * Window - Preferences - PHPeclipse - PHP - Code Templates |
---|
7 | */ |
---|
8 | |
---|
9 | function init_term_convert(){ |
---|
10 | global $base_path; |
---|
11 | |
---|
12 | global $convert; |
---|
13 | $convert = array(); |
---|
14 | $fp = fopen("$base_path/admin/convert/imports/delphe2unimarciso/TabCorrespDelphes.txt","r"); |
---|
15 | while (!feof($fp)) { |
---|
16 | $data = fgetcsv($fp,4096,"\t"); |
---|
17 | $convert[$data[0]] = array('aciege' => $data[2], 'delphes' => $data[3]); |
---|
18 | } |
---|
19 | fclose($fp); |
---|
20 | } |
---|
21 | init_term_convert(); |
---|
22 | function convert_delphe($notice, $s, $islast, $isfirst, $param_path) { |
---|
23 | global $charset; |
---|
24 | global $convert; |
---|
25 | |
---|
26 | $fields=explode("\t",$notice); |
---|
27 | $id=trim($fields[0]); |
---|
28 | $lang=trim($fields[1]); |
---|
29 | $titre=trim($fields[2]); |
---|
30 | $auteur_physiques=trim($fields[3]); |
---|
31 | $auteur_moraux=trim($fields[4]); |
---|
32 | $perio_name=trim($fields[5]); |
---|
33 | $date=trim($fields[6]); |
---|
34 | $resume=trim($fields[7]); |
---|
35 | $num_bulletin=trim($fields[8]); |
---|
36 | $pagin=trim($fields[9]); |
---|
37 | $desc_fre=trim($fields[10]); |
---|
38 | $desc_geo_fre=trim($fields[11]); |
---|
39 | $mots=trim($fields[12]); |
---|
40 | $societe=trim($fields[13]); |
---|
41 | $url=trim($fields[14]); |
---|
42 | |
---|
43 | //Construction du fichier |
---|
44 | $error=""; |
---|
45 | if($fields) |
---|
46 | $data=" |
---|
47 | <notice>"; |
---|
48 | |
---|
49 | $data.= " |
---|
50 | <rs>n</rs> |
---|
51 | <dt>a</dt> |
---|
52 | <bl>a</bl> |
---|
53 | <hl>2</hl> |
---|
54 | <el>1</el> |
---|
55 | <ru>i</ru>"; |
---|
56 | //id |
---|
57 | $data.=" |
---|
58 | <f c='001'>".htmlspecialchars($id,ENT_NOQUOTES,$charset)."</f>"; |
---|
59 | |
---|
60 | //langues |
---|
61 | //peut etre multiple, 1er = langues de publication, 2nd et al.= langues orginales... |
---|
62 | $langues = explode("|",$lang); |
---|
63 | if(count($langues)){ |
---|
64 | if(count($langues)>1) $ind = "1 "; |
---|
65 | else $ind = "0 "; |
---|
66 | $data.=" |
---|
67 | <f c='101' ind='$ind'>"; |
---|
68 | for($i=0 ; $i<count($langues) ; $i++){ |
---|
69 | $lang = strtolower(substr($langues[$i],0,3)); |
---|
70 | if($lang == "fra") $lang = "fre"; |
---|
71 | else $lang = "eng"; |
---|
72 | if($i==0){ |
---|
73 | $data.=" |
---|
74 | <s c='a'>".$lang."</s>"; |
---|
75 | }else{ |
---|
76 | $data.=" |
---|
77 | <s c='c'>".htmlspecialchars($lang,ENT_NOQUOTES,$charset)."</s>"; |
---|
78 | } |
---|
79 | } |
---|
80 | $data.=" |
---|
81 | </f>"; |
---|
82 | } |
---|
83 | |
---|
84 | //titre |
---|
85 | $data.=" |
---|
86 | <f c='200' ind=' 1'>"; |
---|
87 | $data.=" |
---|
88 | <s c='a'>".htmlspecialchars($titre,ENT_NOQUOTES,$charset)."</s>"; |
---|
89 | $data.=" |
---|
90 | </f>"; |
---|
91 | |
---|
92 | //pagination |
---|
93 | if($pagin){ |
---|
94 | $data .= " |
---|
95 | <f c='215' ind=' '> |
---|
96 | <s c='a'>".htmlspecialchars($pagin,ENT_NOQUOTES,$charset)."</s> |
---|
97 | </f>"; |
---|
98 | } |
---|
99 | |
---|
100 | if($resume){ |
---|
101 | $data.=" |
---|
102 | <f c='330' ind=' '> |
---|
103 | <s c='a'>".htmlspecialchars($resume,ENT_NOQUOTES,$charset)."</s> |
---|
104 | </f>"; |
---|
105 | } |
---|
106 | |
---|
107 | //titre pério |
---|
108 | if($perio_name){ |
---|
109 | $data .= " |
---|
110 | <f c='461' ind=' '> |
---|
111 | <s c='t'>".htmlspecialchars($perio_name,ENT_NOQUOTES,$charset)."</s> |
---|
112 | </f>"; |
---|
113 | } |
---|
114 | |
---|
115 | //infos bulletin |
---|
116 | if($date || $num_bulletin){ |
---|
117 | $data .= " |
---|
118 | <f c='463' ind=' '>"; |
---|
119 | if($date) $data.=" |
---|
120 | <s c='d'>$date</s>"; |
---|
121 | if($num_bulletin) $data.=" |
---|
122 | <s c='v'>".htmlspecialchars($num_bulletin,ENT_NOQUOTES,$charset)."</s>"; |
---|
123 | $data.=" |
---|
124 | </f>"; |
---|
125 | } |
---|
126 | |
---|
127 | //descripteurs |
---|
128 | if($desc_fre){ |
---|
129 | $desc= explode("|",$desc_fre); |
---|
130 | if(count($desc)){ |
---|
131 | foreach($desc as $term){ |
---|
132 | $data.=" |
---|
133 | <f c='606' ind=' '> |
---|
134 | <s c='a'>".htmlspecialchars($term,ENT_NOQUOTES,$charset)."</s> |
---|
135 | </f>"; |
---|
136 | // if($convert[$term]){ |
---|
137 | // $data.=" |
---|
138 | // <f c='606' ind='# '>"; |
---|
139 | // if($convert[$term]['aciege']!= ""){ |
---|
140 | // $data.=" |
---|
141 | // <s c='a'>".htmlspecialchars($convert[$term]['aciege'],ENT_NOQUOTES,$charset)."</s>"; |
---|
142 | // }else { |
---|
143 | // $data.=" |
---|
144 | // <s c='2'>delphes</s> |
---|
145 | // <s c='a'>".htmlspecialchars($convert[$term]['delphes'],ENT_NOQUOTES,$charset)."</s>"; |
---|
146 | // } |
---|
147 | // $data.=" |
---|
148 | // </f>"; |
---|
149 | // }else { |
---|
150 | // $data.=" |
---|
151 | // <f c='610' ind=' '> |
---|
152 | // <s c='a'>".htmlspecialchars($term,ENT_NOQUOTES,$charset)."</s> |
---|
153 | // </f>"; |
---|
154 | // } |
---|
155 | } |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | //descripteurs géo |
---|
160 | if($desc_geo_fre){ |
---|
161 | $desc= explode("|",$desc_geo_fre); |
---|
162 | if(count($desc)){ |
---|
163 | foreach($desc as $term){ |
---|
164 | $data.=" |
---|
165 | <f c='606' ind=' '> |
---|
166 | <s c='a'>".htmlspecialchars($term,ENT_NOQUOTES,$charset)."</s> |
---|
167 | </f>"; |
---|
168 | // if($convert[$term]){ |
---|
169 | // $data.=" |
---|
170 | // <f c='606' ind='# '>"; |
---|
171 | // if($convert[$term]['aciege']!= ""){ |
---|
172 | // $data.=" |
---|
173 | // <s c='a'>".htmlspecialchars($convert[$term]['aciege'],ENT_NOQUOTES,$charset)."</s>"; |
---|
174 | // }else { |
---|
175 | // $data.=" |
---|
176 | // <s c='2'>delphes</s> |
---|
177 | // <s c='a'>".htmlspecialchars($convert[$term]['delphes'],ENT_NOQUOTES,$charset)."</s>"; |
---|
178 | // } |
---|
179 | // $data.=" |
---|
180 | // </f>"; |
---|
181 | // }else { |
---|
182 | // $data.=" |
---|
183 | // <f c='610' ind=' '> |
---|
184 | // <s c='a'>".htmlspecialchars($term,ENT_NOQUOTES,$charset)."</s> |
---|
185 | // </f>"; |
---|
186 | // } |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|
190 | //mots-clés |
---|
191 | if($mots){ |
---|
192 | $keywords= explode("|",$mots); |
---|
193 | if(count($keywords)){ |
---|
194 | foreach($keywords as $keyword){ |
---|
195 | $data.=" |
---|
196 | <f c='606' ind=' '> |
---|
197 | <s c='a'>".htmlspecialchars($keyword,ENT_NOQUOTES,$charset)."</s> |
---|
198 | </f>"; |
---|
199 | } |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | //auteurs |
---|
204 | $auteurs =array(); |
---|
205 | if($auteur_physiques) $auteurs = explode("|",$auteur_physiques); |
---|
206 | if(count($auteurs)){ |
---|
207 | for($i=0 ; $i<count($auteurs) ; $i++){ |
---|
208 | if($i == 0 ) $field = "700"; |
---|
209 | else $field = "701"; |
---|
210 | $data .= " |
---|
211 | <f c='$field' ind=' '>"; |
---|
212 | if(preg_match("/([^(]*)\(([^)]*)/",$auteurs[$i],$matches)){ |
---|
213 | $data.=" |
---|
214 | <s c='a'>".trim(htmlspecialchars($matches[1],ENT_NOQUOTES,$charset))."</s> |
---|
215 | <s c='b'>".trim(htmlspecialchars($matches[2],ENT_NOQUOTES,$charset))."</s>"; |
---|
216 | }else{ |
---|
217 | $data.=" |
---|
218 | <s c='a'>".htmlspecialchars($auteurs[$i],ENT_NOQUOTES,$charset)."</s>"; |
---|
219 | } |
---|
220 | $data .= " |
---|
221 | </f>"; |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | //collectivités |
---|
226 | $aut_coll = array(); |
---|
227 | if($auteur_moraux) $aut_coll = explode("|",$auteur_moraux); |
---|
228 | if(count($aut_coll)){ |
---|
229 | for($i=0 ; $i<count($aut_coll) ; $i++){ |
---|
230 | if($i == 0 && count($auteurs) == 0) $field = "710"; |
---|
231 | else $field = "711"; |
---|
232 | $data .= " |
---|
233 | <f c='$field' ind=' '> |
---|
234 | <s c='a'>".htmlspecialchars($aut_coll[$i],ENT_NOQUOTES,$charset)."</s> |
---|
235 | </f>"; |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | //URL |
---|
240 | if($url){ |
---|
241 | $data.=" |
---|
242 | <f c='856' ind=' '> |
---|
243 | <s c='u'>".htmlspecialchars($url,ENT_NOQUOTES,$charset)."</s> |
---|
244 | </f>"; |
---|
245 | } |
---|
246 | |
---|
247 | //societe |
---|
248 | if($societe){ |
---|
249 | $keywords= explode("|",$societe); |
---|
250 | if(count($keywords)){ |
---|
251 | foreach($keywords as $keyword){ |
---|
252 | $data.=" |
---|
253 | <f c='606' ind=' '> |
---|
254 | <s c='2'>local</s> |
---|
255 | <s c='a'>".htmlspecialchars($keyword,ENT_NOQUOTES,$charset)."</s> |
---|
256 | </f>"; |
---|
257 | } |
---|
258 | } |
---|
259 | } |
---|
260 | |
---|
261 | $data .= " |
---|
262 | </notice>"; |
---|
263 | if (!$error) $r['VALID'] = true; else $r['VALID']=false; |
---|
264 | $r['ERROR'] = $error; |
---|
265 | $r['DATA'] = $data; |
---|
266 | return $r; |
---|
267 | } |
---|
268 | ?> |
---|