<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<script type="text/javascript">
   scriptJquery('#profile_groups_blogs_previous').css("display",'<?php echo ( $this->paginator->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>');
    scriptJquery('#profile_groups_blogs_next').css("display",'<?php echo ( $this->paginator->count() == $this->paginator->getCurrentPageNumber() ? 'none' : '' ) ?>');
  en4.core.runonce.add(function(){
     scriptJquery('#profile_groups_blogs_previous').css("display",'<?php echo ( $this->paginator->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>');
    scriptJquery('#profile_groups_blogs_next').css("display",'<?php echo ( $this->paginator->count() == $this->paginator->getCurrentPageNumber() ? 'none' : '' ) ?>');
    <?php if( empty($_POST) ): ?>
      var anchor = scriptJquery('#profile_groups_blogs').parent();
   
    AttachEventListerSE('click','#profile_groups_blogs_previous', function(){
      (scriptJquery.ajax({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        method : 'post',
        dataType : 'html',
        data : {
        format : 'html',
        subject : en4.core.subject.guid,
        page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() - 1) ?>
      },success : function(html){
        scriptJquery(".blogs_profile_paginator").remove();
        anchor.html(html);
      },
                                              }
                                             )
                           )
    }
                                                                  );
    AttachEventListerSE('click','#profile_groups_blogs_next', function(){
      (scriptJquery.ajax({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        method : 'post',
        dataType : 'html',
        data : {
        format : 'html',
        subject : en4.core.subject.guid,
        page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() + 1) ?>
      },success : function(html){
        scriptJquery(".blogs_profile_paginator").remove();
        anchor.html(html);
      }
                                              }
                                             )
                           )
    }
                                                             );
    <?php endif;
    ?>
  }
    );
</script>

<?php if( $this->canAdd && empty($_POST)): ?>
  <div class="profile_tab_options">
    <div>
      <?php echo $this->htmlLink(array('route' => 'blog_general', 'controller' => 'blog', 'action' => 'create', 'parent_type'=> 'group', 'subject_id' => $this->subject()->getIdentity()), $this->translate('Add Blogs'), array('class' => 'btn btn-alt icon_add')) ?>
  </div>
</div>
<?php endif; ?>

<?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
  <div class='container no-padding blogs_listing'>
    <div class='grid_listing' id="profile_groups_blogs">
      <?php foreach( $this->paginator as $blog ): ?>
        <div class='grid_listing_item'>
          <article>
            <div class='grid_listing_item_thumb'>
              <?php echo $this->htmlLink($blog->getHref(), $this->itemBackgroundPhoto($blog, 'thumb.profile')) ?>
            </div>
            <div class='grid_listing_item_info'>
              <span class='grid_listing_item_title'>
                <?php echo $this->htmlLink($blog->getHref(), $blog->getTitle()) ?>
              </span>
              <div class='grid_listing_item_owner'>
                <span><?php echo $this->translate('Posted');?> <?php echo $this->timestamp($blog->creation_date) ?></span>
              </div>
              <div class='grid_listing_item_desc'>
                <?php echo $this->string()->truncate($this->string()->stripTags($blog->body),110) ?>
              </div>
            </div>
          </article>
        </div>
      <?php endforeach;?>
    </div>
  </div>

  <div class="profile_paginator blogs_profile_paginator">
    <div id="profile_groups_blogs_previous" class="paginator_previous">
      <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Previous'), array('onclick' => '', 'class' => 'buttonlink icon_previous')); ?>
    </div>
    <div id="profile_groups_blogs_next" class="paginator_next">
      <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Next'), array('onclick' => '', 'class' => 'buttonlink_right icon_next')); ?>
    </div>
  </div>
<?php else: ?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="<?php echo $this->translate("No Result")?>"></i>
    <p><?php echo $this->translate('No Blog have been added to this group yet.');?></p>
  </div>
<?php endif; ?>
