Skip to content

Commit

Permalink
Add generate SLD option (available on CLASS page) - only if Mapscript…
Browse files Browse the repository at this point in the history
… is enabled
  • Loading branch information
jbelien committed Sep 11, 2015
1 parent 71c12db commit 6ec120b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 5 additions & 2 deletions layer-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@
</tbody>
<tfoot>
<tr>
<td colspan="9" class="text-right"><a href="#modal-class" data-toggle="modal" style="text-decoration:none;"><i class="fa fa-plus-square"></i> Add new class</a></td>
<td colspan="9" class="text-right">
<?= ($mapscript ? '<a href="sld.php?layer='.intval($_GET['layer']).'" target="_blank" style="text-decoration:none;"><i class="fa fa-cog"></i> Generate SLD</a>' : '') ?>
<a href="#modal-class" data-toggle="modal" style="text-decoration:none;"><i class="fa fa-plus-square"></i> Add new class</a>
</td>
</tr>
</tfoot>
</table>
Expand All @@ -266,7 +269,7 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"></h4>
</div>
<form action="layer-class.php?layer=<?= $_GET['layer'] ?>" method="post" class="form-horizontal" autocomplete="off">
<form action="layer-class.php?layer=<?= intval($_GET['layer']) ?>" method="post" class="form-horizontal" autocomplete="off">
<input type="hidden" name="class">
<div class="modal-body">
<div class="form-group">
Expand Down
17 changes: 17 additions & 0 deletions sld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
session_start();

$mapscript = extension_loaded('mapscript');

if ($mapscript && isset($_SESSION['mapfile-generator']['mapfile'], $_GET['layer'])) {
$_map = new mapObj($_SESSION['mapfile-generator']['mapfile']);

header('Content-Type: text/xml');

$l = $_map->getLayer(intval($_GET['layer']));
$l->set('status', MS_ON);

echo $_map->generateSLD();
}

exit();

0 comments on commit 6ec120b

Please sign in to comment.