<?php
$user_id = $this->session->userdata('user_id');
$offset = $this->session->userdata('time_offset');
$replay_comment_counter = 0;
foreach ($comment_reply as $comment_replay_value) {
    ?>
    <div class="media col-sm-10 col-sm-offset-2" style="font-size: 14px">
        <div  class="col-sm-12"><hr></div>
        <div class="media-left">
            <a href="<?php echo base_url() . $comment_replay_value->url . '/profile'; ?>">
                <img class="media-object " 
                     src="<?php
                     if ($comment_replay_value->person_image) {
                         echo base_url() .'content-library/'.$comment_replay_value->url.'/'. $comment_replay_value->person_image_thumb;
                     } else {
                         echo base_url() . 'image/no_profile_picture.png';
                     }
                     ?>" 
                     alt="logo" width="30">
            </a>
        </div>
        <div class="media-body">
            <h5 class="media-heading green text-justify" style="font-size: 16px;">
                <a href="<?php echo base_url() . $comment_replay_value->url . '/profile'; ?>">
                    <?php echo $comment_replay_value->person_first_name . ' ' . $comment_replay_value->person_last_name; ?>
                </a>
            </h5>
            <p class="text-justify" id="reply_comment_detail<?php echo $comment_replay_value->comment_id; ?>">
                <?php
                if (strlen($comment_replay_value->comment_details) > 80) {
                    $limited_string = mb_substr($comment_replay_value->comment_details, 0, 80, 'utf-8');
                    echo $this->cf->view_emoticons($limited_string);
                    ?>
                    <a href="javascript:void(0)" style="padding-left: 10px;"
                       onclick="viewDetails('<?php echo base_url() . 'post/view_post_details/' . $comment_replay_value->comment_id . '/reply' ?>', 'reply_comment_detail', '<?php echo $comment_replay_value->comment_id; ?>')" >
                        more...
                    </a>
                    <?php
                } else {
                    echo $this->cf->view_emoticons($comment_replay_value->comment_details);
                }
                ?>
            </p>
        </div>

        <!-----------------Start View URL Details (if user Comment Reply URL)------------------------>
        <?php
        if ($reply_comment_url[$comment_replay_value->comment_id]) {
            $url_value = explode("URL: ", $reply_comment_url[$comment_replay_value->comment_id]->post_comment_url_info);
            ?>
            <div class="col-sm-12 text-left" style="margin: -10px 0 0 40px; ">
                <div class="col-sm-12">
                    <h5>
                        <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                            <?php echo $url_value[2]; ?>
                        </a>
                    </h5>
                </div>
                <div class="col-sm-12" style="margin-top: -10px;">
                    <p style="font-size: 12px; text-align: justify;">
                        <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                            <?php echo $url_value[3]; ?>
                        </a>
                    </p>
                </div>
                <div class="col-sm-12" style="margin-top: -10px;">
                    <h6>
                        <?php
                        if ($url_value[1]) {
                            ?>
                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                <?php echo $url_value[1]; ?>
                            </a>
                            <?php
                        }
                        if ($url_value[4] == '') {
                            echo '';
                        } else {
                            echo 'BY | ';
                            ?>
                            <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457"><?php echo $url_value[4]; ?></a>
                            <?php
                        }
                        ?>
                    </h6>
                </div>
            </div>
        <?php } ?>
        <!-----------------END View URL Details (if user Comment Reply URL)------------------------>

        <div id="reply_comment_like<?php echo $comment_replay_value->comment_id ?>" class="padding-zero">
            <div class="media-bottom" style="margin-left: 55px" >
                <p class="text-justify">   

                    <?php
                    $post_comment_reply_like_array = explode(",", $comment_replay_value->comment_like_by);
                    echo 'read ('.  count(array_filter($post_comment_reply_like_array)).')';
                    ?>

                    - <span>
                        <?php
                        $this->cf->time_format_for_read_write($comment_replay_value->comment_date_time, $offset);
                        ?>
                    </span> 
                </p>
            </div>

            <!------------------------------------(4-d-iii-1) Start Comment Nested Reply Form----------------------------- -->
            <div style="display: none"
                 id="view_saaved_nested_replies<?php echo $comment_replay_value->comment_id; ?>" >
            </div>
            <!------------------------------------(4-d-iii-1) END Comment Nested Reply Form----------------------------- -->

        </div>


        <!------------------------------------(4-d-iv) Start view replies----------------------------- -->
        <div class="col-sm-12 text-left" id="view_nested_replies<?php echo $comment_replay_value->comment_id; ?>">
            <?php
            $nested_comment_counter = 0;
            if ($total_nested_reply[$comment_replay_value->comment_id]->total_comment > 0 && $total_nested_reply[$comment_replay_value->comment_id]->total_comment != $nested_comment_counter) {
                ?>
                <div class="col-sm-12 text-left" style="margin-left: 40px;">
                    <a href="javascript:void(0)"
                       onclick="viewNestedReplies('<?php echo base_url() . 'super_admin_group/view_nested_replies/' . $comment_replay_value->comment_id . '/' . $nested_comment_counter; ?>', '<?php echo $comment_replay_value->comment_id; ?>')" >
                        view replies
                    </a>
                </div>
            <?php } ?>
        </div>

        <!------------------------------------(4-d-iv) End view replies----------------------------- -->



    </div>

    <?php
    $replay_comment_counter++;
}

if ($total_comment_replay->total_comment > $replay_comment_counter) {
    ?>
    <div class="col-sm-12 text-left" style="margin-left: 120px;">
        <br>
        <a href="javascript:void(0)"
           onclick="viewMoreReply('<?php echo base_url() . 'super_admin_group/view_more_reply/' . $comment_id . '/' . $replay_comment_counter; ?>', '<?php echo $comment_id; ?>')" >
            view more reply
        </a>
    </div>
    <?php
} 