Wedge

Public area => Off-topic => The Pub => Other software => Topic started by: live627 on March 10th, 2012, 08:00 AM

Title: [live627's rants] These trees are [not] simple
Post by: live627 on March 10th, 2012, 08:00 AM
So I needed to get a subset of boards in a category, so I decided to use the data generated by getBoardList(). I've used this function before,, and iterating through $boardList is a snap, so, why not try $boards? It's... a... mess! Much harder to iterate through properly than expected. Not only is the code inside the function confusing, but scanning the output is also confusing!

I suspect that the code dates way back, to 1.0 probably, or even YABBSE.

Seriously, why all thee node subarrays and duplications? It's enough to spend an entire evening just staring and figuring out what the hell it does![1]

And children aren't consistent with graandchildren, either. The former is under 'tree' while the latter isn't. What's the big deal? Either put 'em all under the extra item, or  don't... quite simple, really.
 1. That's where my evening went, in case it wasn't obvious. Add this to an unusually rough day with a headache to boot, yeah, I'm pissed.
Title: Re: [live627's rants] These trees are [not] simple
Post by: Arantor on March 10th, 2012, 11:09 AM
Which one, exactly, are you looking at? getBoardList() in Subs-MessageIndex.php is rather simple to use, and I'm guessing you mean getBoardIndex() which is an utter mess?
Title: Re: [live627's rants] These trees are [not] simple
Post by: live627 on March 11th, 2012, 01:05 AM
getBoard... Tree. Silly me, got it wrong :P
Title: Re: [live627's rants] These trees are [not] simple
Post by: Arantor on March 11th, 2012, 01:06 AM
At a glance, getBoardTree looks reasonably sane?
Title: Re: [live627's rants] These trees are [not] simple
Post by: live627 on March 11th, 2012, 02:48 AM
Here's my code.
Code: [Select]
<?php template_edit_profile_league__r(array($boards[$context['d_board']]));

function 
template_edit_profile_league__r($boards)
{
foreach ($boards as $board)
{
if (isset($board['node']['id']))
$b $board['node'];
else
$b $board;

echo '
<div><input type="text" name="boards['
$b['id'], ']"style="margin-left: ', (($b['level'] * 1.5) + 0.5), 'em;"  value="'$b['name'], '"></div>';

if (!empty($board['tree']['children']))
template_edit_profile_league__r($board['tree']['children']);

if (!empty($board['children']))
template_edit_profile_league__r($board['children']);
}
?>
Title: Re: [live627's rants] These trees are [not] simple
Post by: Arantor on March 11th, 2012, 01:19 PM
I don't see anything wrong with that?