private static function _getBoardArrayTree($parentId = 0, $level = 0) { $ret = []; $dataList = Board::findAll(['parent_id' => $parentId], 'sort_num desc'); if ($dataList == null || empty($dataList)) { return $ret; } foreach ($dataList as $key => $value) { $value->level = $level; $ret[] = $value; $temp = self::_getBoardArrayTree($value['id'], $level + 1); $ret = array_merge($ret, $temp); } return $ret; }
public function buildSubBoards($id = 0, $parentName = '子板块') { $subBoards = Board::findAll(['parent_id' => $id], 'sort_num desc'); $totalRecords = count($subBoards); if ($totalRecords == 0) { return; } $html = ''; $parentBoard = $this->getCachedBoards()[$id]; $columnsCount = intval($parentBoard['columns']); if ($parentName == null) { $parentName = $parentBoard['name']; } $html .= '<div class="tbox border">'; $html .= '<div class="hd" style="border-bottom:none;"><h2>' . $parentName . '</h2></div>'; $html .= '<table class="table" style="margin-bottom:0px;">'; if ($columnsCount > 1) { $html .= $this->getMoreColumn($subBoards, $totalRecords, $columnsCount); } else { $html .= $this->getOneColumn($subBoards, $totalRecords); } $html .= '</table>'; $html .= '</div>'; return $html; }