<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>

<?php
$canComment = $this->canComment;
$comment = $this->comment;
$isPageSubject = !empty($this->isPageSubject) ? $this->isPageSubject : $this->viewer();
$actionBody = $this->actionBody;
$languageTranslate = 'en';
?>

<?php if ($comment->likes()->getLikeCount() > 0): ?>
  <?php $likesGroup = Engine_Api::_()->comment()->commentLikesGroup($comment, false);
  $counts = 0;
  if (engine_count($likesGroup['data'])) {
    ?>
    <span class="comments_likes_total">
      <span class="comments_likes_reactions">
        <?php foreach ($likesGroup['data'] as $type) {
          $counts = $type['counts'] + $counts;
          ?>
          <a title="<?php echo $this->translate('%s (%s)', $type['counts'], Engine_Api::_()->getDbTable('reactions', 'comment')->likeWord($type['type'])) ?>"
            href="javascript:;" class="ajaxsmoothbox"
            data-url="<?php echo $this->url(array('module' => 'activity', 'controller' => 'ajax', 'action' => 'comment-likes', 'comment_id' => $comment->getIdentity(), 'id' => $actionBody->getIdentity(), 'resource_type' => $actionBody->getType(), 'format' => 'smoothbox'), 'default', true); ?>"><i
              style="background-image:url(<?php echo Engine_Api::_()->getDbTable('reactions', 'comment')->likeImage($type['type']); ?>);"></i></a>
        <?php } ?>
      </span>
      <a href="javascript:;" class="ajaxsmoothbox"
        data-url="<?php echo $this->url(array('module' => 'activity', 'controller' => 'ajax', 'action' => 'comment-likes', 'comment_id' => $comment->getIdentity(), 'id' => $actionBody->getIdentity(), 'resource_type' => $actionBody->getType(), 'format' => 'smoothbox'), 'default', true); ?>"><?php echo $counts; ?></a>
    </span>
  <?php } ?>
<?php endif ?>

<ul class="comments_date"
  id="comments_reply_<?php echo $comment->comment_id; ?>_<?php echo $actionBody->getIdentity(); ?>"
  style="display:block;">
  <?php if ($canComment): ?>
    <template
      class="owner-info"><?php echo $this->getUserInfo($this->item($comment->poster_type, $comment->poster_id)); ?></template>
    <?php $isLiked = $comment->likes()->isLike($isPageSubject); ?>
    <?php if ($this->viewer()->getIdentity() && $this->canComment):
      if ($likeRow = $comment->likes()->getLike($isPageSubject)) {

        $like = true;
        if ($likeRow->type)
          $type = $likeRow->type;
        else
          $type = 1;

        $imageLike = Engine_Api::_()->getDbTable('reactions', 'comment')->likeImage($type);
        $text = Engine_Api::_()->getDbTable('reactions', 'comment')->likeWord($type);
      } else {
        $like = false;
        $type = '';
        $imageLike = '';
        $text = 'CORELIKE';
      }
      ?>
      <li class="feed_item_option_<?php echo $like ? 'unlike' : 'like'; ?> actionBox showEmotions comment_hoverbox_wrapper">
        <?php $getReactions = Engine_Api::_()->getDbTable('reactions', 'comment')->getReactions(array('userside' => 1, 'fetchAll' => 1)); ?>
        <?php if (engine_count($getReactions) > 0): ?>
          <div class="comment_hoverbox">
            <?php foreach ($getReactions as $getReaction): ?>
              <span>
                <span data-text="<?php echo $this->translate($getReaction->title); ?>"
                  data-actionid="<?php echo $actionBody->getIdentity(); ?>"                   data-commentid="<?php echo $comment->getIdentity(); ?>" data-type="<?php echo $getReaction->reaction_id; ?>" data-guid="<?php echo $isPageSubject->getGuid(); ?>"
                  class="commentcommentlike reaction_btn comment_hoverbox_btn">
                  <div class="reaction comment_hoverbox_btn_icon"> <i class="react" style="background-image:url(<?php echo Engine_Api::_()->getDbTable('reactions', 'comment')->likeImage($getReaction->reaction_id); ?>)"></i>
                  </div>
                </span>
                <div class="text">
                  <div><?php echo $this->translate($getReaction->title); ?></div>
                </div>
              </span>
            <?php endforeach; ?>
          </div>
        <?php endif; ?>
        <a href="javascript:void(0);" <?php if (!empty($_SESSION["corefromLightbox"])) { ?>
            id="comment_like_action_<?php echo $comment->getIdentity(); ?>" <?php $_SESSION["corefromLightbox"] = '';
        } else { ?>
            id="comment_like_actionrec_<?php echo $comment->getIdentity(); ?>" <?php } ?>
          data-like="<?php echo $this->translate('CORELIKEC') ?>"
          data-unlike="<?php echo $this->translate('COREUNLIKEC') ?>"
          data-actionid="<?php echo $actionBody->getIdentity(); ?>"
          data-commentid="<?php echo $comment->getIdentity(); ?>" data-guid="<?php echo $isPageSubject->getGuid(); ?>"
          data-type="1" class="commentcomment<?php echo $like ? 'unlike _reaction' : 'like'; ?>">
          <span><?php echo $this->translate($text); ?></span>
        </a>
      </li>
    <?php endif; ?>
    <li class="sep">&middot;</li>
  <?php endif ?>
  <li class="comments_reply">
    <?php echo $this->htmlLink($this->viewer()->getIdentity() ? 'javascript:;' : $this->baseUrl().'/login', $this->translate('COREREPLY'), array('class' => $this->viewer()->getIdentity() ? 'commentreply' : "")) ?>
  </li>
  <li class="sep">&middot;</li>
  <?php if ($this->viewer()->getIdentity() && $comment->poster_id != $this->viewer()->getIdentity() && $actionBody->type == "post_self_buysell"): ?>
    <li class="comments_reply">
      <?php echo $this->htmlLink($this->url(array('owner_id' => $comment->poster_id, 'action' => 'contact', 'controller' => 'index', 'module' => 'comment'), 'default', true), $this->translate('COREMESSAGE'), array('class' => 'ajaxsmoothbox')) ?>
    </li>
    <li class="sep">&middot;</li>
  <?php endif; ?>
  <?php $viewer_id = Engine_Api::_()->user()->getViewer()->getIdentity();
  if ($viewer_id && (('user' == $actionBody->subject_type && $viewer_id == $actionBody->subject_id) || ($viewer_id == $comment->poster_id))): ?>
    <?php if ($comment->preview && empty($comment->showpreview)) { ?>
      <li id="remove_preview_<?php echo $comment->comment_id ?>">
        <a href="javascript:void(0);"
          onclick="removePreview('<?php echo $comment->getIdentity(); ?>','<?php echo $comment->comment_id; ?>', '<?php echo $comment->getType(); ?>')">
          <?php echo $this->translate("Remove Preview"); ?>
        </a>
      </li>
      <li id="remove_previewli_<?php echo $comment->comment_id ?>" class="sep">&middot;</li>
    <?php }endif; ?>
  <?php $content = $comment->body; ?>
  <?php if ($canComment) { ?>
  <?php } ?>
  <?php if (strlen(preg_replace("/(\\\u[0-9a-f]{4})+?|\s+/", "", strip_tags($content)))) { ?>
    <!-- <li class="comments_reply_translate"> <a href="javascript:void(0);"
        onClick="socialSharingPopUp('https://translate.google.com/#auto/<?php //echo $languageTranslate; ?>/<?php //echo urlencode(strip_tags($comment->body)); ?>','Google');return false;"><?php //echo $this->translate("Translate"); ?></a>
    </li>
    <li class="sep">&middot;</li> -->
  <?php } ?>
  <li class="comments_timestamp">
    <?php echo $this->timestamp($comment->creation_date); ?>
  </li>
</ul>