diff --git a/include/init/manifest.php b/include/init/manifest.php index 12cdb0722..e030088fa 100644 --- a/include/init/manifest.php +++ b/include/init/manifest.php @@ -18,43 +18,46 @@ * along with this program. If not, see . */ -$creation = file_put_contents('manifest.json', ''); +$manifest_lang = (!empty($lang) && $lang != '|lang|') ? $lang : ($GLOBALS['lang'] ?? 'it_IT'); +$manifest_lang = empty($manifest_lang) || $manifest_lang == '|lang|' ? 'it_IT' : $manifest_lang; -if (!$creation) { - $manifest = '{ +$manifest = [ + 'dir' => 'ltr', + 'lang' => str_replace('_', '-', $manifest_lang), + 'name' => tr('OpenSTAManager'), + 'scope' => './', + 'display' => 'fullscreen', + 'start_url' => './', + 'short_name' => 'OSM', + 'theme_color' => 'transparent', + 'description' => tr('OpenSTAManager'), + 'orientation' => 'any', + 'background_color' => 'transparent', + 'generated' => 'true', + 'icons' => [ + [ + 'src' => 'assets/dist/img/logo_completo.png', + 'type' => 'image/png', + 'sizes' => '489x91', + ], + ], +]; - "dir" : "ltr", - "lang" : "'.((empty($lang) || $lang == '|lang|') ? 'it-IT' : str_replace('_', '-', $lang)).'", - "name" : "'.tr('OpenSTAManager').'", - "scope" : "'.((empty(base_path_osm()) || base_path_osm() == '/') ? '' : '.').'", - "display" : "fullscreen", - "start_url" : "'.((empty(base_path_osm()) || base_path_osm() == '/') ? '/' : './').'", - "short_name" : "OSM", - "theme_color" : "transparent", - "description" : "'.tr('OpenSTAManager').'", - "orientation" : "any", - "background_color" : "transparent", - "generated" : "true", - "icons" : [ - { - "src": "'.App::getPaths()['img'].'/logo_completo.png", - "type": "image/png", - "sizes": "489x91" - } - ] -}'; +$manifest_content = json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); +$creation = $manifest_content !== false + ? file_put_contents(base_dir().'/manifest.json', $manifest_content.PHP_EOL) + : false; - file_put_contents('manifest.json', $manifest); -} else { +if ($creation === false) { echo '
-
-

'.tr('Permessi di scrittura mancanti').'

-
-
-

'.tr('Sembra che non ci siano i permessi di scrittura sul file _FILE_', [ +

+

'.tr('Permessi di scrittura mancanti').'

+
+
+

'.tr('Sembra che non ci siano i permessi di scrittura sul file _FILE_', [ '_FILE_' => 'manifest.json', ]).'

-
+
'; } diff --git a/update/2_12.php b/update/2_12.php index c107a7ae1..ee9f3328f 100644 --- a/update/2_12.php +++ b/update/2_12.php @@ -79,4 +79,7 @@ // File non più presente, reset del valore $dbo->update('zz_settings', ['valore' => ''], ['nome' => 'Filigrana stampe']); } -} \ No newline at end of file +} + +// Rigenerazione del manifest per rendere scope e start_url indipendenti dal percorso di installazione +include base_dir().'/include/init/manifest.php';