Ok, I've been looking at this Kevin, and while one fix is easy, it
opens up a can with a couple other worms. Here's the scoop (that is,
I'm just thinking out loud at this point...):
First, the domarkup function has this line:
if ($zone != '' && $zone != 'SKIN') $out = $out . "\n\n";
You'll see the \n\n used to generate paragraph tags are blocked by
$zone being set to '' or SKIN. When the BOLTdisplayTemplate calls the
domarkup function, it sets the zone to the current zone, which causes
the \n\n to be inserted.
Easy solution: go through the BOLTdisplayTemplate (engine.php 666+)
and change the $zone parameters in the various domarkup function calls
to ''. Problem solved. To make it even easier, we could change the
SKIN call to '' and then just have this in domarkup:
if ($zone != '') $out = $out . "\n\n";
However, what if I want to know the $zone? Perhaps I have a custom
function used in a search template that displays output differently in
the side bar vs the main zone? So my next thought was how about this:
if ($zone == strtolower($zone)) $out = $out . "\n\n";
Then SKIN is ok, and I could do strtoupper($zone) in the
displayTemplate function. So I'd have access to the zone, just upper
case.
But then after some fiddling around I noticed the $zone variable is
not really available anyway. I have it passed to about a half dozen
markup rules as a parameter, (mostly to the functions) but it is never
used anywhere in the core. I was just thinking it might be useful info
for a custom script. So how do we get it to pass properly? If I
change the top few lines of domarkup to this we can get it to work:
function BOLTdomarkup($content, $page='', $zone='', $rules='',
$replace=true, $escape='') {
global $MarkUpTable, $BOLTrules, $Token, $BOLTvar, $pageLink,
$BOLTstripTags, $BOLTmsgOut, $lastquery, $query, $BOLTzone;
$BOLTzone = $zone;
Then we have a global $BOLTzone variable to your functions. Of course
this means all those $zone='' parameters in the various functions are
irrelevant, likewise the markup rules with a zone parameter. And they
should be scrapped. And if I use the lowercase test for adding \n\n I
need to check there are no domarkup functions that pass a '' zone
parameter. Well, perhaps I could just leave both checks in for now...
Ok, so that's the plan.
1) Add the global $BOLTzone to the domarkup function.
2) Use this line as the test for adding \n\n
if ($zone != '' && $zone == strtolower($zone)) $out = $out . "\n\n";
3) I left all the $zone parameters in the displayTemplate calls to
domarkup, but added this line around 688. This way I get the zone, but
not \n\n.
$zone = strtoupper($zone);
4) Now I'm going through and stripping out the $zone markups out of
the markup rules, and the various markup functions that use them.
5) Actually, just added global $BOLTzone to BOLTMfunc and changed
$zone to strtolower($BOLTzone) in the last line, and that now works!
6) Similarly, fixed the BOLTMrules by using the global BOLTzones.
There was one slight problem with all this fixing I encountered.
Currently the BOLTvars function takes a $zone variable as the second
parameter, but it is nonfunctional and only used for system/zone
variables (bet you didn't even know those were possible). So
logically, that parameter should be replaced with a call to the
global, and the $auth parameter bumped up to second place. But this
could break functions that use the $auth function. In all the core,
there are 27 calls to BOLTvars, and only 2 (both in the BOLTXlogin
function) use it. They are easy enough to change. But I'm concerned
there may be custom plugins out there that will be affected. However,
I don't see any way quite around it.
There is another problem I anticipate. Suppose you are in the main
zone and you have a function using the $BOLTzone variable. But there
is a search function or something that changes the zone... Then
because it is global you have a problem... We could perhaps do
$BOLTzone = strotolower($zone); at the end of BOLTdomarkup. Or store
the previous value in a temp location. That would restore it. And
there's no reason I can't pass strtolower($zone) out of the BOLTMfunc
function... So we get nice zone behavior in functions, as expected.
For that matter, we need to make sure we use strtolower in the
BOLTvars and BOLTMrules functions or we could miss the zone in a
search template. Ok, it's all coming together now. And working on my
system. At least on every test I can come up with.
Kind of a quirky solution to a very simple problem, but I prefer the
idea of fixing it properly and not losing functionality of zone
specific behavior, even if it is not currently being used to my
knowledge, and it didn't work like it was supposed to anyway before.
The only disadvantage is plugins might break that rely on the $auth
parameter in the BOLTvars function to bypass permissions for special
purposes. All this will be in the next release.
Cheers,
Dan