editortexto.php
6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
//XODO incluir combo para escolher o estilo
//XODO incluir ajuda de comandos de teclado
//XODO relace de sintaxe para mapfile
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Editor texto</title>
<script src="../../pacotes/codemirror/lib/codemirror.js"></script>
<script src=../../pacotes/codemirror/mode/htmlmixed/htmlmixed.js></script>
<link rel=stylesheet href="../../pacotes/codemirror/doc/docs.css">
<link rel="stylesheet" href="../../pacotes/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="../../pacotes/codemirror/theme/ambiance.css">
<link rel="stylesheet" href="../../pacotes/codemirror/theme/cobalt.css">
<link rel="stylesheet" href="../../pacotes/codemirror/theme/night.css">
<link rel="stylesheet" href="../../pacotes/codemirror/theme/neo.css">
<link rel="stylesheet" href="../../pacotes/codemirror/theme/elegant.css">
<link rel="stylesheet" type="text/css" href="../html/admin.css">
<style type="text/css">
body {
margin: 20;
padding: 20;
font-size: 14px;
}
.CodeMirror {
height:500px;
float: left;
width: 500px;
</style>
</head>
<body class=" yui-skin-sam ">
<div class="" id="divGeral" style="width: 100%;">
<h1>Editor de mapfiles</h1>
Mais detalhes sobre a edição de mapfiles: <a href="http://mapserver.org/mapfile/index.html#mapfile" target="_new">Documentação do Mapserver</a>
<br><br>
<input type=button value="<--- Voltar" onclick="window.history.back()" />
<br> <br> Mapfile em edição:
<div id="comboMapfiles" style="width: 100%; max-width: 450px">Aguarde...</div>
<br><br>
<form style="width: 98%;" onsubmit="atualizaTextArea()" action="editortexto.php?mapfile=<?php echo $_GET["mapfile"];?>" method=post>
<input type=submit value="Salvar (também atualiza o mapa)" />
<input type=button value="Testar" onclick="testar()" />
<input type=button value="Testar no i3Geo" onclick="abrirI3geo()" />
(Salve antes de testar)<br> <br>
<?php
//evita erros removendo caracteres PHP
if(isset($_POST["texto"])){
$gravarTexto = $_POST["texto"];
$_POST["texto"] = "";
}
include_once(dirname(__FILE__)."/login.php");
if(verificaOperacaoSessao("admin/php/editortexto") == false){
echo "Vc nao pode realizar essa operacao.";exit;
}
error_reporting(0);
$mapfile = $locaplic."/temas/".$_GET["mapfile"].".map";
if(!file_exists($mapfile))
{
echo "Arquivo $mapfile não existe.";exit;
}
//remove o cache OGC
$agora = intval(time() / 1000);
$nomeMapfileTmp = $dir_tmp."/ogc_".md5($mapfile)."_".$agora.".map";
$nomeMapfileTmp = str_replace(",","",$nomeMapfileTmp);
$nomeMapfileTmp = str_replace(" ","",$nomeMapfileTmp);
chmod($nomeMapfileTmp,0777);
unlink($nomeMapfileTmp);
//
if($_POST["tipo"] == "gravar"){
$fp = fopen($mapfile,"w");
if($fp == false){
echo "<span style=color:red <b>Não foi possível salvar o arquivo. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>";
}
else{
fwrite($fp,$gravarTexto);
}
fclose($fp);
}
echo 'Ajudante de cores RGB: <input type=text value="clique" size=10 id="corrgb" onclick="i3GEO.util.abreCor(\'\',\'corrgb\',\'rgbSep\')" />';
?>
Estilo: <select onchange="mudaEstilo(this.value)">
<option value=elegant >Elegant</option>
<option value=ambiance >Ambiance</option>
<option value=cobalt >Cobalt</option>
<option value=night >Night</option>
<option value=neo >Neo</option>
</select>
<?php
echo "<div style='width:2000px;' ><TEXTAREA id=editor name=texto cols=100 rows=20 style='width:500px;float:left;height:500px'>";
echo file_get_contents($mapfile);
echo "</TEXTAREA>";
$mapfile = str_replace("\\","/",$mapfile);
echo "<iframe id='mapaPreview' src='../../mashups/openlayers.php?nocache=sim&DESLIGACACHE=sim&controles=navigation,panzoombar,scaleline,mouseposition&botoes=identifica&largura=480&fundo=".$mapfile."&temas=".$mapfile."' cols=100 rows=20 style='left:10px;position:relative;top:2px;overflow:hidden;width:500px;height:500px;border:1px solid gray;'>";
echo "</iframe></div>";
echo "<input type=hidden name=tipo value=gravar />";
if(!@ms_newMapObj($mapfile)){
echo "<span style=color:red <b>Não foi possível criar o mapa. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>";
}
else{
$mapa = ms_newMapObj($mapfile);
$n = $mapa->numlayers;
echo "<br><br>Colunas dos layers:<br><br>";
for($i=0;$i<$n;$i++){
if(@$mapa->getlayer($i)){
$l = $mapa->getlayer($i);
echo $l->name.": ".(implode(",",pegaItens($l)))."<br><br>";
}
else{
echo "<span style=color:red <b>Não foi possível criar o LAYER {$l->name}. Verifique as permissões ou se há algum erro no mapfile</b></span><br><br>";
}
}
}
?>
</form>
</div>
<script type="text/javascript" src="../js/core.js"></script>
<script src="../../classesjs/classe_util.js" type="text/javascript"></script>
<script>
i3GEO.configura = {locaplic: "../../"};
/*
ins = "<p><div id=filtroDeLetras ></div><br>";
document.getElementById("letras").innerHTML = ins;
core_listaDeLetras("filtroDeLetras","filtraLetra");
if(i3GEO.util.pegaCookie("I3GEOletraAdmin")) {
letraAtual = i3GEO.util.pegaCookie("I3GEOletraAdmin");
}
else{
letraAtual = "";
}
*/
var editorCM = CodeMirror.fromTextArea(document.getElementById("editor"), {
mode: 'text',
tabMode: 'indent',
lineNumbers: true,
theme: "elegant"
});
function mudaEstilo(novo){
editorCM.setOption('theme',novo)
}
function atualizaTextArea(){
document.getElementById("editor").value = editorCM.getValue();
}
function filtraLetra(letra) {
letraAtual = letra;
if (letra == "Todos") {
letra = "";
}
i3GEO.util.insereCookie("I3GEOletraAdmin", letra);
core_pegaMapfiles("comboMapfiles()", letra);
}
function comboMapfiles(){
var n = $mapfiles.length,
i,ins;
ins = "<select id='selectComboMapfile' onchange='mudaMapfile(this)'><option value=''>Edite outro mapfile</option>";
for(i=0;i<n;i++){
if($mapfiles[i].extensao === "map"){
ins += "<option value='"+$mapfiles[i].codigo+"'>"+$mapfiles[i].codigo+" - "+$mapfiles[i].nome+"</optiona>";
}
}
ins += "</select>";
$i("comboMapfiles").innerHTML = ins;
$i("selectComboMapfile").value = "<?php echo $_GET["mapfile"];?>";
};
core_pegaMapfiles("comboMapfiles()","","");
function mudaMapfile(obj){
if(obj.value != ""){
window.location.href = "editortexto.php?mapfile="+obj.value;
}
}
function testar(){
window.open("../../testamapfile.php?map=<?php echo $_GET["mapfile"]; ?>");
}
function abrirI3geo(){
window.open("../../ms_criamapa.php?layers=<?php echo $_GET["mapfile"]; ?>");
}
</script>