[pmwiki-users] Misc Questions on FAST Data...
The Editor
editor at fast.st
Mon Sep 11 10:38:17 CDT 2006
I'm doing some rewrite of FAST Data to add various new features and
fix a few small bugs. Here are a couple initial (simple?) questions I
could not seem to solve, and would appreciate some help with.
1) Format used for WritePage().
I'm trying to use writepage to save the data, (instead of my own
getpage/setpage functions, which use fread/fwrite) and have it near
working with these lines:
$page = ReadPage($d);
$page['text'] = $contents;
Lock(2);
WritePage($d, $page);
Lock(0);
The problem is $contents is already encoded with things like %0a,
etc., just like it looks when it is already saved. So when I view
the page I see the raw text string, not what I want. What kind of
formatting should I use when I create $contents? The same markup I
would use when editing the page manually? Can I use \n for line
breaks? Right now the code manually inserts %0a%0a between each set of
data values.
2) How do I return a single line break?
I use the following code to construct a log entry based on the values
of specified fields the recipe is told to save. So far I've been
unable to find anyway to insert a single linebreak between feild
values, when the word "Break" is listed as a field name. I've tried
several possibilities including "\\" "\n" and "[<<]" but nothing seems
to work. "\\" gets changed to \/\/ or something. Any suggestions?
foreach ($d as $f => $v) {
$vv = str_replace($r1, $r2, $_POST[$v]);
if ($v == "Break") $newlog .= "[<<]";
$newlog .= "$vv %0a";
}
This problem may be solved by changing to WritePage, which might then
allow a simple "\\" for the line break.
3) I still have the problem of various characters like -'- being
return -/'- when they are displayed, and not sure how to fix it. The
process is, the field values in the form are saved doing the following
encoding:
$r1 = array('%',"\n", '<');
$r2 = array('%25','%0a','%3c');
$vv = str_replace($r1, $r2, $_POST[$v]);
then they are retrieved (set as page variables) with these lines:
$r1 = array('%',"\n");
$r2 = array('%25','%0a');
foreach ($field as $value) {
$v = explode ("=", $value);
$v[1] = stripslashes("$v[1]");
$v[1] = str_replace($r2, $r1, $v[1]);
if ($v[0] != "") $FmtPV["$$v[0]"] = $v[1];
}
I was told there was a function like PRR() and also the function
stripmagic(), but not sure exactly where to use these or how.
I'm doing some major updates to the recipe, and hope to have a beta
for 2.0 functioning in a few days. May have more questions, but
appreciate any help so far with these longstanding little bugs.
Cheers,
Caveman
More information about the pmwiki-users
mailing list