53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
// * @source See SOURCE.txt for source and other copyright.
|
|
// * @license GNU General Public License version 3; see LICENSE.txt
|
|
|
|
class ControllerBlogMenu extends Controller {
|
|
public function index() {
|
|
|
|
$this->load->language('blog/menu');
|
|
|
|
$configblog_name = $this->config->get('configblog_name');
|
|
|
|
if (!empty($configblog_name)) {
|
|
$data['text_blog'] = $this->config->get('configblog_name');
|
|
} else {
|
|
$data['text_blog'] = $this->language->get('text_blog');
|
|
}
|
|
|
|
$data['text_all'] = $this->language->get('text_all');
|
|
|
|
$data['blog'] = $this->url->link('blog/latest');
|
|
|
|
// Menu
|
|
$this->load->model('blog/category');
|
|
|
|
$this->load->model('blog/article');
|
|
|
|
$data['categories'] = $this->getCategories();
|
|
|
|
return $this->load->view('blog/menu', $data);
|
|
}
|
|
|
|
private function getCategories($parent_id = 0, $path = '') {
|
|
$category_data = array();
|
|
$categories = $this->model_blog_category->getCategories($parent_id);
|
|
|
|
foreach ($categories as $category) {
|
|
$category_path = $path ? $path . '_' . $category['blog_category_id'] : $category['blog_category_id'];
|
|
$filter_data = array(
|
|
'filter_blog_category_id' => $category['blog_category_id']
|
|
);
|
|
|
|
$category_data[] = array(
|
|
'name' => $category['name'] . ($this->config->get('configblog_article_count') ? ' (' . $this->model_blog_article->getTotalArticles($filter_data) . ')' : ''),
|
|
'href' => $this->url->link('blog/category', 'blog_category_id=' . $category_path)
|
|
);
|
|
|
|
$category_data = array_merge($category_data, $this->getCategories($category['blog_category_id'], $category_path));
|
|
}
|
|
|
|
return $category_data;
|
|
}
|
|
}
|