Merge pull request #2515 from Innovailable/master
[dokuwiki.git] / inc / Manifest.php
blob0df9c2b81991be5c346494d8585c30b58b621d8a
1 <?php
3 namespace dokuwiki;
5 class Manifest
7 public function sendManifest()
9 $manifest = retrieveConfig('manifest', 'jsonToArray');
11 global $conf;
13 $manifest['scope'] = DOKU_REL;
15 if (empty($manifest['name'])) {
16 $manifest['name'] = $conf['title'];
19 if (empty($manifest['short_name'])) {
20 $manifest['short_name'] = $conf['title'];
23 if (empty($manifest['description'])) {
24 $manifest['description'] = $conf['tagline'];
27 if (empty($manifest['start_url'])) {
28 $manifest['start_url'] = DOKU_REL;
31 $styleUtil = new \dokuwiki\StyleUtils();
32 $styleIni = $styleUtil->cssStyleini($conf['template']);
33 $replacements = $styleIni['replacements'];
35 if (empty($manifest['background_color'])) {
36 $manifest['background_color'] = $replacements['__background__'];
39 if (empty($manifest['theme_color'])) {
40 $manifest['theme_color'] = !empty($replacements['__theme_color__']) ? $replacements['__theme_color__'] : $replacements['__background_alt__'];
43 if (empty($manifest['icons'])) {
44 $manifest['icons'] = [];
45 if (file_exists(mediaFN(':wiki:favicon.ico'))) {
46 $url = ml(':wiki:favicon.ico', '', true, '', true);
47 $manifest['icons'][] = [
48 'src' => $url,
49 'sizes' => '16x16',
53 $look = [
54 ':wiki:logo.svg',
55 ':logo.svg',
56 ':wiki:dokuwiki.svg'
59 foreach ($look as $svgLogo) {
61 $svgLogoFN = mediaFN($svgLogo);
63 if (file_exists($svgLogoFN)) {
64 $url = ml($svgLogo, '', true, '', true);
65 $manifest['icons'][] = [
66 'src' => $url,
67 'sizes' => '17x17 512x512',
68 'type' => 'image/svg+xml',
70 break;
75 trigger_event('MANIFEST_SEND', $manifest);
77 header('Content-Type: application/manifest+json');
78 echo json_encode($manifest);