DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:displaywikipage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
plugin:displaywikipage [2009-08-11 07:38]
tatewake moved from "display_wiki_page"
plugin:displaywikipage [2020-09-19 11:41] (current)
tjgrant@tatewake.com
Line 1: Line 1:
 ====== Display Wiki Page for DokuWiki ====== ====== Display Wiki Page for DokuWiki ======
 +
 +
  
 ---- plugin ---- ---- plugin ----
-description: This plugin defines an additional template function such that you can display more than one wiki page at a time on any given document. (This is the sidebar/side bar plugin!)+description: Plugin that defines an additional template function such that you can display more than one wiki page at a time on any given document.
 author     : Terence J. Grant author     : Terence J. Grant
 email      : tjgrant@tatewake.com email      : tjgrant@tatewake.com
 type       : admin type       : admin
-lastupdate : 2007-02-15 +lastupdate : 2020-09-19 
-compatible : 2006-03-09+compatible : 2020-07-29 "Hogfather", 2018-04-22 "Greebo", 2017-02-19 "Frusterick Manners", 2016-06-26 "Elenor Of Tsort"
 depends    :  depends    : 
 conflicts  conflicts 
 similar    : include, sidebar similar    : include, sidebar
 tags       : sidebar, include tags       : sidebar, include
 +
 +downloadurl: https://github.com/tatewake/dokuwiki-plugin-displaywikipage/archive/master.zip
 +bugtracker: https://github.com/tatewake/dokuwiki-plugin-displaywikipage/issues
 +sourcerepo: https://github.com/tatewake/dokuwiki-plugin-displaywikipage
 ---- ----
  
-[[http://tatewake.com/wiki/projects:display_wiki_page_for_dokuwiki|Details and Download]]+===== License ===== 
 + 
 +  * **Author:** [[tjgrant@tatewake.com|Terence J. Grant]] 
 +  * **License:** [[http://www.opensource.org/licenses/gpl-license.php|GNU GPL v2]] 
 +  * **Donate:** [[https://www.paypal.com/xclick/business=tjgrant%40tatewake.com&item_name=Display%20wiki%20page%20for%20DokuWiki%20Donation&no_shipping=1&no_note=1&tax=0&currency_code=USD&lc=US|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: {{http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-displaywikipage/displaywikipage-stable.tar.gz}} 
 +    * Github URL:  [[https://github.com/tatewake/dokuwiki-plugin-displaywikipage]] 
 + 
 +  * 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:**\\ 
 +<code> 
 +% cd <dokuwiki>/lib/plugins/ 
 +% git clone git://github.com/tatewake/dokuwiki-plugin-displaywikipage.git displaywikipage 
 +</code> 
 + 
 +**Debian install (or probably any other distribution):** 
 +<code> 
 +# 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/ 
 +</code> 
 + 
 +**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.((If you only do main.php though you'll miss some types of pages (like upload file), so I suggest searching for head tags through all the PHP files in a template to make sure you get them all.)) 
 + 
 +<code php> 
 +<?php if (file_exists(DOKU_PLUGIN.'displaywikipage/code.php')) include_once(DOKU_PLUGIN.'displaywikipage/code.php'); ?> 
 +</code> 
 + 
 +**Note**: Inserting the code above is **required**, not optional. 
 + 
 +To display a wiki page at any point in your document, use the following code: 
 + 
 +<code php> 
 +<?php if (function_exists('dwp_display_wiki_page')) dwp_display_wiki_page(":path:to:page"); ?> 
 +</code> 
 + 
 +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 ===== ===== Discussion =====
  
-Please use the [[http://tatewake.com/wiki/talk:projects:display_wiki_page_for_dokuwiki|discussion page]] for this plugin.+**Start all subtopics with H2.** 
 +===== Recursive stuff ==== 
 + 
 +As written on monobook discussion, I added this feature, I changed code.php a bit to reach this: 
 +<code php> 
 +<?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 . '&amp;do=edit&amp;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 . '&amp;do=edit&amp;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']; 
 +
 +?> 
 +</code> 
 + 
 +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. 
 +<code php> 
 +<?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 . '&amp;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 . '&amp;do=edit' 
 + . '">' . $lang['btn_create'] . '</a></div>'; 
 +
 +
 + 
 + //display page with edits 
 + echo $result; 
 + 
 + //restore status 
 + $ID = $backup['ID']; 
 + $REV = $backup['REV']; 
 +
 +</code> 
plugin/displaywikipage.1249969098.txt.gz · Last modified: 2009-08-11 07:38 by tatewake