Skip to content

Commit

Permalink
store dav prefix in lizUrls object for client side utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
mind84 committed Nov 22, 2023
1 parent f5f6294 commit 857c4f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions assets/src/legacy/attributeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,15 +1510,15 @@ var lizAttributeTable = function() {
}
} else {
// Check if we need to replace url or media by link
let davConf = lizUrls['webDavUrl'] && config.layers[aName]?.webDavFields && Array.isArray(config.layers[aName].webDavFields) && config.layers[aName].webDavFields.includes(columnName) || false;
let davConf = lizUrls.webDavUrl && lizUrls?.resourceUrlReplacement?.webdav && config.layers[aName]?.webDavFields && Array.isArray(config.layers[aName].webDavFields) && config.layers[aName].webDavFields.includes(columnName);
colConf['render'] = function (data, type, row, meta) {
// Replace media and URL with links
if (!data || !(typeof data === 'string'))
return data;
if (davConf) {
// replace the root of the url
if(data.startsWith(lizUrls['webDavUrl'])){
data = data.replace(lizUrls['webDavUrl'],'dav/')
if(data.startsWith(lizUrls.webDavUrl)){
data = data.replace(lizUrls.webDavUrl, lizUrls.resourceUrlReplacement.webdav)
}
}

Expand All @@ -1529,7 +1529,7 @@ var lizAttributeTable = function() {
rdata = data.slice(1);
return '<a href="' + mediaLinkPrefix + '&path=' + rdata + '" target="_blank">' + colMeta.title + '</a>';
}
else if (data.substring(0, 4) == 'dav/') {
else if (davConf && data.substring(0, 4) == lizUrls.resourceUrlReplacement.webdav) {
var rdata = data;
var colMeta = meta.settings.aoColumns[meta.col];
return '<a href="' + mediaLinkPrefix + '&path=' + rdata + '" target="_blank">' + colMeta.title + '</a>';
Expand Down
2 changes: 2 additions & 0 deletions lizmap/modules/view/controllers/lizMap.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function index()
'basepath' => $bp,
'geobookmark' => jUrl::get('lizmap~geobookmark:index'),
'service' => jUrl::get('lizmap~service:index').'?repository='.$repository.'&project='.$project,
'resourceUrlReplacement' => array(),
);

// Get optional WMS public url list
Expand All @@ -226,6 +227,7 @@ function f($x)
$webDavProfile = RemoteStorageRequest::getProfile('webdav');
if ($webDavProfile) {
$lizUrls['webDavUrl'] = $webDavProfile['baseUri'];
$lizUrls['resourceUrlReplacement']['webdav'] = 'dav/';
}

$rep->addJSCode('var lizUrls = '.json_encode($lizUrls).';');
Expand Down

0 comments on commit 857c4f4

Please sign in to comment.