diff --git a/lizmap/modules/lizmap/lib/App/AppContextInterface.php b/lizmap/modules/lizmap/lib/App/AppContextInterface.php
index 4a3fd57802..e16a003c5e 100644
--- a/lizmap/modules/lizmap/lib/App/AppContextInterface.php
+++ b/lizmap/modules/lizmap/lib/App/AppContextInterface.php
@@ -269,8 +269,9 @@ public function createJelixForm($formSel, $formId = null);
* Returns the URL corresponding to the Jelix Selector.
*
* @param string $selector The Jelix selector
+ * @param mixed $params action params
*/
- public function getUrl($selector);
+ public function getUrl($selector, $params = array());
/**
* Returns the absolute Url.
diff --git a/lizmap/modules/lizmap/lib/App/JelixContext.php b/lizmap/modules/lizmap/lib/App/JelixContext.php
index 195cff1749..386946795c 100644
--- a/lizmap/modules/lizmap/lib/App/JelixContext.php
+++ b/lizmap/modules/lizmap/lib/App/JelixContext.php
@@ -329,9 +329,9 @@ public function createJelixForm($formSel, $formId = null)
return \jForms::create($formSel, $formId);
}
- public function getUrl($selector)
+ public function getUrl($selector, $params = array())
{
- return \jUrl::get($selector);
+ return \jUrl::get($selector, $params);
}
public function getFullUrl($selector, $params = array())
diff --git a/lizmap/modules/lizmap/lib/Project/ProjectFilesFinder.php b/lizmap/modules/lizmap/lib/Project/ProjectFilesFinder.php
new file mode 100644
index 0000000000..4bac82c755
--- /dev/null
+++ b/lizmap/modules/lizmap/lib/Project/ProjectFilesFinder.php
@@ -0,0 +1,71 @@
+getRepository()->allowUserDefinedThemes()) {
+ $appContext = $project->getAppContext();
+ $jsDirArray = array('default', $project->getKey());
+ $repositoryPath = $project->getRepository()->getPath();
+ foreach ($jsDirArray as $dir) {
+ $items = array(
+ // current repository
+ 'media/js/',
+ // or root (js shared over repositories)
+ '../media/js/',
+ );
+ foreach ($items as $item) {
+ $jsPathRoot = realpath($repositoryPath.$item.$dir);
+ if (!is_dir($jsPathRoot)) {
+ continue;
+ }
+ foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($jsPathRoot)) as $filename) {
+ $fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
+ if ($fileExtension == 'js' || $fileExtension == 'mjs' || $fileExtension == 'css') {
+ $jsPath = realpath($filename);
+ $jsRelPath = $item.$dir.str_replace($jsPathRoot, '', $jsPath);
+ $url = 'view~media:getMedia';
+ if ($fileExtension == 'css') {
+ $url = 'view~media:getCssFile';
+ }
+
+ $fileUrl = $appContext->getUrl(
+ $url,
+ array(
+ 'repository' => $project->getRepositoryKey(),
+ 'project' => $project->getKey(),
+ 'mtime' => filemtime($filename),
+ 'path' => $jsRelPath,
+ )
+ );
+ if ($fileExtension == 'js') {
+ $jsUrls[] = $fileUrl;
+ } elseif ($fileExtension == 'mjs') {
+ $mjsUrls[] = $fileUrl;
+ } else {
+ $cssUrls[] = $fileUrl;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return array('css' => $cssUrls, 'js' => $jsUrls, 'mjs' => $mjsUrls);
+ }
+}
diff --git a/lizmap/modules/view/controllers/lizMap.classic.php b/lizmap/modules/view/controllers/lizMap.classic.php
index 9488dacd07..c3a40fa37f 100644
--- a/lizmap/modules/view/controllers/lizMap.classic.php
+++ b/lizmap/modules/view/controllers/lizMap.classic.php
@@ -1,5 +1,6 @@
$lrep->getKey(),
- 'project' => $project,
- 'mtime' => filemtime($filename),
- 'path' => $jsRelPath,
- )
- );
- if ($fileExtension == 'js') {
- $jsUrls[] = $jsUrl;
- ++$countUserJs;
- } elseif ($fileExtension == 'mjs') {
- $mjsUrls[] = $jsUrl;
- ++$countUserJs;
- } else {
- $cssUrls[] = $jsUrl;
- }
- }
- }
- }
- }
-
- // Add CSS, MJS and JS files ordered by name
- sort($cssUrls);
- foreach ($cssUrls as $cssUrl) {
- $rep->addCSSLink($cssUrl);
- }
- sort($jsUrls);
- foreach ($jsUrls as $jsUrl) {
- // Use addHeadContent and not addJSLink to be sure it will be loaded after minified code
- $rep->addContent('');
- }
- sort($mjsUrls);
- foreach ($mjsUrls as $mjsUrl) {
- // Use addHeadContent and not addJSLink to be sure it will be loaded after minified code
- $rep->addContent('');
- }
+ $fileFinder = new ProjectFilesFinder();
+ $allURLS = $fileFinder->listFileURLS($lproj);
+
+ $cssUrls = $allURLS['css'];
+ $jsUrls = $allURLS['js'];
+ $mjsUrls = $allURLS['mjs'];
+ $countUserJs = count($jsUrls) + count($mjsUrls);
+ // Add CSS, MJS and JS files ordered by name
+ sort($cssUrls);
+ foreach ($cssUrls as $cssUrl) {
+ $rep->addCSSLink($cssUrl);
+ }
+ sort($jsUrls);
+ foreach ($jsUrls as $jsUrl) {
+ // Use addHeadContent and not addJSLink to be sure it will be loaded after minified code
+ $rep->addContent('');
+ }
+ sort($mjsUrls);
+ foreach ($mjsUrls as $mjsUrl) {
+ // Use addHeadContent and not addJSLink to be sure it will be loaded after minified code
+ $rep->addContent('');
}
}
$rep->setBodyAttributes(array('data-lizmap-user-defined-js-count' => $countUserJs));
diff --git a/tests/units/classes/Project/ProjectTest.php b/tests/units/classes/Project/ProjectTest.php
index 3e1fb5511e..414f419bce 100644
--- a/tests/units/classes/Project/ProjectTest.php
+++ b/tests/units/classes/Project/ProjectTest.php
@@ -1,6 +1,7 @@
setCfg($config);
$this->assertEquals($expectedRet, $proj->checkAcl());
}
+
+ public static function userFiles4Projets() {
+ $eventsBaseURL = 'view~media:getMedia?repository=repo1&project=events&';
+ return array(
+ array(
+ 'montpellier',
+ 'montpellier',
+ array('path' => __DIR__.'/../../../qgis-projects/demoqgis'),
+ array(
+ 'css'=> array(),
+ 'mjs' => array(),
+ 'js' => array()
+ ),
+ ),
+ array(
+ 'events',
+ 'repo1',
+ array('path' => __DIR__.'/Ressources/root4Repository/repo1'),
+ array('css'=> array(
+ 'view~media:getCssFile?repository=repo1&project=events&path=media/js/events/style1.css'
+ ),
+ 'mjs' => array(
+ 'view~media:getMedia?repository=repo1&project=events&path=media/js/events/mjs.mjs'
+ ),
+ 'js' => array(
+ $eventsBaseURL.'path=media/js/default/jsdefaultinrepo.js',
+ $eventsBaseURL.'path=../media/js/default/jsdefaultinroot.js',
+ $eventsBaseURL.'path=media/js/events/subfolder/jsinsubfolder.js',
+ $eventsBaseURL.'path=media/js/events/jsprojetinrepo.js',
+ $eventsBaseURL.'path=../media/js/events/jsprojetinroot.js',
+ )
+ )
+ )
+ ,
+ );
+ }
+
+ /**
+ * @dataProvider userFiles4Projets
+ */
+ public function testFinder(string $projectName, $repoName, array $projectData, array $expectedFiles) {
+ $repo = new Project\Repository($repoName, $projectData
+ , null, null, null
+ );
+
+ $project = new ProjectForTests();
+ $project->setRepo($repo);
+ $project->setKey($projectName);
+ $finder = new ProjectFilesFinder();
+ $listFiles = $finder->listFileURLS($project, true);
+ foreach($listFiles as $fileExt => $list) {
+ // remove mtime=XXX From URLs
+ $urlsWithoutMtime = array_map( function ($url) {
+ $urlok = preg_replace('/&mtime=[0-9]*/', '', $url);
+ return $urlok;
+ }, $list);
+ // sorting to ensure list are in same order
+ sort($urlsWithoutMtime);
+ sort($expectedFiles[$fileExt]);
+ $this->assertEquals($urlsWithoutMtime, $expectedFiles[$fileExt]);
+ }
+ }
}
diff --git a/tests/units/classes/Project/Ressources/root4Repository/media/js/default/jsdefaultinroot.js b/tests/units/classes/Project/Ressources/root4Repository/media/js/default/jsdefaultinroot.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/media/js/events/jsprojetinroot.js b/tests/units/classes/Project/Ressources/root4Repository/media/js/events/jsprojetinroot.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/media/js/invalid_project/unfoundable.js b/tests/units/classes/Project/Ressources/root4Repository/media/js/invalid_project/unfoundable.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs b/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs
new file mode 100644
index 0000000000..dd66cab5bd
--- /dev/null
+++ b/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs
@@ -0,0 +1,957 @@
+
+
+
+
+
+
+
+
+
+ +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs
+ 3857
+ 3857
+ EPSG:3857
+ WGS 84 / Pseudo-Mercator
+ merc
+ WGS84
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - osm_mapnik20190220152650417
+ - osm_stamen_toner20190220152651073
+ - events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101
+
+
+
+
+
+
+
+
+
+ meters
+
+ 417828.47766224615043029
+ 5393709.71128619741648436
+ 441352.08966992393834516
+ 5412981.91368997748941183
+
+ 0
+
+
+ +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs
+ 3857
+ 3857
+ EPSG:3857
+ WGS 84 / Pseudo-Mercator
+ merc
+ WGS84
+ false
+
+
+ 0
+
+
+
+
+
+
+ degrees
+
+ 0
+ 0
+ 0
+ 0
+
+ 0
+
+
+ +proj=longlat +datum=WGS84 +no_defs
+ 3452
+ 4326
+ EPSG:4326
+ WGS 84
+ longlat
+ WGS84
+ true
+
+
+ 0
+
+
+ degrees
+
+ 0
+ 0
+ 0
+ 0
+
+ 0
+
+
+ +proj=longlat +datum=WGS84 +no_defs
+ 3452
+ 4326
+ EPSG:4326
+ WGS 84
+ longlat
+ WGS84
+ true
+
+
+ 0
+
+
+ degrees
+
+ 0
+ 0
+ 0
+ 0
+
+ 0
+
+
+ +proj=longlat +datum=WGS84 +no_defs
+ 3452
+ 4326
+ EPSG:4326
+ WGS 84
+ longlat
+ WGS84
+ true
+
+
+ 0
+
+
+
+
+ 3.70694994926452637
+ 43.51250076293945313
+ 4.07507991790771396
+ 43.75249862670898438
+
+ events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101
+ ./edition/events.gpkg|layername=events
+ Touristic events
+
+
+
+ montpellier_events
+
+
+ +proj=longlat +datum=WGS84 +no_defs
+ 3452
+ 4326
+ EPSG:4326
+ WGS 84
+ longlat
+ WGS84
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ ogr
+
+
+
+
+
+
+
+
+
+
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ COALESCE( "description", '<NULL>' )
+ COALESCE( "description", '<NULL>' )
+
+
+
+
+
+ 0
+ 0
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /home/mdouchin/Documents/3liz/Infra/lizmap-demo/demo
+
+ 0
+ /home/mdouchin/Documents/3liz/Infra/lizmap-demo/demo
+
+ 0
+ generatedlayout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ COALESCE( "description", '<NULL>' )
+ <div style="padding:10px;">
+<p style="font-weight:bold;font-size:1.2em;">[% "titre" %]</p>
+
+<p> <i>[% "field_thematique" %]</i></p>
+
+<p>
+[%'<i class="icon-time"></i> ' || format_date(
+ "field_date",
+ 'd MMMM yyyy - HH:mm'
+)%]
+<br/>
+[%'<i class="icon-map-marker"></i> ' || "field_lieu"%]
+</p>
+
+<img style="width: 100%;" src="[% "vignette_src" %]" alt="[% "vignette_alt" %]" title="[% "vignette_alt" %]"/>
+
+<p style="padding: 10px 0px; font-size:0.8em;">[% "description" %]</p>
+<p style="font-size:0.8em;"><a href="[% "url" %]" target="_blank">Voir le site</a></p>
+
+</div>
+
+
+
+ -20037508.34278924390673637
+ -20037508.34278925508260727
+ 20037508.34278924390673637
+ 20037508.34278924390673637
+
+ osm_mapnik20190220152650417
+ crs=EPSG:3857&format=&type=xyz&url=http://tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png
+
+
+
+ osm-mapnik
+
+
+ +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs
+ 3857
+ 3857
+ EPSG:3857
+ WGS 84 / Pseudo-Mercator
+ merc
+ WGS84
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ false
+
+
+
+
+ wms
+
+
+
+
+
+
+
+ 1
+ 1
+ 0
+
+
+
+
+
+
+
+
+ None
+ WholeRaster
+ Estimated
+ 0.02
+ 0.98
+ 2
+
+
+
+
+
+
+ 0
+
+
+
+ -20037508.34278924390673637
+ -20037508.34278925508260727
+ 20037508.34278924390673637
+ 20037508.34278924390673637
+
+ osm_stamen_toner20190220152651073
+ crs=EPSG:3857&format=&type=xyz&url=http://tile.stamen.com/toner-lite/%7Bz%7D/%7Bx%7D/%7By%7D.png
+
+
+
+ osm-stamen-toner
+
+
+ +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs
+ 3857
+ 3857
+ EPSG:3857
+ WGS 84 / Pseudo-Mercator
+ merc
+ WGS84
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ false
+
+
+
+
+ wms
+
+
+
+
+
+
+
+ 1
+ 1
+ 0
+
+
+
+
+
+
+
+
+ None
+ WholeRaster
+ Estimated
+ 0.02
+ 0.98
+ 2
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ EPSG:3857
+ 3857
+ +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs
+
+
+ conditions unknown
+ true
+
+ 16
+ 30
+ false
+ 0
+ false
+ 50
+ true
+ false
+ 0
+
+
+ edition_polygon_34db893a_6765_42e5_aa9a_712b69e30dc2
+ events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101
+ tramstop_4cdf2dad_6f48_4491_b318_693cc9184208
+
+
+ false
+
+
+
+ 390483.99668047408340499
+ 5375009.91444000415503979
+ 477899.4732063576229848
+ 5436768.56305211596190929
+
+ None
+ 8
+ 90
+
+
+
+
+
+ 1
+
+
+ 255
+
+ true
+
+
+
+ MU
+ 2
+ true
+
+
+ current_layer
+ to vertex and segment
+ 10
+ 1
+
+ false
+
+ 150
+ 255
+ 255
+ 0
+ 255
+ 255
+ 255
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+ WGS84
+
+
+
+ m2
+ meters
+
+
+ true
+
+ EPSG:4326
+ EPSG:3857
+
+
+
+
+ false
+
+
+
+
+
+
+ 5000
+
+
+
+ 8
+ 8
+ 8
+ 8
+
+ Touristic events around Montpellier, France
+
+
+ false
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2000-01-01T00:00:00
+
+
+
+
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs.cfg b/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs.cfg
new file mode 100644
index 0000000000..c1d7bef5d6
--- /dev/null
+++ b/tests/units/classes/Project/Ressources/root4Repository/repo1/events.qgs.cfg
@@ -0,0 +1,247 @@
+{
+ "options": {
+ "projection": {
+ "proj4": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs",
+ "ref": "EPSG:4242"
+ },
+ "bbox": [
+ 390483.9966804741,
+ 5375009.914440004,
+ 477899.4732063576,
+ 5436768.563052116
+ ],
+ "mapScales": [
+ 10000,
+ 25000,
+ 50000,
+ 100000,
+ 250000,
+ 500000
+ ],
+ "minScale": 10000,
+ "maxScale": 500000,
+ "initialExtent": [
+ 390483.9966804741,
+ 5375009.914440004,
+ 477899.4732063576,
+ 5436768.563052116
+ ],
+ "osmMapnik": "True",
+ "osmStamenToner": "True",
+ "popupLocation": "right-dock",
+ "pointTolerance": 25,
+ "lineTolerance": 10,
+ "polygonTolerance": 5,
+ "tmTimeFrameSize": 10,
+ "tmTimeFrameType": "seconds",
+ "tmAnimationFrameLength": 1000,
+ "startupBaselayer": "osm-stamen-toner",
+ "datavizLocation": "dock",
+ "atlasLayer": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "atlasDisplayLayerDescription": "True",
+ "atlasHighlightGeometry": "True",
+ "atlasZoom": "zoom",
+ "atlasDisplayPopup": "True",
+ "atlasMaxWidth": 25,
+ "atlasDuration": 5
+ },
+ "layers": {
+ "montpellier_events": {
+ "id": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "name": "montpellier_events",
+ "type": "layer",
+ "geometryType": "point",
+ "extent": [
+ 3.7069499492645264,
+ 43.51250076293945,
+ 4.075079917907714,
+ 43.752498626708984
+ ],
+ "crs": "EPSG:4326",
+ "title": "Touristic events",
+ "abstract": "test pour voir",
+ "link": "",
+ "minScale": 1,
+ "maxScale": 1000000000000,
+ "toggled": "True",
+ "popup": "True",
+ "popupSource": "qgis",
+ "popupTemplate": "",
+ "popupMaxFeatures": 10,
+ "popupDisplayChildren": "False",
+ "noLegendImage": "False",
+ "groupAsLayer": "False",
+ "baseLayer": "False",
+ "displayInLegend": "True",
+ "singleTile": "True",
+ "imageFormat": "image/png",
+ "cached": "False",
+ "clientCacheExpiration": 300
+ },
+ "Hidden": {
+ "id": "Hidden",
+ "name": "Hidden",
+ "shortname": "test_shortname",
+ "type": "group",
+ "title": "Hidden",
+ "abstract": "",
+ "link": "",
+ "minScale": 1,
+ "maxScale": 1000000000000,
+ "toggled": "True",
+ "popup": "False",
+ "popupSource": "auto",
+ "popupTemplate": "",
+ "popupMaxFeatures": 10,
+ "popupDisplayChildren": "False",
+ "noLegendImage": "False",
+ "groupAsLayer": "False",
+ "baseLayer": "False",
+ "displayInLegend": "True",
+ "singleTile": "True",
+ "imageFormat": "image/png",
+ "cached": "False",
+ "clientCacheExpiration": 300
+ },
+ "osm-stamen-toner": {
+ "id": "osm_stamen_toner20190220152651073",
+ "name": "osm-stamen-toner",
+ "type": "layer",
+ "extent": [
+ -20037508.342789244,
+ -20037508.342789255,
+ 20037508.342789244,
+ 20037508.342789244
+ ],
+ "crs": "EPSG:3857",
+ "title": "osm-test",
+ "abstract": "",
+ "link": "",
+ "minScale": 1,
+ "maxScale": 1000000000000,
+ "toggled": "False",
+ "popup": "False",
+ "popupSource": "auto",
+ "popupTemplate": "",
+ "popupMaxFeatures": 10,
+ "popupDisplayChildren": "False",
+ "noLegendImage": "False",
+ "groupAsLayer": "False",
+ "baseLayer": "False",
+ "displayInLegend": "True",
+ "singleTile": "True",
+ "imageFormat": "image/png",
+ "cached": "False",
+ "clientCacheExpiration": 300
+ },
+ "osm-mapnik": {
+ "id": "osm_mapnik20190220152650417",
+ "name": "osm-mapnik",
+ "type": "layer",
+ "extent": [
+ -20037508.342789244,
+ -20037508.342789255,
+ 20037508.342789244,
+ 20037508.342789244
+ ],
+ "crs": "EPSG:3857",
+ "title": "osm-mapnik",
+ "abstract": "",
+ "link": "",
+ "minScale": 1,
+ "maxScale": 1000000000000,
+ "toggled": "False",
+ "popup": "False",
+ "popupSource": "auto",
+ "popupTemplate": "",
+ "popupMaxFeatures": 10,
+ "popupDisplayChildren": "False",
+ "noLegendImage": "False",
+ "groupAsLayer": "False",
+ "baseLayer": "False",
+ "displayInLegend": "True",
+ "singleTile": "True",
+ "imageFormat": "image/png",
+ "cached": "False",
+ "clientCacheExpiration": 300
+ }
+ },
+ "locateByLayer": {
+ "montpellier_events": {
+ "fieldName": "titre",
+ "displayGeom": "False",
+ "minLength": 0,
+ "filterOnLocate": "False",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 0
+ }
+ },
+ "attributeLayers": {
+ "montpellier_events": {
+ "primaryKey": "fid",
+ "hiddenFields": "",
+ "pivot": "False",
+ "hideAsChild": "False",
+ "hideLayer": "False",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 0
+ }
+ },
+ "datavizLayers": {
+ "0": {
+ "title": "Mon titre",
+ "type": "scatter",
+ "x_field": "field_communes",
+ "aggregation": "count",
+ "y_field": "fid",
+ "color": "#00aaff",
+ "colorfield": "",
+ "has_y2_field": "False",
+ "y2_field": "",
+ "color2": "",
+ "colorfield2": "",
+ "popup_display_child_plot": "False",
+ "only_show_child": "False",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 0
+ }
+ },
+ "formFilterLayers": {
+ "0": {
+ "title": "Cat",
+ "type": "uniquevalues",
+ "field": "field_thematique",
+ "min_date": "",
+ "max_date": "",
+ "format": "checkboxes",
+ "splitter": ", ",
+ "provider": "ogr",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 0
+ },
+ "1": {
+ "title": "Date",
+ "type": "date",
+ "field": "",
+ "min_date": "field_date",
+ "max_date": "field_date",
+ "format": "checkboxes",
+ "splitter": "",
+ "provider": "ogr",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 1
+ },
+ "2": {
+ "title": "Commune",
+ "type": "uniquevalues",
+ "field": "field_communes",
+ "min_date": "",
+ "max_date": "",
+ "format": "select",
+ "splitter": ", ",
+ "provider": "ogr",
+ "layerId": "events_4c3b47b8_3939_4c8c_8e91_55bdb13a2101",
+ "order": 2
+ }
+ }
+}
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/default/jsdefaultinrepo.js b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/default/jsdefaultinrepo.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/jsprojetinrepo.js b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/jsprojetinrepo.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/mjs.mjs b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/mjs.mjs
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/style1.css b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/style1.css
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/subfolder/jsinsubfolder.js b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/events/subfolder/jsinsubfolder.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/invalid_project/unfoundable.js b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/invalid_project/unfoundable.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/js_bad_folder.js b/tests/units/classes/Project/Ressources/root4Repository/repo1/media/js/js_bad_folder.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/units/testslib/ContextForTests.php b/tests/units/testslib/ContextForTests.php
index 2a807da4ed..c072c1b395 100644
--- a/tests/units/testslib/ContextForTests.php
+++ b/tests/units/testslib/ContextForTests.php
@@ -210,8 +210,12 @@ public function createJelixForm($formSel, $formId = null)
{
}
- public function getUrl($selector)
+ public function getUrl($selector, $params = array())
{
+ // simple url build
+ $keyWithVal4QueryString = array();
+ array_walk($params, function($v ,$key) use (&$keyWithVal4QueryString) {$keyWithVal4QueryString[]=$key.'='.$v;});
+ return $selector.'?'.implode("&", $keyWithVal4QueryString);
}
public function getFullUrl($selector, $params = array())