2013-11-17 09:20:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: Fawaz
|
|
|
|
* Date: 11/15/13
|
|
|
|
* Time: 2:59 PM
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
function get_playlist ( $list_id, $user = null ) {
|
|
|
|
global $cbvid;
|
|
|
|
return $cbvid->action->get_playlist( $list_id, $user );
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_playlist_viewable( $list_id ) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_playlist_items( $list_id, $limit = -1, $order = "playlist_items.playlist_item_id DESC" ) {
|
|
|
|
global $cbvid;
|
|
|
|
return $cbvid->get_playlist_items( $list_id, $order, $limit );
|
|
|
|
}
|
|
|
|
|
|
|
|
function playlist_runtime ( $playlist ) {
|
|
|
|
|
|
|
|
$runtime = (int)0;
|
|
|
|
|
|
|
|
if ( is_array( $playlist ) ) {
|
|
|
|
$runtime = $playlist[ 'runtime' ];
|
|
|
|
} else if ( is_numeric( $playlist ) ) {
|
|
|
|
$runtime = $playlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
$string = '';
|
|
|
|
|
|
|
|
if ( $runtime >= 3600 ) {
|
|
|
|
$hours = intval( intval( $runtime ) / 3600 );
|
|
|
|
if ( $hours > 0 ) {
|
|
|
|
$hours = str_pad( $hours, 2, "0", STR_PAD_LEFT );
|
|
|
|
$string .= $hours.' '.( ( $hours == 1 ) ? lang( 'hour' ) : lang( 'hours' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$minutes = intval( ( $runtime / 60 ) % 60 );
|
|
|
|
|
|
|
|
if ( $minutes > 0 ) {
|
|
|
|
$minutes = str_pad( $minutes, 2, "0", STR_PAD_LEFT );
|
|
|
|
$string .= $minutes.' '.( ( $minutes == 1 ) ? lang( 'minute' ) : lang( 'minutes' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
$seconds = intval( $runtime % 60 );
|
|
|
|
$string .= $seconds.' '.( ( $seconds == 1 ) ? lang( 'second' ) : lang( 'seconds' ) );
|
|
|
|
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_playlist_cover ( $playlist ) {
|
|
|
|
$cover = $playlist[ 'cover' ];
|
|
|
|
$playlist_dir = PLAYLIST_COVERS_DIR;
|
|
|
|
|
|
|
|
if ( empty( $cover ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( file_exists( $playlist_dir.'/'.$cover ) ) {
|
|
|
|
return PLAYLIST_COVERS_URL.'/'.$cover;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_playlist_thumb ( $playlist ) {
|
|
|
|
|
|
|
|
$first_item = $playlist[ 'first_item' ];
|
|
|
|
|
|
|
|
if ( isset( $first_item ) ) {
|
|
|
|
|
|
|
|
if ( !is_array( $first_item ) ) {
|
|
|
|
$first_item = json_decode( $first_item, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
$thumb = get_thumb( $first_item, 'big' );
|
|
|
|
|
|
|
|
if ( strpos( 'processing', $thumb ) !== false ) {
|
|
|
|
return $thumb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$thumb = get_playlist_cover( $playlist );
|
|
|
|
|
|
|
|
return ( $thumb ? $thumb : get_playlist_default_thumb() );
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_playlist_default_thumb() {
|
|
|
|
return false;
|
2013-11-18 13:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function view_playlist( $playlist_id ) {
|
|
|
|
|
|
|
|
$playlist_link = BASEURL;
|
|
|
|
|
|
|
|
if ( is_array( $playlist_id ) and isset( $playlist_id[ 'playlist_id' ] ) ) {
|
|
|
|
$playlist = $playlist_id;
|
|
|
|
} else {
|
|
|
|
$playlist = get_playlist( $playlist_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty( $playlist ) ) {
|
|
|
|
return BASEURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$is_seo = SEO;
|
|
|
|
|
|
|
|
|
|
|
|
$data = cb_do_action( 'view_playlist_link', array( 'playlist' => $playlist, 'seo_enabled' => $is_seo ) );
|
|
|
|
|
|
|
|
if ( $is_seo ) {
|
|
|
|
$playlist_link .= '/list/'.$playlist[ 'playlist_id' ].'/'.SEO( $playlist[ 'playlist_name' ] );
|
|
|
|
} else {
|
|
|
|
$playlist_link .= '/view_playlist.php?list='.$playlist_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$data = cb_do_action( 'view_playlist_link', array(
|
|
|
|
'playlist' => $playlist,
|
|
|
|
'seo_enabled' => $is_seo,
|
|
|
|
'playlist_link' => $playlist_link
|
|
|
|
) );
|
|
|
|
|
|
|
|
if ( $data ) {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $playlist_link;
|
2013-11-17 09:20:17 +00:00
|
|
|
}
|