00906: pagelist's #titlespaced broken; {=$Titlespaced} not being called/processed
Description: I updated to beta 39 tonight and it seems that {} is being parsed out of things too soon; I am unsure of this at this time;
Regardless of the cause If you do a pagelist and use #titlespaced the
is NOT called; Usage of $Titlespaced elsewhere seems fine as before.
$AsSpacedFunction
I can dig up version info if wanted; (same as previous entries)
Found where... Line 534 of scripts/pagelist.php
## handle (:template defaults:) $i = 0; while ($i < count($tparts)) { if ($tparts[$i] != 'template') { $i++; continue; } if ($tparts[$i+1] != 'defaults') { $i+=4; continue; } $opt = array_merge(ParseArgs($tparts[$i+2], $PageListArgPattern), $opt); array_splice($tparts, $i, 3); }
At least, rememing that out results in apparent proper action ;)
Perhaps more to the point; If the above is unremed (i.e. untouched) and the following is added just after:
if($opt['fmt'] == '#titlespaced') { // $opt['order']= '-title'; // no work // $opt['order']= 'title'; // no work $opt['order']= ''; // works // $opt['order']= '-name'; // works // $opt['order']= 'name'; //works // $opt['order']= '-group'; // works // $opt['order']= 'group'; // works }
Well, as the comments say, an order of title does not seem to work;
Am I missing something?
From what I can tell the ordering of 'title
' and all still work fine; It's the display that is messed up. An given that the display part has had a large change (diffed below), that is where I am going to point my finger, albeit I have yet to understand this section ;)
--- beta 37, I am pretty sure things worked here; +++ beta 39, things seem broken here. @@ -524,30 +563,61 @@ $vk = array_keys($pseudovars); $vv = array_values($pseudovars); $lgroup = ''; $out = ''; foreach($matches as $i => $pn) { - $prev = (string)@$matches[$i-1]; - $next = (string)@$matches[$i+1]; - $Cursor['<'] = $Cursor['<'] = $prev; - $Cursor['='] = $pn; - $Cursor['>'] = $Cursor['>'] = $next; $group = PageVar($pn, '$Group'); - if ($group != $lgroup) { $groupcount++; $grouppagecount = 0; } + if ($group != $lgroup) { $groupcount++; $grouppagecount = 0; $lgroup = $group; } $grouppagecount++; $pagecount++; - $item = str_replace($vk, $vv, $ttext); - $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', - "PVSE(PageVar(\$pn, '$2', '$1'))", $item); - $out .= MarkupRestore($item); - $lgroup = $group; + $t = 0; + while ($t < count($tparts)) { + if ($tparts[$t] != 'template') { $item = $tparts[$t]; $t++; } + else { + list($when, $control, $item) = array_slice($tparts, $t+1, 3); $t+=4; + if (!$control) { + if ($when == 'first' && $i != 0) continue; + if ($when == 'last' && $i != count($matches) - 1) continue; + } else { + if ($when == 'first' || !isset($last[$t])) { + $Cursor['<'] = $Cursor['<'] = (string)@$matches[$i-1]; + $Cursor['='] = $pn; + $Cursor['>'] = $Cursor['>'] = (string)@$matches[$i+1]; + $curr = str_replace($vk, $vv, $control); + $curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', + "PageVar(\$pn, '$2', '$1')", $curr); + if ($when == 'first' && $i > 0 && $last[$t] == $curr) continue; + $last[$t] = $curr; + } + if ($when == 'last') { + $Cursor['<'] = $Cursor['<'] = $pn; + $Cursor['='] = (string)@$matches[$i+1]; + $Cursor['>'] = $Cursor['>'] = (string)@$matches[$i+2]; + $next = str_replace($vk, $vv, $control); + $next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', + "PageVar(\$pn, '$2', '$1')", $next); + if ($next == $last[$t] && $i != count($matches) - 1) continue; + $last[$t] = $next; + } + } + } + $Cursor['<'] = $Cursor['<'] = (string)@$matches[$i-1]; + $Cursor['='] = $pn; + $Cursor['>'] = $Cursor['>'] = (string)@$matches[$i+1]; + $item = str_replace($vk, $vv, $item); + $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', + "PVSE(PageVar(\$pn, '$2', '$1'))", $item); + $out .= MarkupRestore($item); + } } $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']); $div = ($class) ? "<div class='$class'>" : '<div>'; $out = $div.MarkupToHTML($pagename, $out, array('escape' => 0)).'</div>'; + $Cursor = $savecursor; StopWatch("FPLTemplate end"); return $out; }
I am getting rather confused :P
As near as I can tell the data going into:
$item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '$2', '$1'))", $item);
Is the same when order!='title', i.e. when it works, as when order='title', i.e. when it does not.
Meh, I don't know any more :P
All I can say is an order of title
or -title
seems to break something; *shrug*
You're correct, there was a bug in the handling of order=title in the pagelist code. In fact, I don't know why #titlespaced ever worked (but obviously it used to). It's fixed now for beta40, thanks!
Pm