1
0
Fork 0

Updating ad-hominem to version 2024-10-07+20250317 (9ede6bc).

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-04-13 13:09:37 +02:00
parent b79431e56e
commit 2dec6c784b
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
63 changed files with 2318 additions and 1765 deletions

View file

@ -2,9 +2,9 @@
/**
* Overwriting DokuWiki template functions
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sascha Leib <sascha@leib.be>
* @author Andreas Gohr <andi@splitbrain.org>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sascha Leib <sascha@leib.be>
* @author Andreas Gohr <andi@splitbrain.org>
*/
use dokuwiki\Extension\Event;
@ -19,31 +19,31 @@ use dokuwiki\File\PageResolver;
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers TPL_METAHEADER_OUTPUT
* @param bool $alt Should feeds and alternative format links be added?
* @return bool
* @param bool $alt Should feeds and alternative format links be added?
* @return bool
*/
function my_metaheaders($alt = true) {
global $ID;
global $REV;
global $INFO;
global $JSINFO;
global $ACT;
global $QUERY;
global $lang;
global $conf;
global $updateVersion;
/** @var Input $INPUT */
global $INPUT;
global $ID;
global $REV;
global $INFO;
global $JSINFO;
global $ACT;
global $QUERY;
global $lang;
global $conf;
global $updateVersion;
/** @var Input $INPUT */
global $INPUT;
// prepare the head array
$head = array();
// prepare the head array
$head = array();
// prepare seed for js and css
$tseed = $updateVersion;
$depends = getConfigFiles('main');
$depends[] = DOKU_CONF."tpl/".$conf['template']."/style.ini";
foreach($depends as $f) $tseed .= @filemtime($f);
$tseed = md5($tseed);
// prepare seed for js and css
$tseed = $updateVersion;
$depends = getConfigFiles('main');
$depends[] = DOKU_CONF."tpl/".$conf['template']."/style.ini";
foreach($depends as $f) $tseed .= @filemtime($f);
$tseed = md5($tseed);
// Open Graph information
$meta = p_get_metadata($ID);
@ -55,7 +55,7 @@ function my_metaheaders($alt = true) {
if (array_key_exists('description', $meta) && is_array($meta['description'])) {
if (array_key_exists('abstract', $meta['description'])) {
$parts = explode("\n", $meta['description']['abstract']);
$parts = explode(NL, $meta['description']['abstract']);
if (is_array($parts) && array_key_exists(2, $parts)) {
$head['meta'][] = array('property' => 'og:description', 'content' => $parts[2]);
@ -67,153 +67,153 @@ function my_metaheaders($alt = true) {
}
}
// the usual stuff
$head['meta'][] = array('name'=> 'generator', 'content'=> 'DokuWiki');
if(actionOK('search')) {
$head['link'][] = array(
'rel' => 'search', 'type'=> 'application/opensearchdescription+xml',
'href'=> DOKU_BASE.'lib/exe/opensearch.php', 'title'=> $conf['title']
);
}
// the usual stuff
$head['meta'][] = array('name'=> 'generator', 'content'=> 'DokuWiki');
if(actionOK('search')) {
$head['link'][] = array(
'rel' => 'search', 'type'=> 'application/opensearchdescription+xml',
'href'=> DOKU_BASE.'lib/exe/opensearch.php', 'title'=> $conf['title']
);
}
$head['link'][] = array('rel'=> 'start', 'href'=> DOKU_BASE);
if(actionOK('index')) {
$head['link'][] = array(
'rel' => 'contents', 'href'=> wl($ID, 'do=index', false, '&'),
'title'=> $lang['btn_index']
);
}
$head['link'][] = array('rel'=> 'start', 'href'=> DOKU_BASE);
if(actionOK('index')) {
$head['link'][] = array(
'rel' => 'contents', 'href'=> wl($ID, 'do=index', false, '&'),
'title'=> $lang['btn_index']
);
}
if (actionOK('manifest')) {
$head['link'][] = array('rel'=> 'manifest', 'href'=> DOKU_BASE.'lib/exe/manifest.php');
}
if (actionOK('manifest')) {
$head['link'][] = array('rel'=> 'manifest', 'href'=> DOKU_BASE.'lib/exe/manifest.php');
}
$styleUtil = new \dokuwiki\StyleUtils();
$styleIni = $styleUtil->cssStyleini();
$replacements = $styleIni['replacements'];
if (!empty($replacements['__theme_color__'])) {
$head['meta'][] = array(
$styleUtil = new \dokuwiki\StyleUtils();
$styleIni = $styleUtil->cssStyleini();
$replacements = $styleIni['replacements'];
if (!empty($replacements['__theme_color__'])) {
$head['meta'][] = array(
'name' => 'theme-color',
'content' => $replacements['__theme_color__']
);
}
}
if($alt) {
if(actionOK('rss')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php'
);
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['currentns'],
'href' => DOKU_BASE.'feed.php?mode=list&ns='.(isset($INFO) ? $INFO['namespace'] : '')
);
}
if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) {
$head['link'][] = array(
'rel' => 'edit',
'title'=> $lang['btn_edit'],
'href' => wl($ID, 'do=edit', false, '&')
);
}
if($alt) {
if(actionOK('rss')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php'
);
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['currentns'],
'href' => DOKU_BASE.'feed.php?mode=list&ns='.(isset($INFO) ? $INFO['namespace'] : '')
);
}
if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) {
$head['link'][] = array(
'rel' => 'edit',
'title'=> $lang['btn_edit'],
'href' => wl($ID, 'do=edit', false, '&')
);
}
if(actionOK('rss') && $ACT == 'search') {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['searchresult'],
'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY
);
}
if(actionOK('rss') && $ACT == 'search') {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
'title'=> $lang['searchresult'],
'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY
);
}
if(actionOK('export_xhtml')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'text/html', 'title'=> $lang['plainhtml'],
'href'=> exportlink($ID, 'xhtml', '', false, '&')
);
}
if(actionOK('export_xhtml')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'text/html', 'title'=> $lang['plainhtml'],
'href'=> exportlink($ID, 'xhtml', '', false, '&')
);
}
if(actionOK('export_raw')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> $lang['wikimarkup'],
'href'=> exportlink($ID, 'raw', '', false, '&')
);
}
}
if(actionOK('export_raw')) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> $lang['wikimarkup'],
'href'=> exportlink($ID, 'raw', '', false, '&')
);
}
}
// setup robot tags apropriate for different modes
if(($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) {
if($INFO['exists']) {
//delay indexing:
if((time() - $INFO['lastmod']) >= $conf['indexdelay'] && !isHiddenPage($ID) ) {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow');
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow');
}
$canonicalUrl = wl($ID, '', true, '&');
if ($ID == $conf['start']) {
$canonicalUrl = DOKU_URL;
}
$head['link'][] = array('rel'=> 'canonical', 'href'=> $canonicalUrl);
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,follow');
}
} elseif(defined('DOKU_MEDIADETAIL')) {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow');
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow');
}
// setup robot tags apropriate for different modes
if(($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) {
if($INFO['exists']) {
//delay indexing:
if((time() - $INFO['lastmod']) >= $conf['indexdelay'] && !isHiddenPage($ID) ) {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow');
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow');
}
$canonicalUrl = wl($ID, '', true, '&');
if ($ID == $conf['start']) {
$canonicalUrl = DOKU_URL;
}
$head['link'][] = array('rel'=> 'canonical', 'href'=> $canonicalUrl);
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,follow');
}
} elseif(defined('DOKU_MEDIADETAIL')) {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow');
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow');
}
// set metadata
if($ACT == 'show' || $ACT == 'export_xhtml') {
// keywords (explicit or implicit)
if(!empty($INFO['meta']['subject'])) {
$head['meta'][] = array('name'=> 'keywords', 'content'=> join(',', $INFO['meta']['subject']));
} else {
$head['meta'][] = array('name'=> 'keywords', 'content'=> str_replace(':', ',', $ID));
}
}
// set metadata
if($ACT == 'show' || $ACT == 'export_xhtml') {
// keywords (explicit or implicit)
if(!empty($INFO['meta']['subject'])) {
$head['meta'][] = array('name'=> 'keywords', 'content'=> join(',', $INFO['meta']['subject']));
} else {
$head['meta'][] = array('name'=> 'keywords', 'content'=> str_replace(':', ',', $ID));
}
}
// load stylesheets
$head['link'][] = array(
'rel' => 'stylesheet',
'href'=> DOKU_BASE . 'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed,
// load stylesheets
$head['link'][] = array(
'rel' => 'stylesheet',
'href'=> DOKU_BASE . 'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed,
'defer' => 'defer'
);
);
$script = "var NS='".(isset($INFO)?$INFO['namespace']:'')."';\n\t\t";
if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) {
$script .= "var SIG=".toolbar_signature().";\n\t\t";
}
$script = "var NS='".(isset($INFO)?$INFO['namespace']:'')."';".DOKU_LF.DOKU_TAB.DOKU_TAB;
if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) {
$script .= "var SIG=".toolbar_signature().";".DOKU_LF.DOKU_TAB.DOKU_TAB;
}
if($conf['basedir']) {
$script .= 'var BASEDIR="'.$conf['basedir']."\";\n\t\t";
}
if($conf['basedir']) {
$script .= 'var BASEDIR="'.$conf['basedir']."\";".DOKU_LF.DOKU_TAB.DOKU_TAB;
}
jsinfo();
$script .= 'var JSINFO = ' . json_encode($JSINFO).';';
$head['script'][] = array('_data'=> $script);
jsinfo();
$script .= 'var JSINFO = ' . json_encode($JSINFO).';';
$head['script'][] = array('_data'=> $script);
// load jquery
$jquery = getCdnUrls();
foreach($jquery as $src) {
$head['script'][] = array(
/* 'charset' => 'utf-8', -- obsolete */
'_data' => '',
'src' => $src,
) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
}
// load jquery
$jquery = getCdnUrls();
foreach($jquery as $src) {
$head['script'][] = array(
/* 'charset' => 'utf-8', -- obsolete */
'_data' => '',
'src' => $src,
) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
}
// load our javascript dispatcher
$head['script'][] = array(
/* 'charset'=> 'utf-8', -- obsolete */
// load our javascript dispatcher
$head['script'][] = array(
/* 'charset'=> 'utf-8', -- obsolete */
'_data'=> '',
'src' => DOKU_BASE . 'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed,
) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
'src' => DOKU_BASE . 'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed,
) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
// trigger event here
Event::createAndTrigger('TPL_METAHEADER_OUTPUT', $head, '_my_metaheaders_action', true);
return true;
// trigger event here
Event::createAndTrigger('TPL_METAHEADER_OUTPUT', $head, '_my_metaheaders_action', true);
return true;
}
/**
@ -227,23 +227,23 @@ function my_metaheaders($alt = true) {
* @param array $data
*/
function _my_metaheaders_action($data) {
foreach($data as $tag => $inst) {
foreach($inst as $attr) {
if ( empty($attr) ) { continue; }
echo "\t<", $tag, ' ', buildAttributes($attr);
if(isset($attr['_data']) || $tag == 'script') {
if($tag == 'script' && $attr['_data'])
$attr['_data'] = "/*<![CDATA[*/".
$attr['_data'].
"\n/*!]]>*/";
foreach($data as $tag => $inst) {
foreach($inst as $attr) {
if ( empty($attr) ) { continue; }
echo DOKU_TAB . '<', $tag, ' ', buildAttributes($attr);
if(isset($attr['_data']) || $tag == 'script') {
if($tag == 'script' && $attr['_data'])
$attr['_data'] = "/*<![CDATA[*/".NL. DOKU_TAB . DOKU_TAB .
$attr['_data'].
NL . DOKU_TAB . ' /*!]]>*/';
echo '>', $attr['_data'], '</', $tag, '>';
} else {
echo '/>';
}
echo "\n";
}
}
echo '>', $attr['_data'], '</', $tag, '>';
} else {
echo '/>';
}
echo DOKU_LF;
}
}
}
/**
@ -256,7 +256,7 @@ function _my_metaheaders_action($data) {
* @returns string (link)
*/
function my_homelink() {
global $conf;
global $conf;
$hl = trim(tpl_getConf('homelink'));
@ -280,27 +280,27 @@ function my_homelink() {
* @return void
*/
function my_breadcrumbs($prefix = '') {
global $lang;
global $conf;
global $lang;
global $conf;
//check if enabled
if(!$conf['breadcrumbs']) return false;
//check if enabled
if(!$conf['breadcrumbs']) return false;
$crumbs = breadcrumbs(); //setup crumb trace
$crumbs = breadcrumbs(); //setup crumb trace
/* begin listing */
echo $prefix . "<nav id=\"navBreadCrumbs\">\n";
echo $prefix . "\t<h4>" . $lang['breadcrumb'] . "</h4>\n";
echo $prefix . "\t<ol reversed>\n";
echo $prefix . '<nav id="navBreadCrumbs">'.NL;
echo $prefix . DOKU_TAB . '<h4>' . $lang['breadcrumb'] . '</h4>'.NL;
echo $prefix . DOKU_TAB . '<ol reversed>'.NL;
$last = count($crumbs);
$i = 0;
foreach($crumbs as $id => $name) {
$i++;
echo $prefix . "\t\t<li" . ($i == $last ? ' class="current"' : '') . '><bdi>' . tpl_link(wl($id), hsc($name), '', true) . "</bdi></li>\n";
}
echo $prefix . "\t</ol>\n";
echo $prefix . "</nav>\n";
$last = count($crumbs);
$i = 0;
foreach($crumbs as $id => $name) {
$i++;
echo $prefix . DOKU_TAB . DOKU_TAB . '<li' . ($i == $last ? ' class="current"' : '') . '><bdi>' . tpl_link(wl($id), hsc($name), '', true) . '</bdi></li>'.NL;
}
echo $prefix . DOKU_TAB . '</ol>'.NL;
echo $prefix . '</nav>'.NL;
}
/**
@ -318,58 +318,58 @@ function my_breadcrumbs($prefix = '') {
*
*/
function my_youarehere($prefix = '') {
global $conf;
global $ID;
global $lang;
global $conf;
global $ID;
global $lang;
// check if enabled
if(!$conf['youarehere']) return false;
// check if enabled
if(!$conf['youarehere']) return false;
$parts = explode(':', $ID);
$count = count($parts);
$parts = explode(':', $ID);
$count = count($parts);
$isdir = ( $parts[$count-1] == $conf['start']);
$hl = trim(tpl_getConf('homelink'));
echo $prefix . "<nav id=\"navYouAreHere\">\n";
echo $prefix . "\t<h4>" . $lang['youarehere'] . "</h4>\n";
echo $prefix . "\t<ol>\n";
echo $prefix . '<nav id="navYouAreHere">'.NL;
echo $prefix . DOKU_TAB . '<h4>' . $lang['youarehere'] . '</h4>'.NL;
echo $prefix . DOKU_TAB . '<ol>'.NL;
// always print the startpage
// always print the startpage
if ( $hl !== '' ) {
echo $prefix . "\t\t<li class=\"home\">" . tpl_link( $hl, htmlentities(tpl_getLang('homepage')), ' title="' . htmlentities(tpl_getLang('homepage')) . '"', true) . "</li>\n";
echo $prefix . "\t\t<li>" . tpl_pagelink(':'.$conf['start'], null, true) . "</li>\n";
echo $prefix . DOKU_TAB . DOKU_TAB . '<li class="home">' . tpl_link( $hl, htmlentities(tpl_getLang('homepage')), ' title="' . htmlentities(tpl_getLang('homepage')) . '"', true) . '</li>'.NL;
echo $prefix . DOKU_TAB . DOKU_TAB . '<li>' . tpl_pagelink(':'.$conf['start'], null, true) . '</li>'.NL;
} else {
echo $prefix . "\t\t<li class=\"home\">" . tpl_pagelink(':'.$conf['start'], null, true) . "</li>\n";
echo $prefix . DOKU_TAB . DOKU_TAB . '<li class="home">' . tpl_pagelink(':'.$conf['start'], null, true) . '</li>'.NL;
}
// print intermediate namespace links
$page = '';
for($i = 0; $i < $count - 1; $i++) {
$part = $parts[$i];
$page .= $part . ':';
// print intermediate namespace links
$page = '';
for($i = 0; $i < $count - 1; $i++) {
$part = $parts[$i];
$page .= $part . ':';
if ($i == $count-2 && $isdir) break; // Skip last if it is an index page
echo $prefix . "\t\t<li>" . tpl_pagelink($page, null, true) . "</li>\n";
}
echo $prefix . DOKU_TAB . DOKU_TAB . '<li>' . tpl_pagelink($page, null, true) . '</li>'.NL;
}
// chould the current page be included in the listing?
// chould the current page be included in the listing?
$trail = tpl_getConf('navtrail');
if ($trail !== 'none' && $trail !== '') {
echo $prefix . "\t\t<li class=\"current\">";
echo $prefix . DOKU_TAB . DOKU_TAB . '<li class="current">';
if ($trail == 'text') {
echo tpl_pagetitle($page . $parts[$count-1], true);
} else if ($trail == 'link') {
echo tpl_pagelink($page . $parts[$count-1], null, true);
}
echo "</li>\n";
echo '</li>'.NL;
}
echo $prefix . "\t</ol>\n";
echo $prefix . "</nav>\n";
echo $prefix . DOKU_TAB . '</ol>'.NL;
echo $prefix . '</nav>'.NL;
}
/**
@ -383,8 +383,8 @@ function my_youarehere($prefix = '') {
* @return void
*/
function my_userinfo($prefix = '') {
global $lang;
global $INPUT;
global $lang;
global $INPUT;
// add login/logout button:
$items = (new \dokuwiki\Menu\UserMenu())->getItems();
@ -395,13 +395,13 @@ function my_userinfo($prefix = '') {
echo $prefix . '<li class="action profile"><span class="sronly">' . $lang['loggedinas'] .
' </span><a href="' . htmlentities($it->getLink()) . '" title="' . $it->getTitle() . '">' .
userlink() . "</a></li>\n";
userlink() . "</a></li>".NL;
} else {
echo $prefix . "<li class=\"action $typ\"><a href=\"" . htmlentities($it->getLink()) .
echo $prefix . "<li class=\"action $typ\">" . '<a href="' . htmlentities($it->getLink()) .
'" title="' . $it->getTitle() . '">' . ($typ === 'profile'? userlink() : $it->getLabel() ) .
"</a></li>\n";
'</a></li>'.NL;
}
}
}
@ -419,43 +419,44 @@ function my_userinfo($prefix = '') {
* @return void
*/
function my_toc($prefix = '') {
global $TOC;
global $ACT;
global $ID;
global $REV;
global $INFO;
global $conf;
global $lang;
$toc = array();
global $TOC;
global $ACT;
global $ID;
global $REV;
global $INFO;
global $conf;
global $lang;
$toc = array();
if(is_array($TOC)) {
// if a TOC was prepared in global scope, always use it
$toc = $TOC;
} elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) {
// get TOC from metadata, render if neccessary
$meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE);
if(isset($meta['internal']['toc'])) {
$tocok = $meta['internal']['toc'];
} else {
$tocok = true;
}
$toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null;
if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) {
$toc = array();
}
} elseif($ACT == 'admin') {
// try to load admin plugin TOC
/** @var $plugin AdminPlugin */
if ($plugin = plugin_getRequestAdminPlugin()) {
$toc = $plugin->getTOC();
$TOC = $toc; // avoid later rebuild
}
}
if(is_array($TOC)) {
// if a TOC was prepared in global scope, always use it
$toc = $TOC;
} elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) {
// get TOC from metadata, render if neccessary
$meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE);
if(isset($meta['internal']['toc'])) {
$tocok = $meta['internal']['toc'];
} else {
$tocok = true;
}
$toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null;
if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) {
$toc = array();
}
} elseif($ACT == 'admin') {
// try to load admin plugin TOC
/** @var $plugin AdminPlugin */
if ($plugin = plugin_getRequestAdminPlugin()) {
$toc = $plugin->getTOC();
$TOC = $toc; // avoid later rebuild
}
}
/* Build the hierarchical list of headline links: */
if (count($toc) >= intval($conf['tocminheads'])) {
echo $prefix . "<aside id=\"toc\" class=\"toggle hide\">\n";
echo $prefix . "\t<button type=\"button\" id=\"toc-menubutton\" class=\"tg_button\" title=\"" . htmlentities($lang['toc']) . '" aria-haspopup="true" aria-controls="toc-menu"><span>' . htmlentities($lang['toc']) . "</span></button>\n" . $prefix . "\t<div id=\"toc-menu\" class=\"tg_content\" role=\"menu\" aria-labelledby=\"toc-menubutton\">";
echo $prefix . '<aside id="toc" class="toggle hide">'.NL;
echo $prefix . DOKU_TAB . '<button type="button" id="toc-menubutton" class="tg_button" title="' . htmlentities($lang['toc']) . '" aria-haspopup="true" aria-controls="toc-menu"><span>' . htmlentities($lang['toc']) . '</span></button>'.NL;
echo $prefix . DOKU_TAB . '<nav id="toc-menu" class="tg_content" role="menu" aria-labelledby="toc-menubutton">';
$level = 0;
foreach($toc as $it) {
@ -464,29 +465,34 @@ function my_toc($prefix = '') {
if ($cp > 0) {
while ($level < $nl) {
echo "\n" . $prefix . str_repeat("\t", $level*2 + 2) . "<ol>\n";
echo DOKU_LF . $prefix . str_repeat(DOKU_TAB, $level*2 + 2) . '<ol>'.NL;
$level++;
}
} else if ($cp < 0) {
while ($level > $nl) {
echo "\n" . $prefix . str_repeat("\t", $level*2) . "</ol>\n" . $prefix . str_repeat("\t", $level*2-1) . "</li>\n";
echo DOKU_LF . $prefix . str_repeat(DOKU_TAB, $level*2) . '</ol>'.NL;
echo $prefix . str_repeat(DOKU_TAB, $level*2-1) . '</li>'.NL;
$level--;
}
} else {
echo "</li>\n";
echo '</li>'.NL;
}
$href = ( array_key_exists('link', $it ) ? $it['link'] : '' ) . ( array_key_exists('hid', $it) && $it['hid'] !== '' ? '#' . $it['hid'] : '' );
echo $prefix . str_repeat("\t", $nl*2 + 1) . '<li role="presentation"><a role="menuitem" href="' . $href . '">' . htmlentities($it['title']) . "</a>";
echo $prefix . str_repeat(DOKU_TAB, $nl*2 + 1) . '<li role="presentation">' . "<a role=\"menuitem\" href=\"{$href}\">" . htmlentities($it['title']) . '</a>';
$level = $nl;
}
for ($i = $level-1; $i > 0; $i--) {
echo "</li>\n" . $prefix . str_repeat("\t", $i*2 + 1) . "</ol>";
echo '</li>'.NL;
echo $prefix . str_repeat(DOKU_TAB, $i*2 + 1) . '</ol>';
}
echo "</li>\n" . $prefix . "\t\t</ol>\n" . $prefix . "\t</div>\n" . $prefix . "</aside>\n";
echo '</li>'.NL;
echo $prefix . DOKU_TAB . DOKU_TAB . '</ol>'.NL;
echo $prefix . DOKU_TAB . '</nav>'.NL;
echo $prefix . '</aside>'.NL;
}
}
@ -501,9 +507,9 @@ function my_toc($prefix = '') {
*/
function my_lastchange($prefix = '') {
global $lang;
global $INFO;
global $conf;
global $lang;
global $INFO;
global $conf;
$lastmod = $INFO['lastmod'];
@ -511,14 +517,14 @@ function my_lastchange($prefix = '') {
$longDate = htmlentities(dformat($lastmod));
echo $prefix . "<p class=\"docInfo\">\n";
echo $prefix . "\t<bdi>" . $lang['lastmod'] . "</bdi>\n";
echo $prefix . "\t<time datetime=\"" . date('c', $lastmod) . '" title="' . $longDate . '"><span class="print-only">' . $longDate . '</span><span class="noprint">' . datetime_h($lastmod) . "</span></time>\n";
echo $prefix . "</p>\n";
echo $prefix . '<p class="docInfo">'.NL;
echo $prefix . DOKU_TAB . '<bdi>' . $lang['lastmod'] . '</bdi>'.NL;
echo $prefix . DOKU_TAB . '<time datetime="' . date('c', $lastmod) . '" title="' . $longDate . '"><span class="print-only">' . $longDate . '</span><span class="noprint">' . datetime_h($lastmod) . "</span></time>".NL;
echo $prefix . '</p>'.NL;
}
/* user name for last change (is this really interesting to the visitor?) */
/* echo $prefix .'<span class="editorname" tabindex="0">' . $lang['by'] . ' <bdi>' . editorinfo($INFO['editor']) . "</bdi></span>\n"; */
/* echo $prefix .'<span class="editorname" tabindex="0">' . $lang['by'] . ' <bdi>' . editorinfo($INFO['editor']) . '</bdi></span>'.NL; */
}
/**
@ -527,24 +533,24 @@ function my_lastchange($prefix = '') {
* @return string html of description list
*/
function my_img_meta($prefix = '') {
global $lang;
global $lang;
$format = '%Y-%m-%dT%T%z'; /* e.g. 2021-21-05T16:45:12+02:00 */
$tags = tpl_get_img_meta();
$tags = tpl_get_img_meta();
foreach($tags as $tag) {
$label = $lang[$tag['langkey']];
if(!$label) $label = $tag['langkey'] . ':';
foreach($tags as $tag) {
$label = $lang[$tag['langkey']];
if(!$label) $label = $tag['langkey'] . ':';
echo $prefix . '<tr><th>'.$label.'</th><td>';
if ($tag['type'] == 'date') {
echo '<time datetime="' . strftime($format, $tag['value']) . '">' . dformat($tag['value']) . '</time>';
} else {
echo hsc($tag['value']);
}
echo "</td></tr>\n";
}
echo $prefix . "<tr><th>{$label}</th><td>";
if ($tag['type'] == 'date') {
echo '<time datetime="' . strftime($format, $tag['value']) . '">' . dformat($tag['value']) . '</time>';
} else {
echo hsc($tag['value']);
}
echo '</td></tr>'.NL;
}
}
/**
@ -552,13 +558,13 @@ function my_img_meta($prefix = '') {
*
*/
function my_sitelogo() {
global $conf;
global $conf;
// get logo either out of the template images folder or data/media folder
$logoSize = array();
$logo = tpl_getMediaFile(array(':logo.svg', ':wiki:logo.svg', ':logo.png', ':wiki:logo.png', 'images/sitelogo.svg'), false, $logoSize);
tpl_link( my_homelink(),
'<img src="'.$logo.'" ' . (is_array($logoSize) && array_key_exists(3, $logoSize) ? $logoSize[3] : '') . ' alt="' . htmlentities($conf['title']) . '" />', 'accesskey="h" title="[H]" class="logo"');
"<img src=\"{$logo}\" " . (is_array($logoSize) && array_key_exists(3, $logoSize) ? $logoSize[3] : '') . ' alt="' . htmlentities($conf['title']) . '" />', 'accesskey="h" title="[H]" class="logo"');
}
/**
@ -583,16 +589,16 @@ function my_favicons($color = null) {
if ($color== null) { $color = '#2b73b7'; }
}
echo "\t<meta name=\"theme-color\" content=\"" . $color . "\" />\n"; */
echo DOKU_TAB . "<meta name=\"theme-color\" content=\"" . $color . "\" />".NL; */
// get the favicon:
$link = tpl_getMediaFile(array(':favicon.ico', ':favicon.png', ':favicon.svg', ':wiki:favicon.ico', ':wiki:favicon.png', ':wiki:favicon.svg'), false, $logoSize);
echo "\t<link rel=\"icon\" href=\"" . $link . "\" />\n";
echo DOKU_TAB . "<link rel=\"icon\" href=\"{$link}\" />".NL;
// Apple Touch Icon
$logoSize = array();
$link = tpl_getMediaFile(array(':apple-touch-icon.png', ':wiki:apple-touch-icon.png', 'images/apple-touch-icon.png'), false, $logoSize);
echo "\t<link rel=\"apple-touch-icon\" href=\"" . $link . "\" />\n";
echo DOKU_TAB . "<link rel=\"apple-touch-icon\" href=\"{$link}\" />".NL;
}
@ -614,20 +620,25 @@ function my_cookiebanner($prefix = '') {
return;
}
// define the cookie icon:
$svg = '<svg width="100%" height="100%" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><path d="M17.272,19.443c6.035,-0.582 10.759,-5.673 10.759,-11.858c-0,-1.843 -0.42,-3.588 -1.168,-5.146c1.668,-0.289 3.385,-0.439 5.137,-0.439c16.557,-0 30,13.443 30,30c0,16.557 -13.443,30 -30,30c-16.557,-0 -30,-13.443 -30,-30c0,-0.925 0.042,-1.84 0.124,-2.743c1.061,0.31 2.183,0.476 3.345,0.476c6.025,0 11.011,-4.482 11.803,-10.29Z" style="fill:#d5944b;stroke:#26251d;stroke-width:4px;"/><circle cx="17.927" cy="41.07" r="3.488" style="fill:#443017;"/><circle cx="31.33" cy="30.835" r="3.488" style="fill:#443017;"/><circle cx="32" cy="49.883" r="3.488" style="fill:#443017;"/><circle cx="43.952" cy="41.07" r="3.488" style="fill:#443017;"/><circle cx="49.092" cy="27.347" r="3.488" style="fill:#443017;"/><circle cx="38.306" cy="16.056" r="3.488" style="fill:#443017;"/></svg>';
// output the HTML code:
echo $prefix . "<div id=\"cookiebanner\" class=\"cb_" . $position . "\">\n";
echo $prefix . "\t<p class=\"cb_info\"><span class=\"cb_icon\"></span>\n";
echo $prefix . "\t\t<span class=\"cb_msg\">". $msg . "</span>\r";
echo $prefix . "\t</p>\n";
echo $prefix . "\t<p class=\"cb_action\">\n";
echo $prefix . "\t\t<button>" . hsc(tpl_getLang('cookie_consent')) . "</button>\n";
echo $prefix . "\t\t";
echo $prefix . "<div id=\"cookiebanner\" class=\"cb_{$position}\">".NL;
echo $prefix . DOKU_TAB . '<p class="cb_info">'.NL;
echo $prefix . DOKU_TAB . DOKU_TAB . "<span class=\"cb_icon\">{$svg}</span>".NL;
echo $prefix . DOKU_TAB . DOKU_TAB . "<span class=\"cb_msg\">{$msg}</span>".NL;
echo $prefix . DOKU_TAB . '</p>'.NL;
echo $prefix . DOKU_TAB . '<p class="cb_action">'.NL;
echo $prefix . DOKU_TAB . DOKU_TAB . '<button>' . hsc(tpl_getLang('cookie_consent')) . '</button>'.NL;
echo $prefix . DOKU_TAB . DOKU_TAB;
if ( substr($link, 0, 7) == 'http://' || substr($link, 0, 8) == 'https://') {
echo '<a href="' . $link . '" target="_blank">' . hsc(tpl_getLang('cookie_linktext')) . '</a>';
echo "<a href=\"{$link}\" target=\"_blank\">" . hsc(tpl_getLang('cookie_linktext')) . '</a>';
} else {
tpl_pagelink($link, tpl_getLang('cookie_linktext'));
}
echo $prefix . "\n\t</p>\n" . $prefix . "</div>\n";
echo $prefix . DOKU_LF . DOKU_TAB.'</p>'.NL;
echo $prefix . '</div>'.NL;
}
@ -671,7 +682,7 @@ function my_langmenu($prefix, $place, $checkage = true) {
$asMenu = ($place == 'tb'); // display as menu only in toolbar!
$out .= "{$prefix}<div id=\"{$place}Languages\">\n";
$out .= $prefix . "<div id=\"{$place}Languages\">".NL;
// create the header item
@ -684,9 +695,10 @@ function my_langmenu($prefix, $place, $checkage = true) {
$svg = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><title>{$langName}</title><path d='M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4C22,2.89 21.1,2 20,2Z' /><text lengthAdjust='spacingAndGlyphs' x='50%' y='47%' dominant-baseline='middle' text-anchor='middle' style='font-size:50%'>{$lang}</text></svg>";
// prepare the menu button:
$out .= "{$prefix}\t<button id=\"langButton\" aria-haspopup=\"menu\" aria-controls=\"langMenuWrapper\" aria-expanded=\"false\">\n";
$out .= "{$prefix}\t\t{$svg}\n";
$out .= "{$prefix}\t\t<span class=\"sronly\">" . $trans->getLang('translations') . "</span>\n{$prefix}\t</button>\n";
$out .= $prefix . DOKU_TAB . '<button id="langButton" aria-haspopup="menu" aria-controls="langMenuWrapper" aria-expanded="false">'.NL;
$out .= $prefix . DOKU_TAB . DOKU_TAB . $svg . NL;
$out .= $prefix . DOKU_TAB . DOKU_TAB . '<span class="sronly">' . $trans->getLang('translations') . '</span>'.NL;
$out .= $prefix . DOKU_TAB . '</button>'.NL;
} else { // show as list (sidebar)
@ -709,13 +721,13 @@ function my_langmenu($prefix, $place, $checkage = true) {
$headline = html_wikilink($about, $headline);
}
/* complete the headline */
$out .= "{$prefix}\t<h3><span>" . $headline . "</span></h3>\n";
$out .= $prefix . DOKU_TAB . "<h3><span>{$headline}</span></h3>".NL;
}
}
/* build the menu content */
$out .= "{$prefix}\t<div id=\"langMenu" . ( $asMenu ? 'Wrapper" role="menu" style="display: none"' : 'List"') . ">\n"
. "{$prefix}\t\t<ul id=\"lang" . ( $asMenu ? 'Menu" role="group"' : 'List"' ) . ">\n";
$out .= $prefix . DOKU_TAB . '<div id="langMenu' . ( $asMenu ? 'Wrapper" role="menu" style="display: none"' : 'List"') . '>'.NL;
$out .= $prefix . DOKU_TAB . DOKU_TAB . '<ul id="lang' . ( $asMenu ? 'Menu" role="group"' : 'List"' ) . '>'.NL;
// loop over each language and add it to the menu:
foreach ($trans->translations as $t) {
@ -732,16 +744,16 @@ function my_langmenu($prefix, $place, $checkage = true) {
$link = wl($trg);
$current = ($lng == $lang);
$out .= "{$prefix}\t\t\t<li" . ( $asMenu ? ' role="presentation"' : '' ). ( $current ? ' class="current"' : '' ) . ">\n";
$out .= "{$prefix}\t\t\t\t<a href=\"{$link}\" lang=\"{$lng}\" hreflang=\"{$lng}\" class=\"{$class}\"" . ( $asMenu ? ' role="menuitem"' : '' ) . '><bdi>'. $trans->getLocalName($lng) . "</bdi></a>\n";
$out .= "{$prefix}\t\t\t</li>\n";
$out .= $prefix . DOKU_TAB . DOKU_TAB . DOKU_TAB .'<li' . ( $asMenu ? ' role="presentation"' : '' ). ( $current ? ' class="current"' : '' ) . '>'.NL;
$out .= $prefix . DOKU_TAB . DOKU_TAB . DOKU_TAB . DOKU_TAB . "<a href=\"{$link}\" lang=\"{$lng}\" hreflang=\"{$lng}\" class=\"{$class}\"" . ( $asMenu ? ' role="menuitem"' : '' ) . '><bdi>'. $trans->getLocalName($lng) . '</bdi></a>'.NL;
$out .= $prefix . DOKU_TAB . DOKU_TAB . DOKU_TAB . '</li>'.NL;
}
}
// close all open elements:
$out .= "{$prefix}\t\t</ul>\n"
. "{$prefix}\t</div>\n"
. "{$prefix}</div>\n";
$out .= $prefix . DOKU_TAB . DOKU_TAB . '</ul>'.NL
. $prefix . DOKU_TAB . '</div>'.NL
. $prefix . '</div>'.NL;
}
echo $out; // done.
}