_xmlEntities($text) . '" level="' . ($bookmarklevel) . '" />';
}
// print header
$this->doc .= DOKU_LF . "$bookmark";
$this->doc .= $header_prefix."";
$this->doc .= $this->_xmlEntities($text);
$this->doc .= "";
$this->doc .= "" . DOKU_LF;
$this->previous_level = $level;
}
/**
* Bookmark levels might increase maximal +1 per level.
* (note: levels start at 1, bookmarklevels at 0)
*
* @param int $level 1 (highest) to 6 (lowest)
* @return int
*/
protected function calculateBookmarklevel($level) {
if($this->lastHeaderLevel == -1) {
$this->lastHeaderLevel = $level;
}
$step = $level - $this->lastHeaderLevel;
if($step > 1) {
$this->difference = $this->difference + ($step - 1);
}
if($step < 0) {
$this->difference = min($this->difference, $level - $this->originalHeaderLevel);
$this->difference = max($this->difference, 0);
}
$bookmarklevel = $level - $this->difference;
if($step > 1) {
$this->originalHeaderLevel = $bookmarklevel;
}
$this->lastHeaderLevel = $level;
return $bookmarklevel - 1; //zero indexed
}
/**
* Render a page local link
*
* // modified copy of parent function
*
* @param string $hash hash link identifier
* @param string $name name for the link
* @param bool $returnonly
* @return string|void
*
* @see Doku_Renderer_xhtml::locallink
*/
function locallink($hash, $name = null, $returnonly = false) {
global $ID;
$name = $this->_getLinkTitle($name, $hash, $isImage);
$hash = $this->_headerToLink($hash);
$title = $ID . ' ↵';
$check = false;
$pid = sectionID($ID, $check);
$this->doc .= '';
$this->doc .= $name;
$this->doc .= '';
}
/**
* Wrap centered media in a div to center it
*
* @param string $src media ID
* @param string $title descriptive text
* @param string $align left|center|right
* @param int $width width of media in pixel
* @param int $height height of media in pixel
* @param string $cache cache|recache|nocache
* @param bool $render should the media be embedded inline or just linked
* @return string
*/
function _media($src, $title = NULL, $align = NULL, $width = NULL,
$height = NULL, $cache = NULL, $render = true) {
$out = '';
if($align == 'center') {
$out .= '';
}
$out .= parent::_media($src, $title, $align, $width, $height, $cache, $render);
if($align == 'center') {
$out .= '
';
}
return $out;
}
/**
* hover info makes no sense in PDFs, so drop acronyms
*
* @param string $acronym
*/
function acronym($acronym) {
$this->doc .= $this->_xmlEntities($acronym);
}
/**
* reformat links if needed
*
* @param array $link
* @return string
*/
function _formatLink($link) {
// for internal links contains the title the pageid
if(in_array($link['title'], $this->actioninstance->getExportedPages())) {
list(/* $url */, $hash) = explode('#', $link['url'], 2);
$check = false;
$pid = sectionID($link['title'], $check);
$link['url'] = "#" . $pid . '__' . $hash;
}
// prefix interwiki links with interwiki icon
if($link['name'][0] != '<' && preg_match('/\binterwiki iw_(.\w+)\b/', $link['class'], $m)) {
if(file_exists(DOKU_INC . 'lib/images/interwiki/' . $m[1] . '.png')) {
$img = DOKU_BASE . 'lib/images/interwiki/' . $m[1] . '.png';
} elseif(file_exists(DOKU_INC . 'lib/images/interwiki/' . $m[1] . '.gif')) {
$img = DOKU_BASE . 'lib/images/interwiki/' . $m[1] . '.gif';
} else {
$img = DOKU_BASE . 'lib/images/interwiki.png';
}
$link['name'] = '
' . $link['name'];
}
return parent::_formatLink($link);
}
/**
* no obfuscation for email addresses
*
* @param string $address
* @param null $name
* @param bool $returnonly
* @return string|void
*/
function emaillink($address, $name = NULL, $returnonly = false) {
global $conf;
$old = $conf['mailguard'];
$conf['mailguard'] = 'none';
parent::emaillink($address, $name, $returnonly);
$conf['mailguard'] = $old;
}
}