1c9071834SMichael Große<?php 2c9071834SMichael Große 3c9071834SMichael Großenamespace dokuwiki; 4c9071834SMichael Große 5cbb44eabSAndreas Gohruse dokuwiki\Extension\Event; 6cbb44eabSAndreas Gohr 7c9071834SMichael Großeclass Manifest 8c9071834SMichael Große{ 9c9071834SMichael Große public function sendManifest() 10c9071834SMichael Große { 11c9071834SMichael Große $manifest = retrieveConfig('manifest', 'jsonToArray'); 12c9071834SMichael Große 13c9071834SMichael Große global $conf; 14c9071834SMichael Große 15c9071834SMichael Große $manifest['scope'] = DOKU_REL; 16c9071834SMichael Große 17c9071834SMichael Große if (empty($manifest['name'])) { 18*1e5f7f1fSAndreas Gohr $manifest['name'] = html_entity_decode( 19*1e5f7f1fSAndreas Gohr strip_tags($conf['title']), 20*1e5f7f1fSAndreas Gohr ENT_QUOTES | ENT_HTML5, 21*1e5f7f1fSAndreas Gohr 'UTF-8' 22*1e5f7f1fSAndreas Gohr ); 23c9071834SMichael Große } 24c9071834SMichael Große 25c9071834SMichael Große if (empty($manifest['short_name'])) { 26*1e5f7f1fSAndreas Gohr $manifest['short_name'] = html_entity_decode( 27*1e5f7f1fSAndreas Gohr strip_tags($conf['title']), 28*1e5f7f1fSAndreas Gohr ENT_QUOTES | ENT_HTML5, 29*1e5f7f1fSAndreas Gohr 'UTF-8' 30*1e5f7f1fSAndreas Gohr ); 31c9071834SMichael Große } 32c9071834SMichael Große 33c9071834SMichael Große if (empty($manifest['description'])) { 34*1e5f7f1fSAndreas Gohr $manifest['description'] = html_entity_decode( 35*1e5f7f1fSAndreas Gohr strip_tags($conf['tagline']), 36*1e5f7f1fSAndreas Gohr ENT_QUOTES | ENT_HTML5, 37*1e5f7f1fSAndreas Gohr 'UTF-8' 38*1e5f7f1fSAndreas Gohr ); 39c9071834SMichael Große } 40c9071834SMichael Große 41c9071834SMichael Große if (empty($manifest['start_url'])) { 42c9071834SMichael Große $manifest['start_url'] = DOKU_REL; 43c9071834SMichael Große } 44c9071834SMichael Große 4524870174SAndreas Gohr $styleUtil = new StyleUtils(); 464593dbd2SAnna Dabrowska $styleIni = $styleUtil->cssStyleini(); 47c9071834SMichael Große $replacements = $styleIni['replacements']; 48c9071834SMichael Große 49c9071834SMichael Große if (empty($manifest['background_color'])) { 50c9071834SMichael Große $manifest['background_color'] = $replacements['__background__']; 51c9071834SMichael Große } 52c9071834SMichael Große 53c9071834SMichael Große if (empty($manifest['theme_color'])) { 5424870174SAndreas Gohr $manifest['theme_color'] = empty($replacements['__theme_color__']) 5524870174SAndreas Gohr ? $replacements['__background_alt__'] 5624870174SAndreas Gohr : $replacements['__theme_color__']; 57c9071834SMichael Große } 58c9071834SMichael Große 59c9071834SMichael Große if (empty($manifest['icons'])) { 60c9071834SMichael Große $manifest['icons'] = []; 612d8226d6SMichael Große if (file_exists(mediaFN(':wiki:favicon.ico'))) { 622d8226d6SMichael Große $url = ml(':wiki:favicon.ico', '', true, '', true); 63c9071834SMichael Große $manifest['icons'][] = [ 64c9071834SMichael Große 'src' => $url, 652d8226d6SMichael Große 'sizes' => '16x16', 66c9071834SMichael Große ]; 672d8226d6SMichael Große } 682d8226d6SMichael Große 692d8226d6SMichael Große $look = [ 702d8226d6SMichael Große ':wiki:logo.svg', 712d8226d6SMichael Große ':logo.svg', 722d8226d6SMichael Große ':wiki:dokuwiki.svg' 732d8226d6SMichael Große ]; 742d8226d6SMichael Große 752d8226d6SMichael Große foreach ($look as $svgLogo) { 762d8226d6SMichael Große $svgLogoFN = mediaFN($svgLogo); 772d8226d6SMichael Große 782d8226d6SMichael Große if (file_exists($svgLogoFN)) { 792d8226d6SMichael Große $url = ml($svgLogo, '', true, '', true); 802d8226d6SMichael Große $manifest['icons'][] = [ 812d8226d6SMichael Große 'src' => $url, 822d8226d6SMichael Große 'sizes' => '17x17 512x512', 832d8226d6SMichael Große 'type' => 'image/svg+xml', 842d8226d6SMichael Große ]; 852d8226d6SMichael Große break; 86c9071834SMichael Große }; 87c9071834SMichael Große } 88c9071834SMichael Große } 89c9071834SMichael Große 90cbb44eabSAndreas Gohr Event::createAndTrigger('MANIFEST_SEND', $manifest); 91c9071834SMichael Große 92c9071834SMichael Große header('Content-Type: application/manifest+json'); 9324870174SAndreas Gohr echo json_encode($manifest, JSON_THROW_ON_ERROR); 94c9071834SMichael Große } 95c9071834SMichael Große} 96