Subversion Repositories Sites.tela-botanica.org

Rev

Rev 623 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
623 jpm 1
DELIMITER $$
627 jpm 2
DROP FUNCTION IF EXISTS pterido2.HTML_UnEncode$$
3
CREATE DEFINER=`pterido2`@`localhost` FUNCTION `HTML_UnEncode`(x VARCHAR(255)) RETURNS varchar(255) CHARSET latin1
623 jpm 4
BEGIN
5
 
6
DECLARE TextString VARCHAR(255) ;
7
SET TextString = x ;
8
 
627 jpm 9
IF INSTR( x , '"' )
10
THEN SET TextString = REPLACE(TextString, '"', '"') ;
11
END IF ;
12
 
623 jpm 13
IF INSTR( x , '&' )
14
THEN SET TextString = REPLACE(TextString, '&', '&') ;
15
END IF ;
16
 
627 jpm 17
IF INSTR( x , '<' )
18
THEN SET TextString = REPLACE(TextString, '&#60;', '<') ;
19
END IF ;
20
 
21
IF INSTR( x , '&#62;' )
22
THEN SET TextString = REPLACE(TextString, '&#62;', '>') ;
23
END IF ;
24
 
25
IF INSTR( x , '&#145;' )
26
THEN SET TextString = REPLACE(TextString, '&#145;', '‘') ;
27
END IF ;
28
 
623 jpm 29
IF INSTR( x , '&#146;' )
30
THEN SET TextString = REPLACE(TextString, '&#146;', '''') ;
31
END IF ;
32
 
627 jpm 33
IF INSTR( x , '&#147;' )
34
THEN SET TextString = REPLACE(TextString, '&#147;', '“') ;
35
END IF ;
36
 
37
IF INSTR( x , '&#148;' )
38
THEN SET TextString = REPLACE(TextString, '&#148;', '”') ;
39
END IF ;
40
 
41
IF INSTR( x , '&#156;' )
42
THEN SET TextString = REPLACE(TextString, '&#156;', 'œ') ;
43
END IF ;
44
 
45
IF INSTR( x , '&#171;' )
46
THEN SET TextString = REPLACE(TextString, '&#171;', '«') ;
47
END IF ;
48
 
623 jpm 49
IF INSTR( x , '&#176;' )
50
THEN SET TextString = REPLACE(TextString, '&#176;', '°') ;
51
END IF ;
52
 
627 jpm 53
IF INSTR( x , '&#177;' )
54
THEN SET TextString = REPLACE(TextString, '&#177;', '±') ;
55
END IF ;
56
 
57
IF INSTR( x , '&#178;' )
58
THEN SET TextString = REPLACE(TextString, '&#178;', '²') ;
59
END IF ;
60
 
61
IF INSTR( x , '&#185;' )
62
THEN SET TextString = REPLACE(TextString, '&#185;', '¹') ;
63
END IF ;
64
 
65
IF INSTR( x , '&#187;' )
66
THEN SET TextString = REPLACE(TextString, '&#187;', '»') ;
67
END IF ;
68
 
69
IF INSTR( x , '&#201;' )
70
THEN SET TextString = REPLACE(TextString, '&#201;', 'É');
71
END IF ;
72
 
73
IF INSTR( x , '&#206;' )
74
THEN SET TextString = REPLACE(TextString, '&#206;', 'Î');
75
END IF ;
76
 
77
IF INSTR( x , '&#225;' )
78
THEN SET TextString = REPLACE(TextString, '&#225;', 'á');
79
END IF ;
80
 
623 jpm 81
IF INSTR( x , '&#224;' )
82
THEN SET TextString = REPLACE(TextString, '&#224;', 'à');
83
END IF ;
84
 
85
IF INSTR( x , '&#226;' )
86
THEN SET TextString = REPLACE(TextString, '&#226;', 'â');
87
END IF ;
88
 
89
IF INSTR( x , '&#228;' )
90
THEN SET TextString = REPLACE(TextString, '&#228;', 'ä');
91
END IF ;
92
 
627 jpm 93
IF INSTR( x , '&#231;' )
94
THEN SET TextString = REPLACE(TextString, '&#231;', 'ç');
95
END IF ;
96
 
623 jpm 97
IF INSTR( x , '&#232;' )
98
THEN SET TextString = REPLACE(TextString, '&#232;', 'è');
99
END IF ;
100
 
101
IF INSTR( x , '&#233;' )
102
THEN SET TextString = REPLACE(TextString, '&#233;', 'é');
103
END IF ;
104
 
105
IF INSTR( x , '&#234;' )
106
THEN SET TextString = REPLACE(TextString, '&#234;', 'ê');
107
END IF ;
108
 
627 jpm 109
IF INSTR( x , '&#235;' )
110
THEN SET TextString = REPLACE(TextString, '&#235;', 'ë');
111
END IF ;
112
 
623 jpm 113
IF INSTR( x , '&#237;' )
114
THEN SET TextString = REPLACE(TextString, '&#237;', 'í');
115
END IF ;
116
 
117
IF INSTR( x , '&#238;' )
118
THEN SET TextString = REPLACE(TextString, '&#238;', 'î');
119
END IF ;
120
 
627 jpm 121
IF INSTR( x , '&#239;' )
122
THEN SET TextString = REPLACE(TextString, '&#239;', 'ï');
123
END IF ;
124
 
125
IF INSTR( x , '&#242;' )
126
THEN SET TextString = REPLACE(TextString, '&#242;', 'ò');
127
END IF ;
128
 
623 jpm 129
IF INSTR( x , '&#244;' )
130
THEN SET TextString = REPLACE(TextString, '&#244;', 'ô');
131
END IF ;
132
 
133
IF INSTR( x , '&#246;' )
134
THEN SET TextString = REPLACE(TextString, '&#246;', 'ö');
135
END IF ;
136
 
627 jpm 137
IF INSTR( x , '&#249;' )
138
THEN SET TextString = REPLACE(TextString, '&#249;', 'ù');
139
END IF ;
140
 
141
IF INSTR( x , '&#251;' )
142
THEN SET TextString = REPLACE(TextString, '&#251;', 'û');
143
END IF ;
144
 
623 jpm 145
IF INSTR( x , '&#252;' )
146
THEN SET TextString = REPLACE(TextString, '&#252;', 'ü');
147
END IF ;
148
 
627 jpm 149
IF INSTR( x , '&#255;' )
150
THEN SET TextString = REPLACE(TextString, '&#255;', 'ÿ');
151
END IF ;
152
 
623 jpm 153
RETURN TextString ;
154
 
155
END$$
156
 
157
DELIMITER ;
158
 
159
DROP VIEW IF EXISTS legumino.legumino_tapir;
622 jpm 160
CREATE ALGORITHM=UNDEFINED DEFINER=`legumino`@`localhost` SQL SECURITY DEFINER VIEW `legumino_tapir` AS
161
	SELECT
623 jpm 162
		CONCAT('urn:lsid:tela-botanica.org:legumino:', c.id_contributions) AS guid,
163
		c.id_contributions AS observation_id,
164
		c.date AS observation_date,
165
		HTML_UnEncode(CONCAT_WS(' ',
166
			l.Genre,
167
			l.Espece,
168
			IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))),
169
			IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL))),
170
			IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL)))))) AS nom_scientifique_complet,
171
		l.NumNomen AS nom_num_nomenclatural,
172
		l.NumTaxon AS nom_num_taxonomique,
173
		HTML_UnEncode(l.Famille) AS nom_famille,
174
		HTML_UnEncode(l.Genre) AS nom_genre,
175
		HTML_UnEncode(l.Espece) AS nom_espece,
176
		IF (TypeInfra3 != '', TypeInfra3, IF (TypeInfra2 != '', TypeInfra2, IF (TypeSousEspece != '', TypeSousEspece, NULL))) AS nom_type,
177
		HTML_UnEncode(IF (Infra3 != '', Infra3, IF (Infra2 != '', Infra2, IF (SousEspece != '', SousEspece, NULL)))) AS nom_infra_sp,
178
		HTML_UnEncode(IF (AuteurInfra3 != '', AuteurInfra3, IF (AuteurInfra2 != '', AuteurInfra2, IF (AuteurSousEspece != '', AuteurSousEspece, IF (Auteur != '', Auteur, NULL))))) AS nom_auteur,
179
		d.nom_departements AS lieu_departement_nom,
180
		CONCAT(CONVERT(cm.nom_communes USING UTF8), ' [INSEE:', SUBSTRING(cm.code_insee FROM 4), ']') AS lieu_commune_nom_complet,
181
		cm.nom_communes AS lieu_commune_nom,
182
		SUBSTRING(cm.code_insee FROM 4) AS lieu_commune_code_insee,
183
		cm.latitude AS lieu_commune_latitude,
184
		cm.longitude AS lieu_commune_longitude,
185
		HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs , CONCAT('<', ct.mail, '>'))) AS observateur_nom_complet,
186
		HTML_UnEncode(CONCAT_WS(' ', ct.prenom_contributeurs, ct.nom_contributeurs)) AS observateur_nom,
187
		ct.mail AS observateur_courriel,
188
		HTML_UnEncode(c.commentaire) AS observation_commentaire,
189
		CONCAT(_utf8'<?xml version="1.0" encoding="UTF-8"?>',
190
			'<info>',
191
				'<nom_num_nomenclatural>',l.NumNomen,'</nom_num_nomenclatural>',
192
				'<nom_num_taxonomique>',l.NumTaxon,'</nom_num_taxonomique>',
193
			'</info>') AS observation_information_complement,
627 jpm 194
		DATE_FORMAT(c.date_saisie, '%Y-%m-%d 00:00:00') AS saisie_date_modification
623 jpm 195
	FROM contributions AS c
196
		LEFT JOIN communes AS cm ON (c.code_insee = cm.code_insee)
197
		LEFT JOIN departements AS d ON (cm.num_departements = d.num_departements)
198
		LEFT JOIN legumino AS l ON (c.NumTaxon = l.NumTaxon)
199
		LEFT JOIN contributeurs AS ct ON (c.id_contributeurs = ct.id_contributeurs);
200