Skip to content

Commit

Permalink
UPDATE: Apply PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
neo-garaix committed Jan 27, 2025
1 parent fe2a33a commit 9778c82
Show file tree
Hide file tree
Showing 20 changed files with 621 additions and 590 deletions.
72 changes: 35 additions & 37 deletions mapBuilder/classes/listBaseLayer.class.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
<?php

<?php

class listBaseLayer implements jIFormsDatasource
{
protected $formId = 0;

protected $data = array();

function __construct($id)
{
$this->formId = $id;

$this->data = array(
'osmMapnik' => 'OSM Mapnik',
'osmStadiaMapsToner' => 'OSM StadiaMaps Toner',
'bingStreets' => 'Bing Streets',
'bingSatellite' => 'Bing Satellite',
'bingHybrid' => 'Bing Hybrid',
'ignStreets' => 'IGN Streets',
'ignSatellite' => 'IGN Satellite',
'ignCadastral' => 'IGN Cadastral',
'emptyBaselayer' => jLocale::get('view~dictionnary.baselayer.empty.title')
);
}

public function getData($form)
{
return ($this->data);
}

public function getLabel($key)
{
if(isset($this->data[$key]))
return $this->data[$key];
else
return null;
}

protected $formId = 0;

protected $data = [];

public function __construct($id)
{
$this->formId = $id;

$this->data = [
'osmMapnik' => 'OSM Mapnik',
'osmStadiaMapsToner' => 'OSM StadiaMaps Toner',
'bingStreets' => 'Bing Streets',
'bingSatellite' => 'Bing Satellite',
'bingHybrid' => 'Bing Hybrid',
'ignStreets' => 'IGN Streets',
'ignSatellite' => 'IGN Satellite',
'ignCadastral' => 'IGN Cadastral',
'emptyBaselayer' => jLocale::get('view~dictionnary.baselayer.empty.title'),
];
}

public function getData($form)
{
return $this->data;
}

public function getLabel($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
}

return null;
}
}
?>
52 changes: 25 additions & 27 deletions mapBuilder/classes/listRepositories.class.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
<?php

<?php

class listRepositories implements jIFormsDatasource
{
protected $formId = 0;
protected $formId = 0;

protected $data = array();
protected $data = [];

function __construct($id)
{
$this->formId = $id;
public function __construct($id)
{
$this->formId = $id;

$repositories = array();
$repositories = [];

foreach (lizmap::getRepositoryList() as $repositoryName) {
$repository = lizmap::getRepository($repositoryName);
if( jAcl2::check('lizmap.repositories.view', $repository->getKey() )){
$repositories[$repository->getKey()] = $repository->getData('label');
foreach (lizmap::getRepositoryList() as $repositoryName) {
$repository = lizmap::getRepository($repositoryName);
if (jAcl2::check('lizmap.repositories.view', $repository->getKey())) {
$repositories[$repository->getKey()] = $repository->getData('label');
}
}
}

$this->data = $repositories;
}
$this->data = $repositories;
}

public function getData($form)
{
return ($this->data);
}
public function getData($form)
{
return $this->data;
}

public function getLabel($key)
{
if(isset($this->data[$key]))
return $this->data[$key];
else
return null;
}
public function getLabel($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
}

return null;
}
}
?>
63 changes: 34 additions & 29 deletions mapBuilder/classes/mapBuilderView.listener.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php
class mapBuilderViewListener extends jEventListener{

function onmainviewGetMaps ($event) {
use proj4php\Point;
use proj4php\Proj;

class mapBuilderViewListener extends jEventListener
{
public function onmainviewGetMaps($event)
{
// Access control
if( jAcl2::check("mapBuilder.access") ){
if (jAcl2::check('mapBuilder.access')) {
$name = jLocale::get('mapBuilder~default.app.name');
$access = jLocale::get('mapBuilder~default.app.access');
$description = jLocale::get('mapBuilder~default.app.description');
Expand All @@ -15,54 +19,55 @@ function onmainviewGetMaps ($event) {
$configFile = jApp::varconfigPath('mapBuilder.ini.php');
if (!file_exists($configFile)) {
jLog::log('Configuration file mapBuilder.ini.php is missing', 'error');

return;
}
$readConfigPath = parse_ini_file($configFile, True);
$readConfigPath = parse_ini_file($configFile, true);
// Get original extent from ini file if set
if(array_key_exists('extent', $readConfigPath)){
if (array_key_exists('extent', $readConfigPath)) {
// Reproject extent in ini file from EPSG:4326 to EPSG:3857.
if (class_exists('Proj4php') ) { // lizmap 3.6
$proj4 = new \Proj4php();
$sourceProj = new \Proj4phpProj('EPSG:4326', $proj4);
$destProj = new \Proj4phpProj('EPSG:3857', $proj4);
if (class_exists('Proj4php')) { // lizmap 3.6
$proj4 = new Proj4php();
$sourceProj = new Proj4phpProj('EPSG:4326', $proj4);
$destProj = new Proj4phpProj('EPSG:3857', $proj4);
} else {
// proj4php > 2.0, lizmap 3.7+
$proj4 = new \proj4php\Proj4php();
$sourceProj = new \proj4php\Proj('EPSG:4326', $proj4);
$destProj = new \proj4php\Proj('EPSG:3857', $proj4);
$proj4 = new proj4php\Proj4php();
$sourceProj = new Proj('EPSG:4326', $proj4);
$destProj = new Proj('EPSG:3857', $proj4);
}
$extentArraySource = explode(",", $readConfigPath['extent']);
$extentArraySource = explode(',', $readConfigPath['extent']);

// Is extent valid ?
if(count($extentArraySource) == 4 && $extentArraySource === array_filter($extentArraySource, 'is_numeric')){
if (4 == count($extentArraySource) && $extentArraySource === array_filter($extentArraySource, 'is_numeric')) {
// Cast as float
$extentArraySource = array_map('floatval', $extentArraySource);

// Handle WGS84 bounds
if (class_exists('proj4phpPoint') ) { // lizmap 3.6
$sourceMinPt = new \proj4phpPoint(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06));
$sourceMaxPt = new \proj4phpPoint(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06));
if (class_exists('proj4phpPoint')) { // lizmap 3.6
$sourceMinPt = new proj4phpPoint(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06));
$sourceMaxPt = new proj4phpPoint(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06));
} else {
// proj4php >2.0, lizmap 3.7+
$sourceMinPt = new \proj4php\Point(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06));
$sourceMaxPt = new \proj4php\Point(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06));
$sourceMinPt = new Point(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06));
$sourceMaxPt = new Point(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06));
}
try {
$destMinPt = $proj4->transform($sourceProj,$destProj,$sourceMinPt);
$destMaxPt = $proj4->transform($sourceProj,$destProj,$sourceMaxPt);

$extent = implode(", ", array( $destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y ));
try {
$destMinPt = $proj4->transform($sourceProj, $destProj, $sourceMinPt);
$destMaxPt = $proj4->transform($sourceProj, $destProj, $sourceMaxPt);

$extent = implode(', ', [$destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y]);
} catch (Exception $e) {
// Max extent in EPSG:3857
$extent = "-20026376.39,-20048966.10,20026376.39,20048966.10";
$extent = '-20026376.39,-20048966.10,20026376.39,20048966.10';
}
}else{
jMessage::add(jLocale::get("mapBuilder~default.extent.value.error"), 'error');
$extent = jLocale::get("mapBuilder~default.extent.value.error");
} else {
jMessage::add(jLocale::get('mapBuilder~default.extent.value.error'), 'error');
$extent = jLocale::get('mapBuilder~default.extent.value.error');
}
}

$illustration = jApp::urlBasePath().'themes/'.jApp::config()->theme.'/css/img/250x250_mappemonde.jpg';

jClasses::inc('lizmapMainViewItem');
Expand All @@ -80,7 +85,7 @@ function onmainviewGetMaps ($event) {
'_map_builder_rep',
'map'
);
$event->add( $mrep );
$event->add($mrep);
}
}
}
Loading

0 comments on commit 9778c82

Please sign in to comment.