1<?php 2 3class Kiwiki_Functions { 4 5 6 /** 7 * Edit icon button 8 */ 9 public static function _edit_icon($what){ 10 global $ACT; 11 global $INFO; 12 $rev = ($INFO['rev']) ? '&rev='.$INFO['rev'] : ''; 13 if ($ACT == 'show'){ 14 $editicon = (new \dokuwiki\Menu\KiwikiEdit())->getListItems('kiwiki-',true); 15 if (!empty($what)){ 16 $editicon = preg_replace('/<a(.*)href="([^"]*)"(.*)>/','<a$1href="'.DOKU_BASE.'doku.php?id='.$what.'&do=edit"$3 role="button">',$editicon); 17 }else{ 18 $editicon = preg_replace('/<a(.*)href="([^"]*)"(.*)>/','<a$1href="'.DOKU_BASE.'doku.php?id='.$INFO['id'].'&do=edit'.$rev.'"$3 role="button">',$editicon); 19 } 20 return $editicon; 21 } 22 } 23 24 25 /** 26 * Go bottom button 27 */ 28 29 public static function html_bottombtn() { 30 global $lang; 31 32 return '<a class="nolink" href="#dokuwiki__bottom" role="button" aria-label="' . $lang['btn_bottom'] . '" title="' . $lang['btn_bottom'] . '">' 33 .'<button class="button" onclick="window.scrollTo(0, 0)" title="'. $lang['btn_bottom'] .'">' 34 . $lang['btn_bottom'] 35 .'</button></a>'; 36 } 37 38 /** 39 * Custom ACL Informations in footer 40 * Original code from Chris75 41 * https://forum.dokuwiki.org/d/21636-acl-deny-a-user-group-to-a-namespace/13 42 */ 43 44 public static function tpl_aclinfo() { 45 global $ID, $AUTH_ACL, $INFO; 46 47 if ((auth_quickaclcheck($ID) == 0) ||(!$INFO['editable'])) 48 return; // no rights to view, no rights to get this info 49 50 $page_acls = array(); 51 $namespaces = array(); 52 53 $ns = getNS($ID); 54 while ($ns) { 55 array_unshift($namespaces,$ns . ':*'); 56 $ns = getNS($ns); 57 } 58 array_unshift($namespaces,'*'); // root 59 60 $namespaces[] = $ID; 61 62 // check matches 63 foreach ($namespaces as $level) { 64 $matches = preg_grep('/^'.preg_quote($level,'/').'\s+\S+\s+\d+\s*$/',$AUTH_ACL); 65 $this_acls = array(); 66 foreach($matches as $match){ 67 $match = preg_replace('/#.*$/','',$match); //ignore comments 68 $acl = preg_split('/\s+/',$match); 69 $this_acls[urldecode($acl[1])] = $acl[2]; 70 if ($acl[1] == "@ALL") // overwrites stuff from upper level 71 $page_acls = array(); 72 } 73 $page_acls = array_merge($page_acls,$this_acls); 74 } 75 76 // check if visible to everyone: 77 /*if (($page_acls['@ALL'] !== false) && $page_acls['@ALL'] > 0) 78 return; // page is visible to everyone*/ 79 80 $list = array(); 81 foreach ($page_acls as $user => $right) { 82 if ($right > 0 && $user != "@admin" ) // admins can see everything 83 array_push($list,$user); 84 } 85 if (count($list)) { 86 sort($list); 87 print tpl_getLang('Visible to'); 88 print join(', ',$list); 89 } 90 91 // Uncomment this, if you want to display users/groups who cannot access this page, too: 92 $list = array(); 93 foreach ($page_acls as $user => $right) { 94 if ($right == 0) 95 array_push($list,$user); 96 } 97 if (count($list)) { 98 sort($list); 99 print " • "; 100 print tpl_getLang('Hidden to'); 101 print join(', ',$list); 102 } 103 } 104} 105