1*c9071834SMichael Große<?php 2*c9071834SMichael Große 3*c9071834SMichael Großenamespace dokuwiki; 4*c9071834SMichael Große 5*c9071834SMichael Großeclass Manifest 6*c9071834SMichael Große{ 7*c9071834SMichael Große public function sendManifest() 8*c9071834SMichael Große { 9*c9071834SMichael Große $manifest = retrieveConfig('manifest', 'jsonToArray'); 10*c9071834SMichael Große 11*c9071834SMichael Große global $conf; 12*c9071834SMichael Große 13*c9071834SMichael Große $manifest['scope'] = DOKU_REL; 14*c9071834SMichael Große 15*c9071834SMichael Große if (empty($manifest['name'])) { 16*c9071834SMichael Große $manifest['name'] = $conf['title']; 17*c9071834SMichael Große } 18*c9071834SMichael Große 19*c9071834SMichael Große if (empty($manifest['short_name'])) { 20*c9071834SMichael Große $manifest['short_name'] = $conf['title']; 21*c9071834SMichael Große } 22*c9071834SMichael Große 23*c9071834SMichael Große if (empty($manifest['description'])) { 24*c9071834SMichael Große $manifest['description'] = $conf['tagline']; 25*c9071834SMichael Große } 26*c9071834SMichael Große 27*c9071834SMichael Große if (empty($manifest['start_url'])) { 28*c9071834SMichael Große $manifest['start_url'] = DOKU_REL; 29*c9071834SMichael Große } 30*c9071834SMichael Große 31*c9071834SMichael Große $styleUtil = new \dokuwiki\StyleUtils(); 32*c9071834SMichael Große $styleIni = $styleUtil->cssStyleini($conf['template']); 33*c9071834SMichael Große $replacements = $styleIni['replacements']; 34*c9071834SMichael Große 35*c9071834SMichael Große if (empty($manifest['background_color'])) { 36*c9071834SMichael Große $manifest['background_color'] = $replacements['__background__']; 37*c9071834SMichael Große } 38*c9071834SMichael Große 39*c9071834SMichael Große if (empty($manifest['theme_color'])) { 40*c9071834SMichael Große $manifest['theme_color'] = !empty($replacements['__theme_color__']) ? $replacements['__theme_color__'] : $replacements['__background_alt__']; 41*c9071834SMichael Große } 42*c9071834SMichael Große 43*c9071834SMichael Große if (empty($manifest['icons'])) { 44*c9071834SMichael Große $manifest['icons'] = []; 45*c9071834SMichael Große $look = [ 46*c9071834SMichael Große ':wiki:logo.png', 47*c9071834SMichael Große ':logo.png', 48*c9071834SMichael Große 'images/logo.png', 49*c9071834SMichael Große ':wiki:apple-touch-icon.png', 50*c9071834SMichael Große ':apple-touch-icon.png', 51*c9071834SMichael Große 'images/apple-touch-icon.png', 52*c9071834SMichael Große ':wiki:favicon.svg', 53*c9071834SMichael Große ':favicon.svg', 54*c9071834SMichael Große 'images/favicon.svg', 55*c9071834SMichael Große ':wiki:favicon.ico', 56*c9071834SMichael Große ':favicon.ico', 57*c9071834SMichael Große 'images/favicon.ico', 58*c9071834SMichael Große ':wiki:logo', 59*c9071834SMichael Große ]; 60*c9071834SMichael Große 61*c9071834SMichael Große $abs = true; 62*c9071834SMichael Große foreach ($look as $img) { 63*c9071834SMichael Große if ($img[0] === ':') { 64*c9071834SMichael Große $file = mediaFN($img); 65*c9071834SMichael Große $ismedia = true; 66*c9071834SMichael Große } else { 67*c9071834SMichael Große $file = tpl_incdir() . $img; 68*c9071834SMichael Große $ismedia = false; 69*c9071834SMichael Große } 70*c9071834SMichael Große 71*c9071834SMichael Große if (file_exists($file)) { 72*c9071834SMichael Große $imginfo = getimagesize($file); 73*c9071834SMichael Große if ($ismedia) { 74*c9071834SMichael Große $url = ml($img, '', true, '', $abs); 75*c9071834SMichael Große } else { 76*c9071834SMichael Große $url = tpl_basedir() . $img; 77*c9071834SMichael Große if ($abs) { 78*c9071834SMichael Große $url = DOKU_URL . substr($url, strlen(DOKU_REL)); 79*c9071834SMichael Große } 80*c9071834SMichael Große } 81*c9071834SMichael Große $manifest['icons'][] = [ 82*c9071834SMichael Große 'src' => $url, 83*c9071834SMichael Große 'sizes' => $imginfo[0] . 'x' . $imginfo[1], 84*c9071834SMichael Große 'type' => $imginfo['mime'], 85*c9071834SMichael Große ]; 86*c9071834SMichael Große }; 87*c9071834SMichael Große } 88*c9071834SMichael Große } 89*c9071834SMichael Große 90*c9071834SMichael Große trigger_event('MANIFEST_SEND', $manifest); 91*c9071834SMichael Große 92*c9071834SMichael Große header('Content-Type: application/manifest+json'); 93*c9071834SMichael Große echo json_encode($manifest); 94*c9071834SMichael Große } 95*c9071834SMichael Große} 96