Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata - Add WFS link if the user has enough rights #5305

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lizmap/modules/lizmap/lib/Project/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,25 @@ public function getWMTSGetCapabilitiesUrl()
);
}

/**
* Get the WFS GetCapabilities Url.
*
* @return string
*/
public function getWFSGetCapabilitiesUrl()
{
return $this->appContext->getFullUrl(
'lizmap~service:index',
array(
'repository' => $this->repository->getKey(),
'project' => $this->key,
'SERVICE' => 'WFS',
'VERSION' => '1.0.0',
'REQUEST' => 'GetCapabilities',
)
);
}

public function getFileTime()
{
return $this->cacheHandler->getFileTime();
Expand Down Expand Up @@ -689,6 +708,9 @@ public function getData($key)

case 'wmtsGetCapabilitiesUrl':
return $this->getWMTSGetCapabilitiesUrl();

case 'wfsGetCapabilitiesUrl':
return $this->getWFSGetCapabilitiesUrl();
}

return $this->qgis->getData($key);
Expand Down Expand Up @@ -2233,13 +2255,15 @@ public function getDefaultDockable()
if ($wmsGetCapabilitiesUrl) {
$wmsGetCapabilitiesUrl = $this->getWMSGetCapabilitiesUrl();
$wmtsGetCapabilitiesUrl = $this->getWMTSGetCapabilitiesUrl();
$wfsGetCapabilitiesUrl = $this->getWFSGetCapabilitiesUrl();
}
$metadataTpl->assign(array_merge(array(
'repositoryLabel' => $this->repository->getLabel(),
'repository' => $this->repository->getKey(),
'project' => $this->getKey(),
'wmsGetCapabilitiesUrl' => $wmsGetCapabilitiesUrl,
'wmtsGetCapabilitiesUrl' => $wmtsGetCapabilitiesUrl,
'wfsGetCapabilitiesUrl' => $wfsGetCapabilitiesUrl,
), $wmsInfo));
$dockable[] = new \lizmapMapDockItem(
'metadata',
Expand Down
20 changes: 20 additions & 0 deletions lizmap/modules/lizmap/lib/Project/ProjectMainData.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ public function __construct($repository, $id, $file, $requiredTargetLwcVersion,
'REQUEST' => 'GetCapabilities',
)
);
$this->data['wfsGetCapabilitiesUrl'] = $appContext->getFullUrl(
'lizmap~service:index',
array(
'repository' => $repository,
'project' => $id,
'SERVICE' => 'WFS',
'VERSION' => '1.0.0',
'REQUEST' => 'GetCapabilities',
)
);

// Check right on repository
if ($this->data['acl'] && !$appContext->aclCheck('lizmap.repositories.view', $repository)) {
Expand Down Expand Up @@ -225,6 +235,16 @@ public function getWMTSGetCapabilitiesUrl()
return $this->data['wmtsGetCapabilitiesUrl'];
}

/**
* The url of WFS GetCapabilities.
*
* @return string
*/
public function getWFSGetCapabilitiesUrl()
{
return $this->data['wfsGetCapabilitiesUrl'];
}

/**
* The main data.
*
Expand Down
12 changes: 12 additions & 0 deletions lizmap/modules/lizmap/lib/Project/ProjectMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(Project $project)
'bbox' => $project->getBbox(),
'wmsGetCapabilitiesUrl' => $project->getWMSGetCapabilitiesUrl(),
'wmtsGetCapabilitiesUrl' => $project->getWMTSGetCapabilitiesUrl(),
'wfsGetCapabilitiesUrl' => $project->getWFSGetCapabilitiesUrl(),
'map' => $project->getRelativeQgisPath(),
'acl' => $project->checkAcl(),
'qgisProjectVersion' => $project->getQgisProjectVersion(),
Expand Down Expand Up @@ -182,6 +183,17 @@ public function getWMTSGetCapabilitiesUrl()
{
return $this->data['wmtsGetCapabilitiesUrl'];
}
}

/**
* The url of WFS GetCapabilities.
*
* @return string
*/
public function getWFSGetCapabilitiesUrl()
{
return $this->data['wfsGetCapabilitiesUrl'];
}

/**
* The QGIS desktop project version.
Expand Down
8 changes: 7 additions & 1 deletion lizmap/modules/view/classes/lizmapMainViewItem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ class lizmapMainViewItem
public $type = '';
public $wmsGetCapabilitiesUrl = '';
public $wmtsGetCapabilitiesUrl = '';
public $wfsGetCapabilitiesUrl = '';

public $childItems = array();

public function __construct($id, $title, $abstract = '', $keywordList = '', $proj = '', $bbox = '', $url = '', $img = '', $order = 0, $parentId = '', $type = 'rep', $wmsGetCapabilitiesUrl = '', $wmtsGetCapabilitiesUrl = '')
public function __construct(
$id, $title, $abstract = '', $keywordList = '', $proj = '', $bbox = '', $url = '',
$img = '', $order = 0, $parentId = '', $type = 'rep',
$wmsGetCapabilitiesUrl = '', $wmtsGetCapabilitiesUrl = '', $wfsGetCapabilitiesUrl = ''
)
{
$this->id = $id;
$this->parentId = $parentId;
Expand All @@ -42,6 +47,7 @@ public function __construct($id, $title, $abstract = '', $keywordList = '', $pro
$this->type = $type;
$this->wmsGetCapabilitiesUrl = $wmsGetCapabilitiesUrl;
$this->wmtsGetCapabilitiesUrl = $wmtsGetCapabilitiesUrl;
$this->wfsGetCapabilitiesUrl = $wfsGetCapabilitiesUrl;
}

public function copyFrom($item)
Expand Down
5 changes: 5 additions & 0 deletions lizmap/modules/view/templates/map_metadata.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@
<dd><small class="bbox">{$WMSExtent}</small></dd>
<br/>

{ifacl2 'lizmap.tools.displayGetCapabilitiesLinks'}
{if $wmsGetCapabilitiesUrl}
<dt>{@view~map.metadata.properties.wmsGetCapabilitiesUrl@}</dt>
<dd><small><a href="{$wmsGetCapabilitiesUrl}" target="_blank">WMS Url</a></small></dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<dd><small><a href="{$wmsGetCapabilitiesUrl}" target="_blank">WMS Url</a></small></dd>
<dd><small><a href="{$wmsGetCapabilitiesUrl}" target="_blank">WMS URL</a></small></dd>

<dd><small><a id="metadata-wmts-getcapabilities-url" href="{$wmtsGetCapabilitiesUrl}" target="_blank">WMTS Url</a></small></dd>
{ifacl2 'lizmap.tools.layer.export'}
<dd><small><a href="{$wfsGetCapabilitiesUrl}" target="_blank">WFS Url</a></small></dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<dd><small><a href="{$wfsGetCapabilitiesUrl}" target="_blank">WFS Url</a></small></dd>
<dd><small><a href="{$wfsGetCapabilitiesUrl}" target="_blank">WFS URL</a></small></dd>

{/ifacl2}
<br/>
{/if}
{/ifacl2}
</dl>
</p>
</div>
Expand Down
3 changes: 3 additions & 0 deletions lizmap/modules/view/templates/view.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<div class="col-8">
<dd><small><a href="{$p->wmsGetCapabilitiesUrl}" target="_blank">WMS Url</a></small></dd>
<dd><small><a href="{$p->wmtsGetCapabilitiesUrl}" target="_blank">WMTS Url</a></small></dd>
{ifacl2 'lizmap.tools.layer.export'}
<dd><small><a href="{$p->wfsGetCapabilitiesUrl}" target="_blank">WFS Url</a></small></dd>
{/ifacl2}
</div>
</dl>
{/if}
Expand Down
4 changes: 3 additions & 1 deletion lizmap/modules/view/zones/main_view.zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected function _prepareTpl()
if ($wmsGetCapabilitiesUrl) {
$wmsGetCapabilitiesUrl = $meta->getWMSGetCapabilitiesUrl();
$wmtsGetCapabilitiesUrl = $meta->getWMTSGetCapabilitiesUrl();
$wfsGetCapabilitiesUrl = $meta->getWFSGetCapabilitiesUrl();
}

// Allowed image types lower or upper case
Expand Down Expand Up @@ -114,7 +115,8 @@ protected function _prepareTpl()
$r,
'map',
$wmsGetCapabilitiesUrl,
$wmtsGetCapabilitiesUrl
$wmtsGetCapabilitiesUrl,
$wfsGetCapabilitiesUrl
);
}
}
Expand Down
Loading