/**
* Handle the categories
*
* @param int $parent_id If this is set to something other than 0 it will only list categories under the category_id given
* @param string $block Set the name of the block to output it to.
* @param bool $ignore_subcats True to ignore subcategories, false to display them.
* @param array $category_list If you want to send the already gotten category list...
*/
function handle_categories($parent_id = 0, $block = 'category_row', $ignore_subcats = false, $category_list = false)
{
    global $config, $template, $user;
    if (!is_array($category_list)) {
        $category_list = get_blog_categories('left_id');
    }
    blog_plugins::plugin_do('function_handle_categories');
    foreach ($category_list as $left_id => $row) {
        if ($parent_id == $row['category_id'] && !$ignore_subcats) {
            $template->assign_vars(array('U_CURRENT_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'CURRENT_CATEGORY' => $row['category_name'], 'CATEGORY_RULES' => generate_text_for_display($row['rules'], $row['rules_uid'], $row['rules_bitfield'], $row['rules_options'])));
        }
        if ($parent_id == $row['parent_id']) {
            $template->assign_block_vars($block, array('CATEGORY_NAME' => $row['category_name'], 'CATEGORY_DESCRIPTION' => generate_text_for_display($row['category_description'], $row['category_description_uid'], $row['category_description_bitfield'], $row['category_description_options']), 'BLOGS' => $row['blog_count'], 'U_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'S_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats, 'L_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 3 ? $user->lang['SUBCATEGORIES'] : $user->lang['SUBCATEGORY']));
            // If not, then there are subcategories
            if ($row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats) {
                handle_categories($row['category_id'], 'category_row.subcategory', true, $category_list);
            }
        }
    }
}
Example #2
0
generate_blog_breadcrumbs();
generate_menu();
if ($category_id) {
    $category_list = get_blog_categories('category_id');
    if (isset($category_list[$category_id])) {
        page_header($category_list[$category_id]['category_name']);
    } else {
        trigger_error('NO_CATEGORY');
    }
    unset($category_list);
} else {
    page_header($user->lang['BLOGS']);
}
blog_plugins::plugin_do('view_main_start');
// Handle the categories and output them
handle_categories($category_id);
switch ($mode) {
    case 'last_visit_blogs':
    case 'random_blogs':
    case 'recent_blogs':
    case 'popular_blogs':
    case 'recent_comments':
        // for sorting and pagination
        if (strpos($mode, 'comments') === false) {
            $sort_by_sql = array('t' => 'blog_time', 'c' => 'blog_reply_count', 'bt' => 'blog_subject');
            $ids = $blog_data->get_blog_data(str_replace('_blogs', '', $mode), 0, array('start' => $start, 'limit' => $limit, 'category_id' => $category_id, 'order_by' => $sort_by_sql[$sort_key], 'order_dir' => $order_dir, 'sort_days' => $sort_days));
            $total = $blog_data->get_blog_data('count', 0, array('sort_days' => $sort_days, 'category_id' => $category_id));
            $sort_by_text = array('t' => $user->lang['POST_TIME'], 'c' => $user->lang['REPLY_COUNT'], 'bt' => $user->lang['BLOG_SUBJECT']);
        } else {
            $sort_by_sql = array('t' => 'reply_time');
            $ids = $blog_data->get_reply_data(str_replace('_comments', '', $mode), 0, array('start' => $start, 'limit' => $limit, 'category_id' => $category_id, 'order_by' => $sort_by_sql[$sort_key], 'order_dir' => $order_dir, 'sort_days' => $sort_days));