<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
// this is done to make these links more uniform with other viewscripts
$playlist = $this->playlist;
$songs    = $playlist->getSongs();
?>

<?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('music.enable.rating', 1)) { ?>
  <script type="text/javascript">
    var modulename = 'music';
    var pre_rate = <?php echo $this->playlist->rating;?>;
    var rated = '<?php echo $this->rated;?>';
    var resource_id = <?php echo $this->playlist->playlist_id;?>;
    var total_votes = <?php echo $this->rating_count;?>;
    var viewer = <?php echo $this->viewer_id;?>;
    new_text = '';
    var resource_type = 'music';
    var rating_text = "<?php echo $this->translate(array('%s rating', '%s ratings', $this->rating_count),$this->locale()->toNumber($this->rating_count)) ?>";
    var ratingIcon = '<?php echo Engine_Api::_()->getApi('settings', 'core')->getSetting('music.ratingicon', 'fas fa-star'); ?>';
  </script>
<?php } ?>
<?php if ($this->popout): ?>
<?php $this->headTitle($playlist->getTitle(), Zend_View_Helper_Placeholder_Container_Abstract::SET) ?>
<div class="music_playlist_popout_wrapper">
  <div class="music_playlist_info_title">
    <h3><?php echo $playlist->getTitle() ?></h3>
  </div>
  <div class="music_playlist_info_date">
    <?php echo $this->translate('Created %1$s by %2$s', $this->timestamp($playlist->creation_date), $this->htmlLink($playlist->getOwner(), $playlist->getOwner()->getTitle())) ?>
  </div>
  <?php echo $this->partial('_Player.tpl', array('playlist'=>$this->playlist,'popout'=>true)) ?>
</div>
<?php return; endif; ?>
<h1 class="music_view_title p-0 m-0">
  <?php echo $playlist->getTitle() ?>
</h1>
<div class="music_playlist" id="music_playlist_item_<?php echo $playlist->getIdentity() ?>">
  <div class="music_view_header d-flex flex-wrap gap-3 mt-2">
    <div class="music_view_header_icon">
      <?php echo $this->htmlLink($playlist->getOwner(), $this->itemBackgroundPhoto($playlist->getOwner(), 'thumb.icon') ) ?>
      </div>
      <div class="music_view_header_info d-flex gap-2">
        <div class="music_view_header_info_left">
        <div class="music_playlist_info_date">
          <?php echo $this->translate('Created %s by ', $this->timestamp($playlist->creation_date)) ?>
          <?php echo $this->htmlLink($playlist->getOwner(), $playlist->getOwner()->getTitle(), array('class' => 'font_color' )) ?>
        </div>   
        <div class="music_playlist_info_rating">
          <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('music.enable.rating', 1)) { ?>
            <?php echo $this->partial('_rating.tpl', 'core', array('item'=>$playlist, 'rated' => $this->rated, 'param' => 'create', 'module' => 'music')); ?>
          <?php } ?>
        </div>       
        </div>
        <div class="music_view_header_info_right">
          <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>
        </div>
      </div>
  </div>
  <div class="music_playlist_info_des mt-2 mb-2">
    <p><?php echo Engine_Api::_()->core()->smileyToEmoticons($playlist->description); ?></p>
  </div>
  <?php echo $this->partial('_Player.tpl', array('playlist'=>$playlist)) ?>
  </div>

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