-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.php
executable file
·91 lines (62 loc) · 2.09 KB
/
renderer.php
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
<?php
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
// we inherit from the XHTML renderer instead directly of the base renderer
require_once DOKU_INC.'inc/parser/xhtml.php';
require_once DOKU_INC.'inc/pageutils.php';
class renderer_plugin_driver extends Doku_Renderer_xhtml {
var $hasContent = false; // used to check if a section has content, or if its just a heading.
var $sectionCount = 0; // section counter to re-use "edit button" event callbacks
var $sectionTitle = ""; // section title to use on "like" onclick callback.
function getInfo(){
return confToHash(dirname(__FILE__).'/README');
}
function getFormat(){
return 'xhtml';
}
function canRender($format) {
return ($format=='xhtml');
}
function header($text, $level, $pos) {
parent::header($text, $level, $pos);
global $sectionTitle;
if (!$text) {
$sectionTitle = "";
return;
}
$sectionTitle = $text;
}
function section_open($level) {
parent::section_open($level);
global $sectionCount;
global $hasContent;
$hasContent = false;
$sectionCount++;
}
function cdata($text) {
parent::cdata($text);
global $hasContent;
$hasContent = true;
}
function section_close() {
global $sectionCount;
global $hasContent;
global $sectionTitle;
global $ID;
// I want to do this
// Only if in "trail" (learning) mode
session_start();
//error_log("section_close on ".$ID." isTrailing: ".print_r(isset($_SESSION[DOKU_COOKIE]['isTrailing']),true));
if (isset($_SESSION[DOKU_COOKIE]['isTrailing'])) {
if (($hasContent) && ($sectionCount != 1)) //first section means the entire page: ignore! Let _addJump handle that!
{
$this->doc .= DOKU_LF.'<div class=\'secedit editbutton_'.$sectionCount.'\'><form class=\'button btn_secedit\'>';
$this->doc .= '<a href="#" class="likeLink" onclick="driver_addSectionJump(\''.$sectionTitle.'\');return false;">';
$this->doc .= 'Like</a></form></div>';
}
}
// parent code
parent::section_close();
//$this->doc .= DOKU_LF.'</div>'.DOKU_LF;
}
}