Commit aa6fc1d30059a1055203c366f6cfcce84ba033a2
1 parent
e0a6ebff
Exists in
master
Atualização do sistema de adm
Showing
28 changed files
with
1918 additions
and
108 deletions
Show diff stats
admin/abrefontemapfile.php
... | ... | @@ -1,73 +0,0 @@ |
1 | -<html> | |
2 | -<style> | |
3 | -body { | |
4 | - font: 14pt arial, helvetica, clean, sans-serif; | |
5 | - color: rgb(100, 100, 100); | |
6 | -} | |
7 | -</style> | |
8 | -<body> | |
9 | - <?php | |
10 | - /* | |
11 | - Title: abrefontemapfile | |
12 | - | |
13 | - Abre no navegador a página com os metadados sobre um tema. | |
14 | - | |
15 | - O link para os metadados é obtido do banco de administração. | |
16 | - | |
17 | - Para usar esse programa digite <http://localhost/i3geo/admin/abrefontemapfile.php?tema=codigo> | |
18 | - | |
19 | - Parametro: | |
20 | - | |
21 | - tema {string} - codigo do tema (nome do mapfile existente em i3geo/temas) | |
22 | - | |
23 | - Licenca: | |
24 | - | |
25 | - GPL2 | |
26 | - | |
27 | - i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
28 | - | |
29 | - Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
30 | - Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
31 | - | |
32 | - Este programa é software livre; você pode redistribuí-lo | |
33 | - e/ou modificá-lo sob os termos da Licença Pública Geral | |
34 | - GNU conforme publicada pela Free Software Foundation; | |
35 | - | |
36 | - Este programa é distribuído na expectativa de que seja útil, | |
37 | - porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
38 | - de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
39 | - Consulte a Licença Pública Geral do GNU para mais detalhes. | |
40 | - Você deve ter recebido uma cópia da Licença Pública Geral do | |
41 | - GNU junto com este programa; se não, escreva para a | |
42 | - Free Software Foundation, Inc., no endereço | |
43 | - 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
44 | - | |
45 | - Arquivo: | |
46 | - | |
47 | - i3geo/admin/abrefontemapfile.php | |
48 | - */ | |
49 | - error_reporting(0); | |
50 | - if(!isset($locaplic)) | |
51 | - { | |
52 | - $locaplic = ""; | |
53 | - include(dirname(__FILE__)."/../ms_configura.php"); | |
54 | - } | |
55 | - include_once($locaplic."/classesphp/pega_variaveis.php"); | |
56 | - include_once($locaplic."/admin/php/admin.php"); | |
57 | - if(!isset($tema)) | |
58 | - { | |
59 | - echo "Nenhum tema definido.";exit; | |
60 | - } | |
61 | - $editor = verificaEditores($editores); | |
62 | - $dbh = ""; | |
63 | - include($locaplic."/admin/php/conexao.php"); | |
64 | - $r = pegaDados("select * from ".$esquemaadmin."i3geoadmin_temas where codigo_tema = '$tema'"); | |
65 | - error_reporting(0); | |
66 | - $link = $r[0]["link_tema"]; | |
67 | - if($link == "") | |
68 | - { | |
69 | - echo "O link para a fonte não está cadastrado. Entre em contato com o administrador do sistema."; | |
70 | - } | |
71 | - else | |
72 | - {echo "<meta http-equiv='refresh' content='0;url=$link'>";} | |
73 | -?> | |
74 | 0 | \ No newline at end of file |
... | ... | @@ -0,0 +1,964 @@ |
1 | +<?php | |
2 | +/* | |
3 | +Title: xml.php | |
4 | + | |
5 | +Conjunto de funções que geram arquivos na estrutura XML conforme os dados cadastrados no sistema de administração. | |
6 | + | |
7 | +Permite a geração de XML no padrão RSS e outros. É utilizado por funções internas do i3Geo e por programas | |
8 | +utilitários que fornecem dados no formato RSS para outros fins. | |
9 | + | |
10 | +Licenca: | |
11 | + | |
12 | +GPL2 | |
13 | + | |
14 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
15 | + | |
16 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
17 | +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
18 | + | |
19 | +Este programa é software livre; você pode redistribuí-lo | |
20 | +e/ou modificá-lo sob os termos da Licença Pública Geral | |
21 | +GNU conforme publicada pela Free Software Foundation; | |
22 | + | |
23 | +Este programa é distribuído na expectativa de que seja útil, | |
24 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
25 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
26 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | |
27 | +Você deve ter recebido uma copia da Licença Pública Geral do | |
28 | +GNU junto com este programa; se não, escreva para a | |
29 | +Free Software Foundation, Inc., no endereço | |
30 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
31 | + | |
32 | +Arquivo: | |
33 | + | |
34 | +i3geo/admin/php/xml.php | |
35 | +*/ | |
36 | +// | |
37 | +//processa a variável $esquemaadmin definida em ms_configura.php | |
38 | +//essa variável precisa ter um . no final quando não for vazia, evitando erros na inclusão dentro dos SQLs | |
39 | +// | |
40 | + | |
41 | +if (!isset($esquemaadmin)){ | |
42 | + include_once(dirname(__FILE__)."/../../ms_configura.php"); | |
43 | +} | |
44 | +if(!empty($esquemaadmin)){ | |
45 | + $esquemaadmin = str_replace(".","",$esquemaadmin)."."; | |
46 | +} | |
47 | + | |
48 | +/* | |
49 | +Function: geraXmlSistemas (depreciado) | |
50 | + | |
51 | +Parametros: | |
52 | + | |
53 | +perfil {string} - perfil que será considerado na geração do XML | |
54 | + | |
55 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
56 | + | |
57 | +editores {array} - lista de editores cadastrados em ms_configura.php | |
58 | + | |
59 | +Retorno: | |
60 | + | |
61 | +String na estrutura XML | |
62 | +*/ | |
63 | +function geraXmlSistemas($perfil,$locaplic,$editores) | |
64 | +{ | |
65 | + global $esquemaadmin; | |
66 | + $editor = "nao";//verificaEditores($editores); | |
67 | + if (!isset($perfil)){$perfil = "";} | |
68 | + $perfil = str_replace(","," ",$perfil); | |
69 | + $perfil = explode(" ",$perfil); | |
70 | + $dbh = ""; | |
71 | + include($locaplic."/admin/php/conexao.php"); | |
72 | + if($convUTF) | |
73 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
74 | + else | |
75 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
76 | + $xml .= "\n<SISTEMAS>\n"; | |
77 | + $q = "select * from ".$esquemaadmin."i3geoadmin_sistemas"; | |
78 | + $qatlas = $dbh->query($q); | |
79 | + foreach($qatlas as $row) | |
80 | + { | |
81 | + if($row["perfil_sistema"] == "") | |
82 | + $mostra = true; | |
83 | + else | |
84 | + { | |
85 | + $perfilS = explode(" ",str_replace(","," ",$row["perfil_sistema"])); | |
86 | + $mostra = array_in_array($perfil,$perfilS); | |
87 | + } | |
88 | + if(strtolower($row["publicado_sistema"] == "nao")) | |
89 | + {$mostra = false;} | |
90 | + if($editor) | |
91 | + {$mostra = true;} | |
92 | + if($mostra) | |
93 | + { | |
94 | + $xml .= "<SISTEMA>\n"; | |
95 | + $xml .= " <PERFIL>".$row["perfil_sistema"]."</PERFIL>\n"; | |
96 | + $xml .= " <PUBLICADO>".$row["publicado_sistema"]."</PUBLICADO>\n"; | |
97 | + $xml .= " <NOMESIS>".xmlTexto_prepara($row["nome_sistema"])."</NOMESIS>\n"; | |
98 | + $xml = geraXmlSistemas_pegafuncoes($perfil,$xml,$row["id_sistema"],$dbh); | |
99 | + $xml .= "</SISTEMA>\n"; | |
100 | + } | |
101 | + } | |
102 | + $xml .= "</SISTEMAS>\n"; | |
103 | + $dbh = null; | |
104 | + $dbhw = null; | |
105 | + return $xml; | |
106 | +} | |
107 | +/* | |
108 | +Function: geraRSScomentariosTemas | |
109 | + | |
110 | +RSS com os comentarios sobre um ou todos os temas | |
111 | + | |
112 | +Parametros: | |
113 | + | |
114 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
115 | + | |
116 | +id_tema {numeric} - (opcional) id do tema para mostrar apenas os comentários de um tema | |
117 | + | |
118 | +Retorno: | |
119 | + | |
120 | +RSS | |
121 | +*/ | |
122 | +function geraRSScomentariosTemas($locaplic,$id_tema=""){ | |
123 | + global $esquemaadmin; | |
124 | + xml_testaNum([$id_tema]); | |
125 | + $sql = "select '' as tipo_ws, b.nome_tema||' '||a.data as nome_ws,a.openidnome||' '||a.openidurl||' <br>'||a.comentario as desc_ws, a.openidnome as autor_ws, b.link_tema as link_ws from ".$esquemaadmin."i3geoadmin_comentarios as a,".$esquemaadmin."i3geoadmin_temas as b where a.id_tema = b.id_tema "; | |
126 | + if($id_tema != ""){ | |
127 | + $sql .= " and a.id_tema = $id_tema "; | |
128 | + } | |
129 | + return geraXmlRSS($locaplic,$sql,"Lista de comentarios"); | |
130 | +} | |
131 | +/* | |
132 | +Function: geraRSStemas | |
133 | + | |
134 | +RSS com os temas cadastrados | |
135 | + | |
136 | +Parametros: | |
137 | + | |
138 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
139 | + | |
140 | +id_n2 {string} - c�digo do subgrupo do sistema de administração | |
141 | + | |
142 | +Retorno: | |
143 | + | |
144 | +RSS | |
145 | +*/ | |
146 | +function geraRSStemas($locaplic,$id_n2,$output="xml") | |
147 | +{ | |
148 | + global $esquemaadmin; | |
149 | + xml_testaNum([$id_n2]); | |
150 | + $sql = " | |
151 | + select '' as tipo_ws, i3geoadmin_temas.codigo_tema as id_ws,i3geoadmin_temas.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||i3geoadmin_temas.codigo_tema as link_ws,i3geoadmin_temas.link_tema as autor_ws | |
152 | + from ".$esquemaadmin."i3geoadmin_n3 as n3 | |
153 | + LEFT JOIN ".$esquemaadmin."i3geoadmin_temas ON i3geoadmin_temas.id_tema = n3.id_tema | |
154 | + LEFT JOIN ".$esquemaadmin."i3geousr_grupotema ON n3.id_tema = i3geousr_grupotema.id_tema | |
155 | + where i3geousr_grupotema.id_grupo is null and i3geoadmin_temas.id_tema = n3.id_tema and n3.id_n2 = '$id_n2' and n3.n3_perfil = '' and n3.publicado != 'NAO' order by nome_ws"; | |
156 | + return geraXmlRSS($locaplic,$sql,"Lista de temas",$output); | |
157 | +} | |
158 | +/* | |
159 | +Function: geraRSStemasRaiz | |
160 | + | |
161 | +RSS com os temas localizados na raiz de um nível | |
162 | + | |
163 | +Parametros: | |
164 | + | |
165 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
166 | + | |
167 | +id {string} - codigo do no | |
168 | + | |
169 | +nivel {string} - nível do no | |
170 | + | |
171 | +Retorno: | |
172 | + | |
173 | +RSS | |
174 | +*/ | |
175 | +function geraRSStemasRaiz($locaplic,$id,$nivel) | |
176 | +{ | |
177 | + global $esquemaadmin; | |
178 | + xml_testaNum([$id,$nivel]); | |
179 | + $sql = " | |
180 | + select '' as tipo_ws, i3geoadmin_temas.codigo_tema as id_ws,i3geoadmin_temas.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||i3geoadmin_temas.codigo_tema as link_ws,i3geoadmin_temas.link_tema as autor_ws | |
181 | + from ".$esquemaadmin."i3geoadmin_raiz as r | |
182 | + LEFT JOIN ".$esquemaadmin."i3geoadmin_temas ON i3geoadmin_temas.id_tema = r.id_tema | |
183 | + LEFT JOIN ".$esquemaadmin."i3geousr_grupotema ON r.id_tema = i3geousr_grupotema.id_tema | |
184 | + where i3geousr_grupotema.id_grupo is null and i3geoadmin_temas.id_tema = r.id_tema and r.nivel = '$nivel' and r.id_nivel = '$id' order by nome_ws"; | |
185 | + return geraXmlRSS($locaplic,$sql,"Temas na raiz"); | |
186 | +} | |
187 | +/* | |
188 | +Function: geraRSSsubgrupos | |
189 | + | |
190 | +RSS com os subgrupos cadastrados | |
191 | + | |
192 | +Parametros: | |
193 | + | |
194 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
195 | + | |
196 | +id_n1 {string} - c�digo do grupo do sistema de administração | |
197 | + | |
198 | +Retorno: | |
199 | + | |
200 | +RSS | |
201 | +*/ | |
202 | +function geraRSSsubgrupos($locaplic,$id_n1,$output="json") | |
203 | +{ | |
204 | + global $esquemaadmin; | |
205 | + xml_testaNum([$id_n1]); | |
206 | + $sql = "select '' as tipo_ws, n2.id_n2 as id_ws,g.nome_subgrupo as nome_ws,'' as desc_ws,'rsstemas.php?id='||n2.id_n2 as link_ws,'' as autor_ws from ".$esquemaadmin."i3geoadmin_n2 as n2,".$esquemaadmin."i3geoadmin_subgrupos as g "; | |
207 | + $sql .= " where g.id_subgrupo = n2.id_subgrupo and n2.id_n1 = '$id_n1' and n2.n2_perfil = '' and n2.publicado != 'NAO' order by nome_ws"; | |
208 | + return geraXmlRSS($locaplic,$sql,"Lista de sub-grupos",$output); | |
209 | +} | |
210 | +/* | |
211 | +Function: geraRSSgrupos | |
212 | + | |
213 | +RSS com os grupos cadastrados | |
214 | + | |
215 | +Parametros: | |
216 | + | |
217 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
218 | + | |
219 | +Retorno: | |
220 | + | |
221 | +RSS | |
222 | +*/ | |
223 | +function geraRSSgrupos($locaplic,$output="xml") | |
224 | +{ | |
225 | + global $esquemaadmin; | |
226 | + $sql = "select '' as tipo_ws, n1.id_n1 as id_ws, g.nome_grupo as nome_ws,'rsstemasraiz.php?nivel=1&id='||n1.id_n1 as desc_ws,'rsssubgrupos.php?id='||n1.id_n1 as link_ws,'' as autor_ws "; | |
227 | + $sql .= "from ".$esquemaadmin."i3geoadmin_n1 as n1,".$esquemaadmin."i3geoadmin_grupos as g "; | |
228 | + $sql .= "where g.id_grupo = n1.id_grupo and n1.n1_perfil = '' and n1.publicado != 'NAO' group by id_ws,tipo_ws,nome_ws,desc_ws,link_ws,autor_ws order by nome_ws"; | |
229 | + return geraXmlRSS($locaplic,$sql,"Lista de grupos",$output); | |
230 | +} | |
231 | +/* | |
232 | +Function: geraXmlDownload | |
233 | + | |
234 | +RSS com os links para sistemas de download | |
235 | + | |
236 | +Parametros: | |
237 | + | |
238 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
239 | + | |
240 | +Retorno: | |
241 | + | |
242 | +RSS | |
243 | +*/ | |
244 | +function geraXmlDownload($locaplic) | |
245 | +{ | |
246 | + global $esquemaadmin; | |
247 | + $sql = "select * from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = 'DOWNLOAD' and nome_ws <> ''"; | |
248 | + return geraXmlRSS($locaplic,$sql,"Enderecos para download"); | |
249 | +} | |
250 | +/* | |
251 | +Function: geraXmlWS | |
252 | + | |
253 | +RSS com a lista de WS cadastrados | |
254 | + | |
255 | +Parametros: | |
256 | + | |
257 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
258 | + | |
259 | +Retorno: | |
260 | + | |
261 | +RSS | |
262 | +*/ | |
263 | +function geraXmlWS($locaplic,$output) | |
264 | +{ | |
265 | + global $esquemaadmin; | |
266 | + $sql = "select * from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = 'WS' and nome_ws <> ''"; | |
267 | + return geraXmlRSS($locaplic,$sql,"Web services",$output); | |
268 | +} | |
269 | +/* | |
270 | +Function: geraXmlKmlrss | |
271 | + | |
272 | +RSS com a lista de KML cadastrados | |
273 | + | |
274 | +Parametros: | |
275 | + | |
276 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
277 | + | |
278 | +Retorno: | |
279 | + | |
280 | +RSS | |
281 | +*/ | |
282 | +function geraXmlKmlrss($locaplic) | |
283 | +{ | |
284 | + global $esquemaadmin; | |
285 | + $sql = "select * from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = 'KML' and nome_ws <> ''"; | |
286 | + return geraXmlRSS($locaplic,$sql,"Web services"); | |
287 | +} | |
288 | +/* | |
289 | +Function: geraXmlWMS | |
290 | + | |
291 | +RSS com a lista de WMS cadastrados | |
292 | + | |
293 | +Parametros: | |
294 | + | |
295 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
296 | + | |
297 | +Retorno: | |
298 | + | |
299 | +RSS | |
300 | +*/ | |
301 | +function geraXmlWMS($locaplic,$output) | |
302 | +{ | |
303 | + global $esquemaadmin; | |
304 | + $sql = "select * from ".$esquemaadmin."i3geoadmin_ws where (tipo_ws = 'WMS' or tipo_ws = 'WMS-Tile') and nome_ws <> '' order by nome_ws"; | |
305 | + return geraXmlRSS($locaplic,$sql,"Web services WMS-OGC",$output); | |
306 | +} | |
307 | +/* | |
308 | +Function: geraXmlWMSmetaestat | |
309 | + | |
310 | +RSS com a lista de WMS das variaveis cadastradas no sistema de metadados estatisticos | |
311 | + | |
312 | +Parametros: | |
313 | + | |
314 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
315 | + | |
316 | +Retorno: | |
317 | + | |
318 | +RSS | |
319 | +*/ | |
320 | +function geraXmlWMSmetaestat($locaplic) | |
321 | +{ | |
322 | + global $esquemaadmin; | |
323 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
324 | + $c = "/admin/php/xml.php"; | |
325 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | |
326 | + $c = "\admin\php\xml.php"; | |
327 | + } | |
328 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST']."/".(basename(str_replace($c,"",__FILE__))); | |
329 | + $sql = "select DISTINCT b.id_medida_variavel as id_ws, 'WMSMETAESTAT' as tipo_ws,'".$url."/ogc.php?id_medida_variavel='||b.id_medida_variavel as link_ws,a.nome||' -> '||b.nomemedida as nome_ws,a.descricao as desc_ws, '' as autor_ws from i3geoestat_variavel as a ,i3geoestat_medida_variavel as b WHERE a.codigo_variavel = b.codigo_variavel ORDER BY a.nome"; | |
330 | + return geraXmlRSS($locaplic,$sql,"Web services WMS-TIME OGC"); | |
331 | +} | |
332 | +/* | |
333 | +Function: geraXmlGeorss | |
334 | + | |
335 | +RSS com a lista de GEORSS cadastrados | |
336 | + | |
337 | +Parametros: | |
338 | + | |
339 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
340 | + | |
341 | +Retorno: | |
342 | + | |
343 | +RSS | |
344 | +*/ | |
345 | +function geraXmlGeorss($locaplic,$output) | |
346 | +{ | |
347 | + global $esquemaadmin; | |
348 | + $sql = "select * from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = 'GEORSS' and nome_ws <> ''"; | |
349 | + return geraXmlRSS($locaplic,$sql,"Georss",$output); | |
350 | +} | |
351 | +/* | |
352 | +Function: geraRSStemasDownload | |
353 | + | |
354 | +RSS com a lista de temas para download | |
355 | + | |
356 | +Parametros: | |
357 | + | |
358 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
359 | + | |
360 | +Retorno: | |
361 | + | |
362 | +RSS | |
363 | +*/ | |
364 | +function geraRSStemasDownload($locaplic) | |
365 | +{ | |
366 | + global $esquemaadmin; | |
367 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
368 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST'].(str_replace("/admin/rsstemasdownload.php","",$_SERVER['PHP_SELF'])); | |
369 | + $sql = "select '' as tipo_ws,'".$url."/datadownload.htm?'||codigo_tema as link_ws, g.nome_grupo||' -> '||sg.nome_subgrupo||' -> '||nome_tema as nome_ws, desc_tema as desc_ws, link_tema as autor_ws "; | |
370 | + $sql .= " | |
371 | + from ".$esquemaadmin."i3geoadmin_temas as t,".$esquemaadmin."i3geoadmin_n3 as n3, ".$esquemaadmin."i3geoadmin_n2 as n2, ".$esquemaadmin."i3geoadmin_n1 as n1, ".$esquemaadmin."i3geoadmin_grupos as g, ".$esquemaadmin."i3geoadmin_subgrupos as sg | |
372 | + where | |
373 | + t.id_tema = n3.id_tema | |
374 | + and n3.id_n2 = n2.id_n2 | |
375 | + and n2.id_subgrupo = sg.id_subgrupo | |
376 | + and n2.id_n1 = n1.id_n1 | |
377 | + and n1.id_grupo = g.id_grupo | |
378 | + and (t.download_tema != 'nao' and t.download_tema != 'NAO') | |
379 | + and t.tipoa_tema != 'WMS' | |
380 | + and n3.n3_perfil = '' | |
381 | + and n2.n2_perfil = '' | |
382 | + and n1.n1_perfil = '' | |
383 | + and n3.publicado != 'NAO' | |
384 | + and n2.publicado != 'NAO' | |
385 | + and n1.publicado != 'NAO' | |
386 | + "; | |
387 | + //echo $sql;exit; | |
388 | + return geraXmlRSS($locaplic,$sql,"Temas para download"); | |
389 | +} | |
390 | +/* | |
391 | +Function: geraRSStemasKml | |
392 | + | |
393 | +RSS com a lista de temas que permitem KML | |
394 | + | |
395 | +Parametros: | |
396 | + | |
397 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
398 | + | |
399 | +Retorno: | |
400 | + | |
401 | +RSS | |
402 | +*/ | |
403 | +function geraRSStemasKml($locaplic) | |
404 | +{ | |
405 | + global $esquemaadmin; | |
406 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
407 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST'].(str_replace("/admin/rsstemaskml.php","",$_SERVER['PHP_SELF'])); | |
408 | + $sql = "select '' as tipo_ws,'".$url."/pacotes/kmlmapserver/kmlservice.php?request=kml&map='||codigo_tema||'&typename='||codigo_tema as link_ws, g.nome_grupo||' -> '||sg.nome_subgrupo||' -> '||nome_tema as nome_ws, desc_tema as desc_ws, link_tema as autor_ws "; | |
409 | + $sql .= " | |
410 | + from ".$esquemaadmin."i3geoadmin_temas as t,".$esquemaadmin."i3geoadmin_n3 as n3, ".$esquemaadmin."i3geoadmin_n2 as n2, ".$esquemaadmin."i3geoadmin_n1 as n1, ".$esquemaadmin."i3geoadmin_grupos as g, ".$esquemaadmin."i3geoadmin_subgrupos as sg | |
411 | + where | |
412 | + t.id_tema = n3.id_tema | |
413 | + and n3.id_n2 = n2.id_n2 | |
414 | + and n2.id_subgrupo = sg.id_subgrupo | |
415 | + and n2.id_n1 = n1.id_n1 | |
416 | + and n1.id_grupo = g.id_grupo | |
417 | + and (t.kml_tema != 'nao' and t.kml_tema != 'NAO') | |
418 | + and n3.n3_perfil = '' | |
419 | + and n2.n2_perfil = '' | |
420 | + and n1.n1_perfil = '' | |
421 | + and n3.publicado != 'NAO' | |
422 | + and n2.publicado != 'NAO' | |
423 | + and n1.publicado != 'NAO' | |
424 | + "; | |
425 | + //echo $sql;exit; | |
426 | + return geraXmlRSS($locaplic,$sql,"Temas em KML"); | |
427 | +} | |
428 | +/* | |
429 | +Function: geraRSStemasOgc | |
430 | + | |
431 | +RSS com a lista de temas que permitem serviços OGC | |
432 | + | |
433 | +Parametros: | |
434 | + | |
435 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
436 | + | |
437 | +Retorno: | |
438 | + | |
439 | +RSS | |
440 | +*/ | |
441 | +function geraRSStemasOgc($locaplic) | |
442 | +{ | |
443 | + global $esquemaadmin; | |
444 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
445 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST'].(str_replace("/admin/rsstemasogc.php","",$_SERVER['PHP_SELF'])); | |
446 | + $sql = "select '' as tipo_ws,'".$url."/ogc.php?request=getcapabilities&service=wms&tema='||codigo_tema as link_ws, g.nome_grupo||' -> '||sg.nome_subgrupo||' -> '||nome_tema as nome_ws, desc_tema as desc_ws, link_tema as autor_ws "; | |
447 | + $sql .= " | |
448 | + from ".$esquemaadmin."i3geoadmin_temas as t,".$esquemaadmin."i3geoadmin_n3 as n3, ".$esquemaadmin."i3geoadmin_n2 as n2, ".$esquemaadmin."i3geoadmin_n1 as n1, ".$esquemaadmin."i3geoadmin_grupos as g, ".$esquemaadmin."i3geoadmin_subgrupos as sg | |
449 | + where | |
450 | + t.id_tema = n3.id_tema | |
451 | + and n3.id_n2 = n2.id_n2 | |
452 | + and n2.id_subgrupo = sg.id_subgrupo | |
453 | + and n2.id_n1 = n1.id_n1 | |
454 | + and n1.id_grupo = g.id_grupo | |
455 | + and (t.ogc_tema != 'nao' or t.ogc_tema != 'NAO') | |
456 | + and t.tipoa_tema != 'WMS' | |
457 | + and n3.n3_perfil = '' | |
458 | + and n2.n2_perfil = '' | |
459 | + and n1.n1_perfil = '' | |
460 | + and n3.publicado != 'NAO' | |
461 | + and n2.publicado != 'NAO' | |
462 | + and n1.publicado != 'NAO' | |
463 | + "; | |
464 | + //echo $sql;exit; | |
465 | + return geraXmlRSS($locaplic,$sql,"Temas em KML"); | |
466 | +} | |
467 | +/* | |
468 | +Function: geraXmlRSS | |
469 | + | |
470 | +Gera um RSS com base em um SQL compatível com o sistema de administração. | |
471 | + | |
472 | +O SQL deverá retornar os itens nome_ws desc_ws e link_ws | |
473 | + | |
474 | +Parametros: | |
475 | + | |
476 | +locaplic {string} - localização do i3Geo no sistema de arquivos | |
477 | + | |
478 | +sql {string} - SQL que será aplicado ao sistema de administração | |
479 | + | |
480 | +descricao {string} - descrição que será inserida no canal RSS | |
481 | + | |
482 | +output {string} - xml|json | |
483 | +Retorno: | |
484 | + | |
485 | +RSS | |
486 | +*/ | |
487 | +function geraXmlRSS($locaplic,$sql,$descricao,$output="xml") | |
488 | +{ | |
489 | + global $esquemaadmin; | |
490 | + //var_dump($_SERVER);exit; | |
491 | + $dbh = ""; | |
492 | + include($locaplic."/admin/php/conexao.php"); | |
493 | + if($convUTF) | |
494 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
495 | + else | |
496 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
497 | + $xml .= "<rss version='2.0'>"; | |
498 | + $xml .= "<channel>\n"; | |
499 | + $xml .= "<title>RSS</title>\n"; | |
500 | + $xml .= "<description>".str_replace("&","&",$descricao)."</description>\n"; | |
501 | + $xml .= "<link></link>\n"; | |
502 | + $xml .= "<docs></docs>\n"; | |
503 | + $xml .= "<copyright>Gerado pelo i3Geo</copyright>\n"; | |
504 | + $xml .= "<language>pt-br</language>\n"; | |
505 | + $xml .= "<webmaster></webmaster>\n"; | |
506 | + $json = array( | |
507 | + "description"=>$descricao, | |
508 | + "copyright"=>"Gerado pelo i3Geo", | |
509 | + "language"=>"pt-br" | |
510 | + ); | |
511 | + $jsonItems = array(); | |
512 | + $qatlas = $dbh->query($sql); | |
513 | + foreach($qatlas as $row) | |
514 | + { | |
515 | + $xml .= "<item>\n"; | |
516 | + $xml .= "<category/>\n"; | |
517 | + $xml .= "<title>".entity_decode($row["nome_ws"])."</title>\n"; | |
518 | + $xml .= "<description>".xmlTexto_prepara(entity_decode($row["desc_ws"]))."</description>\n"; | |
519 | + $link = xmlTexto_prepara($row["link_ws"]); | |
520 | + if(stristr($link, 'http') === FALSE){ | |
521 | + $link = "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["REQUEST_URI"])."/".$link; | |
522 | + } | |
523 | + $xml .= "<link><![CDATA[".$link."]]></link>\n"; | |
524 | + $xml .= "<pubDate/>\n"; | |
525 | + $xml .= "<author>".xmlTexto_prepara($row["autor_ws"])."</author>\n"; | |
526 | + $xml .= "<nacessos></nacessos>\n"; | |
527 | + $xml .= "<nacessosok></nacessosok>\n"; | |
528 | + $xml .= "<id>".xmlTexto_prepara($row["id_ws"])."</id>\n"; | |
529 | + $xml .= "<tipo>".$row["tipo_ws"]."</tipo>\n"; | |
530 | + $xml .= "</item>\n"; | |
531 | + $jsonItems[] = array( | |
532 | + "title"=>$row["nome_ws"], | |
533 | + "description"=>$row["desc_ws"], | |
534 | + "link"=>$link."&output=json", | |
535 | + "author"=>$row["autor_ws"], | |
536 | + "id"=>$row["id_ws"], | |
537 | + "tipo"=>$row["tipo_ws"] | |
538 | + ); | |
539 | + } | |
540 | + $json["items"] = $jsonItems; | |
541 | + $xml .= "</channel></rss>\n"; | |
542 | + $dbh = null; | |
543 | + $dbhw = null; | |
544 | + if($output=="xml"){ | |
545 | + return $xml; | |
546 | + } | |
547 | + else{ | |
548 | + return json_encode($json); | |
549 | + } | |
550 | +} | |
551 | +function geraXmlAtlas($locaplic,$editores) | |
552 | +{ | |
553 | + global $esquemaadmin; | |
554 | + error_reporting(0); | |
555 | + $dbh = ""; | |
556 | + include($locaplic."/admin/php/conexao.php"); | |
557 | + | |
558 | + if($convUTF) | |
559 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
560 | + else | |
561 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
562 | + $xml .= "\n<RAIZ>\n"; | |
563 | + //$q = "select * from i3geoadmin_atlas"; | |
564 | + $qatlas = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_atlas"); | |
565 | + | |
566 | + $editor = "nao";//$editor = verificaEditores($editores); | |
567 | + foreach($qatlas as $row) | |
568 | + { | |
569 | + $mostra = true; | |
570 | + if(strtolower($row["publicado_atlas"] == "nao")) | |
571 | + {$mostra = false;} | |
572 | + if($editor) | |
573 | + {$mostra = true;} | |
574 | + if($mostra) | |
575 | + { | |
576 | + $xml .= "<ATLAS>\n"; | |
577 | + $xml .= " <ID>".$row["id_atlas"]."</ID>\n"; | |
578 | + $xml .= " <PUBLICADO>".$row["publicado_atlas"]."</PUBLICADO>\n"; | |
579 | + $xml .= " <TITULO>".xmlTexto_prepara($row["titulo_atlas"])."</TITULO>\n"; | |
580 | + $xml .= " <DESCRICAO>".xmlTexto_prepara($row["desc_atlas"])."</DESCRICAO>\n"; | |
581 | + $xml .= " <ICONE>".$row["icone_atlas"]."</ICONE>\n"; | |
582 | + $xml .= " <LINKMAISINFO><![CDATA[".xmlTexto_prepara($row["link_atlas"])."]]></LINKMAISINFO>\n"; | |
583 | + $xml .= " <TEMPLATEHTML>".xmlTexto_prepara($row["template_atlas"])."</TEMPLATEHTML>\n"; | |
584 | + $xml .= " <WABERTURA>".$row["w_atlas"]."</WABERTURA>\n"; | |
585 | + $xml .= " <HABERTURA>".$row["h_atlas"]."</HABERTURA>\n"; | |
586 | + $xml .= " <PRANCHADEFAULT>".$row["pranchadefault_atlas"]."</PRANCHADEFAULT>\n"; | |
587 | + $xml .= " <TIPOGUIAS>".$row["tipoguias_atlas"]."</TIPOGUIAS>\n"; | |
588 | + $xml .= " <BASEMAPFILE>".$row["basemapfile_atlas"]."</BASEMAPFILE>\n"; | |
589 | + $xml .= " <PRANCHAS>\n"; | |
590 | + $xml = geraXmlAtlas_pegapranchas($xml,$row["id_atlas"],$dbh); | |
591 | + $xml .= " </PRANCHAS>\n"; | |
592 | + $xml .= " </ATLAS>\n"; | |
593 | + } | |
594 | + } | |
595 | + $xml .= "</RAIZ>\n"; | |
596 | + $dbh = null; | |
597 | + $dbhw = null; | |
598 | + return $xml; | |
599 | +} | |
600 | +function geraXmlIdentifica($perfil,$locaplic,$editores) | |
601 | +{ | |
602 | + global $esquemaadmin; | |
603 | + $editor = "nao";//$editor = verificaEditores($editores); | |
604 | + if (!isset($perfil)){$perfil = "";} | |
605 | + $perfil = str_replace(","," ",$perfil); | |
606 | + $perfil = explode(" ",$perfil); | |
607 | + $dbh = ""; | |
608 | + include($locaplic."/admin/php/conexao.php"); | |
609 | + if($convUTF) | |
610 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
611 | + else | |
612 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
613 | + $xml .= "\n<SISTEMAS>\n"; | |
614 | + $q = "select * from ".$esquemaadmin."i3geoadmin_identifica "; | |
615 | + $qi = $dbh->query($q); | |
616 | + foreach($qi as $row) | |
617 | + { | |
618 | + $mostra = true; | |
619 | + if(strtolower($row["publicado_i"] == "nao")) | |
620 | + {$mostra = false;} | |
621 | + if($editor) | |
622 | + {$mostra = true;} | |
623 | + if($mostra) | |
624 | + { | |
625 | + $xml .= " <FUNCAO>\n"; | |
626 | + $xml .= " <NOMESIS>".xmlTexto_prepara($row["nome_i"])."</NOMESIS>\n"; | |
627 | + $xml .= " <ABRIR>".xmlTexto_prepara($row["abrir_i"])."</ABRIR>\n"; | |
628 | + $xml .= " <PUBLICADO>".$row["publicado_i"]."</PUBLICADO>\n"; | |
629 | + $target = $row["target_i"]; | |
630 | + if($target == ""){$target = "_self";} | |
631 | + $xml .= " <TARGET>".$target."</TARGET>\n"; | |
632 | + $xml .= " </FUNCAO>\n"; | |
633 | + }error_reporting(0); | |
634 | + } | |
635 | + $xml .= "</SISTEMAS>\n"; | |
636 | + $dbh = null; | |
637 | + $dbhw = null; | |
638 | + return $xml; | |
639 | +} | |
640 | +function geraXmlMapas($perfil,$locaplic,$editores) | |
641 | +{ | |
642 | + global $esquemaadmin; | |
643 | + if (!isset($perfil)){$perfil = "";} | |
644 | + $perfil = str_replace(","," ",$perfil); | |
645 | + $perfil = explode(" ",$perfil); | |
646 | + $dbh = ""; | |
647 | + include($locaplic."/admin/php/conexao.php"); | |
648 | + if($convUTF) | |
649 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
650 | + else | |
651 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
652 | + $xml .= "\n<MAPAS>\n"; | |
653 | + $q = "select * from ".$esquemaadmin."i3geoadmin_mapas"; | |
654 | + $q = $dbh->query($q); | |
655 | + $editor = "nao";//$editor = "nao";//verificaEditores($editores); | |
656 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
657 | + $c = "/admin/php/xml.php"; | |
658 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | |
659 | + $c = "\admin\php\xml.php"; | |
660 | + } | |
661 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST']."/".(basename(str_replace($c,"",__FILE__))); | |
662 | + foreach($q as $row) | |
663 | + { | |
664 | + $mostraMapa = false; | |
665 | + if($row["perfil_mapa"] == "") | |
666 | + {$mostraMapa = true;} | |
667 | + else | |
668 | + { | |
669 | + $perfilMapa = explode(" ",str_replace(","," ",$row["perfil_mapa"])); | |
670 | + $mostraMapa = array_in_array($perfil,$perfilMapa); | |
671 | + } | |
672 | + if(strtolower($row["publicado_mapa"] == "nao")) | |
673 | + {$mostraMapa = false;} | |
674 | + if($editor) | |
675 | + {$mostraMapa = true;} | |
676 | + | |
677 | + if($mostraMapa) | |
678 | + { | |
679 | + $xml .= "<MAPA>\n"; | |
680 | + $perfil = $row["perfil_mapa"]; | |
681 | + $xml .= " <PERFIL>".$perfil."</PERFIL>\n"; | |
682 | + $xml .= " <NOME>".xmlTexto_prepara($row["nome_mapa"])."</NOME>\n"; | |
683 | + $xml .= " <DESCRICAO>".xmlTexto_prepara($row["desc_mapa"])."</DESCRICAO>\n"; | |
684 | + $xml .= " <IMAGEM>".xmlTexto_prepara($row["imagem_mapa"])."</IMAGEM>\n"; | |
685 | + $xml .= " <TEMAS>".$row["temas_mapa"]."</TEMAS>\n"; | |
686 | + $xml .= " <LIGADOS>".$row["ligados_mapa"]."</LIGADOS>\n"; | |
687 | + $extensao = $row["ext_mapa"]; | |
688 | + $xml .= " <EXTENSAO>".$extensao."</EXTENSAO>\n"; | |
689 | + $outros = xmlTexto_prepara($row["outros_mapa"]); | |
690 | + $xml .= " <OUTROS><![CDATA[".$outros."]]></OUTROS>\n"; | |
691 | + $linkdireto = xmlTexto_prepara($row["linkdireto_mapa"]); | |
692 | + if(empty($linkdireto)){ | |
693 | + $linkdireto = $url."/ms_criamapa.php?mapext=".$extensao."&perfil=".$perfil."&temasa=".$temas."&layers=".$ligados.$row["outros_mapa"]; | |
694 | + $linkdireto = xmlTexto_prepara($linkdireto); | |
695 | + } | |
696 | + $xml .= " <LINKDIRETO><![CDATA[".$linkdireto."]]></LINKDIRETO>\n"; | |
697 | + $xml .= " <PUBLICADO>".$row["publicado_mapa"]."</PUBLICADO>\n"; | |
698 | + $xml .= " <ID_MAPA>".$row["id_mapa"]."</ID_MAPA>\n"; | |
699 | + if($row["mapfile"] != ""){ | |
700 | + $xml .= " <CONTEMMAPFILE>sim</CONTEMMAPFILE>\n"; | |
701 | + } | |
702 | + else{ | |
703 | + $xml .= " <CONTEMMAPFILE>nao</CONTEMMAPFILE>\n"; | |
704 | + } | |
705 | + $xml .= "</MAPA>\n"; | |
706 | + } | |
707 | + } | |
708 | + $xml .= "</MAPAS>\n"; | |
709 | + $dbh = null; | |
710 | + $dbhw = null; | |
711 | + return $xml; | |
712 | +} | |
713 | +//mostra apenas os mapas que possuem outros_mapa definido, o que e tipico do sistema de metadados estatisticos | |
714 | +function geraRSSmapas($locaplic,$output) | |
715 | +{ | |
716 | + global $esquemaadmin; | |
717 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
718 | + $c = "/admin/php/xml.php"; | |
719 | + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')){ | |
720 | + $c = "\admin\php\xml.php"; | |
721 | + } | |
722 | + $url = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST']."/".(basename(str_replace($c,"",__FILE__))); | |
723 | + $descricao = "'<![CDATA[Outros links<br>"; | |
724 | + $descricao .= "<a href=$url/mashups/openlayers.php?restauramapa='||id_mapa||'&fundo=e_wsm >Openlayers 1</a><br><br>"; | |
725 | + $descricao .= "<a href=$url/mashups/openlayers.php?restauramapa='||id_mapa||'&fundo= >Openlayers 2</a><br><br>"; | |
726 | + $descricao .= "<a href=$url/mashups/openlayers.php?restauramapa='||id_mapa||'&fundo=e_wsm&botoes=legenda pan zoombox zoomtot zoomin zoomout distancia area identifica >Openlayers 3</a><br><br>"; | |
727 | + $descricao .= "<a href=$url/mashups/openlayers.php?restauramapa='||id_mapa||' >Openlayers 4</a><br><br>"; | |
728 | + $descricao .= "<img src=$url/ferramentas/salvamapa/geraminiatura.php?w=300&h=300&restauramapa='||id_mapa||' >]]>'"; | |
729 | + $sql = "select '' as tipo_ws,'".$url."/ms_criamapa.php?restauramapa='||id_mapa as link_ws, nome_mapa as nome_ws, ".$descricao." as desc_ws, '' as autor_ws from ".$esquemaadmin."i3geoadmin_mapas WHERE publicado_mapa = 'sim' AND mapfile != ''"; | |
730 | + //echo $sql;exit; | |
731 | + return geraXmlRSS($locaplic,$sql,"Mapas cadastrados",$output); | |
732 | +} | |
733 | + | |
734 | +// | |
735 | +//$id_menu = id do menu que será montado | |
736 | +//$perfil = perfis separados por espaços | |
737 | +//$tipo = gruposeraiz|subgrupos|temas | |
738 | +//$dbh objeto com a conexão com o banco | |
739 | +//$locaplic = localização do i3geo no servidor | |
740 | +// | |
741 | +function geraXmlMenutemas($perfil,$id_menu,$tipo,$locaplic) | |
742 | +{ | |
743 | + global $esquemaadmin; | |
744 | + xml_testaNum([$id_menu]); | |
745 | + $dbh = ""; | |
746 | + include($locaplic."/admin/php/conexao.php"); | |
747 | + if (!isset($perfil)){$perfil = "";} | |
748 | + $perfil = str_replace(","," ",$perfil); | |
749 | + $perfil = explode(" ",$perfil); | |
750 | + if($convUTF) | |
751 | + $xml = "<"."\x3F"."xml version='1.0' encoding='UTF-8' "."\x3F".">"; | |
752 | + else | |
753 | + $xml = "<"."\x3F"."xml version='1.0' encoding='ISO-8859-1' "."\x3F".">"; | |
754 | + $xml .= "\n<TEMASGEO>\n"; | |
755 | + if(!isset($id_menu)) | |
756 | + $xml .= "<CABECALHO>Utilize ?id_menu=1 por exemplo</CABECALHO>\n"; | |
757 | + else | |
758 | + $xml .= "<CABECALHO></CABECALHO>\n"; | |
759 | + // | |
760 | + //pega os temas na raiz | |
761 | + // | |
762 | + $q = "select nome_tema,codigo_tema,desc_tema,link_tema,tipoa_tema,tags_tema,kml_tema,ogc_tema,download_tema,r.perfil as perfil from ".$esquemaadmin."i3geoadmin_raiz as r,".$esquemaadmin."i3geoadmin_temas as temas where r.id_nivel = 0 and r.id_tema = temas.id_tema and r.id_menu = $id_menu "; | |
763 | + $qtemasraiz = $dbh->query($q); | |
764 | + $xml = geraXmlMenutemas_notema($qtemasraiz,$xml,$perfil); | |
765 | + $q = "select nome_grupo,desc_grupo,n1.id_grupo,n1.id_n1,n1.n1_perfil as perfil from ".$esquemaadmin."i3geoadmin_n1 as n1,".$esquemaadmin."i3geoadmin_grupos as grupos where n1.id_menu = $id_menu and n1.id_grupo = grupos.id_grupo "; | |
766 | + $qgrupos = $dbh->query($q); | |
767 | + foreach($qgrupos as $row) | |
768 | + { | |
769 | + //filtra pelo perfil | |
770 | + if($row["perfil"] == "") | |
771 | + {$mostra = true;} | |
772 | + else | |
773 | + { | |
774 | + $perfilatual = explode(" ",str_replace(","," ",$row["perfil"])); | |
775 | + $mostra = array_in_array($perfil,$perfilatual); | |
776 | + } | |
777 | + if($mostra) | |
778 | + { | |
779 | + $xml .= "<GRUPO>\n"; | |
780 | + $xml .= " <GTIPO>".xmlTexto_prepara($row["nome_grupo"])."</GTIPO>\n"; | |
781 | + // | |
782 | + //pega temas na raiz | |
783 | + // | |
784 | + $q = "select nome_tema,codigo_tema,desc_tema,link_tema,tipoa_tema,tags_tema,kml_tema,ogc_tema,download_tema,r.perfil as perfil from ".$esquemaadmin."i3geoadmin_raiz as r,".$esquemaadmin."i3geoadmin_temas as temas where r.nivel = 1 and r.id_nivel = ".$row["id_n1"]." and r.id_tema = temas.id_tema and r.id_menu = $id_menu "; | |
785 | + $qtemasraiz = $dbh->query($q); | |
786 | + $xml = geraXmlMenutemas_notema($qtemasraiz,$xml,$perfil); | |
787 | + if(isset($tipo) && ($tipo == "subgrupos") || ($tipo == "")) | |
788 | + $xml = geraXmlMenutemas_pegasubgrupos($row["id_n1"],$xml,$dbh,$tipo,$perfil); | |
789 | + $xml .= " <DTIPO>".xmlTexto_prepara($row["desc_grupo"])."</DTIPO>\n"; | |
790 | + $xml .= " <PERFIL>".$row["perfil"]."</PERFIL>\n"; | |
791 | + $xml .= "</GRUPO>\n"; | |
792 | + } | |
793 | + } | |
794 | + $xml .= "</TEMASGEO>\n"; | |
795 | + $dbh = null; | |
796 | + $dbhw = null; | |
797 | + return $xml; | |
798 | +} | |
799 | +function geraXmlMenutemas_pegasubgrupos($id_n1,$xml,$dbh,$tipo,$perfil) | |
800 | +{ | |
801 | + global $esquemaadmin; | |
802 | + xml_testaNum([$id_n1]); | |
803 | + $q = "select subgrupos.id_subgrupo,nome_subgrupo,id_n2,n2.n2_perfil as perfil from ".$esquemaadmin."i3geoadmin_n2 as n2,".$esquemaadmin."i3geoadmin_subgrupos as subgrupos where n2.id_n1 = $id_n1 and n2.id_subgrupo = subgrupos.id_subgrupo "; | |
804 | + //echo $q;exit; | |
805 | + $qsgrupos = $dbh->query($q); | |
806 | + foreach($qsgrupos as $row) | |
807 | + { | |
808 | + if($row["perfil"] == "") | |
809 | + $mostra = true; | |
810 | + else | |
811 | + { | |
812 | + $perfilatual = explode(" ",str_replace(","," ",$row["perfil"])); | |
813 | + $mostra = array_in_array($perfil,$perfilatual); | |
814 | + } | |
815 | + if($mostra) | |
816 | + { | |
817 | + $xml .= "<SGRUPO>\n"; | |
818 | + $xml .= "<SDTIPO>".xmlTexto_prepara($row["nome_subgrupo"])."</SDTIPO>\n"; | |
819 | + $xml .= "<PERFIL>".xmlTexto_prepara($row["perfil"])."</PERFIL>\n"; | |
820 | + if(isset($tipo) && ($tipo == "temas") || ($tipo == "")) | |
821 | + $xml = geraXmlMenutemas_pegatemas($row["id_n2"],$xml,$dbh,$perfil); | |
822 | + $xml .= "</SGRUPO>\n"; | |
823 | + } | |
824 | + } | |
825 | + return $xml; | |
826 | +} | |
827 | +function geraXmlMenutemas_pegatemas($id_n2,$xml,$dbh,$perfil) | |
828 | +{ | |
829 | + global $esquemaadmin; | |
830 | + xml_testaNum([$id_n2]); | |
831 | + $q = "select nome_tema,codigo_tema,desc_tema,link_tema,tipoa_tema,tags_tema,kml_tema,ogc_tema,download_tema,n3.n3_perfil as perfil from ".$esquemaadmin."i3geoadmin_n3 as n3,".$esquemaadmin."i3geoadmin_temas as temas where n3.id_n2 = $id_n2 and n3.id_tema = temas.id_tema "; | |
832 | + $qtemas = $dbh->query($q); | |
833 | + $xml = geraXmlMenutemas_notema($qtemas,$xml,$perfil); | |
834 | + return $xml; | |
835 | +} | |
836 | +function geraXmlMenutemas_notema($qtemas,$xml,$perfil) | |
837 | +{ | |
838 | + global $esquemaadmin; | |
839 | + foreach($qtemas as $row) | |
840 | + { | |
841 | + if($row["perfil"] == "") | |
842 | + {$mostra = true;} | |
843 | + else | |
844 | + { | |
845 | + $perfilatual = explode(" ",str_replace(","," ",$row["perfil"])); | |
846 | + $mostra = array_in_array($perfil,$perfilatual); | |
847 | + } | |
848 | + if($mostra) | |
849 | + { | |
850 | + $xml .= "<TEMA>\n"; | |
851 | + $xml .= "<TID>".$row["codigo_tema"]."</TID>\n"; | |
852 | + $xml .= "<PERFIL>".$row["perfil"]."</PERFIL>\n"; | |
853 | + $xml .= "<TNOME>".xmlTexto_prepara($row["nome_tema"])."</TNOME>\n"; | |
854 | + $xml .= "<TDESC>".xmlTexto_prepara($row["desc_tema"])."</TDESC>\n"; | |
855 | + $xml .= "<TLINK><![CDATA[".xmlTexto_prepara($row["link_tema"])."]]></TLINK>\n"; | |
856 | + $xml .= "<TIPOA>".$row["tipoa_tema"]."</TIPOA>\n"; | |
857 | + $xml .= "<TAGS>".xmlTexto_prepara($row["tags_tema"])."</TAGS>\n"; | |
858 | + $xml .= "<KML>".$row["kml_tema"]."</KML>\n"; | |
859 | + if($row["tipoa_tema"] == "WMS") | |
860 | + {$xml .= "<OGC>nao</OGC>\n";} | |
861 | + else | |
862 | + {$xml .= "<OGC>".$row["ogc_tema"]."</OGC>\n";} | |
863 | + $xml .= "<DOWNLOAD>".$row["download_tema"]."</DOWNLOAD>\n"; | |
864 | + $xml .= "<NACESSOS></NACESSOS>\n"; | |
865 | + $xml .= "</TEMA>\n"; | |
866 | + } | |
867 | + } | |
868 | + return $xml; | |
869 | +} | |
870 | +function geraXmlAtlas_pegapranchas($xml,$id_atlas,$dbh) | |
871 | +{ | |
872 | + global $esquemaadmin; | |
873 | + xml_testaNum([$id_atlas]); | |
874 | + $q = "select * from ".$esquemaadmin."i3geoadmin_atlasp as p where p.id_atlas = $id_atlas order by ordem_prancha"; | |
875 | + $qpranchas = $dbh->query($q); | |
876 | + foreach($qpranchas as $row) | |
877 | + { | |
878 | + $xml .= " <PRANCHA>\n"; | |
879 | + $xml .= " <ID>".$row["id_prancha"]."</ID>\n"; | |
880 | + $xml .= " <TITULO>".xmlTexto_prepara($row["titulo_prancha"])."</TITULO>\n"; | |
881 | + $xml .= " <DESCRICAO>".xmlTexto_prepara($row["desc_prancha"])."</DESCRICAO>\n"; | |
882 | + $xml .= " <ICONE>".$row["icone_prancha"]."</ICONE>\n"; | |
883 | + $xml .= " <LINKMAISINFO><![CDATA[".xmlTexto_prepara($row["link_prancha"])."]]></LINKMAISINFO>\n"; | |
884 | + $xml .= " <WABERTURA>".$row["w_prancha"]."</WABERTURA>\n"; | |
885 | + $xml .= " <HABERTURA>".$row["h_prancha"]."</HABERTURA>\n"; | |
886 | + $xml .= " <MAPEXT>".$row["mapext_prancha"]."</MAPEXT>\n"; | |
887 | + $xml .= " <TEMAS>\n"; | |
888 | + $xml = geraXmlAtlas_pegatemas($xml,$row["id_prancha"],$dbh); | |
889 | + $xml .= " </TEMAS>\n"; | |
890 | + $xml .= " </PRANCHA>\n"; | |
891 | + } | |
892 | + return $xml; | |
893 | +} | |
894 | +function geraXmlAtlas_pegatemas($xml,$id_prancha,$dbh) | |
895 | +{ | |
896 | + global $esquemaadmin; | |
897 | + xml_testaNum([$id_prancha]); | |
898 | + $q = "select t.codigo_tema,t.ligado_tema from ".$esquemaadmin."i3geoadmin_atlast as t where t.id_prancha = '$id_prancha' order by ordem_tema"; | |
899 | + //echo $q; | |
900 | + $qtemas = $dbh->query($q); | |
901 | + foreach($qtemas as $row) | |
902 | + { | |
903 | + $xml .= "<TEMA>\n"; | |
904 | + $xml .= "<CODIGO>".$row["codigo_tema"]."</CODIGO>\n"; | |
905 | + $xml .= "<LIGADO>".$row["ligado_tema"]."</LIGADO>\n"; | |
906 | + $xml .= "</TEMA>\n"; | |
907 | + } | |
908 | + return $xml; | |
909 | +} | |
910 | +function geraXmlSistemas_pegafuncoes($perfil,$xml,$id_sistema,$dbh) | |
911 | +{ | |
912 | + global $esquemaadmin; | |
913 | + xml_testaNum([$id_sistema]); | |
914 | + $q = "select * from ".$esquemaadmin."i3geoadmin_sistemasf where id_sistema = '$id_sistema'"; | |
915 | + $qtemas = $dbh->query($q); | |
916 | + foreach($qtemas as $row) | |
917 | + { | |
918 | + if($row["perfil_funcao"] == "") | |
919 | + $mostra = true; | |
920 | + else | |
921 | + { | |
922 | + $perfilF = explode(" ",str_replace(","," ",$row["perfil_funcao"])); | |
923 | + $mostra = array_in_array($perfil,$perfilF); | |
924 | + } | |
925 | + if($mostra) | |
926 | + { | |
927 | + $xml .= "<FUNCAO>\n"; | |
928 | + $xml .= " <NOMEFUNCAO>".xmlTexto_prepara($row["nome_funcao"])."</NOMEFUNCAO>\n"; | |
929 | + $xml .= " <ABRIR>".xmlTexto_prepara($row["abrir_funcao"])."</ABRIR>\n"; | |
930 | + $xml .= " <JANELAW>".$row["w_funcao"]."</JANELAW>\n"; | |
931 | + $xml .= " <JANELAH>".$row["h_funcao"]."</JANELAH>\n"; | |
932 | + $xml .= " <PERFIL>".$row["perfil_funcao"]."</PERFIL>\n"; | |
933 | + $xml .= "</FUNCAO>\n"; | |
934 | + } | |
935 | + } | |
936 | + return $xml; | |
937 | +} | |
938 | +function array_in_array($needle, $haystack) | |
939 | +{ | |
940 | + //Make sure $needle is an array for foreach | |
941 | + if(!is_array($needle)) $needle = array($needle); | |
942 | + //For each value in $needle, return TRUE if in $haystack | |
943 | + foreach($needle as $pin) | |
944 | + if(in_array($pin, $haystack)) return TRUE; | |
945 | + //Return FALSE if none of the values from $needle are found in $haystack | |
946 | + return FALSE; | |
947 | +} | |
948 | +function xmlTexto_prepara($texto) | |
949 | +{ | |
950 | + return str_replace("&","&",$texto); | |
951 | +} | |
952 | +function entity_decode($texto) | |
953 | +{ | |
954 | + return html_entity_decode($texto); | |
955 | +} | |
956 | +function xml_testaNum($valores){ | |
957 | + foreach ($valores as $valor) { | |
958 | + if(!empty($valor) && !is_numeric($valor)) { | |
959 | + echo "valor nao numerico"; | |
960 | + exit; | |
961 | + } | |
962 | + } | |
963 | +} | |
964 | +?> | ... | ... |
admin/php/xml.php
... | ... | @@ -119,12 +119,13 @@ Retorno: |
119 | 119 | |
120 | 120 | RSS |
121 | 121 | */ |
122 | -function geraRSScomentariosTemas($locaplic,$id_tema="") | |
123 | -{ | |
122 | +function geraRSScomentariosTemas($locaplic,$id_tema=""){ | |
124 | 123 | global $esquemaadmin; |
124 | + xml_testaNum([$id_tema]); | |
125 | 125 | $sql = "select '' as tipo_ws, b.nome_tema||' '||a.data as nome_ws,a.openidnome||' '||a.openidurl||' <br>'||a.comentario as desc_ws, a.openidnome as autor_ws, b.link_tema as link_ws from ".$esquemaadmin."i3geoadmin_comentarios as a,".$esquemaadmin."i3geoadmin_temas as b where a.id_tema = b.id_tema "; |
126 | - if($id_tema != "") | |
127 | - {$sql .= " and a.id_tema = $id_tema ";} | |
126 | + if($id_tema != ""){ | |
127 | + $sql .= " and a.id_tema = $id_tema "; | |
128 | + } | |
128 | 129 | return geraXmlRSS($locaplic,$sql,"Lista de comentarios"); |
129 | 130 | } |
130 | 131 | /* |
... | ... | @@ -145,6 +146,7 @@ RSS |
145 | 146 | function geraRSStemas($locaplic,$id_n2,$output="xml") |
146 | 147 | { |
147 | 148 | global $esquemaadmin; |
149 | + xml_testaNum([$id_n2]); | |
148 | 150 | $sql = " |
149 | 151 | select '' as tipo_ws, i3geoadmin_temas.codigo_tema as id_ws,i3geoadmin_temas.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||i3geoadmin_temas.codigo_tema as link_ws,i3geoadmin_temas.link_tema as autor_ws |
150 | 152 | from ".$esquemaadmin."i3geoadmin_n3 as n3 |
... | ... | @@ -173,6 +175,7 @@ RSS |
173 | 175 | function geraRSStemasRaiz($locaplic,$id,$nivel) |
174 | 176 | { |
175 | 177 | global $esquemaadmin; |
178 | + xml_testaNum([$id,$nivel]); | |
176 | 179 | $sql = " |
177 | 180 | select '' as tipo_ws, i3geoadmin_temas.codigo_tema as id_ws,i3geoadmin_temas.nome_tema as nome_ws,'' as desc_ws,'php/parsemapfile.php?id='||i3geoadmin_temas.codigo_tema as link_ws,i3geoadmin_temas.link_tema as autor_ws |
178 | 181 | from ".$esquemaadmin."i3geoadmin_raiz as r |
... | ... | @@ -199,6 +202,7 @@ RSS |
199 | 202 | function geraRSSsubgrupos($locaplic,$id_n1,$output="json") |
200 | 203 | { |
201 | 204 | global $esquemaadmin; |
205 | + xml_testaNum([$id_n1]); | |
202 | 206 | $sql = "select '' as tipo_ws, n2.id_n2 as id_ws,g.nome_subgrupo as nome_ws,'' as desc_ws,'rsstemas.php?id='||n2.id_n2 as link_ws,'' as autor_ws from ".$esquemaadmin."i3geoadmin_n2 as n2,".$esquemaadmin."i3geoadmin_subgrupos as g "; |
203 | 207 | $sql .= " where g.id_subgrupo = n2.id_subgrupo and n2.id_n1 = '$id_n1' and n2.n2_perfil = '' and n2.publicado != 'NAO' order by nome_ws"; |
204 | 208 | return geraXmlRSS($locaplic,$sql,"Lista de sub-grupos",$output); |
... | ... | @@ -737,6 +741,7 @@ function geraRSSmapas($locaplic,$output) |
737 | 741 | function geraXmlMenutemas($perfil,$id_menu,$tipo,$locaplic) |
738 | 742 | { |
739 | 743 | global $esquemaadmin; |
744 | + xml_testaNum([$id_menu]); | |
740 | 745 | $dbh = ""; |
741 | 746 | include($locaplic."/admin/php/conexao.php"); |
742 | 747 | if (!isset($perfil)){$perfil = "";} |
... | ... | @@ -794,6 +799,7 @@ function geraXmlMenutemas($perfil,$id_menu,$tipo,$locaplic) |
794 | 799 | function geraXmlMenutemas_pegasubgrupos($id_n1,$xml,$dbh,$tipo,$perfil) |
795 | 800 | { |
796 | 801 | global $esquemaadmin; |
802 | + xml_testaNum([$id_n1]); | |
797 | 803 | $q = "select subgrupos.id_subgrupo,nome_subgrupo,id_n2,n2.n2_perfil as perfil from ".$esquemaadmin."i3geoadmin_n2 as n2,".$esquemaadmin."i3geoadmin_subgrupos as subgrupos where n2.id_n1 = $id_n1 and n2.id_subgrupo = subgrupos.id_subgrupo "; |
798 | 804 | //echo $q;exit; |
799 | 805 | $qsgrupos = $dbh->query($q); |
... | ... | @@ -821,6 +827,7 @@ function geraXmlMenutemas_pegasubgrupos($id_n1,$xml,$dbh,$tipo,$perfil) |
821 | 827 | function geraXmlMenutemas_pegatemas($id_n2,$xml,$dbh,$perfil) |
822 | 828 | { |
823 | 829 | global $esquemaadmin; |
830 | + xml_testaNum([$id_n2]); | |
824 | 831 | $q = "select nome_tema,codigo_tema,desc_tema,link_tema,tipoa_tema,tags_tema,kml_tema,ogc_tema,download_tema,n3.n3_perfil as perfil from ".$esquemaadmin."i3geoadmin_n3 as n3,".$esquemaadmin."i3geoadmin_temas as temas where n3.id_n2 = $id_n2 and n3.id_tema = temas.id_tema "; |
825 | 832 | $qtemas = $dbh->query($q); |
826 | 833 | $xml = geraXmlMenutemas_notema($qtemas,$xml,$perfil); |
... | ... | @@ -863,6 +870,7 @@ function geraXmlMenutemas_notema($qtemas,$xml,$perfil) |
863 | 870 | function geraXmlAtlas_pegapranchas($xml,$id_atlas,$dbh) |
864 | 871 | { |
865 | 872 | global $esquemaadmin; |
873 | + xml_testaNum([$id_atlas]); | |
866 | 874 | $q = "select * from ".$esquemaadmin."i3geoadmin_atlasp as p where p.id_atlas = $id_atlas order by ordem_prancha"; |
867 | 875 | $qpranchas = $dbh->query($q); |
868 | 876 | foreach($qpranchas as $row) |
... | ... | @@ -886,6 +894,7 @@ function geraXmlAtlas_pegapranchas($xml,$id_atlas,$dbh) |
886 | 894 | function geraXmlAtlas_pegatemas($xml,$id_prancha,$dbh) |
887 | 895 | { |
888 | 896 | global $esquemaadmin; |
897 | + xml_testaNum([$id_prancha]); | |
889 | 898 | $q = "select t.codigo_tema,t.ligado_tema from ".$esquemaadmin."i3geoadmin_atlast as t where t.id_prancha = '$id_prancha' order by ordem_tema"; |
890 | 899 | //echo $q; |
891 | 900 | $qtemas = $dbh->query($q); |
... | ... | @@ -901,6 +910,7 @@ function geraXmlAtlas_pegatemas($xml,$id_prancha,$dbh) |
901 | 910 | function geraXmlSistemas_pegafuncoes($perfil,$xml,$id_sistema,$dbh) |
902 | 911 | { |
903 | 912 | global $esquemaadmin; |
913 | + xml_testaNum([$id_sistema]); | |
904 | 914 | $q = "select * from ".$esquemaadmin."i3geoadmin_sistemasf where id_sistema = '$id_sistema'"; |
905 | 915 | $qtemas = $dbh->query($q); |
906 | 916 | foreach($qtemas as $row) |
... | ... | @@ -943,5 +953,13 @@ function entity_decode($texto) |
943 | 953 | { |
944 | 954 | return html_entity_decode($texto); |
945 | 955 | } |
946 | - | |
956 | +function xml_testaNum($valores){ | |
957 | + foreach ($valores as $valor) { | |
958 | + if(!empty($valor) && !is_numeric($valor)) { | |
959 | + ob_clean(); | |
960 | + header ( "HTTP/1.1 403 valor nao numerico" ); | |
961 | + exit; | |
962 | + } | |
963 | + } | |
964 | +} | |
947 | 965 | ?> | ... | ... |
admin/rsscomentariostemas.php
... | ... | @@ -41,11 +41,13 @@ error_reporting(0); |
41 | 41 | if(!isset($locaplic)){ |
42 | 42 | include(dirname(__FILE__)."/../ms_configura.php"); |
43 | 43 | } |
44 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
45 | -include_once($locaplic."/admin/php/xml.php"); | |
44 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
46 | 45 | $parametros = array_merge($_POST,$_GET); |
47 | -if(empty($parametros["id_tema"])) | |
48 | -{$parametros["id_tema"] = "";} | |
46 | +include_once($locaplic."/admin/php/xml.php"); | |
47 | + | |
48 | +if(empty($parametros["id_tema"])){ | |
49 | + $parametros["id_tema"] = ""; | |
50 | +} | |
49 | 51 | echo header("Content-type: application/xml"); |
50 | 52 | echo geraRSScomentariosTemas($locaplic,$parametros["id_tema"]); |
51 | 53 | ?> | ... | ... |
admin/rssgrupos.php
... | ... | @@ -36,7 +36,7 @@ error_reporting(0); |
36 | 36 | if(!isset($locaplic)){ |
37 | 37 | include(dirname(__FILE__)."/../ms_configura.php"); |
38 | 38 | } |
39 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
39 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
40 | 40 | include_once($locaplic."/admin/php/xml.php"); |
41 | 41 | $output = "xml"; |
42 | 42 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ | ... | ... |
admin/rssmapas.php
... | ... | @@ -36,7 +36,7 @@ error_reporting(0); |
36 | 36 | if(!isset($locaplic)){ |
37 | 37 | include(dirname(__FILE__)."/../ms_configura.php"); |
38 | 38 | } |
39 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
39 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
40 | 40 | include_once($locaplic."/admin/php/xml.php"); |
41 | 41 | $output = "xml"; |
42 | 42 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ | ... | ... |
admin/rsssubgrupos.php
... | ... | @@ -42,12 +42,13 @@ error_reporting(0); |
42 | 42 | if(!isset($locaplic)){ |
43 | 43 | include(dirname(__FILE__)."/../ms_configura.php"); |
44 | 44 | } |
45 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
45 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
46 | +$_GET = array_merge($_GET,$_POST); | |
46 | 47 | include_once($locaplic."/admin/php/xml.php"); |
47 | 48 | $output = "xml"; |
48 | 49 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ |
49 | 50 | $output = "json"; |
50 | 51 | } |
51 | 52 | echo header("Content-type: application/".$output); |
52 | -echo geraRSSsubgrupos($locaplic,$id,$output); | |
53 | +echo geraRSSsubgrupos($locaplic,$_GET["id"],$output); | |
53 | 54 | ?> | ... | ... |
admin/rsstemas.php
... | ... | @@ -42,12 +42,13 @@ error_reporting(0); |
42 | 42 | if(!isset($locaplic)){ |
43 | 43 | include(dirname(__FILE__)."/../ms_configura.php"); |
44 | 44 | } |
45 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
45 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
46 | +$_GET = array_merge($_GET,$_POST); | |
46 | 47 | include_once($locaplic."/admin/php/xml.php"); |
47 | 48 | $output = "xml"; |
48 | 49 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ |
49 | 50 | $output = "json"; |
50 | 51 | } |
51 | 52 | echo header("Content-type: application/".$output); |
52 | -echo geraRSStemas($locaplic,$id,$output); | |
53 | +echo geraRSStemas($locaplic,$_GET["id"],$output); | |
53 | 54 | ?> | ... | ... |
admin/rsstemasdownload.php
... | ... | @@ -39,7 +39,8 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
43 | +$_GET = array_merge($_GET,$_POST); | |
43 | 44 | include_once($locaplic."/admin/php/xml.php"); |
44 | 45 | echo header("Content-type: application/xml"); |
45 | 46 | echo geraRSStemasDownload($locaplic); | ... | ... |
admin/rsstemaskml.php
... | ... | @@ -39,7 +39,8 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
43 | +$_GET = array_merge($_GET,$_POST); | |
43 | 44 | include_once($locaplic."/admin/php/xml.php"); |
44 | 45 | echo header("Content-type: application/xml"); |
45 | 46 | echo geraRSStemasKml($locaplic); | ... | ... |
admin/rsstemasogc.php
... | ... | @@ -38,7 +38,8 @@ error_reporting(0); |
38 | 38 | if(!isset($locaplic)){ |
39 | 39 | include(dirname(__FILE__)."/../ms_configura.php"); |
40 | 40 | } |
41 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
41 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
42 | +$_GET = array_merge($_GET,$_POST); | |
42 | 43 | include_once($locaplic."/admin/php/xml.php"); |
43 | 44 | echo header("Content-type: application/xml"); |
44 | 45 | echo geraRSStemasOgc($locaplic); | ... | ... |
admin/rsstemasraiz.php
... | ... | @@ -44,8 +44,9 @@ error_reporting(0); |
44 | 44 | if(!isset($locaplic)){ |
45 | 45 | include(dirname(__FILE__)."/../ms_configura.php"); |
46 | 46 | } |
47 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
47 | +include_once(dirname(__FILE__)."/../classesphp/sani_request.php"); | |
48 | +$_GET = array_merge($_GET,$_POST); | |
48 | 49 | include_once($locaplic."/admin/php/xml.php"); |
49 | 50 | echo header("Content-type: application/xml"); |
50 | -echo geraRSStemasRaiz($locaplic,$id,$nivel); | |
51 | +echo geraRSStemasRaiz($locaplic,$_GET["id"],$_GET["nivel"]); | |
51 | 52 | ?> | ... | ... |
admin/xmlatlas.php
... | ... | @@ -4,8 +4,8 @@ error_reporting(0); |
4 | 4 | if(!isset($locaplic)){ |
5 | 5 | include(dirname(__FILE__)."/../ms_configura.php"); |
6 | 6 | } |
7 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
7 | +include_once($locaplic."/admin/safe.php"); | |
8 | 8 | include_once($locaplic."/admin/php/xml.php"); |
9 | 9 | echo header("Content-type: application/xml"); |
10 | -echo geraXmlAtlas($locaplic,$editores); | |
10 | +echo geraXmlAtlas($locaplic); | |
11 | 11 | ?> | ... | ... |
admin/xmlgeorss.php
... | ... | @@ -39,7 +39,7 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | $output = "xml"; |
45 | 45 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ | ... | ... |
admin/xmlidentifica.php
... | ... | @@ -43,9 +43,9 @@ error_reporting(0); |
43 | 43 | if(!isset($locaplic)){ |
44 | 44 | include(dirname(__FILE__)."/../ms_configura.php"); |
45 | 45 | } |
46 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
46 | +include_once($locaplic."/admin/safe.php"); | |
47 | 47 | include_once($locaplic."/admin/php/xml.php"); |
48 | 48 | if(!isset($perfil)){$perfil = "";} |
49 | 49 | echo header("Content-type: application/xml"); |
50 | -echo geraXmlIdentifica($perfil,$locaplic,$editores); | |
50 | +echo geraXmlIdentifica($perfil,$locaplic); | |
51 | 51 | ?> | ... | ... |
admin/xmlkmlrss.php
... | ... | @@ -38,7 +38,7 @@ error_reporting(0); |
38 | 38 | if(!isset($locaplic)){ |
39 | 39 | include(dirname(__FILE__)."/../ms_configura.php"); |
40 | 40 | } |
41 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
41 | +include_once($locaplic."/admin/safe.php"); | |
42 | 42 | include_once($locaplic."/admin/php/xml.php"); |
43 | 43 | echo header("Content-type: application/xml"); |
44 | 44 | echo geraXmlKmlrss($locaplic); | ... | ... |
admin/xmllinksdownload.php
... | ... | @@ -39,7 +39,7 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | echo header("Content-type: application/xml"); |
45 | 45 | echo geraXmlDownload($locaplic); | ... | ... |
admin/xmlmapas.php
... | ... | @@ -39,9 +39,9 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | if(!isset($perfil)){$perfil = "";} |
45 | 45 | echo header("Content-type: application/xml"); |
46 | -echo geraXmlMapas($perfil,$locaplic,$editores); | |
46 | +echo geraXmlMapas($perfil,$locaplic); | |
47 | 47 | ?> | ... | ... |
admin/xmlmenutemas.php
... | ... | @@ -3,7 +3,7 @@ error_reporting(0); |
3 | 3 | if(!isset($locaplic)){ |
4 | 4 | include(dirname(__FILE__)."/../ms_configura.php"); |
5 | 5 | } |
6 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
6 | +include_once($locaplic."/admin/safe.php"); | |
7 | 7 | include_once($locaplic."/admin/php/xml.php"); |
8 | 8 | if(!isset($perfil)){$perfil = "";} |
9 | 9 | if(!isset($id_menu)){$id_menu = "";} | ... | ... |
admin/xmlmetaestatogc.php
... | ... | @@ -38,7 +38,7 @@ error_reporting(0); |
38 | 38 | if(!isset($locaplic)){ |
39 | 39 | include(dirname(__FILE__)."/../ms_configura.php"); |
40 | 40 | } |
41 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
41 | +include_once($locaplic."/admin/safe.php"); | |
42 | 42 | include_once($locaplic."/admin/php/xml.php"); |
43 | 43 | echo header("Content-type: application/xml"); |
44 | 44 | echo geraXmlWMSmetaestat($locaplic); | ... | ... |
admin/xmlservicoswms.php
... | ... | @@ -39,7 +39,7 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | $output = "xml"; |
45 | 45 | if(strtolower($_GET["output"]) == "json" || strtolower($_POST["output"]) == "json"){ | ... | ... |
admin/xmlservicosws.php
... | ... | @@ -39,7 +39,7 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | |
45 | 45 | $output = "xml"; | ... | ... |
admin/xmlsistemas.php
... | ... | @@ -39,9 +39,9 @@ error_reporting(0); |
39 | 39 | if(!isset($locaplic)){ |
40 | 40 | include(dirname(__FILE__)."/../ms_configura.php"); |
41 | 41 | } |
42 | -include_once($locaplic."/classesphp/pega_variaveis.php"); | |
42 | +include_once($locaplic."/admin/safe.php"); | |
43 | 43 | include_once($locaplic."/admin/php/xml.php"); |
44 | 44 | if(!isset($perfil)){$perfil = "";} |
45 | 45 | echo header("Content-type: application/xml"); |
46 | -echo geraXmlSistemas($perfil,$locaplic,$editores); | |
46 | +echo geraXmlSistemas($perfil,$locaplic); | |
47 | 47 | ?> | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +Copyright (c) 2014, PayPal | |
2 | +All rights reserved. | |
3 | + | |
4 | +Redistribution and use in source and binary forms, with or without modification, | |
5 | +are permitted provided that the following conditions are met: | |
6 | + | |
7 | +* Redistributions of source code must retain the above copyright notice, this | |
8 | + list of conditions and the following disclaimer. | |
9 | + | |
10 | +* Redistributions in binary form must reproduce the above copyright notice, this | |
11 | + list of conditions and the following disclaimer in the documentation and/or | |
12 | + other materials provided with the distribution. | |
13 | + | |
14 | +* Neither the name of the PayPal nor the names of its | |
15 | + contributors may be used to endorse or promote products derived from | |
16 | + this software without specific prior written permission. | |
17 | + | |
18 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
19 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
20 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
21 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | |
22 | +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
24 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
25 | +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
27 | +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ... | ... |
... | ... | @@ -0,0 +1,145 @@ |
1 | +<img src="images/logo/logo_347x50_PPa11y.png" alt="PayPal accessibility logo"> | |
2 | +# Bootstrap Accessibility Plugin, v1.0 | |
3 | +## by the PayPal Accessibility Team | |
4 | +See the [Authors](#authors) section below for more information. | |
5 | + | |
6 | +## What is it? | |
7 | +This plugin adds accessibility mark-up to the [default components of Bootstrap 3](http://getbootstrap.com/javascript/) to make them accessible for keyboard and screen reader users. Do not worry, the plugin does not affect the performance or the visual layout of your website. Let the magic remain magic! | |
8 | + | |
9 | +## Why do I want it? | |
10 | +If you use Bootstrap library (version 3.x) on your website, your pages will now be much more usable and navigable for and by keyboard and screen reader users with no work on your part. Believe us, for this they will thank you! Read on to learn about all the enhancements introduced by this plugin. | |
11 | + | |
12 | +## How do I get it on my website? | |
13 | +1. Download and include Bootstrap.js from [getbootstrap.com](http://getbootstrap.com/). | |
14 | +2. Download and include the [bootstrap accessibility plugin js](plugins/js). | |
15 | +3. Download and include the [bootstrap accessibility plugin css](plugins/css) to override css styles. | |
16 | +4. Optional: Lazily load the JavaScript plugin after the page is loaded ([example](demo.html)). | |
17 | +5. For basic implementation: | |
18 | + | |
19 | + ```html | |
20 | + <link rel="stylesheet" href="/css/bootstrap.min.css"> | |
21 | + <link rel="stylesheet" href="/css/bootstrap-accessibility.css"> | |
22 | + | |
23 | + <script src="http://code.jquery.com/jquery.js"></script> | |
24 | + <script src="/js/bootstrap.min.js"></script> | |
25 | + <script src="/js/bootstrap-accessibility.min.js"></script> | |
26 | + ``` | |
27 | +6. You can also install it from npm or bower: | |
28 | + | |
29 | + ```sh | |
30 | + bower install bootstrapaccessibilityplugin | |
31 | + npm install bootstrap-accessibility-plugin | |
32 | + ``` | |
33 | + | |
34 | +## Which components become accessible? | |
35 | +- Alert | |
36 | +- Tooltip | |
37 | +- Popover | |
38 | +- Modal dialog | |
39 | +- Dropdown menu | |
40 | +- Tab panel | |
41 | +- Collapse | |
42 | +- Carousel | |
43 | + | |
44 | +## Plugin Live Demo | |
45 | +Feel free to play with the [live demo](https://paypal.github.io/bootstrap-accessibility-plugin/demo.html) of the components listed above and the Bootstrap Accessibility Plugin in action. Seeing how "accessified" widgets work in this demo will help you verify whether the plugin is installed correctly on your website. | |
46 | + | |
47 | +## Details | |
48 | + | |
49 | +### Alert | |
50 | +1. Add role of Alert to Alert, Warning, and Success Bootstrap Messages. | |
51 | +2. Increase the color contrast. The foreground to background color contrast ratio for the message was too low. | |
52 | +3. Add instructions in message dialog, so that the developer using the alert knows to manage keyboard focus on alert dismissal. | |
53 | +4. Close button now accessible to screen readers. | |
54 | + | |
55 | +### Tooltip | |
56 | +1. Add role of Tooltip to tooltip div. | |
57 | +2. Generate a random id, assign it to the tooltip div, and reference it from the Tooltip element with the ARIA attribute "aria-describedby". | |
58 | +3. Remove aria-describedby when the tooltip is hidden. | |
59 | + | |
60 | +### Popover | |
61 | +1. Add role of Tooltip to popover div. | |
62 | +2. Generate a random id, assign it to Popover div, and reference it from the Tooltip element with the ARIA attribute "aria-describedby". | |
63 | +3. Remove aria-describedby when the popover is dismissed. | |
64 | + | |
65 | +### Modal Dialog | |
66 | +1. Add role of Document to content div inside dialog, so that NVDA can force document mode and read contents inside Dialog. | |
67 | +2. When the Modal is closed, return the focus to the element which opened the dialog. | |
68 | +3. Change the focus outline of close button to visible. | |
69 | +4. Close button now accessible to screen readers. | |
70 | + | |
71 | +### Dropdown | |
72 | +1. Add aria-haspopup and and aria-expanded attributes to dropdown toggle link. | |
73 | +2. Dynamically change aria-expanded when the dropdown closes or opens. | |
74 | +3. Focus to first item on activating dropdown. | |
75 | +4. Add ability to open dropdown with spacebar. | |
76 | +5. Close dropdown when tabbing out from dropdown. | |
77 | +6. Change the focus outline of dropdown to visible. | |
78 | + | |
79 | +### Tab Panel | |
80 | +1. Add ARIA roles like tablist, presentation, and tab for tabs UL, LI. | |
81 | +2. Add tabIndex, aria-expanded, aria-selected, aria-controls for tab. | |
82 | +3. Add ARIA roles of tabPanel, tabIndex, aria-hidden, and aria-labelledBy for tabPanel. | |
83 | +4. Add keydown event listener for the tab to work with keyboard. | |
84 | +5. Dynamically flip tabIndex, aria-selected, and aria-expanded for tab when it is activated and add aria-hidden to hide the previously visible tab. | |
85 | + | |
86 | +### Collapse | |
87 | +1. Add tab role, aria-selected, aria-expanded, aria-controls, and tabIndex for collapse tab. | |
88 | +2. Add ARIA roles of tabPanel, tabIndex, aria-hidden, and aria-labelledBy for collapsible panel. | |
89 | +3. Add role of tabList and aria-multiselectable for collapse container div. | |
90 | +4. Dynamically flip tabIndex, aria-selected, and aria-expanded for tab when it is activated and add aria-hidden to hide the previously visible collapse tabpanel. | |
91 | +5. Add keydown event listener for the collapse component to work with keyboard. | |
92 | + | |
93 | +### Carousel | |
94 | +1. Prevent automatic cycling of the carousel. | |
95 | +2. Prevent wrapping to first item on next button navigation or wrapping to last item on previous button navigation. | |
96 | +3. Add role of listbox for carousel div. | |
97 | +4. Add ARIA role of option, aria-selected, and tabIndex for individual carousel items. | |
98 | +5. Add role of button for previous and next anchor links and a hidden screen reader text of "Previous" and "Next". | |
99 | +6. Add keydown event listener for the carousel to work with keyboard. | |
100 | +7. Dynamically change tabIndex and aria-selected property of active and inactive tabs. | |
101 | +8. Remove display:none and hide (offscreen) of the inactive carousel items, so that screen readers can count the total number of carousel items. | |
102 | + | |
103 | +## Re-compiling | |
104 | +You may want to extend the plugin further or change some of the code. Here is how to do it: | |
105 | + | |
106 | +1. Get NodeJS from [http://nodejs.org](http://nodejs.org) | |
107 | +2. Clone the latest code from [https://github.com/paypal/bootstrap-accessibility-plugin.git](https://github.com/paypal/bootstrap-accessibility-plugin.git) | |
108 | +3. Go to the root of this project and install Compass and Sass: | |
109 | + | |
110 | + ```sh | |
111 | + cd bootstrap-accessibility-plugin | |
112 | + sudo gem install compass | |
113 | + ``` | |
114 | +4. Install and run grunt: | |
115 | + | |
116 | + ```sh | |
117 | + sudo npm install grunt-cli -g | |
118 | + npm install | |
119 | + grunt | |
120 | + ``` | |
121 | +5. To run the examples, initialize the git submodules: | |
122 | + | |
123 | + ```sh | |
124 | + git submodule init | |
125 | + git submodule update | |
126 | + ``` | |
127 | + | |
128 | +## Feedback and Contributions | |
129 | +Please do not hesitate to open an issue or send a pull request if something doesn't work or you have ideas for improvement. For instructions on how to contribute to this project please read the [contribution guide](CONTRIBUTING.md). | |
130 | + | |
131 | +## Authors | |
132 | + | |
133 | + - Prem Nawaz Khan, primary developer || [https://github.com/mpnkhan](https://github.com/mpnkhan) || [@mpnkhan](https://twitter.com/mpnkhan) | |
134 | + - Victor Tsaran, project manager, user interaction, testing, documentation || [https://github.com/vick08](https://github.com/vick08) || [@vick08](https://twitter.com/vick08) | |
135 | + - Dennis Lembree, developer, user interaction, testing || [https://github.com/weboverhauls](https://github.com/weboverhauls) || [@dennisl](https://twitter.com/dennisl) | |
136 | + - Srinivasu Chakravarthula, user interaction, testing || [@csrinivasu](https://twitter.com/csrinivasu) | |
137 | + - Cathy O'Connor, design || [@cagocon](https://twitter.com/cagocon) | |
138 | + | |
139 | +## Related Resources | |
140 | + | |
141 | + - [Bootstrap a11y theme](https://github.com/bassjobsen/bootstrap-a11y-theme) - makes web accessibility easier for Bootstrap developers, a pure LESS/CSS solution. | |
142 | + | |
143 | +## Copyright and License | |
144 | + | |
145 | +Copyright 2015, PayPal under [the BSD license](LICENSE.md). | ... | ... |
pacotes/bootstrap-accessibility-plugin/plugins/css/bootstrap-accessibility.css
0 → 100755
... | ... | @@ -0,0 +1 @@ |
1 | +.btn:focus{outline:dotted 2px #000}div.active:focus{outline:dotted 1px #000}a:focus{outline:dotted 1px #000}.close:hover,.close:focus{outline:dotted 1px #000}.nav>li>a:hover,.nav>li>a:focus{outline:dotted 1px #000}.carousel-indicators li,.carousel-indicators li.active{height:18px;width:18px;border-width:2px;position:relative;box-shadow:0px 0px 0px 1px #808080}.carousel-indicators.active li{background-color:rgba(100,149,253,0.6)}.carousel-indicators.active li.active{background-color:white}.carousel-tablist-highlight{display:block;position:absolute;outline:2px solid transparent;background-color:transparent;box-shadow:0px 0px 0px 1px transparent}.carousel-tablist-highlight.focus{outline:2px solid #6495ED;background-color:rgba(0,0,0,0.4)}a.carousel-control:focus{outline:2px solid #6495ED;background-image:linear-gradient(to right, transparent 0px, rgba(0,0,0,0.5) 100%);box-shadow:0px 0px 0px 1px #000000}.carousel-pause-button{position:absolute;top:-30em;left:-300em;display:block}.carousel-pause-button.focus{top:0.5em;left:0.5em}.carousel:hover .carousel-caption,.carousel.contrast .carousel-caption{background-color:rgba(0,0,0,0.5);z-index:10}.alert-success{color:#2d4821}.alert-info{color:#214c62}.alert-warning{color:#6c4a00;background-color:#f9f1c6}.alert-danger{color:#e13023}.alert-danger:hover{color:#a82824} | ... | ... |
pacotes/bootstrap-accessibility-plugin/plugins/js/bootstrap-accessibility.js
0 → 100755
... | ... | @@ -0,0 +1,716 @@ |
1 | +/* ======================================================================== | |
2 | +* Extends Bootstrap v3.1.1 | |
3 | + | |
4 | +* Copyright (c) <2015> PayPal | |
5 | + | |
6 | +* All rights reserved. | |
7 | + | |
8 | +* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
9 | + | |
10 | +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
11 | + | |
12 | +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
13 | + | |
14 | +* Neither the name of PayPal or any of its subsidiaries or affiliates nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | |
15 | + | |
16 | +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
17 | + | |
18 | +* ======================================================================== */ | |
19 | + | |
20 | + | |
21 | + (function($) { | |
22 | + "use strict"; | |
23 | + | |
24 | + // GENERAL UTILITY FUNCTIONS | |
25 | + // =============================== | |
26 | + | |
27 | + var uniqueId = function(prefix) { | |
28 | + return (prefix || 'ui-id') + '-' + Math.floor((Math.random()*1000)+1) | |
29 | + } | |
30 | + | |
31 | + | |
32 | + var removeMultiValAttributes = function (el, attr, val) { | |
33 | + var describedby = (el.attr( attr ) || "").split( /\s+/ ) | |
34 | + , index = $.inArray(val, describedby) | |
35 | + if ( index !== -1 ) { | |
36 | + describedby.splice( index, 1 ) | |
37 | + } | |
38 | + describedby = $.trim( describedby.join( " " ) ) | |
39 | + if (describedby ) { | |
40 | + el.attr( attr, describedby ) | |
41 | + } else { | |
42 | + el.removeAttr( attr ) | |
43 | + } | |
44 | + } | |
45 | + | |
46 | +// selectors Courtesy: https://github.com/jquery/jquery-ui/blob/master/ui/focusable.js and tabbable.js | |
47 | +/* | |
48 | +Copyright jQuery Foundation and other contributors, https://jquery.org/ | |
49 | + | |
50 | +This software consists of voluntary contributions made by many | |
51 | +individuals. For exact contribution history, see the revision history | |
52 | +available at https://github.com/jquery/jquery-ui | |
53 | + | |
54 | +The following license applies to all parts of this software except as | |
55 | +documented below: | |
56 | + | |
57 | +==== | |
58 | + | |
59 | +Permission is hereby granted, free of charge, to any person obtaining | |
60 | +a copy of this software and associated documentation files (the | |
61 | +"Software"), to deal in the Software without restriction, including | |
62 | +without limitation the rights to use, copy, modify, merge, publish, | |
63 | +distribute, sublicense, and/or sell copies of the Software, and to | |
64 | +permit persons to whom the Software is furnished to do so, subject to | |
65 | +the following conditions: | |
66 | + | |
67 | +The above copyright notice and this permission notice shall be | |
68 | +included in all copies or substantial portions of the Software. | |
69 | + | |
70 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
71 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
72 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
73 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
74 | +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
75 | +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
76 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
77 | + | |
78 | +==== | |
79 | + | |
80 | +Copyright and related rights for sample code are waived via CC0. Sample | |
81 | +code is defined as all source code contained within the demos directory. | |
82 | + | |
83 | +CC0: http://creativecommons.org/publicdomain/zero/1.0/ | |
84 | + | |
85 | +==== | |
86 | +*/ | |
87 | + | |
88 | + var focusable = function ( element, isTabIndexNotNaN ) { | |
89 | + var map, mapName, img, | |
90 | + nodeName = element.nodeName.toLowerCase(); | |
91 | + if ( "area" === nodeName ) { | |
92 | + map = element.parentNode; | |
93 | + mapName = map.name; | |
94 | + if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { | |
95 | + return false; | |
96 | + } | |
97 | + img = $( "img[usemap='#" + mapName + "']" )[ 0 ]; | |
98 | + return !!img && visible( img ); | |
99 | + } | |
100 | + return ( /input|select|textarea|button|object/.test( nodeName ) ? | |
101 | + !element.disabled : | |
102 | + "a" === nodeName ? | |
103 | + element.href || isTabIndexNotNaN :isTabIndexNotNaN) && visible( element ); // the element and all of its ancestors must be visible | |
104 | + } | |
105 | + var visible = function ( element ) { | |
106 | + return $.expr.filters.visible( element ) && | |
107 | + !$( element ).parents().addBack().filter(function() { | |
108 | + return $.css( this, "visibility" ) === "hidden"; | |
109 | + }).length; | |
110 | + } | |
111 | + | |
112 | + $.extend( $.expr[ ":" ], { | |
113 | + data: $.expr.createPseudo ? | |
114 | + $.expr.createPseudo(function( dataName ) { | |
115 | + return function( elem ) { | |
116 | + return !!$.data( elem, dataName ); | |
117 | + }; | |
118 | + }) : | |
119 | + // support: jQuery <1.8 | |
120 | + function( elem, i, match ) { | |
121 | + return !!$.data( elem, match[ 3 ] ); | |
122 | + }, | |
123 | + | |
124 | + focusable: function( element ) { | |
125 | + return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); | |
126 | + }, | |
127 | + | |
128 | + tabbable: function( element ) { | |
129 | + var tabIndex = $.attr( element, "tabindex" ), | |
130 | + isTabIndexNaN = isNaN( tabIndex ); | |
131 | + return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); | |
132 | + } | |
133 | + }); | |
134 | + | |
135 | + // Modal Extension | |
136 | + // =============================== | |
137 | + | |
138 | + $('.modal-dialog').attr( {'role' : 'document'}) | |
139 | + var modalhide = $.fn.modal.Constructor.prototype.hide | |
140 | + $.fn.modal.Constructor.prototype.hide = function(){ | |
141 | + modalhide.apply(this, arguments) | |
142 | + $(document).off('keydown.bs.modal') | |
143 | + } | |
144 | + | |
145 | + var modalfocus = $.fn.modal.Constructor.prototype.enforceFocus | |
146 | + $.fn.modal.Constructor.prototype.enforceFocus = function(){ | |
147 | + var $content = this.$element.find(".modal-content") | |
148 | + var focEls = $content.find(":tabbable") | |
149 | + , $lastEl = $(focEls[focEls.length-1]) | |
150 | + , $firstEl = $(focEls[0]) | |
151 | + $lastEl.on('keydown.bs.modal', $.proxy(function (ev) { | |
152 | + if(ev.keyCode === 9 && !(ev.shiftKey | ev.ctrlKey | ev.metaKey | ev.altKey)) { // TAB pressed | |
153 | + ev.preventDefault(); | |
154 | + $firstEl.focus(); | |
155 | + } | |
156 | + }, this)) | |
157 | + $firstEl.on('keydown.bs.modal', $.proxy(function (ev) { | |
158 | + if(ev.keyCode === 9 && ev.shiftKey) { // SHIFT-TAB pressed | |
159 | + ev.preventDefault(); | |
160 | + $lastEl.focus(); | |
161 | + } | |
162 | + }, this)) | |
163 | + modalfocus.apply(this, arguments) | |
164 | + } | |
165 | + | |
166 | + // DROPDOWN Extension | |
167 | + // =============================== | |
168 | + | |
169 | + var toggle = '[data-toggle=dropdown]' | |
170 | + , $par | |
171 | + , firstItem | |
172 | + , focusDelay = 200 | |
173 | + , menus = $(toggle).parent().find('ul').attr('role','menu') | |
174 | + , lis = menus.find('li').attr('role','presentation') | |
175 | + | |
176 | + // add menuitem role and tabIndex to dropdown links | |
177 | + lis.find('a').attr({'role':'menuitem', 'tabIndex':'-1'}) | |
178 | + // add aria attributes to dropdown toggle | |
179 | + $(toggle).attr({ 'aria-haspopup':'true', 'aria-expanded': 'false'}) | |
180 | + | |
181 | + $(toggle).parent() | |
182 | + // Update aria-expanded when open | |
183 | + .on('shown.bs.dropdown',function(e){ | |
184 | + $par = $(this) | |
185 | + var $toggle = $par.find(toggle) | |
186 | + $toggle.attr('aria-expanded','true') | |
187 | + $toggle.on('keydown.bs.dropdown', $.proxy(function (ev) { | |
188 | + setTimeout(function() { | |
189 | + firstItem = $('.dropdown-menu [role=menuitem]:visible', $par)[0] | |
190 | + try{ firstItem.focus()} catch(ex) {} | |
191 | + }, focusDelay) | |
192 | + }, this)) | |
193 | + | |
194 | + }) | |
195 | + // Update aria-expanded when closed | |
196 | + .on('hidden.bs.dropdown',function(e){ | |
197 | + $par = $(this) | |
198 | + var $toggle = $par.find(toggle) | |
199 | + $toggle.attr('aria-expanded','false') | |
200 | + }) | |
201 | + | |
202 | + // Close the dropdown if tabbed away from | |
203 | + $(document) | |
204 | + .on('focusout.dropdown.data-api', '.dropdown-menu', function(e){ | |
205 | + var $this = $(this) | |
206 | + , that = this; | |
207 | + // since we're trying to close when appropriate, | |
208 | + // make sure the dropdown is open | |
209 | + if (!$this.parent().hasClass('open')) { | |
210 | + return; | |
211 | + } | |
212 | + setTimeout(function() { | |
213 | + if(!$.contains(that, document.activeElement)){ | |
214 | + $this.parent().find('[data-toggle=dropdown]').dropdown('toggle') | |
215 | + } | |
216 | + }, 150) | |
217 | + }) | |
218 | + .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , $.fn.dropdown.Constructor.prototype.keydown); | |
219 | + | |
220 | + // Tab Extension | |
221 | + // =============================== | |
222 | + | |
223 | + var $tablist = $('.nav-tabs, .nav-pills') | |
224 | + , $lis = $tablist.children('li') | |
225 | + , $tabs = $tablist.find('[data-toggle="tab"], [data-toggle="pill"]') | |
226 | + | |
227 | + if($tabs){ | |
228 | + $tablist.attr('role', 'tablist') | |
229 | + $lis.attr('role', 'presentation') | |
230 | + $tabs.attr('role', 'tab') | |
231 | + } | |
232 | + | |
233 | + $tabs.each(function( index ) { | |
234 | + var tabpanel = $($(this).attr('href')) | |
235 | + , tab = $(this) | |
236 | + , tabid = tab.attr('id') || uniqueId('ui-tab') | |
237 | + | |
238 | + tab.attr('id', tabid) | |
239 | + | |
240 | + if(tab.parent().hasClass('active')){ | |
241 | + tab.attr( { 'tabIndex' : '0', 'aria-selected' : 'true', 'aria-controls': tab.attr('href').substr(1) } ) | |
242 | + tabpanel.attr({ 'role' : 'tabpanel', 'tabIndex' : '0', 'aria-hidden' : 'false', 'aria-labelledby':tabid }) | |
243 | + }else{ | |
244 | + tab.attr( { 'tabIndex' : '-1', 'aria-selected' : 'false', 'aria-controls': tab.attr('href').substr(1) } ) | |
245 | + tabpanel.attr( { 'role' : 'tabpanel', 'tabIndex' : '-1', 'aria-hidden' : 'true', 'aria-labelledby':tabid } ) | |
246 | + } | |
247 | + }) | |
248 | + | |
249 | + $.fn.tab.Constructor.prototype.keydown = function (e) { | |
250 | + var $this = $(this) | |
251 | + , $items | |
252 | + , $ul = $this.closest('ul[role=tablist] ') | |
253 | + , index | |
254 | + , k = e.which || e.keyCode | |
255 | + | |
256 | + $this = $(this) | |
257 | + if (!/(37|38|39|40)/.test(k)) return | |
258 | + | |
259 | + $items = $ul.find('[role=tab]:visible') | |
260 | + index = $items.index($items.filter(':focus')) | |
261 | + | |
262 | + if (k == 38 || k == 37) index-- // up & left | |
263 | + if (k == 39 || k == 40) index++ // down & right | |
264 | + | |
265 | + | |
266 | + if(index < 0) index = $items.length -1 | |
267 | + if(index == $items.length) index = 0 | |
268 | + | |
269 | + var nextTab = $items.eq(index) | |
270 | + if(nextTab.attr('role') ==='tab'){ | |
271 | + | |
272 | + nextTab.tab('show') //Comment this line for dynamically loaded tabPabels, to save Ajax requests on arrow key navigation | |
273 | + .focus() | |
274 | + } | |
275 | + // nextTab.focus() | |
276 | + | |
277 | + e.preventDefault() | |
278 | + e.stopPropagation() | |
279 | + } | |
280 | + | |
281 | + $(document).on('keydown.tab.data-api','[data-toggle="tab"], [data-toggle="pill"]' , $.fn.tab.Constructor.prototype.keydown) | |
282 | + | |
283 | + var tabactivate = $.fn.tab.Constructor.prototype.activate; | |
284 | + $.fn.tab.Constructor.prototype.activate = function (element, container, callback) { | |
285 | + var $active = container.find('> .active') | |
286 | + $active.find('[data-toggle=tab], [data-toggle=pill]').attr({ 'tabIndex' : '-1','aria-selected' : false }) | |
287 | + $active.filter('.tab-pane').attr({ 'aria-hidden' : true,'tabIndex' : '-1' }) | |
288 | + | |
289 | + tabactivate.apply(this, arguments) | |
290 | + | |
291 | + element.addClass('active') | |
292 | + element.find('[data-toggle=tab], [data-toggle=pill]').attr({ 'tabIndex' : '0','aria-selected' : true }) | |
293 | + element.filter('.tab-pane').attr({ 'aria-hidden' : false,'tabIndex' : '0' }) | |
294 | + } | |
295 | + | |
296 | + // Collapse Extension | |
297 | + // =============================== | |
298 | + | |
299 | + var $colltabs = $('[data-toggle="collapse"]') | |
300 | + $colltabs.each(function( index ) { | |
301 | + var colltab = $(this) | |
302 | + , collpanel = (colltab.attr('data-target')) ? $(colltab.attr('data-target')) : $(colltab.attr('href')) | |
303 | + , parent = colltab.attr('data-parent') | |
304 | + , collparent = parent && $(parent) | |
305 | + , collid = colltab.attr('id') || uniqueId('ui-collapse') | |
306 | + | |
307 | + colltab.attr('id', collid) | |
308 | + | |
309 | + if(collparent){ | |
310 | + colltab.attr({ 'role':'tab', 'aria-selected':'false', 'aria-expanded':'false' }) | |
311 | + $(collparent).find('div:not(.collapse,.panel-body), h4').attr('role','presentation') | |
312 | + collparent.attr({ 'role' : 'tablist', 'aria-multiselectable' : 'true' }) | |
313 | + | |
314 | + if(collpanel.hasClass('in')){ | |
315 | + colltab.attr({ 'aria-controls': collpanel.attr('id'), 'aria-selected':'true', 'aria-expanded':'true', 'tabindex':'0' }) | |
316 | + collpanel.attr({ 'role':'tabpanel', 'tabindex':'0', 'aria-labelledby':collid, 'aria-hidden':'false' }) | |
317 | + }else{ | |
318 | + colltab.attr({'aria-controls' : collpanel.attr('id'), 'tabindex':'-1' }) | |
319 | + collpanel.attr({ 'role':'tabpanel', 'tabindex':'-1', 'aria-labelledby':collid, 'aria-hidden':'true' }) | |
320 | + } | |
321 | + } | |
322 | + }) | |
323 | + | |
324 | + var collToggle = $.fn.collapse.Constructor.prototype.toggle | |
325 | + $.fn.collapse.Constructor.prototype.toggle = function(){ | |
326 | + var prevTab = this.$parent && this.$parent.find('[aria-expanded="true"]') , href | |
327 | + | |
328 | + if(prevTab){ | |
329 | + var prevPanel = prevTab.attr('data-target') || (href = prevTab.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') | |
330 | + , $prevPanel = $(prevPanel) | |
331 | + , $curPanel = this.$element | |
332 | + , par = this.$parent | |
333 | + , curTab | |
334 | + | |
335 | + if (this.$parent) curTab = this.$parent.find('[data-toggle=collapse][href="#' + this.$element.attr('id') + '"]') | |
336 | + | |
337 | + collToggle.apply(this, arguments) | |
338 | + | |
339 | + if ($.support.transition) { | |
340 | + this.$element.one($.support.transition.end, function(){ | |
341 | + | |
342 | + prevTab.attr({ 'aria-selected':'false','aria-expanded':'false', 'tabIndex':'-1' }) | |
343 | + $prevPanel.attr({ 'aria-hidden' : 'true','tabIndex' : '-1'}) | |
344 | + | |
345 | + curTab.attr({ 'aria-selected':'true','aria-expanded':'true', 'tabIndex':'0' }) | |
346 | + | |
347 | + if($curPanel.hasClass('in')){ | |
348 | + $curPanel.attr({ 'aria-hidden' : 'false','tabIndex' : '0' }) | |
349 | + }else{ | |
350 | + curTab.attr({ 'aria-selected':'false','aria-expanded':'false'}) | |
351 | + $curPanel.attr({ 'aria-hidden' : 'true','tabIndex' : '-1' }) | |
352 | + } | |
353 | + }) | |
354 | + } | |
355 | + }else{ | |
356 | + collToggle.apply(this, arguments) | |
357 | + } | |
358 | + } | |
359 | + | |
360 | + $.fn.collapse.Constructor.prototype.keydown = function (e) { | |
361 | + var $this = $(this) | |
362 | + , $items | |
363 | + , $tablist = $this.closest('div[role=tablist] ') | |
364 | + , index | |
365 | + , k = e.which || e.keyCode | |
366 | + | |
367 | + $this = $(this) | |
368 | + if (!/(32|37|38|39|40)/.test(k)) return | |
369 | + if(k==32) $this.click() | |
370 | + | |
371 | + $items = $tablist.find('[role=tab]') | |
372 | + index = $items.index($items.filter(':focus')) | |
373 | + | |
374 | + if (k == 38 || k == 37) index-- // up & left | |
375 | + if (k == 39 || k == 40) index++ // down & right | |
376 | + if(index < 0) index = $items.length -1 | |
377 | + if(index == $items.length) index = 0 | |
378 | + | |
379 | + $items.eq(index).focus() | |
380 | + | |
381 | + e.preventDefault() | |
382 | + e.stopPropagation() | |
383 | + | |
384 | + } | |
385 | + | |
386 | + $(document).on('keydown.collapse.data-api','[data-toggle="collapse"]' , $.fn.collapse.Constructor.prototype.keydown); | |
387 | + | |
388 | + | |
389 | +// Carousel Extension | |
390 | + // =============================== | |
391 | + | |
392 | + $('.carousel').each(function (index) { | |
393 | + | |
394 | + // This function positions a highlight box around the tabs in the tablist to use in focus styling | |
395 | + | |
396 | + function setTablistHighlightBox() { | |
397 | + | |
398 | + var $tab | |
399 | + , offset | |
400 | + , height | |
401 | + , width | |
402 | + , highlightBox = {} | |
403 | + | |
404 | + highlightBox.top = 0 | |
405 | + highlightBox.left = 32000 | |
406 | + highlightBox.height = 0 | |
407 | + highlightBox.width = 0 | |
408 | + | |
409 | + for (var i = 0; i < $tabs.length; i++) { | |
410 | + $tab = $tabs[i] | |
411 | + offset = $($tab).offset() | |
412 | + height = $($tab).height() | |
413 | + width = $($tab).width() | |
414 | + | |
415 | +// console.log(" Top: " + offset.top + " Left: " + offset.left + " Height: " + height + " Width: " + width) | |
416 | + | |
417 | + if (highlightBox.top < offset.top) { | |
418 | + highlightBox.top = Math.round(offset.top) | |
419 | + } | |
420 | + | |
421 | + if (highlightBox.height < height) { | |
422 | + highlightBox.height = Math.round(height) | |
423 | + } | |
424 | + | |
425 | + if (highlightBox.left > offset.left) { | |
426 | + highlightBox.left = Math.round(offset.left) | |
427 | + } | |
428 | + | |
429 | + var w = (offset.left - highlightBox.left) + Math.round(width) | |
430 | + | |
431 | + if (highlightBox.width < w) { | |
432 | + highlightBox.width = w | |
433 | + } | |
434 | + | |
435 | + } // end for | |
436 | + | |
437 | +// console.log("[HIGHLIGHT] Top: " + highlightBox.top + " Left: " + highlightBox.left + " Height: " + highlightBox.height + " Width: " + highlightBox.width) | |
438 | + | |
439 | + $tablistHighlight.style.top = (highlightBox.top - 2) + 'px' | |
440 | + $tablistHighlight.style.left = (highlightBox.left - 2) + 'px' | |
441 | + $tablistHighlight.style.height = (highlightBox.height + 7) + 'px' | |
442 | + $tablistHighlight.style.width = (highlightBox.width + 8) + 'px' | |
443 | + | |
444 | + } // end function | |
445 | + | |
446 | + var $this = $(this) | |
447 | + , $prev = $this.find('[data-slide="prev"]') | |
448 | + , $next = $this.find('[data-slide="next"]') | |
449 | + , $tablist = $this.find('.carousel-indicators') | |
450 | + , $tabs = $this.find('.carousel-indicators li') | |
451 | + , $tabpanels = $this.find('.item') | |
452 | + , $tabpanel | |
453 | + , $tablistHighlight | |
454 | + , $pauseCarousel | |
455 | + , $complementaryLandmark | |
456 | + , $tab | |
457 | + , $is_paused = false | |
458 | + , offset | |
459 | + , height | |
460 | + , width | |
461 | + , i | |
462 | + , id_title = 'id_title' | |
463 | + , id_desc = 'id_desc' | |
464 | + | |
465 | + | |
466 | + $tablist.attr('role', 'tablist') | |
467 | + | |
468 | + $tabs.focus(function() { | |
469 | + $this.carousel('pause') | |
470 | + $is_paused = true | |
471 | + $pauseCarousel.innerHTML = "Play Carousel" | |
472 | + $(this).parent().addClass('active'); | |
473 | +// $(this).addClass('focus') | |
474 | + setTablistHighlightBox() | |
475 | + $($tablistHighlight).addClass('focus') | |
476 | + $(this).parents('.carousel').addClass('contrast') | |
477 | + }) | |
478 | + | |
479 | + $tabs.blur(function(event) { | |
480 | + $(this).parent().removeClass('active'); | |
481 | +// $(this).removeClass('focus') | |
482 | + $($tablistHighlight).removeClass('focus') | |
483 | + $(this).parents('.carousel').removeClass('contrast') | |
484 | + }) | |
485 | + | |
486 | + | |
487 | + for (i = 0; i < $tabpanels.length; i++) { | |
488 | + $tabpanel = $tabpanels[i] | |
489 | + $tabpanel.setAttribute('role', 'tabpanel') | |
490 | + $tabpanel.setAttribute('id', 'tabpanel-' + index + '-' + i) | |
491 | + $tabpanel.setAttribute('aria-labelledby', 'tab-' + index + '-' + i) | |
492 | + } | |
493 | + | |
494 | + if (typeof $this.attr('role') !== 'string') { | |
495 | + $this.attr('role', 'complementary'); | |
496 | + $this.attr('aria-labelledby', id_title); | |
497 | + $this.attr('aria-describedby', id_desc); | |
498 | + $this.prepend('<p id="' + id_desc + '" class="sr-only">A carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.</p>') | |
499 | + $this.prepend('<h2 id="' + id_title + '" class="sr-only">Carousel content with ' + $tabpanels.length + ' slides.</h2>') | |
500 | + } | |
501 | + | |
502 | + | |
503 | + for (i = 0; i < $tabs.length; i++) { | |
504 | + $tab = $tabs[i] | |
505 | + | |
506 | + $tab.setAttribute('role', 'tab') | |
507 | + $tab.setAttribute('id', 'tab-' + index + '-' + i) | |
508 | + $tab.setAttribute('aria-controls', 'tabpanel-' + index + '-' + i) | |
509 | + | |
510 | + var tpId = '#tabpanel-' + index + '-' + i | |
511 | + var caption = $this.find(tpId).find('h1').text() | |
512 | + | |
513 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = $this.find(tpId).text() | |
514 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = $this.find(tpId).find('h3').text() | |
515 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = $this.find(tpId).find('h4').text() | |
516 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = $this.find(tpId).find('h5').text() | |
517 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = $this.find(tpId).find('h6').text() | |
518 | + if ((typeof caption !== 'string') || (caption.length === 0)) caption = "no title"; | |
519 | + | |
520 | +// console.log("CAPTION: " + caption ) | |
521 | + | |
522 | + var tabName = document.createElement('span') | |
523 | + tabName.setAttribute('class', 'sr-only') | |
524 | + tabName.innerHTML='Slide ' + (i+1) | |
525 | + if (caption) tabName.innerHTML += ": " + caption | |
526 | + $tab.appendChild(tabName) | |
527 | + | |
528 | + } | |
529 | + | |
530 | + // create div for focus styling of tablist | |
531 | + $tablistHighlight = document.createElement('div') | |
532 | + $tablistHighlight.className = 'carousel-tablist-highlight' | |
533 | + document.body.appendChild($tablistHighlight) | |
534 | + | |
535 | + // create button for screen reader users to stop rotation of carousel | |
536 | + | |
537 | + // create button for screen reader users to pause carousel for virtual mode review | |
538 | + $complementaryLandmark = document.createElement('aside') | |
539 | + $complementaryLandmark.setAttribute('class', 'carousel-aside-pause') | |
540 | + $complementaryLandmark.setAttribute('aria-label', 'carousel pause/play control') | |
541 | + $this.prepend($complementaryLandmark) | |
542 | + | |
543 | + $pauseCarousel = document.createElement('button') | |
544 | + $pauseCarousel.className = "carousel-pause-button" | |
545 | + $pauseCarousel.innerHTML = "Pause Carousel" | |
546 | + $pauseCarousel.setAttribute('title', "Pause/Play carousel button can be used by screen reader users to stop carousel animations") | |
547 | + $($complementaryLandmark).append($pauseCarousel) | |
548 | + | |
549 | + $($pauseCarousel).click(function() { | |
550 | + if ($is_paused) { | |
551 | + $pauseCarousel.innerHTML = "Pause Carousel" | |
552 | + $this.carousel('cycle') | |
553 | + $is_paused = false | |
554 | + } | |
555 | + else { | |
556 | + $pauseCarousel.innerHTML = "Play Carousel" | |
557 | + $this.carousel('pause') | |
558 | + $is_paused = true | |
559 | + } | |
560 | + }) | |
561 | + $($pauseCarousel).focus(function() { | |
562 | + $(this).addClass('focus') | |
563 | + }) | |
564 | + | |
565 | + $($pauseCarousel).blur(function() { | |
566 | + $(this).removeClass('focus') | |
567 | + }) | |
568 | + | |
569 | + setTablistHighlightBox() | |
570 | + | |
571 | + $( window ).resize(function() { | |
572 | + setTablistHighlightBox() | |
573 | + }) | |
574 | + | |
575 | + // Add space bar behavior to prev and next buttons for SR compatibility | |
576 | + $prev.attr('aria-label', 'Previous Slide') | |
577 | + $prev.keydown(function(e) { | |
578 | + var k = e.which || e.keyCode | |
579 | + if (/(13|32)/.test(k)) { | |
580 | + e.preventDefault() | |
581 | + e.stopPropagation() | |
582 | + $prev.trigger('click'); | |
583 | + } | |
584 | + }); | |
585 | + | |
586 | + $prev.focus(function() { | |
587 | + $(this).parents('.carousel').addClass('contrast') | |
588 | + }) | |
589 | + | |
590 | + $prev.blur(function() { | |
591 | + $(this).parents('.carousel').removeClass('contrast') | |
592 | + }) | |
593 | + | |
594 | + $next.attr('aria-label', 'Next Slide') | |
595 | + $next.keydown(function(e) { | |
596 | + var k = e.which || e.keyCode | |
597 | + if (/(13|32)/.test(k)) { | |
598 | + e.preventDefault() | |
599 | + e.stopPropagation() | |
600 | + $next.trigger('click'); | |
601 | + } | |
602 | + }); | |
603 | + | |
604 | + $next.focus(function() { | |
605 | + $(this).parents('.carousel').addClass('contrast') | |
606 | + }) | |
607 | + | |
608 | + $next.blur(function() { | |
609 | + $(this).parents('.carousel').removeClass('contrast') | |
610 | + }) | |
611 | + | |
612 | + $('.carousel-inner a').focus(function() { | |
613 | + $(this).parents('.carousel').addClass('contrast') | |
614 | + }) | |
615 | + | |
616 | + $('.carousel-inner a').blur(function() { | |
617 | + $(this).parents('.carousel').removeClass('contrast') | |
618 | + }) | |
619 | + | |
620 | + $tabs.each(function () { | |
621 | + var item = $(this) | |
622 | + if(item.hasClass('active')) { | |
623 | + item.attr({ 'aria-selected': 'true', 'tabindex' : '0' }) | |
624 | + }else{ | |
625 | + item.attr({ 'aria-selected': 'false', 'tabindex' : '-1' }) | |
626 | + } | |
627 | + }) | |
628 | + }) | |
629 | + | |
630 | + var slideCarousel = $.fn.carousel.Constructor.prototype.slide | |
631 | + $.fn.carousel.Constructor.prototype.slide = function (type, next) { | |
632 | + var $element = this.$element | |
633 | + , $active = $element.find('[role=tabpanel].active') | |
634 | + , $next = next || $active[type]() | |
635 | + , $tab | |
636 | + , $tab_count = $element.find('[role=tabpanel]').size() | |
637 | + , $prev_side = $element.find('[data-slide="prev"]') | |
638 | + , $next_side = $element.find('[data-slide="next"]') | |
639 | + , $index = 0 | |
640 | + , $prev_index = $tab_count -1 | |
641 | + , $next_index = 1 | |
642 | + , $id | |
643 | + | |
644 | + if ($next && $next.attr('id')) { | |
645 | + $id = $next.attr('id') | |
646 | + $index = $id.lastIndexOf("-") | |
647 | + if ($index >= 0) $index = parseInt($id.substring($index+1), 10) | |
648 | + | |
649 | + $prev_index = $index - 1 | |
650 | + if ($prev_index < 1) $prev_index = $tab_count - 1 | |
651 | + | |
652 | + $next_index = $index + 1 | |
653 | + if ($next_index >= $tab_count) $next_index = 0 | |
654 | + } | |
655 | + | |
656 | + $prev_side.attr('aria-label', 'Show slide ' + ($prev_index+1) + ' of ' + $tab_count) | |
657 | + $next_side.attr('aria-label', 'Show slide ' + ($next_index+1) + ' of ' + $tab_count) | |
658 | + | |
659 | + | |
660 | + slideCarousel.apply(this, arguments) | |
661 | + | |
662 | + $active | |
663 | + .one('bsTransitionEnd', function () { | |
664 | + var $tab | |
665 | + | |
666 | + $tab = $element.find('li[aria-controls="' + $active.attr('id') + '"]') | |
667 | + if ($tab) $tab.attr({'aria-selected':false, 'tabIndex': '-1'}) | |
668 | + | |
669 | + $tab = $element.find('li[aria-controls="' + $next.attr('id') + '"]') | |
670 | + if ($tab) $tab.attr({'aria-selected': true, 'tabIndex': '0'}) | |
671 | + | |
672 | + }) | |
673 | + } | |
674 | + | |
675 | + var $this; | |
676 | + $.fn.carousel.Constructor.prototype.keydown = function (e) { | |
677 | + | |
678 | + $this = $this || $(this) | |
679 | + if(this instanceof Node) $this = $(this) | |
680 | + | |
681 | + function selectTab(index) { | |
682 | + if (index >= $tabs.length) return | |
683 | + if (index < 0) return | |
684 | + | |
685 | + $carousel.carousel(index) | |
686 | + setTimeout(function () { | |
687 | + $tabs[index].focus() | |
688 | + // $this.prev().focus() | |
689 | + }, 150) | |
690 | + } | |
691 | + | |
692 | + var $carousel = $(e.target).closest('.carousel') | |
693 | + , $tabs = $carousel.find('[role=tab]') | |
694 | + , k = e.which || e.keyCode | |
695 | + , index | |
696 | + | |
697 | + if (!/(37|38|39|40)/.test(k)) return | |
698 | + | |
699 | + index = $tabs.index($tabs.filter('.active')) | |
700 | + if (k == 37 || k == 38) { // Up | |
701 | + index-- | |
702 | + selectTab(index); | |
703 | + } | |
704 | + | |
705 | + if (k == 39 || k == 40) { // Down | |
706 | + index++ | |
707 | + selectTab(index); | |
708 | + } | |
709 | + | |
710 | + e.preventDefault() | |
711 | + e.stopPropagation() | |
712 | + } | |
713 | + $(document).on('keydown.carousel.data-api', 'li[role=tab]', $.fn.carousel.Constructor.prototype.keydown); | |
714 | + | |
715 | + | |
716 | + })(jQuery); | |
0 | 717 | \ No newline at end of file | ... | ... |
pacotes/bootstrap-accessibility-plugin/plugins/js/bootstrap-accessibility.min.js
0 → 100755
... | ... | @@ -0,0 +1,4 @@ |
1 | +/*! bootstrap-accessibility-plugin - v1.0.5 - 2016-07-19 | |
2 | +* https://github.com/paypal/bootstrap-accessibility-plugin | |
3 | +* Copyright (c) 2016 PayPal Accessibility Team; Licensed BSD */ | |
4 | +!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){modalhide.apply(this,arguments),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var $content=this.$element.find(".modal-content"),focEls=$content.find(":tabbable"),$lastEl=$(focEls[focEls.length-1]),$firstEl=$(focEls[0]);$lastEl.on("keydown.bs.modal",$.proxy(function(ev){9!==ev.keyCode||ev.shiftKey|ev.ctrlKey|ev.metaKey|ev.altKey||(ev.preventDefault(),$firstEl.focus())},this)),$firstEl.on("keydown.bs.modal",$.proxy(function(ev){9===ev.keyCode&&ev.shiftKey&&(ev.preventDefault(),$lastEl.focus())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.dropdown",$.proxy(function(ev){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}).on("hidden.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(e){var $this=$(this),that=this;$this.parent().hasClass("open")&&setTimeout(function(){$.contains(that,document.activeElement)||$this.parent().find("[data-toggle=dropdown]").dropdown("toggle")},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(index){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container,callback){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(index){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse");colltab.attr("id",collid),collparent&&(colltab.attr({role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.hasClass("in")?(colltab.attr({"aria-controls":collpanel.attr("id"),"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({role:"tabpanel",tabindex:"0","aria-labelledby":collid,"aria-hidden":"false"})):(colltab.attr({"aria-controls":collpanel.attr("id"),tabindex:"-1"}),collpanel.attr({role:"tabpanel",tabindex:"-1","aria-labelledby":collid,"aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent;this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.click(),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(index){function setTablistHighlightBox(){var $tab,offset,height,width,highlightBox={};highlightBox.top=0,highlightBox.left=32e3,highlightBox.height=0,highlightBox.width=0;for(var i=0;i<$tabs.length;i++){$tab=$tabs[i],offset=$($tab).offset(),height=$($tab).height(),width=$($tab).width(),highlightBox.top<offset.top&&(highlightBox.top=Math.round(offset.top)),highlightBox.height<height&&(highlightBox.height=Math.round(height)),highlightBox.left>offset.left&&(highlightBox.left=Math.round(offset.left));var w=offset.left-highlightBox.left+Math.round(width);highlightBox.width<w&&(highlightBox.width=w)}$tablistHighlight.style.top=highlightBox.top-2+"px",$tablistHighlight.style.left=highlightBox.left-2+"px",$tablistHighlight.style.height=highlightBox.height+7+"px",$tablistHighlight.style.width=highlightBox.width+8+"px"}var $tabpanel,$tablistHighlight,$pauseCarousel,$complementaryLandmark,$tab,i,$this=$(this),$prev=$this.find('[data-slide="prev"]'),$next=$this.find('[data-slide="next"]'),$tablist=$this.find(".carousel-indicators"),$tabs=$this.find(".carousel-indicators li"),$tabpanels=$this.find(".item"),$is_paused=!1,id_title="id_title",id_desc="id_desc";for($tablist.attr("role","tablist"),$tabs.focus(function(){$this.carousel("pause"),$is_paused=!0,$pauseCarousel.innerHTML="Play Carousel",$(this).parent().addClass("active"),setTablistHighlightBox(),$($tablistHighlight).addClass("focus"),$(this).parents(".carousel").addClass("contrast")}),$tabs.blur(function(event){$(this).parent().removeClass("active"),$($tablistHighlight).removeClass("focus"),$(this).parents(".carousel").removeClass("contrast")}),i=0;i<$tabpanels.length;i++)$tabpanel=$tabpanels[i],$tabpanel.setAttribute("role","tabpanel"),$tabpanel.setAttribute("id","tabpanel-"+index+"-"+i),$tabpanel.setAttribute("aria-labelledby","tab-"+index+"-"+i);for("string"!=typeof $this.attr("role")&&($this.attr("role","complementary"),$this.attr("aria-labelledby",id_title),$this.attr("aria-describedby",id_desc),$this.prepend('<p id="'+id_desc+'" class="sr-only">A carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.</p>'),$this.prepend('<h2 id="'+id_title+'" class="sr-only">Carousel content with '+$tabpanels.length+" slides.</h2>")),i=0;i<$tabs.length;i++){$tab=$tabs[i],$tab.setAttribute("role","tab"),$tab.setAttribute("id","tab-"+index+"-"+i),$tab.setAttribute("aria-controls","tabpanel-"+index+"-"+i);var tpId="#tabpanel-"+index+"-"+i,caption=$this.find(tpId).find("h1").text();("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h3").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h4").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h5").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h6").text()),("string"!=typeof caption||0===caption.length)&&(caption="no title");var tabName=document.createElement("span");tabName.setAttribute("class","sr-only"),tabName.innerHTML="Slide "+(i+1),caption&&(tabName.innerHTML+=": "+caption),$tab.appendChild(tabName)}$tablistHighlight=document.createElement("div"),$tablistHighlight.className="carousel-tablist-highlight",document.body.appendChild($tablistHighlight),$complementaryLandmark=document.createElement("aside"),$complementaryLandmark.setAttribute("class","carousel-aside-pause"),$complementaryLandmark.setAttribute("aria-label","carousel pause/play control"),$this.prepend($complementaryLandmark),$pauseCarousel=document.createElement("button"),$pauseCarousel.className="carousel-pause-button",$pauseCarousel.innerHTML="Pause Carousel",$pauseCarousel.setAttribute("title","Pause/Play carousel button can be used by screen reader users to stop carousel animations"),$($complementaryLandmark).append($pauseCarousel),$($pauseCarousel).click(function(){$is_paused?($pauseCarousel.innerHTML="Pause Carousel",$this.carousel("cycle"),$is_paused=!1):($pauseCarousel.innerHTML="Play Carousel",$this.carousel("pause"),$is_paused=!0)}),$($pauseCarousel).focus(function(){$(this).addClass("focus")}),$($pauseCarousel).blur(function(){$(this).removeClass("focus")}),setTablistHighlightBox(),$(window).resize(function(){setTablistHighlightBox()}),$prev.attr("aria-label","Previous Slide"),$prev.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$prev.trigger("click"))}),$prev.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$prev.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$next.attr("aria-label","Next Slide"),$next.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$next.trigger("click"))}),$next.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$next.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$(".carousel-inner a").focus(function(){$(this).parents(".carousel").addClass("contrast")}),$(".carousel-inner a").blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$tabs.each(function(){var item=$(this);item.hasClass("active")?item.attr({"aria-selected":"true",tabindex:"0"}):item.attr({"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $id,$element=this.$element,$active=$element.find("[role=tabpanel].active"),$next=next||$active[type](),$tab_count=$element.find("[role=tabpanel]").size(),$prev_side=$element.find('[data-slide="prev"]'),$next_side=$element.find('[data-slide="next"]'),$index=0,$prev_index=$tab_count-1,$next_index=1;$next&&$next.attr("id")&&($id=$next.attr("id"),$index=$id.lastIndexOf("-"),$index>=0&&($index=parseInt($id.substring($index+1),10)),$prev_index=$index-1,1>$prev_index&&($prev_index=$tab_count-1),$next_index=$index+1,$next_index>=$tab_count&&($next_index=0)),$prev_side.attr("aria-label","Show slide "+($prev_index+1)+" of "+$tab_count),$next_side.attr("aria-label","Show slide "+($next_index+1)+" of "+$tab_count),slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){var $tab;$tab=$element.find('li[aria-controls="'+$active.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!1,tabIndex:"-1"}),$tab=$element.find('li[aria-controls="'+$next.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){function selectTab(index){index>=$tabs.length||0>index||($carousel.carousel(index),setTimeout(function(){$tabs[index].focus()},150))}$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$carousel=$(e.target).closest(".carousel"),$tabs=$carousel.find("[role=tab]"),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$tabs.index($tabs.filter(".active")),(37==k||38==k)&&(index--,selectTab(index)),(39==k||40==k)&&(index++,selectTab(index)),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","li[role=tab]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery); | |
0 | 5 | \ No newline at end of file | ... | ... |