- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
public static function getTree($version, $lang = 'en')
{
$pt_root = KbTree::findOne(($version == 'pt2') ?
KbTree::NODE_PT2 : KbTree::NODE_PT3);
$list = $pt_root
->children()
->andWhere(['root' => ($version == 'pt2') ? KbTree::NODE_PT2 : KbTree::NODE_PT3])
->andWhere(['visible' => 1, 'pub' => 1])
->orderBy('lft ASC')
->all();
$tree = [$pt_root->id => []];
$currentLevel = 1;
$levelsIds[$currentLevel] = $pt_root->id;
$dic = [];
foreach($list as $key => $_node)
{
if(isset($_node->level, $_node->id))
{
$dic[$_node->id][] = $_node->getTranslateMessage($lang);
$dic[$_node->id][] = $_node->getFullAlias();
$currentLevel = $_node->level;
switch($_node->level) {
case 2:
$tree[$levelsIds[1]][$_node->id] = [];
break;
case 3:
$tree[$levelsIds[1]][$levelsIds[2]][$_node->id] = [];
break;
case 4:
$tree[$levelsIds[1]][$levelsIds[2]][$levelsIds[3]][$_node->id] = [];
break;
case 5:
$tree[$levelsIds[1]][$levelsIds[2]][$levelsIds[3]][$levelsIds[4]][$_node->id] = [];
break;
case 6:
$tree[$levelsIds[1]][$levelsIds[2]][$levelsIds[3]][$levelsIds[4]][$levelsIds[5]][$_node->id] = [];
break;
}
$levelsIds[$currentLevel] = $_node->id;
}
}
return [$tree[$pt_root->id], $dic];
}
bot 29.08.2016 17:52 # 0
Analotolievich 30.08.2016 21:09 # 0
void_main 30.08.2016 21:13 # −9
ponchic 29.08.2016 18:49 # 0
guest 30.08.2016 11:38 # −17
roman-kashitsyn 30.08.2016 12:52 # +4
Сеньёр бы до 10 уровня проверил, а тут только до 6. Так что миддл.
3_14dar 30.08.2016 18:17 # −12
void_main 30.08.2016 18:27 # −9
guesto 30.08.2016 18:35 # −12
void_main 30.08.2016 18:37 # −8
myaut 30.08.2016 11:50 # 0
Recursion unrolling?
guest 21.04.2017 15:02 # −17