<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;
$citation_fact_score = isset($campoal_options['conikal_citation_fact_score_field']) ? $campoal_options['conikal_citation_fact_score_field'] : 'all';
$citations_per_page = isset($campoal_options['conikal_citations_per_page_field']) ? $campoal_options['conikal_citations_per_page_field'] : 5;

$petition_id = $post->ID;

// get petition citation status
$citation = conikal_citation_status($petition_id);
?>

<?php if ($citation) : ?>
<!-- CITTION LIST -->
<div class="petition-citation-section">
    <div id="citations<?php echo esc_attr($petition_id) ?>" class="citation-list" data-id="<?php echo esc_attr($petition_id) ?>" data-load="0">
        <h2 class="ui <?php echo esc_attr(!in_array($citation_fact_score, array('list', 'all')) ? 'dividing ' : '') ?>header"><?php esc_html_e('Citations', 'campoal') ?></h2>
        <?php if ( in_array($citation_fact_score, array('list', 'all')) ) :
            $citation_opinion = conikal_citation_fact_score($petition_id);  ?>
            <div class="ui tiny progress fact-score-status-<?php echo esc_attr(intval($citation_opinion->score) >= 50 ? 'agree' : 'disagree') ?> citation-opinion-progress" id="citation-opinion-progress" data-value="<?php echo esc_attr($citation_opinion->yes) ?>" data-total="<?php echo esc_attr($citation_opinion->total) ?>">
                <div class="bar">
                    <div class="progress"></div>
                </div>
                <div class="label"><?php esc_html_e('Fact score: ', 'campoal') ?> <span id="citation-fact-score"><?php echo esc_html($citation_opinion->score) ?></span><?php esc_html_e('%', 'campoal') ?></div>
            </div>
        <?php endif; ?>
        <div id="citation-list<?php echo esc_attr($petition_id) ?>" data-id="<?php echo esc_attr($petition_id) ?>"></div>
        <div class="ui hidden divider"></div>
        <div class="ui basic fluid button citations-more" id="citations-more<?php echo esc_attr($petition_id) ?>" data-offset="<?php echo esc_attr($citations_per_page) ?>" data-id="<?php echo esc_attr($petition_id) ?>"><i class="long arrow down icon"></i><?php esc_html_e('More Citation...', 'campoal') ?></div>
    </div>
</div>
<?php endif; ?>