Please see SVN Access for information regarding DokuWiki projects.
Your Donations help keep my Software going!

Talk:Projects:Display Wiki Page for DokuWiki

Start all subtopics with H2.

ACL Issues

Here's the latest in the ACL permissions saga…

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. I had started a thread a few days back:

http://www.freelists.org/archives/dokuwiki/02-2007/msg00134.html

I've not seen any replies yet, however, once this is figured out, the problem with ACL will go away. — Terence J. Grant 02/15/2007 19:26

"[edit]" tag

Good work, I like your work very much.
Small but annoying issue : In my wiki Navigation and Copyright both bear the ”[edit]” tag in the lower right corner for all users (functionality only for me via ACL-settings). Any ideas to hide the ”[edit]” tag for all who are not entitled to edit? Klaus03.14.2007

Hello; unfortunately this is related to the “ACL Issues” topic above… fundamentally there's a problem with DokuWiki's authentication that's yet to be solved by the author. The only way to hide “edit” from guests is to make your default in ACL to read only. — Terence J. Grant 03/14/2007 07:04

Needs Perms

This plugin should support read permissions to only display the navigation menu for logged in users if that's how you have your wiki set up. I added this by putting in a check like this:
if($perm >= AUTH_READ)
{
  tpl_content();
}

Good idea, added. — Terence J. Grant 11/18/2006 01:22

First, thanks for your job. Monobook is a very good template, and the best I found for my wiki and my needs. But here come the (little) bad news : I have a problem with auth system for the navigation page. The page is readable by anyone, but the root domain (*) is not. And when I'm not logged in, the navigation frame tells me I don't have access to the page, whereas I can read it through the site map. I use the latest versions of monobook and display wiki page. In addition, please note that after a few changes to ACL conf, things work perfectly (instead of blocking access to all by default, I only do that for some subdomains), so I just report the bug. — Marc A. 12/18/2006 00:56

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 . '&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'];
}
?>

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 . '&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'];
}

FP


Personal Tools