<commit_before><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: render_functions.php
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
use PHPFusion\BreadCrumbs;

if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Render comments template
if (!function_exists("render_comments")) {
    /**
     * Show comments
     * @param       $c_data
     * @param       $c_info
     * @param array $options
     * @return string
     */
    function render_comments($c_data, $c_info, array $options = array()) {

        $locale = fusion_get_locale('',
                                    [
                                        LOCALE.LOCALESET."comments.php",
                                        LOCALE.LOCALESET."ratings.php"
                                    ]
        );

        /*
         * Get ratings information
         */
        $ratings_html = '';
        if (!empty($c_info['ratings_count'])) {
            $ratings_html = "<ul class='well clearfix p-15'>\n";
            $ratings_html .= "<li class='col-xs-12 col-sm-6'>\n";
            for ($i = 1; $i <= $c_info['ratings_count']['avg']; $i++) {
                $ratings_html .= "<i class='fa fa-star text-warning fa-lg'></i>\n";
            }
            $ratings_html .= "<span class='text-lighter m-l-5'>".format_word($c_info['ratings_count']['total'], "review|reviews")."</span>\n";
            $ratings_html .= "</li>\n";
            $ratings_html .= "<li class='col-xs-12 col-sm-6'>\n";
            for ($i = 5; $i >= 1; $i--) {
                $bal = 5 - $i;
                $ratings_html .= "<div class='row'>\n";
                $ratings_html .= "<div class='display-inline-block m-r-5'>\n";
                for ($x = 1; $x <= $i; $x++) {
                    $ratings_html .= "<i class='fa fa-star text-warning'></i>\n";
                }
                for ($b = 1; $b <= $bal; $b++) {
                    $ratings_html .= "<i class='fa fa-star-o text-lighter'></i>\n";
                }
                $ratings_html .= "<span class='text-lighter m-l-5 m-r-5'>(".($c_info['ratings_count'][$i] ?: 0).")</span>";
                $ratings_html .= "</div>\n<div class='display-inline-block m-l-5' style='width:50%;'>\n";
                $progress_num = $c_info['ratings_count'][$i] > 0 ? floor($c_info['ratings_count'][$i] / $c_info['ratings_count']['total']) * 100 : 0;
                $ratings_html .= progress_bar($progress_num, '', '', '10px', FALSE, TRUE, FALSE, TRUE, 'm-0');
                $ratings_html .= "</div>\n";
                $ratings_html .= "</div>\n";
            }
            $ratings_html .= "</li>\n";
            $ratings_html .= "</ul>\n";
            $ratings_html .= ($c_info['ratings_remove_form'] ?: '');
        }

        /*
         * Get comments
         */
        $comments_html = "";
        if (!empty($c_data)) {
            /*
             * Declare function for recursively calling comments
             */
            if (!function_exists("display_all_comments")) {

                function display_all_comments($c_data, $index = 0, $options) { //&$comments_html = FALSE

                    $comments_html = &$comments_html;

                    $locale = fusion_get_locale('', LOCALE.LOCALESET."comments.php");

                    foreach ($c_data[$index] as $comments_id => $data) {
                        $comments_html .= "<!---comment-".$data['comment_id']."--->\n<li id='c".$data['comment_id']."' class='m-b-15'>\n";
                        $comments_html .= "<div class='pull-left text-center m-r-15'>\n";
                        $comments_html .= $data['user_avatar'];
                        $comments_html .= "</div>\n";
                        $comments_html .= "<div class='overflow-hide'>\n";

                        $comments_html .= "<div class='comment_name display-inline-block m-r-10'>\n";
                        $comments_html .= $data['comment_name'];
                        $comments_html .= "<span class='comment_status text-lighter'>".$data['user']['groups']."</span> <small class='comment_date'>".$data['comment_datestamp']."</small>";
                        $comments_html .= "</div>\n";
                        $comments_html .= "<p class='ratings'>\n";
                        $remainder = 5 - $data['ratings'];
                        for ($i = 1; $i <= $data['ratings']; $i++) {
                            $comments_html .= "<i class='fa fa-star text-warning'></i>\n";
                        }
                        if ($remainder) {
                            for ($i = 1; $i <= $remainder; $i++) {
                                $comments_html .= "<i class='fa fa-star-o text-lighter'></i>\n";
                            }
                        }
                        $comments_html .= "</p>\n";
                        $comments_html .= "<p class='comment_title'>".$data['comment_subject']."</p>\n";
                        $comments_html .= "<p class='comment_message'>".$data['comment_message']."</p>\n";
                        if ($options['comment_allow_reply']) {
                            $comments_html .= "<a href='".$data['reply_link']."' class='comments-reply display-inline m-5 m-l-0' data-id='$comments_id'>".$locale['c112']."</a>\n&middot;";
                        }

                        $data_api = \defender::serialize($options);
                        $comments_html .= ($data['edit_link'] ? "<a href='".$data['edit_link']['link']."' class='edit-comment display-inline m-5' data-id='".$data['comment_id']."' data-api='$data_api'>".$data['edit_link']['name']."</a>&middot;" : "");
                        $comments_html .= ($data['delete_link'] ? "<a href='".$data['delete_link']['link']."' class='delete-comment display-inline m-5' data-id='".$data['comment_id']."' data-api='$data_api' data-type='".$options['comment_item_type']."' data-item='".$options['comment_item_id']."'>".$data['delete_link']['name']."</a>" : "");
                        $comments_html .= "</div>\n";

                        if (!empty($data['reply_form'])) {
                            $comments_html .= $data['reply_form'];
                        }
                        // Replies is here
                        if (isset($c_data[$data['comment_id']])) {
                            $comments_html .= "<ul class='sub-comments'>\n";
                            $comments_html .= display_all_comments($c_data, $data['comment_id'], $options);
                            $comments_html .= "</ul>\n";
                        }
                        $comments_html .= "</li><!---//comment-".$data['comment_id']."--->";
                    }
                    return $comments_html;
                }
            }

            $c_makepagenav = ($c_info['c_makepagenav'] !== FALSE) ? "<div class=\"text-center m-b-5\">".$c_info['c_makepagenav']."</div>\n" : "";
            $comments_html .= "<ul class='comments clearfix'>\n";
            $comments_html .= display_all_comments($c_data, 0, $options);
            $comments_html .= $c_makepagenav;
            if ($c_info['admin_link'] !== FALSE) {
                $comments_html .= "<div style='float:right' class='comment_admin'>".$c_info['admin_link']."</div>\n";
            }
            $comments_html .= "</ul>\n";
        } else {
            $comments_html .= "<div class='well text-center'>\n";
            $comments_html .= $locale['c101']."\n";
            $comments_html .= "</div>\n";
        }

		// Comments form
        $html = "<div class='comments-panel'>\n";
        $html .= "<div class='comments-header'>\n";
        $html .= $options['comment_title'].($options['comment_count'] ? $c_info['comments_count'] : '');
        $html .= "</div>\n";
        $html .= "<div class='ratings overflow-hide m-b-20'>\n";
        $html .= $ratings_html;
        $html .= "</div>\n";
        $html .= "<div class='comments overflow-hide'>\n";
        $html .= $comments_html;
        $html .= "</div>\n";
        $html .= "</div>\n";

        return $html;
    }
}

if (!function_exists("render_comments_form")) {
    /**
     * Comment Form
     *
     * @param       $comment_type
     * @param       $clink
     * @param       $comment_item_id
     * @param       $_CAPTCHA_HIDE_INPUT
     * @param array $options
     * @return string
     */
    function render_comments_form($comment_type, $clink, $comment_item_id, $_CAPTCHA_HIDE_INPUT, array $options = array()) {

        $userdata = fusion_get_userdata();
        $settings = fusion_get_settings();
        $locale = fusion_get_locale('', LOCALE.LOCALESET."ratings.php");
        $prefix = $comment_type."-".$comment_item_id;
        $edata = [
            'comment_cat' => 0,<commit_msg>Update comments<commit_after><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: render_functions.php
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
use PHPFusion\BreadCrumbs;

if (!defined("IN_FUSION")) {
    die("Access Denied");
}

// Render comments template
if (!function_exists("render_comments")) {
    /**
     * Show comments
     * @param       $c_data
     * @param       $c_info
     * @param array $options
     * @return string
     */
    function render_comments($c_data, $c_info, array $options = array()) {

        $locale = fusion_get_locale('',
                                    [
                                        LOCALE.LOCALESET."comments.php",
                                        LOCALE.LOCALESET."ratings.php"
                                    ]
        );

        /*
         * Get ratings information
         */
        $ratings_html = '';
        if (!empty($c_info['ratings_count'])) {
            $ratings_html = "<ul class='well clearfix p-15'>\n";
            $ratings_html .= "<li class='col-xs-12 col-sm-6'>\n";
            for ($i = 1; $i <= $c_info['ratings_count']['avg']; $i++) {
                $ratings_html .= "<i class='fa fa-star text-warning fa-lg'></i>\n";
            }
            $ratings_html .= "<span class='text-lighter m-l-5'>".format_word($c_info['ratings_count']['total'], "review|reviews")."</span>\n";
            $ratings_html .= "</li>\n";
            $ratings_html .= "<li class='col-xs-12 col-sm-6'>\n";
            for ($i = 5; $i >= 1; $i--) {
                $bal = 5 - $i;
                $ratings_html .= "<div class='row'>\n";
                $ratings_html .= "<div class='display-inline-block m-r-5'>\n";
                for ($x = 1; $x <= $i; $x++) {
                    $ratings_html .= "<i class='fa fa-star text-warning'></i>\n";
                }
                for ($b = 1; $b <= $bal; $b++) {
                    $ratings_html .= "<i class='fa fa-star-o text-lighter'></i>\n";
                }
                $ratings_html .= "<span class='text-lighter m-l-5 m-r-5'>(".($c_info['ratings_count'][$i] ?: 0).")</span>";
                $ratings_html .= "</div>\n<div class='display-inline-block m-l-5' style='width:50%;'>\n";
                $progress_num = $c_info['ratings_count'][$i] > 0 ? floor($c_info['ratings_count'][$i] / $c_info['ratings_count']['total']) * 100 : 0;
                $ratings_html .= progress_bar($progress_num, '', '', '10px', FALSE, TRUE, FALSE, TRUE, 'm-0');
                $ratings_html .= "</div>\n";
                $ratings_html .= "</div>\n";
            }
            $ratings_html .= "</li>\n";
            $ratings_html .= "</ul>\n";
            $ratings_html .= ($c_info['ratings_remove_form'] ?: '');
        }

        /*
         * Get comments
         */
        $comments_html = "";
        if (!empty($c_data)) {
            /*
             * Declare function for recursively calling comments
             */
            if (!function_exists("display_all_comments")) {

                function display_all_comments($c_data, $index = 0, $options) { //&$comments_html = FALSE

                    $comments_html = &$comments_html;

                    $locale = fusion_get_locale('', LOCALE.LOCALESET."comments.php");

                    foreach ($c_data[$index] as $comments_id => $data) {
                        $comments_html .= "<!---comment-".$data['comment_id']."--->\n<li id='c".$data['comment_id']."' class='m-b-15'>\n";
                        $comments_html .= "<div class='pull-left text-center m-r-15'>\n";
                        $comments_html .= $data['user_avatar'];
                        $comments_html .= "</div>\n";
                        $comments_html .= "<div class='overflow-hide'>\n";

                        $comments_html .= "<div class='comment_name display-inline-block m-r-10'>\n";
                        $comments_html .= $data['comment_name'];
                        $comments_html .= "<span class='comment_status text-lighter'>".$data['user']['groups']."</span> <small class='comment_date'>".$data['comment_datestamp']."</small>";
                        $comments_html .= "</div>\n";

                        if (fusion_get_settings('ratings_enabled')) {
                            $comments_html .= "<p class='ratings'>\n";
                            $remainder = 5 - $data['ratings'];
                            for ($i = 1; $i <= $data['ratings']; $i++) {
                                $comments_html .= "<i class='fa fa-star text-warning'></i>\n";
                            }
                            if ($remainder) {
                                for ($i = 1; $i <= $remainder; $i++) {
                                    $comments_html .= "<i class='fa fa-star-o text-lighter'></i>\n";
                                }
                            }
                            $comments_html .= "</p>\n";
                        }


                        $comments_html .= "<p class='comment_title'>".$data['comment_subject']."</p>\n";
                        $comments_html .= "<p class='comment_message'>".$data['comment_message']."</p>\n";
                        if ($options['comment_allow_reply']) {
                            $comments_html .= "<a href='".$data['reply_link']."' class='comments-reply display-inline m-5 m-l-0' data-id='$comments_id'>".$locale['c112']."</a>\n";
                        }

                        $data_api = \defender::serialize($options);
                        $comments_html .= ($data['edit_link'] ? "&middot;<a href='".$data['edit_link']['link']."' class='edit-comment display-inline m-5' data-id='".$data['comment_id']."' data-api='$data_api'>".$data['edit_link']['name']."</a>" : "");
                        $comments_html .= ($data['delete_link'] ? "&middot;<a href='".$data['delete_link']['link']."' class='delete-comment display-inline m-5' data-id='".$data['comment_id']."' data-api='$data_api' data-type='".$options['comment_item_type']."' data-item='".$options['comment_item_id']."'>".$data['delete_link']['name']."</a>" : "");
                        $comments_html .= "</div>\n";

                        if (!empty($data['reply_form'])) {
                            $comments_html .= $data['reply_form'];
                        }
                        // Replies is here
                        if (isset($c_data[$data['comment_id']])) {
                            $comments_html .= "<ul class='sub-comments'>\n";
                            $comments_html .= display_all_comments($c_data, $data['comment_id'], $options);
                            $comments_html .= "</ul>\n";
                        }
                        $comments_html .= "</li><!---//comment-".$data['comment_id']."--->";
                    }
                    return $comments_html;
                }
            }

            $c_makepagenav = ($c_info['c_makepagenav'] !== FALSE) ? "<div class=\"text-center m-b-5\">".$c_info['c_makepagenav']."</div>\n" : "";
            $comments_html .= "<ul class='comments clearfix'>\n";
            $comments_html .= display_all_comments($c_data, 0, $options);
            $comments_html .= $c_makepagenav;
            if ($c_info['admin_link'] !== FALSE) {
                $comments_html .= "<div style='float:right' class='comment_admin'>".$c_info['admin_link']."</div>\n";
            }
            $comments_html .= "</ul>\n";
        } else {
            $comments_html .= "<div class='well text-center'>\n";
            $comments_html .= $locale['c101']."\n";
            $comments_html .= "</div>\n";
        }

		// Comments form
        $html = "<div class='comments-panel'>\n";
        $html .= "<div class='comments-header'>\n";
        $html .= $options['comment_title'].($options['comment_count'] ? $c_info['comments_count'] : '');
        $html .= "</div>\n";

        if (fusion_get_settings('ratings_enabled')) {
            $html .= "<div class='ratings overflow-hide m-b-20'>\n";
            $html .= $ratings_html;
            $html .= "</div>\n";
        }

        $html .= "<div class='comments overflow-hide'>\n";
        $html .= $comments_html;
        $html .= "</div>\n";
        $html .= "</div>\n";

        return $html;
    }
}

if (!function_exists("render_comments_form")) {
    /**
     * Comment Form
     *
     * @param       $comment_type
     * @param       $clink
     * @param       $comment_item_id
     * @param       $_CAPTCHA_HIDE_INPUT
     * @param array $options
     * @return string
     */
    function render_comments_form($comment_type, $clink, $comment_item_id, $_CAPTCHA_HIDE_INPUT, array $options = array()) {

        $userdata = fusion_get_userdata();
        $settings = fusion_get_settings();
        $locale = fusion_get_locale('', LOCALE.LOCALESET."ratings.php");
        $prefix = $comment_type."-".$comment_item_id;
        $edata = [
            'comment_cat' => 0,
{'fraction_non_alphanumeric': 0.20590565738735409, 'fraction_numerical': 0.005810575246949448, 'mean_word_length': 1.6196208661962086, 'pattern_counts': {'":': 0, '<': 155, '<?xml version=': 0, '>': 151, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2122830', 'n_tokens_mistral': 5657, 'n_tokens_neox': 5425, 'n_words': 950}