Skip to content

Commit

Permalink
Fix Display a warning box when the CFG contains warnings
Browse files Browse the repository at this point in the history
After #4226 and #4242, the warning message can generate the error `Uncaught SyntaxError: missing ) after argument list`
and `Uncaught ReferenceError: lizUrls is not defined`. These error messages are generated by a quote in the warning message.

To fix it, we use the Lizmap dictionnary which is a JSON version of the Dictionnary local.
  • Loading branch information
rldhont authored and Gustry committed Feb 27, 2024
1 parent e8beba2 commit 4065fda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lizmap/modules/view/controllers/lizMap.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,20 @@ function f($x)

$serverInfoAccess = (\jAcl2::check('lizmap.admin.access') || \jAcl2::check('lizmap.admin.server.information.view'));
if ($serverInfoAccess && $lproj->projectCountCfgWarnings() >= 1) {
$message = htmlspecialchars(jLocale::get('view~default.project.has.warnings'));
$messageLink = $message.'<br><a href="'.jUrl::get('admin~qgis_projects:index').'">'.htmlspecialchars(jLocale::get('view~default.project.has.warnings.link')).'</a>';
$jsWarning = "
lizMap.events.on(
{
'uicreated':function(evt){
lizMap.addMessage('{$messageLink}', 'warning', true).attr('id','lizmap-warning-message');
var message = lizDict['project.has.warnings'];
message += '<br><a href=\"".jUrl::get('admin~qgis_projects:index')."\">';
message += lizDict['project.has.warnings.link'];
message += '</a>'
lizMap.addMessage(message, 'warning', true).attr('id','lizmap-warning-message');
}
}
);
";
$rep->addJSCode($jsWarning);
\jLog::log($message);
}

$rep->body->assign($assign);
Expand Down
3 changes: 0 additions & 3 deletions lizmap/modules/view/locales/en_US/default.UTF-8.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ project.open.map=Load the map
project.open.map.metadata=View metadata
project.close.map.metadata=Close
project.needs.update=The project needs an update from the GIS administrator. Please contact the GIS administrator to check the QGIS projects panel.
project.has.warnings=The project has some warnings in the QGIS desktop Lizmap plugin which must be fixed. \
Only administrators or publishers can see this message.
project.has.warnings.link=Visit the QGIS project page in the administration panel.

header.connect=Connect
header.disconnect=Disconnect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
startup.error=An error occurred while loading this map. Some necessary resources may temporarily be unavailable. Please try again later.
startup.goToProject=Go back to the home page.

project.has.warnings=The project has some warnings in the QGIS desktop Lizmap plugin which must be fixed. Only administrators or publishers can see this message.
project.has.warnings.link=Visit the QGIS project page in the administration panel.

tree.button.checkbox=Display/Hide
tree.button.link=Open documentation
tree.button.removeCache=Remove server's cache for this layer
Expand Down

0 comments on commit 4065fda

Please sign in to comment.