[pmwiki] Re: [Pmwiki-users] broken wiki links on home page fer an instalaltion

Patrick R. Michaud pmichaud at pobox.com
Fri Jun 20 10:17:36 CDT 2003


On Thu, Jun 19, 2003 at 12:27:24AM +0200, Bernhard.Weichel at t-online.de wrote:
> 
> There is UrlFmt, but at many places, the url syntax is hardwired. So what
> about to provide a function that does the url formatting. [...]
> This function should generate appropriate urls such that it would never be
> necessary to write in a php script things like
>   <a href='\$ScriptUrl?action=search&amp;text=\$Title_'>\$Title</a>
>one couuld write instead
>   <a href='".FormatUrl($Group.$Title, "search",
>     "text=\$Title_")."'>\$Title</a>

Eek, that's liable to scare a few people off--I much prefer the
syntax of the first string than the one with the function call embedded in
it (this is why I created FmtPageName in the first place).  Plus, the
problem with the function call approach is that the function gets called
when the string is being stored into a variable, whereas we really need to
have the substitutions performed when the variable is being output
(i.e., when we know the actual page names and values that need to be
substituted).

However, I think the hardwired url syntax only presents a problem when 
$ScriptUrl is being followed by a pagename that goes into PATH_INFO.  
Thus, the query string you gave in the example above isn't really a problem,
but it would be for something like 
  <a href='$PageUrl?action=diff'>Diff</a>
and
  <a href='$ScriptUrl/$Group/$Title_?action=diff'>Diff</a>

So, I have an alternate solution.  Instead of creating another special 
function call to replace what FmtPageName is trying to do in the first
place, I've simply modified FmtPageName to allow some last-minute rewriting
of any string containing '$ScriptUrl/' to put the pagename component into
QUERY_STRING instead of PATH_INFO and fix any other query parameters
appropriately.

By default pmwiki.php does the same as it always has--putting page names
into PATH_INFO.  To have PmWiki use query strings instead of PATH_INFO, set
   $EnablePathInfo = 0;
in local.php.  This is now in pmwiki-0.5.4 (just released).

At the moment the code for converting '$ScriptUrl/' is hardwired in
FmtPageName.  If someone needs the conversion itself to be customizable, 
I can arrange it.

Finally, note that very little of the URL syntax is actually "hardwired".
I think there's only two places (in pmwiki.php:HandleDiff and 
upload.php:FmtAttachLink) where the URL syntax is currently fixed by 
the code--all of the other URLs are controlled by configurable variables.
However, I'll grant that reassigning all of those variables could be
a pain to manage, which is why I've gone the $ScriptUrl/ replacement
route.  :-)

Pm




More information about the pmwiki-users mailing list