Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Modified plugins

andjar edited this page May 4, 2020 · 5 revisions

Modifications

Include backlinks in the include plugin

The include plugin does not support including backlinks out of the box. Two modifications were made:

In incude.php I have added this on line 15

$this->Lexer->addSpecialPattern("{{blinks>.+?}}", $mode, 'plugin_include_include');

Secondly, in helper.php (line 715) I have added

case 'blinks':
            $page = $this->_apply_macro($page, $parent_id);
            resolve_pageid(getNS($parent_id), $page, $exists);
            @require_once(DOKU_INC.'inc/fulltext.php');
            $pagearrays = ft_backlinks($page,true);
            $this->taghelper =& plugin_load('helper', 'tag');
            $tags = $this->taghelper->getTopic(getNS($parent_id), null, $sect);
            foreach ($tags as $tag){
                $tagss[] = $tag['id'];
            }
            if(!empty($pagearrays)){
                foreach ($pagearrays as $pagearray) {
                    if(in_array($pagearray,$tagss)){
                        $pages[] = $pagearray;
                    }
                }
            }else{
                $pages[] = 'notes:dummy';
            }
            break;

In sum, these allows you to to use "blinks" in the same way as "tagtopic" or "namespace". The syntax is

{{blinks>[pagename]#[includetag]&[flags]}}

Only pages in the current namespace tagged with [includetag] are included. The tag is to avoid recursion, and it may be a bad idea having the same tag on the backlinks and the page containing the include. Eg., you should only use the tag note on notes, an notetopic on note topics and only include those with tag note in the note topics. If there are no backlinks yet, notes:dummy is included.

Include specified WRAP sections

Now you can use the include plugin to transclude only text within a specified WRAP element.

{{WRAP>[pageid]#[WRAP class]&[flags]}}

will transclude all text within <WRAP [WRAP class]> in [pageid]. You may have several instances of WRAP;

<WRAP test>
Some text
</WRAP>
with some text in between
<WRAP test>
before a list

  * a
  * b

</WRAP>

will be displayed as

Some text
before a list

  * a
  * b

Allow wikification of hidden fields in the bureaucracy plugin

To make the note field in the sidebar properly link back to the page from which the note was made, I added a hidden field. However, we need the bureaucracy plugin to render the content of the hidden field as wikitext. In fieldhidden.php (line 28):

$tlp = $this->getParam('value');
       $ins = array_slice(p_get_instructions($tlp), 2, -2);
       $tlp = p_render('xhtml', $ins, $byref_ignore);
       $form->addHidden($params['name'], $tlp. '');

Make the bureaucracy plugin redirect you

The bureaucracy plugin usually shows you a thank you page with a link to the new page, which adds an extra click. Now, you are redirected directly to the new page. On line 364 in helper/actiontemplate.php I have added:

$html = '<meta http-equiv="refresh" content="0; URL=' . "'" . 'doku.php?id=' . ($pages[0]) . "'" . '" />';

and much of the buildThankYouPage function can be removed.

Customize the links in the monthcal plugin

We want the links in the monthcal plugin to apply specific templates for dates and for months. This we can do by exploiting the newpagetemplate plugin.

Line 332 in syntax.php:

$id = $data['namespace'] . ':' . $date->format('Y') . $date->format('m') . $date->format('d');
			$linkstring = '&newpagetemplate=journal:tmplt&newpagevars=@tododate@%2C'.$date->format('Y') . '-' . $date->format('m') . '-' . $date->format('d');

and line 345:

$html_day = '<a href="' . wl($id) . $linkstring . '">' . $date->format('d') . '</a>';

To make a new calendar view, we edit line 280:

$html .= html_wikilink($data['namespace'] . ':' . $date_prev_month->format('Y') . $date_prev_month->format('m') . ':', '<<');
$html .= html_wikilink($data['namespace'] . ':' . $date_next_month->format('Y') . $date_next_month->format('m') . ':', '>>');

bibtexbrowser.php

We need to allow for .txt files, so edit line 327 to

if (BIBTEXBROWSER_LOCAL_BIB_ONLY && (!file_exists($bib) || strcasecmp($ext, 'bib') != 0 || strcasecmp($ext, 'txt') != 0)) {

Also, we want to show the key (line 94);

@define('ABBRV_TYPE','key');// may be year/x-abbrv/key/none/index/keys-index

Keep the sidebar when editor is open

To keep the sidebar visible when in editing mode, set return to true in lib/tpl/bootstrap3/Template.php line 615:

case 'showSidebar':

                if ($ACT !== 'show') {
                    return true;
                }