[pmwiki-users] Markup Processing Order

The Editor editor at fast.st
Sun Aug 20 18:41:56 CDT 2006


Thanks again Patrick, but I'm getting tired of both chicken and eggs!

I tried setting $pagename as a global variable but it seemed to make
no difference. It still blanks out the value.

I also tried commenting out the preg_replace call and added PRR();
instead, just before the recipe returns (oh, and switched processing
order to '>{$var}').  This seemed to process properly (no error
messages, indicating it read the write page and may have set the page
variables), but the Page Variables all came up blank.

According to the documentation I could find,  PRR() "simply increments
the global $RedoMarkupLine variable, which tells the markup engine to
begin reprocessing the CURRENT STRING (line) from the beginning of the
markup translation table."

Does this mean it will only redo the current line of wiki code?  The
data read function is supposed to set page variables that can be used
anywhere on the page.  Unless PRR reprocesses the whole wiki page, I
don't think it will work for us.

Which means we would be left trying to debug why option two is not
working. How can we get the $Name variable into the recipe before page
variables are processed? I still have a few hairs left I haven't
pulled out yet.

Cheers,
Caveman


PS: Here's the full function again...

# Directive to retrieve data from another page
Markup('fastdata', '<{$var}', '/\(:data(.*?):\)/ei', "ReadData('$1')");

# Function called by directive to retrieve form data
function ReadData($l) {
	global $WorkDir, $FmtPV, $pagename;
	$l = substr($l, 1);
	$l = preg_replace('/\\{(!?[-\\w.\\/]*)(\\$\\w+)\\}/e',
	    "htmlspecialchars(PageVar(\$pagename, '$2', '$1'), ENT_NOQUOTES)");
	$datapage = $l;
	if (substr($datapage, 0, 4) != "Data") {
		return "invalid data parameter";
		}
	clearstatcache();
	if ($dr = fopen("$WorkDir/$datapage", "rb")){
		$pc = fread($dr, filesize("$WorkDir/$datapage"));
		fclose($dr);
		$dc = explode("(:comment data:) %0a%0a", $pc);
		$db = explode(" %0a%0a", $dc[1]);
		$i = 0;
		while ($i < count($db)-1) {
			$dv = explode ("=", $db[$i]);
			$FmtPV["$$dv[0]"] = stripslashes("$dv[1]");
			$i = $i + 1;
			}
//		PRR();
		return;
		}
	return "data not found";
}




More information about the pmwiki-users mailing list