Skip to content

Commit

Permalink
Remove webdav stuff. The webdav module will bring info via events.
Browse files Browse the repository at this point in the history
Using the new metadata event, will allow any modules like webdav
to provide metadata on the url /view/app/metadata.

The webdav will also use the existing LizmapServerVersion event to
show information on the server information panel.
  • Loading branch information
laurentj committed Jul 13, 2023
1 parent 00f985c commit 18fa910
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ public function index()
'minimumQgisVersion' => $qgisMinimumVersionRequired,
'minimumLizmapServer' => $lizmapPluginMinimumVersionRequired,
);
if (\jApp::isModuleEnabled('webdav') && class_exists('\\LizmapDAV\\Server')) {
if (\jAcl2::check('lizmap.webdav.access')) {
$assign['webdav'] = \jServer::getServerURI().\LizmapDAV\Server::serverBaseUri();
}
}
$tpl->assign($assign);
$rep->body->assign('MAIN', $tpl->fetch('server_information'));
$rep->body->assign('selectedMenuItem', 'lizmap_server_information');
Expand Down
11 changes: 0 additions & 11 deletions lizmap/modules/admin/templates/server_information.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@
</button>
</td>
</tr>
{if isset($webdav)}
<tr>
<th>{@admin.server.information.webdav.url@}</th>
<td>
{$webdav}
<button type="button" class="btn-small copy-to-clipboard" data-text="{$webdav}">
<svg aria-hidden="true" height="16" width="16" data-view-component="true"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25v-7.5z"/><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25v-7.5zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25h-7.5z"/></svg>
</button>
</td>
</tr>
{/if}
</table>
{hook 'LizmapServerVersion', $data['info']}

Expand Down
42 changes: 42 additions & 0 deletions lizmap/modules/lizmap/lib/Events/LizmapMetadataEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Event for metadata.
*
* @author 3liz
* @copyright 2023 3liz
*
* @see http://3liz.com
*
* @license Mozilla Public License : http://www.mozilla.org/MPL/
*/

namespace Lizmap\Events;

class LizmapMetadataEvent extends \jEvent
{
public function __construct()
{
parent::__construct('LizmapMetadata');
$this->_responses = array(
array(),
);
}

/**
* @param mixed $key
* @param mixed $value
*/
public function addMetadata($key, $value)
{
$this->_responses[0][$key] = $value;
}

/**
* @return array
*/
public function getMetadata()
{
return $this->_responses[0];
}
}
6 changes: 0 additions & 6 deletions lizmap/modules/lizmap/lib/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ private function getLizmapMetadata()
);
}

if (\jApp::isModuleEnabled('webdav') && class_exists('\\LizmapDAV\\Server')) {
if (\jAcl2::check('lizmap.webdav.access')) {
$data['webdav'] = \jServer::getServerURI().\LizmapDAV\Server::serverBaseUri();
}
}

return $data;
}

Expand Down
7 changes: 7 additions & 0 deletions lizmap/modules/view/controllers/app.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public function metadata()
$data['qgis_server_info'] = array('error' => 'WRONG_CREDENTIALS');
}

// retrieves foreign metadata
$event = new \Lizmap\Events\LizmapMetadataEvent();
\jEvent::notify($event);
// merge other foreign metadata with current metadata.
// We don't want that foreign metadata overwrite our own metadata.
$data = array_merge($event->getMetadata(), $data);

$rep->data = $data;

return $rep;
Expand Down

0 comments on commit 18fa910

Please sign in to comment.