Table of Contents
Display Wiki Page for DokuWiki
License
- Author: Terence J. Grant
- License: GNU GPL v2
- Donate: Click here.
Download
Before downloading or using this product, make sure you understand and accept the terms of the license.
After downloading, make sure to follow the install instructions or upgrading instructions below; trust me, they're worth reading.
- This is the latest version, compatible with The Latest DokuWiki:
- Latest Version: displaywikipage-stable.tar.gz
- Older downloads are available on request only.
Note: http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-displaywikipage/displaywikipage-stable.tar.gz always points to the latest stable version!
Installation
Use the plugin manager to install, or…
- download the tarball/zip-file
- unpack it into
<dokuwiki>/lib/plugins/
- login as admin and change the plugin in the configuration manager
using git:
% cd <dokuwiki>/lib/plugins/ % git clone git://github.com/tatewake/dokuwiki-plugin-displaywikipage.git displaywikipage
Debian install (or probably any other distribution):
# cd /usr/share/dokuwiki/lib/plugins/ # wget http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-displaywikipage/displaywikipage-stable.tar.gz # tar -xvzf displaywikipage-stable.tar.gz # chown -Rv 33 displaywikipage/
Note: http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-displaywikipage/displaywikipage-stable.tar.gz always points to the latest stable version!
About
This plugin defines an additional template function such that you can display more than one wiki page at a time on any given document.
The plugin also exports a function for use with your template, so you will have to insert the following code into your template, somewhere inside of the <head></head> tags.
Typically you'll want to do this for any PHP (or HTML) files containing the string “<head>”; at a minimum you can do just main.php.1)
<?php if (file_exists(DOKU_PLUGIN.'displaywikipage/code.php')) include_once(DOKU_PLUGIN.'displaywikipage/code.php'); ?>
Note: Inserting the code above is required, not optional.
To display a wiki page at any point in your document, use the following code:
<?php if (function_exists('dwp_display_wiki_page')) dwp_display_wiki_page(":path:to:page"); ?>
Doing it in this fashion will allow your users to use the template whether or not you have the plugin installed.
Upgrading
To upgrade, remove the original lib/plugins/displaywikipage folder, and install the new version as instructed above.
What's New
Sep 19, 2020
- Updated release with nicer documentation and code cleanup
May 28, 2009
- A work-around to the ACL issue has been implemented, thanks to an anonymous contributor.
Apparently auth_aclquickcheck can't handle leading colons in IDs– so I feel this is still broken in DokuWiki, but at least the plugin can honor ACL properly.
February 15, 2007
- Cleaner rewrite, but nothing new otherwise.
The problem regarding ACL is something broken in the DokuWiki source; it's nothing on my end. I've reported it, and there's not much else I can do from here.
November 18, 2006
- Display Wiki Page now honors page permissions for read. Thanks anonymous.
August 23, 2006
- Initial release
Sites using this plugin
List your site here if you wish!
Discussion
Start all subtopics with H2.
Is it possible to remove Edit button?
I love this for adding a copyright notice and header notice to existing dokuwiki template. However, it is obtrusive because it adds a blank line then another “EDIT” button (if the user has editing privileges). Is it possible to remove the EDIT button and minimize the space around the included wiki page?
Thanks!
— lenehey 2022-10-03 23:24
Recursive stuff
As written on monobook discussion, I added this feature, I changed code.php a bit to reach this:
<?php /** * Display Wiki Page for DokuWiki * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Etienne Gauthier, Terence J. Grant<tjgrant@tatewake.com> */ /* Etienne Gauthier, 23/04/2006 Function that get a wiki page (to insert into into a bar, for instance) All Wiki parameters are first 'backup', to totally separate the rendering of the sidebar, and the display of the main content. Martin Schleyer, 29/11/2006 Added recursive search, thanks to Christopher Smith and his sidebar template for nice a function :) Credits for dwp_display_wiki_page_getFN: * @link http://wiki.jalakai.co.uk/dokuwiki/doku.php?id=tutorials:dev:navigation_sidebar * @author Christopher Smith <chris@jalakai.co.uk> */ function dwp_display_wiki_page_getFN($ns, $file) { // check for wiki page = $ns:$file (or $file where no namespace) $nsFile = ($ns) ? "$ns:$file" : $file; if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) return $nsFile; // remove deepest namespace level and call function recursively // no namespace left, exit with empty if (!$ns) return ''; $i = strrpos($ns, ":"); $ns = ($i) ? substr($ns, 0, $i) : false; return dwp_display_wiki_page_getFN($ns, $file); } function dwp_display_wiki_page ($wikipagename, $checkrecursive = false) { global $ID; global $REV; global $ACT; global $IDX; global $DATE; global $RANGE; global $HIGH; global $TEXT; global $PRE; global $SUF; global $SUM; global $lang; global $_SERVER; // Save the configuration for the current page: $backup['ID'] = $ID; $backup['REV'] = $REV; $backup['ACT'] = $ACT; $backup['IDX'] = $IDX; $backup['INFO'] = $INFO; $backup['DATE'] = $DATE; $backup['RANGE'] = $RANGE; $backup['HIGH'] = $HIGH; $backup['TEXT'] = $TEXT; $backup['PRE'] = $PRE; $backup['SUF'] = $SUF; $backup['SUM'] = $SUM; if (!$checkrecursive) { $ID = $wikipagename; } else { $i = strrpos($wikipagename, ":"); // finds pagename in wikipage to display $j = strrpos($backup['ID'], ":"); // finds complete namespace in surrounding wiki page $ID = dwp_display_wiki_page_getFN(($j) ? substr($backup['ID'], 0, $j) : $wikipagename, ($i) ? substr($wikipagename, $i + 1) : $wikipagename); // gets the page, checking recursive from namespace in // surrounding wiki page to root if($ID == '') { $ID = $wikipagename; } // if not found use complete path of wikipage to display // -> adds backwards compatibility } $ACT = 'show'; $REV = ''; $IDX = ''; $DATE = ''; $RANGE = ''; $HIGH = ''; $TEXT = ''; $PRE = ''; $SUF = ''; $SUM = ''; //Check the user's rights ont the sidebar page. if($_SERVER['REMOTE_USER']) $perm = auth_quickaclcheck($ID); else $perm = auth_aclcheck($ID,'',null); //Use of wiki content : if this page exists, else we do nothing (the Edit link will be there, it's enough). $file = wikiFN($ID); if (@file_exists($file)) { if($perm >= AUTH_READ) //11-18-2006 User must have proper permissions. (Anonymous contribution.) { tpl_content(); } //Add the edit link, for this page. if($perm >= AUTH_EDIT) { echo '<div class="secedit2"><a href="' . DOKU_BASE . 'doku.php?id=' . $ID . '&do=edit&rev=' . $_REQUEST['rev'] . '">' . $lang['btn_secedit'] . '</a></div>'; } } else { //Add the create link, for this page. if($perm >= AUTH_EDIT) { echo '<div class="secedit2"><a href="' . DOKU_BASE . 'doku.php?id=' . $ID . '&do=edit&rev=' . $_REQUEST['rev'] . '">' . $lang['btn_create'] . '</a></div>'; } } //Rest ore previous value for $ID and $ACT. $ID = $backup['ID']; $REV = $backup['REV']; $ACT = $backup['ACT']; $IDX = $backup['IDX']; $INFO = $backup['INFO']; $DATE = $backup['DATE']; $RANGE = $backup['RANGE']; $HIGH = $backup['HIGH']; $TEXT = $backup['TEXT']; $PRE = $backup['PRE']; $SUF = $backup['SUF']; $SUM = $backup['SUM']; } ?>
I also added ?>
at the end to avoid whitespace problems somewhere, or did it have a special reason which I didn't see?
— Martin Schleyer 11/29/2006 13:46
To make displaywikipage working with the last DokuWiki, I change code.php like this (might broke something, but it seems to work.
<?php /** * Display Wiki Page for DokuWiki * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Etienne Gauthier, Terence J. Grant<tjgrant@tatewake.com> */ /* History... Etienne Gauthier, 04/23/2006 - Initial version Terence J. Grant, 02/14/2007 - Rewrite */ function dwp_display_wiki_page($wikipagename) { global $conf, $lang; global $auth; global $ID, $REV; //save status $backup['ID'] = $ID; $backup['REV'] = $REV; $result = ''; //Check user permissions... $perm = auth_quickaclcheck($ID); if(@file_exists(wikiFN($wikipagename))) { //check page permissions if ($perm >= AUTH_READ) { $result = p_wiki_xhtml($wikipagename,'',false); if ($perm >= AUTH_EDIT) { // create and add the 'edit' button $result .='<div class="secedit2"><a href="' . DOKU_BASE . 'doku.php?id=' . $wikipagename . '&do=edit' . '">' . $lang['btn_secedit'] . '</a></div>'; } } else //show access denied { $result = '<b>Access Denied</b>'; } } else { if ($perm >= AUTH_CREATE) { // create and add the 'create' button $result .='<div class="secedit2"><a href="' . DOKU_BASE . 'doku.php?id=' . $wikipagename . '&do=edit' . '">' . $lang['btn_create'] . '</a></div>'; } } //display page with edits echo $result; //restore status $ID = $backup['ID']; $REV = $backup['REV']; }