[pmwiki-users] Action to list pages in group

Jeremy Sproat sproaticus at gmail.com
Thu Sep 22 08:32:02 CDT 2005

I'm playing with the TinyMCE editor, which lets you plug in a
DHTML-based file browser for creating hyperlinks.  Such a browser
would depend on the server providing a list of pages, hence this
recipe.  I hope to eventually work one into the RichEdit recipe.

I'm very new to PHP (most of my experience is in Java and Perl), and
even newer to writing code for PmWiki, so I'd like a critique and/or
suggestions based on what I've gotten so far.

This action simply lists the pages in the current page group in plain
text format, one entry per line.  The idea is that the browser-side
javascript picks up this list via XMLHttpRequest and presents it to a
user who wants to create a link to an existing page.

One of the problems I'm facing is I'm not sure how to pass arguments
to an action.  For example, if I wanted to alternatively list pages in
the current group or all pages in the wiki - could I pass an argument
as a request parameter, or should I define separate actions for the
different behaviors?

Another possible issue is security - it's possible that a wiki admin
may not want all the page names exposed to anyone who knows the
?action=listgrouppages URL.  Is there anything special I need to do to
the action to prevent this, or is this all handled in config.php using
the $DefaultPasswords array?


p.s. Here's the action's code:

<?php if (!defined('PmWiki')) exit();

# parts ripped from pagelist.php


function HandleListGroupPages($pagename) {
  header('Content-type: text/plain');
  SDVA($FPLByGroupOpt, array('readf' => 0, 'order' => 'name'));
  $thisgroup = FmtPageName('$Group', $pagename);
  $matches = MakePageList($pagename,$FPLByGroupOpt);
  foreach($matches as $pc) {
    if( FmtPageName('$Group', $pc['pagename']) == $thisgroup )
      print( FmtPageName('$Group.$Name', $pc['pagename']) . "\n" );

More information about the pmwiki-users mailing list