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*ffc5e5e9Sfiwswe $manifest['name'] = strip_tags($conf['title']); 19c9071834SMichael Große } 20c9071834SMichael Große 21c9071834SMichael Große if (empty($manifest['short_name'])) { 22*ffc5e5e9Sfiwswe $manifest['short_name'] = strip_tags($conf['title']); 23c9071834SMichael Große } 24c9071834SMichael Große 25c9071834SMichael Große if (empty($manifest['description'])) { 26*ffc5e5e9Sfiwswe $manifest['description'] = strip_tags($conf['tagline']); 27c9071834SMichael Große } 28c9071834SMichael Große 29c9071834SMichael Große if (empty($manifest['start_url'])) { 30c9071834SMichael Große $manifest['start_url'] = DOKU_REL; 31c9071834SMichael Große } 32c9071834SMichael Große 3324870174SAndreas Gohr $styleUtil = new StyleUtils(); 344593dbd2SAnna Dabrowska $styleIni = $styleUtil->cssStyleini(); 35c9071834SMichael Große $replacements = $styleIni['replacements']; 36c9071834SMichael Große 37c9071834SMichael Große if (empty($manifest['background_color'])) { 38c9071834SMichael Große $manifest['background_color'] = $replacements['__background__']; 39c9071834SMichael Große } 40c9071834SMichael Große 41c9071834SMichael Große if (empty($manifest['theme_color'])) { 4224870174SAndreas Gohr $manifest['theme_color'] = empty($replacements['__theme_color__']) 4324870174SAndreas Gohr ? $replacements['__background_alt__'] 4424870174SAndreas Gohr : $replacements['__theme_color__']; 45c9071834SMichael Große } 46c9071834SMichael Große 47c9071834SMichael Große if (empty($manifest['icons'])) { 48c9071834SMichael Große $manifest['icons'] = []; 492d8226d6SMichael Große if (file_exists(mediaFN(':wiki:favicon.ico'))) { 502d8226d6SMichael Große $url = ml(':wiki:favicon.ico', '', true, '', true); 51c9071834SMichael Große $manifest['icons'][] = [ 52c9071834SMichael Große 'src' => $url, 532d8226d6SMichael Große 'sizes' => '16x16', 54c9071834SMichael Große ]; 552d8226d6SMichael Große } 562d8226d6SMichael Große 572d8226d6SMichael Große $look = [ 582d8226d6SMichael Große ':wiki:logo.svg', 592d8226d6SMichael Große ':logo.svg', 602d8226d6SMichael Große ':wiki:dokuwiki.svg' 612d8226d6SMichael Große ]; 622d8226d6SMichael Große 632d8226d6SMichael Große foreach ($look as $svgLogo) { 642d8226d6SMichael Große $svgLogoFN = mediaFN($svgLogo); 652d8226d6SMichael Große 662d8226d6SMichael Große if (file_exists($svgLogoFN)) { 672d8226d6SMichael Große $url = ml($svgLogo, '', true, '', true); 682d8226d6SMichael Große $manifest['icons'][] = [ 692d8226d6SMichael Große 'src' => $url, 702d8226d6SMichael Große 'sizes' => '17x17 512x512', 712d8226d6SMichael Große 'type' => 'image/svg+xml', 722d8226d6SMichael Große ]; 732d8226d6SMichael Große break; 74c9071834SMichael Große }; 75c9071834SMichael Große } 76c9071834SMichael Große } 77c9071834SMichael Große 78cbb44eabSAndreas Gohr Event::createAndTrigger('MANIFEST_SEND', $manifest); 79c9071834SMichael Große 80c9071834SMichael Große header('Content-Type: application/manifest+json'); 8124870174SAndreas Gohr echo json_encode($manifest, JSON_THROW_ON_ERROR); 82c9071834SMichael Große } 83c9071834SMichael Große} 84