<?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">
  //<![CDATA[
    en4.core.runonce.add(function() {
      scriptJquery('#sort, #show').on('change', function(){
        scriptJquery(this).parents('form').trigger("submit");
      });
    });
  //]]>
</script>


<?php if( 0 == engine_count($this->paginator) ): ?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="No Result"></i>
    <p><?php echo $this->translate('There is no music uploaded yet.') ?></p>
    <p>
      <?php if( $this->canCreate ): ?>
        <?php echo $this->htmlLink(array(
          'route' => 'music_general',
          'action' => 'create'
        ), $this->translate('Why don\'t you add some?')) ?>
      <?php endif; ?>
    </p>
  </div>
<?php else: ?>

  <ul class="music_listing">
    <?php foreach ($this->paginator as $playlist): ?>
      <li id="music_playlist_item_<?php echo $playlist->getIdentity() ?>" class="music_listing_item">
        <article class="d-flex align-items-start justify-content-start">
          <div class="music_browse_info">
            <div class="manage_listing_header">
              <div class="manage_listing_title">
               <?php echo $this->htmlLink($playlist->getHref(), $playlist->getTitle(), array('class' => 'font_color')) ?>
              </div>
              <?php if ($playlist->isDeletable() || $playlist->isEditable()): ?>
                <div class="dropdown options_menu">
                  <button class="btn btn-alt" type="button" id="manageoption" data-bs-toggle="dropdown" aria-expanded="false"><i class="icon_option_menu"></i></button>
                  <ul class="dropdown-menu dropdown-option-menu dropdown-menu-end" aria-labelledby="manageoption">
                    <?php if ($playlist->isEditable()): ?>
                      <li>
                        <?php echo $this->htmlLink($playlist->getHref(array('route' => 'music_playlist_specific', 'action' => 'edit')),
                          $this->translate('Edit Playlist'),
                          array('class'=>'dropdown-item icon_edit'
                          )) ?>
                      </li>
                    <?php endif; ?>
                    <?php if( $playlist->isDeletable() ): ?>
                      <li>
                        <?php
                            echo $this->htmlLink(array('route' => 'default', 'module' => 'music', 'controller' => 'playlist', 'action' => 'delete', 'playlist_id' => $playlist->getIdentity(), 'format' => 'smoothbox'), $this->translate('Delete Playlist'), array(
                              'class' => 'dropdown-item smoothbox icon_delete'
                            ));
                        ?>
                      </li>
                    <?php endif; ?>
                    <?php if( $playlist->getOwner()->isSelf( Engine_Api::_()->user()->getViewer() ) ): ?>
                      <li>
                        <?php echo $this->htmlLink($playlist->getHref(array('route' => 'music_playlist_specific', 'action' => 'set-profile')),
                          $this->translate($playlist->profile ? 'Disable Profile Playlist' : 'Play on my Profile'),
                          array(
                            'class' => 'dropdown-item icon_music ' . ( $playlist->profile ? 'icon_music_disableonprofile' : 'icon_music_playonprofile' )
                          )
                        ) ?>
                      </li>
                    <?php endif; ?>
                  </ul> 
                </div>  
              <?php endif; ?>
            </div>
            <div class="music_info_top d-flex align-items-start justify-content-start flex-wrap gap-2 mt-2">
              <div class="music_browse_info_date">
                <?php echo $this->translate('Created %s by ', $this->timestamp($playlist->creation_date)) ?>
              </div>
              <div class="music_playlist_stats">
                <?php //if( $playlist->like_count > 0 ) :?>
                  <span>
                    <i class="icon_like"></i>
                    <?php echo $this->translate(array('%s Like', '%s Likes', $playlist->like_count), $this->locale()->toNumber($playlist->like_count)) ?>
                  </span>
                <?php //endif; ?>
               <?php //if( $playlist->comment_count > 0 ) :?>
                  <span>
                    <i class="icon_comment"></i>
                    <?php echo $this->translate(array('%s Comment', '%s Comments', $playlist->comment_count), $this->locale()->toNumber($playlist->comment_count)) ?>
                  </span>
                <?php //endif; ?>
                <?php //if( $playlist->view_count > 0 ) :?>
                  <span class="music_views">
                    <i class="icon_view"></i>
                    <?php echo $this->translate(array('%s View', '%s Views', $playlist->view_count), $this->locale()->toNumber($playlist->view_count)) ?>
                  </span>
                <?php //endif; ?>
                <?php //if( $playlist->play_count > 0 ) :?>
                  <span>
                    <i class="icon_play"></i>
                    <?php echo $this->translate(array('%s Play', '%s Plays', $playlist->play_count), $this->locale()->toNumber($playlist->play_count)) ?>
                  </span>
                <?php //endif; ?>
              </div>         
            </div>
            <?php echo $this->partial('_Player.tpl', array('playlist' => $playlist, 'hideStats' => true)) ?>
            <div class="music_browse_info_desc">
              <?php echo $playlist->description ?>
            </div>
            <div class="manage_listing_approve_tip mt-2">
              <?php echo $this->partial('_approved_tip.tpl', 'core', array('item' => $playlist)); ?>
            </div>
          </div>
        </article>
      </li>
    <?php endforeach; ?>
  </ul>

  <?php echo $this->paginationControl($this->paginator, null, null, array(
    'pageAsQuery' => true,
    'query' => $this->formValues,
    //'params' => $this->formValues,
  )); ?>

<?php endif; ?>


<script type="text/javascript">
  scriptJquery('.core_main_music').parent().addClass('active');
</script>
