<?php

/**
 * FAQ template markups are generated in this file.
 *
 * @package Flexible_FAQs
 */
namespace WPGO_Plugins\Flexible_Faqs;

/**
 * FAQ templates markup.
 */
class FAQ_Templates_Markup
{
    /**
     * FAQ text expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @param Integer $group_index The current group index, or 0 for single set of FAQs.
     * @return String Either FAQs HTML markup or no FAQS found message.
     */
    public static function text_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled,
        $group_index = 0
    )
    {
        // don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        $question_btn_id = 'faq-q-btn-' . $args['unique_id_raw'];
        $accordion_mode = '';
        $max_height = '';
        $expanded_status = '';
        $aria_expanded = 'false';
        $dont_render_count = array();
        $faq_set = '';
        $faq_separator_html = ( true === $args['faq_separator'] ? '<div class="faq-separator"></div>' : '' );
        $q_a_separator_outside = FAQ_Templates::q_a_separator( $args, 'outside' );
        $q_a_separator_inside = FAQ_Templates::q_a_separator( $args, 'inside' );
        $faq_post_status = get_post_status( $args['id'] );
        if ( false !== $faq_post_status && 'publish' !== $faq_post_status ) {
            // Display message if FAQ post not published.
            return FAQ_Templates::get_not_published_faq( $args );
        }
        ob_start();
        // Start recording output.
        ?>
<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-text-style<?php 
        echo  $faq_set ;
        ?>"<?php 
        echo  $accordion_mode ;
        ?>>
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
	<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        $faq_index = 0;
        foreach ( $questions[0] as $key => $value ) {
            $faq_index_str = ( 0 < $group_index ? '-' . $group_index . '-' . ($faq_index + 1) : '-' . ($faq_index + 1) );
            $aria_controls = ' aria-controls="' . $args['unique_id'] . $faq_index_str . '"';
            // if Q or A empty, or FAQ item disabled then skip to next FAQ item.
            
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                array_push( $dont_render_count, $key );
                continue;
            }
            
            echo  $faq_separator_html ;
            ?>
		<div class="flexible-faq-wrapper faq<?php 
            echo  $faq_index_str ;
            echo  $faq_group_class ;
            echo  $expanded_status ;
            ?>">
			<button id="<?php 
            echo  $question_btn_id . $faq_index_str ;
            ?>" class="faq-question flexible-faq" aria-expanded="<?php 
            echo  $aria_expanded ;
            ?>" <?php 
            echo  $aria_controls ;
            ?>>
				<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
					<span class="question-text"><?php 
            echo  $value ;
            ?></span>
					<?php 
            echo  FAQ_Templates::get_icon( $args, $faq_index ) ;
            ?>
				</div>
			</button>
			<div class="faq-answer flexible-faq"<?php 
            echo  $max_height ;
            ?>>
				<?php 
            echo  $q_a_separator_outside ;
            ?>
				<div class="faq-inner-answer">
			<?php 
            echo  $q_a_separator_inside ;
            ?>
			<?php 
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
		</div>
			</div>
		</div>
			<?php 
            $faq_index++;
            ?>
		<?php 
        }
        ?>
		<?php 
        echo  $faq_separator_html ;
        ?>
	</div>
</div>
		<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return array( $faq_content, $dont_render_count );
    }
    
    /**
     * FAQ box expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @param Integer $group_index The current group index, or 0 for single set of FAQs.
     * @return String Either FAQs HTML markup or no FAQS found message.
     */
    public static function box_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled,
        $group_index = 0
    )
    {
        // Don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        $question_btn_id = 'faq-q-btn-' . $args['unique_id_raw'];
        $accordion_mode = '';
        $max_height = '';
        $expanded_status = '';
        $aria_expanded = 'false';
        $dont_render_count = array();
        $faq_set = '';
        $faq_post_status = get_post_status( $args['id'] );
        if ( false !== $faq_post_status && 'publish' !== $faq_post_status ) {
            // Display message if FAQ post not published.
            return FAQ_Templates::get_not_published_faq( $args );
        }
        ob_start();
        // Start recording output.
        ?>
<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-box-style<?php 
        echo  $faq_set ;
        ?>"<?php 
        echo  $accordion_mode ;
        ?>>
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
	<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        $faq_index = 0;
        foreach ( $questions[0] as $key => $value ) {
            $faq_index_str = ( 0 < $group_index ? '-' . $group_index . '-' . ($faq_index + 1) : '-' . ($faq_index + 1) );
            $aria_controls = ' aria-controls="' . $args['unique_id'] . $faq_index_str . '"';
            // If Q or A empty, or FAQ item disabled then skip to next FAQ item.
            
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                array_push( $dont_render_count, $key );
                continue;
            }
            
            ?>
		<div class="flexible-faq-wrapper faq<?php 
            echo  $faq_index_str ;
            echo  $faq_group_class ;
            echo  $expanded_status ;
            ?>">
			<button id="<?php 
            echo  $question_btn_id . $faq_index_str ;
            ?>" class="faq-question flexible-faq" aria-expanded="<?php 
            echo  $aria_expanded ;
            ?>" <?php 
            echo  $aria_controls ;
            ?>>
				<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
					<span class="question-text"><?php 
            echo  $value ;
            ?></span>
					<?php 
            echo  FAQ_Templates::get_icon( $args, $faq_index ) ;
            ?>
				</div>
			</button>
			<div class="faq-answer flexible-faq"<?php 
            echo  $max_height ;
            ?>>
				<?php 
            echo  $q_a_separator_outside ;
            ?>
				<div class="faq-inner-answer">
				<?php 
            echo  $q_a_separator_inside ;
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
				</div>
			</div>
		</div>
			<?php 
            $faq_index++;
            ?>
		<?php 
        }
        ?>
		<?php 
        ?>
	</div>
</div>
		<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return array( $faq_content, $dont_render_count );
    }
    
    /**
     * FAQ accordion expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @param Integer $group_index The current group index, or 0 for single set of FAQs.
     * @return String FAQs HTML markup or no FAQS found message.
     */
    public static function accordion_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled,
        $group_index = 0
    )
    {
        // don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        $question_btn_id = 'faq-q-btn-' . $args['unique_id_raw'];
        $accordion_mode = '';
        $max_height = '';
        $expanded_status = '';
        $aria_expanded = 'false';
        $dont_render_count = array();
        $faq_set = '';
        $faq_post_status = get_post_status( $args['id'] );
        if ( false !== $faq_post_status && 'publish' !== $faq_post_status ) {
            // Display message if FAQ post not published.
            return FAQ_Templates::get_not_published_faq( $args );
        }
        ob_start();
        // Start recording output.
        ?>
<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-accordion-style<?php 
        echo  $faq_set ;
        ?>"<?php 
        echo  $accordion_mode ;
        ?>>
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
	<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        $faq_index = 0;
        foreach ( $questions[0] as $key => $value ) {
            $faq_index_str = ( 0 < $group_index ? '-' . $group_index . '-' . ($faq_index + 1) : '-' . ($faq_index + 1) );
            $aria_controls = ' aria-controls="' . $args['unique_id'] . $faq_index_str . '"';
            // If Q or A empty, or FAQ item disabled then skip to next FAQ item.
            
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                array_push( $dont_render_count, $key );
                continue;
            }
            
            ?>
		<div class="flexible-faq-wrapper faq<?php 
            echo  $faq_index_str ;
            echo  $faq_group_class ;
            echo  $expanded_status ;
            ?>">
			<button id="<?php 
            echo  $question_btn_id . $faq_index_str ;
            ?>" class="faq-question flexible-faq" aria-expanded="<?php 
            echo  $aria_expanded ;
            ?>" <?php 
            echo  $aria_controls ;
            ?>>
				<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
					<span class="question-text"><?php 
            echo  $value ;
            ?></span>
					<?php 
            echo  FAQ_Templates::get_icon( $args, $faq_index ) ;
            ?>
				</div>
			</button>
			<div class="faq-answer flexible-faq"<?php 
            echo  $max_height ;
            ?>>
				<?php 
            echo  $q_a_separator_outside ;
            ?>
			<div class="faq-inner-answer">
				<?php 
            echo  $q_a_separator_inside ;
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
			</div>
			</div>
		</div>
			<?php 
            $faq_index++;
            ?>
		<?php 
        }
        ?>
		<?php 
        ?>
	</div>
</div>
		<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return array( $faq_content, $dont_render_count );
    }
    
    // LEGACY TEMPLATES.
    /**
     * FAQ text expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @return String Either FAQs HTML markup or no FAQS found message.
     */
    public static function _text_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled
    )
    {
        // don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $icon = FAQ_Templates::get_icon( $args );
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        ob_start();
        // Start recording output.
        ?>
<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-text-style">
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
	<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        foreach ( $questions[0] as $key => $value ) {
            $aria_controls = ' aria-controls="' . $args['unique_id'] . '-' . ($key + 1) . '"';
            // if Q or A empty, or FAQ item disabled then skip to next FAQ item.
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                continue;
            }
            ?>
		<div class="flexible-faq-wrapper faq<?php 
            echo  $key + 1 ;
            echo  $faq_group_class ;
            ?>">
			<div class="faq-question flexible-faq" aria-expanded="false" <?php 
            echo  $aria_controls ;
            ?>>
				<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
					<span class="question-text"><?php 
            echo  $value ;
            ?></span>
					<?php 
            echo  $icon ;
            ?>
				</div>
			</div>
			<div class="faq-answer flexible-faq">
				<?php 
            echo  $q_a_separator_outside ;
            ?>
				<div class="faq-inner-answer">
			<?php 
            echo  $q_a_separator_inside ;
            ?>
			<?php 
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
		</div>
			</div>
		</div>
			<?php 
            ?>
		<?php 
        }
        ?>
	</div>
</div>
			<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return $faq_content;
    }
    
    /**
     * FAQ box expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @return String Either FAQs HTML markup or no FAQS found message.
     */
    public static function _box_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled
    )
    {
        // Don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $icon = FAQ_Templates::get_icon( $args );
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        ob_start();
        // Start recording output.
        ?>
<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-box-style">
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
	<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        foreach ( $questions[0] as $key => $value ) {
            // If Q or A empty, or FAQ item disabled then skip to next FAQ item.
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                continue;
            }
            ?>
	<div class="flexible-faq-wrapper faq<?php 
            echo  $key + 1 ;
            echo  $faq_group_class ;
            ?>">
		<div class="faq-question flexible-faq">
			<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
				<span class="question-text"><?php 
            echo  $value ;
            ?></span>
				<?php 
            echo  $icon ;
            ?>
			</div>
		</div>
		<div class="faq-answer flexible-faq">
			<?php 
            echo  $q_a_separator_outside ;
            ?>
		<div class="faq-inner-answer">
			<?php 
            echo  $q_a_separator_inside ;
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
		</div>
		</div>
	</div>
			<?php 
            ?>
	<?php 
        }
        ?>
	</div>
</div>
		<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return $faq_content;
    }
    
    /**
     * FAQ accordion expand template markup.
     *
     * @param Integer $post_id The unique ID of post or page.
     * @param Array   $args The arguments supplied to the template.
     * @param Array   $questions An array of FAQ questions set.
     * @param Array   $answers An array of FAQ answers set.
     * @param Array   $disabled An array of Booleans indicating disabled status of question.
     * @return String FAQs HTML markup or no FAQS found message.
     */
    public static function _accordion_expand_template(
        $post_id,
        $args = array(),
        $questions,
        $answers,
        $disabled
    )
    {
        // don't attempt output if no FAQs found.
        if ( !isset( $questions[0] ) || empty($questions[0]) ) {
            return FAQ_Templates::get_no_faqs_found( $post_id );
        }
        $outer_wrapper_classes = FAQ_Templates::outer_wrapper_classes( $args );
        $icon = FAQ_Templates::get_icon( $args );
        $container_id = ( empty($args['group']) ? ' id="' . $args['unique_id'] . '"' : '' );
        $faq_title = FAQ_Templates::get_faq_title( $post_id, $args );
        $faq_description = '';
        $faq_group_class = '';
        $icon_align = '';
        $q_a_separator_outside = '';
        $q_a_separator_inside = '';
        ob_start();
        // Start recording output.
        ?>
	<div<?php 
        echo  $container_id ;
        ?> class="flexible-faq-container faq-expandable faq-accordion-style">
		<?php 
        echo  $faq_title ;
        echo  $faq_description ;
        ?>
		<div class="flexible-faq-outer-wrapper<?php 
        echo  $outer_wrapper_classes ;
        ?>">
		<?php 
        foreach ( $questions[0] as $key => $value ) {
            $aria_controls = ' aria-controls="' . $args['unique_id'] . '-' . ($key + 1) . '"';
            // If Q or A empty, or FAQ item disabled then skip to next FAQ item.
            if ( empty($value) || empty($answers[0][$key]) || isset( $disabled[0][$key] ) && '1' === $disabled[0][$key] ) {
                continue;
            }
            ?>
			<div class="flexible-faq-wrapper faq<?php 
            echo  $key + 1 ;
            echo  $faq_group_class ;
            ?>">
				<div class="faq-question flexible-faq" aria-expanded="false" <?php 
            echo  $aria_controls ;
            ?>>
					<div class="faq-inner-question<?php 
            echo  $icon_align ;
            ?>">
					<span class="question-text"><?php 
            echo  $value ;
            ?></span>
					<?php 
            echo  $icon ;
            ?>
				</div>
				</div>
				<div class="faq-answer flexible-faq">
					<?php 
            echo  $q_a_separator_outside ;
            ?>
				<div class="faq-inner-answer">
					<?php 
            echo  $q_a_separator_inside ;
            echo  apply_filters( 'the_content', wpautop( $answers[0][$key] ) ) ;
            ?>
				</div>
				</div>
			</div>
			<?php 
            ?>
		<?php 
        }
        ?>
		</div>
	</div>
		<?php 
        $faq_content = ob_get_contents();
        // Get output contents.
        ob_end_clean();
        // End recording output and flush buffer.
        return $faq_content;
    }

}
/* End of class definition */