BlogHelper::_getCategoryList PHP Method

_getCategoryList() protected method

カテゴリーリストを取得する
protected _getCategoryList ( array $categories, integer $depth = 3, integer $current = 1, boolean $count = false, array $options = [] ) : string
$categories array カテゴリ一覧データ
$depth integer 階層(初期値 : 3)
$current integer 現在の階層(初期値 : 1)
$count boolean 件数を表示するかどうか(初期値 : false)
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return string HTMLのカテゴリ一覧
    protected function _getCategoryList($categories, $depth = 3, $current = 1, $count = false, $options = array())
    {
        if ($depth < $current) {
            return '';
        }
        if ($categories) {
            $out = '<ul class="depth-' . $current . '">';
            $current++;
            foreach ($categories as $category) {
                if ($count && isset($category['BlogCategory']['count'])) {
                    $category['BlogCategory']['title'] .= '(' . $category['BlogCategory']['count'] . ')';
                }
                $url = $this->getCategoryUrl($category['BlogCategory']['id']);
                $url = preg_replace('/^\\//', '', $url);
                if ($this->_View->request->url == $url) {
                    $class = ' class="current"';
                } elseif (!empty($this->_View->params['named']['category']) && $this->_View->params['named']['category'] == $category['BlogCategory']['name']) {
                    $class = ' class="selected"';
                } else {
                    $class = '';
                }
                $out .= '<li' . $class . '>' . $this->getCategory($category, $options);
                if (!empty($category['BlogCategory']['children'])) {
                    $out .= $this->_getCategoryList($category['BlogCategory']['children'], $depth, $current, $count, $options);
                }
                $out .= '</li>';
            }
            $out .= '</ul>';
            return $out;
        } else {
            return '';
        }
    }