<?php
/**
 * Search Content Part
 *
 * @package bbPress
 * @subpackage Theme
 */

// Exit if accessed directly
defined('ABSPATH') || exit;

$has_sidebar = is_active_sidebar('forum_archive_sidebar');
$main_column = $has_sidebar ? '8' : '12';
?>

<div class="frmx-row frmx-sidebar-<?php echo esc_attr(forumax_get_opt('sidebar_position', 'right')); ?>">
    <div class="frmx-col-lg-<?php echo esc_attr($main_column); ?>">
        <div id="bbpress-forums" class="bbpress-wrapper">

            <?php bbp_set_query_name(bbp_get_search_rewrite_id()); ?>

            <?php do_action('bbp_template_before_search'); ?>

            <?php if (bbp_has_search_results()): ?>

                <div class="bbp-search-summary">
                    <h2 class="bbp-search-summary-title">
                        <?php
                        printf(
                            esc_html__( 'Search results for "%s"', 'forumax' ),
                            esc_html( bbp_get_search_terms() )
                        );
                        ?>
                    </h2>
                </div>

                <?php bbp_get_template_part('loop', 'search'); ?>

                <?php bbp_get_template_part('pagination', 'search'); ?>

            <?php elseif (bbp_get_search_terms()): ?>

                <?php bbp_get_template_part('feedback', 'no-search'); ?>

            <?php else: ?>

                <?php bbp_get_template_part('form', 'search'); ?>

            <?php endif; ?>

            <?php do_action('bbp_template_after_search_results'); ?>

        </div>
    </div>

    <?php if ($has_sidebar): ?>
        <div class="frmx-col-lg-4">
            <aside class="forum-sidebar">
                <?php dynamic_sidebar('forum_archive_sidebar'); ?>
            </aside>
        </div>
    <?php endif; ?>
</div>