-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathfooter.php
More file actions
134 lines (115 loc) · 4.77 KB
/
footer.php
File metadata and controls
134 lines (115 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
use dokuwiki\Extension\SyntaxPlugin;
/**
* Include plugin (footer component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Klier <chi@chimeric.de>
*/
class syntax_plugin_include_footer extends SyntaxPlugin
{
public function getType()
{
return 'formatting';
}
public function getSort()
{
return 300;
}
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
}
/**
* Renders a permalink header.
*
* Code heavily copied from the header renderer from inc/parser/xhtml.php, just
* added an href parameter to the anchor tag linking to the wikilink.
*/
public function render($mode, Doku_Renderer $renderer, $data)
{
[$page, $sect, $sect_title, $flags, $redirect_id, $footer_lvl] = $data;
if ($mode == 'xhtml') {
$renderer->doc .= $this->html_footer($page, $sect, $sect_title, $flags, $footer_lvl, $renderer);
return true;
}
return false;
}
/**
* Returns the meta line below the included page
* @param $renderer Doku_Renderer_xhtml The (xhtml) renderer
* @return string The HTML code of the footer
*/
public function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer)
{
global $conf, $ID;
if (!$flags['footer']) return '';
$meta = p_get_metadata($page);
$exists = page_exists($page);
$xhtml = [];
// permalink
if ($flags['permalink']) {
$class = ($exists ? 'wikilink1' : 'wikilink2');
$url = ($sect) ? wl($page) . '#' . $sect : wl($page);
$name = ($sect) ? $sect_title : $page;
$title = ($sect) ? $page . '#' . $sect : $page;
if (!$title) $title = str_replace('_', ' ', noNS($page));
$link = ['url' => $url, 'title' => $title, 'name' => $name, 'target' => $conf['target']['wiki'], 'class' => $class . ' permalink', 'more' => 'rel="bookmark"'];
$xhtml[] = $renderer->_formatLink($link);
}
// date
if ($flags['date'] && $exists) {
$date = $meta['date']['created'];
if ($date) {
$xhtml[] = '<abbr class="published" title="' . dformat($date, '%Y-%m-%dT%H:%M:%SZ') . '">'
. dformat($date)
. '</abbr>';
}
}
// modified date
if ($flags['mdate'] && $exists) {
$mdate = $meta['date']['modified'];
if ($mdate) {
$xhtml[] = '<abbr class="published" title="' . dformat($mdate, '%Y-%m-%dT%H:%M:%SZ') . '">'
. dformat($mdate)
. '</abbr>';
}
}
// author
if ($flags['user'] && $exists) {
$author = $meta['user'];
if ($author) {
if (function_exists('userlink')) {
$xhtml[] = '<span class="vcard author">' . userlink($author) . '</span>';
} else { // DokuWiki versions < 2014-05-05 doesn't have userlink support, fall back to not providing a link
$xhtml[] = '<span class="vcard author">' . editorinfo($author) . '</span>';
}
}
}
// comments - let Discussion Plugin do the work for us
if (empty($sect) && $flags['comments'] && (!plugin_isdisabled('discussion')) && ($discussion = plugin_load('helper', 'discussion'))) {
$disc = $discussion->td($page);
if ($disc) $xhtml[] = '<span class="comment">' . $disc . '</span>';
}
// linkbacks - let Linkback Plugin do the work for us
if (empty($sect) && $flags['linkbacks'] && (!plugin_isdisabled('linkback')) && ($linkback = plugin_load('helper', 'linkback'))) {
$link = $linkback->td($page);
if ($link) $xhtml[] = '<span class="linkback">' . $link . '</span>';
}
$xhtml = implode(DOKU_LF . DOKU_TAB . '· ', $xhtml);
// tags - let Tag Plugin do the work for us
if (empty($sect) && $flags['tags'] && (!plugin_isdisabled('tag')) && ($tag = plugin_load('helper', 'tag'))) {
$tags = $tag->td($page);
if ($tags) {
$xhtml .= '<div class="tags"><span>' . DOKU_LF
. DOKU_TAB . $tags . DOKU_LF
. DOKU_TAB . '</span></div>' . DOKU_LF;
}
}
if (!$xhtml) $xhtml = ' ';
$class = 'inclmeta';
$class .= ' level' . $footer_lvl;
return '<div class="' . $class . '">' . DOKU_LF . DOKU_TAB . $xhtml . DOKU_LF . '</div>' . DOKU_LF;
}
}
// vim:ts=4:sw=4:et: