From: Dan F <dfr...@cs...> - 2004-03-16 16:29:41
|
Folks, Again, thanks for PhpWiki. Here is another patch (from 1.3.7 more or less) to support an "initial_content" argument to my CreatePage plug-in. This is so that I can put a "CreatePage" button on a category page that creates another page that already has example text (the "initial_content" parameter) to refer to the category. I'm not sure if this is the right place to post patches; please give me more info on this. In particular, I changed WikiPlugin->expandArg() so that it allows quoting (via ~) of "[Restaurant]" (which would normally be evaluated to the "Restaurant" arg of a request, which probably doesn't exist). This allows me to put sufficient ~s in front of "[Restaurant]" to allow it to pass through multiple layers of expansion (one ~ dissappears through each layer). I hope changes such as these can be accepted into the codebase. Thanks for your attention. Dan -- Dan Frankowski dfr...@cs... 612-626-8396 Patches for support of CreatePage with initial content: cvs diff -u -b lib/editpage.php Index: lib/editpage.php =================================================================== RCS file: /project/Grouplens/cvs-repository/phpwiki/lib/editpage.php,v retrieving revision 1.1.1.1 diff -u -b -r1.1.1.1 editpage.php --- lib/editpage.php 29 Jan 2004 14:30:27 -0000 1.1.1.1 +++ lib/editpage.php 12 Mar 2004 22:13:18 -0000 @@ -42,6 +42,13 @@ else { $this->_initializeState(); $this->_initialEdit = true; + + $initial_content = $request->getArg('initial_content'); + if ($initial_content) { + // The edit request has specified some initial content for + // the page if it doesn't exist. Use that content. + $this->_content = $initial_content; + } } header("Content-Type: text/html; charset=" . CHARSET); % cvs diff -u -b lib/WikiPlugin.php Index: lib/WikiPlugin.php =================================================================== RCS file: /project/Grouplens/cvs-repository/phpwiki/lib/WikiPlugin.php,v retrieving revision 1.1.1.1 diff -u -b -r1.1.1.1 WikiPlugin.php --- lib/WikiPlugin.php 29 Jan 2004 14:30:27 -0000 1.1.1.1 +++ lib/WikiPlugin.php 16 Mar 2004 16:12:01 -0000 @@ -121,9 +121,13 @@ return $args; } + // Expand [arg] to $request->getArg("arg") unless preceded by ~ function expandArg($argval, $request) { - return preg_replace('/\[(\w[\w\d]*)\]/e', '$request->getArg("$1")', + // Replace the arg unless it is preceded by a ~ + $ret = preg_replace('/[^~]\[(\w[\w\d]*)\]/e', '$request->getArg("$1")', $argval); + // Ditch the ~ so later versions can be expanded if desired + return preg_replace('/~(\[\w[\w\d]*\])/', '$1', $ret); } function parseArgStr($argstr) { |