";
if ($prettyPhoto) {
+ if ($size['width'] >= 150) {
+ echo "
";
+ echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id, ' ', 'directplay_art_' . $object_type . '_' .$object_id);
+ echo "
";
$burl = substr($_SERVER['REQUEST_URI'], strlen(AmpConfig::get('raw_web_path')) + 1);
$burl = rawurlencode($burl);
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 36b359c074..1a82ffe63b 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -367,8 +367,30 @@ public function get_parent()
public function get_childrens()
{
+ $albums = $this->get_albums();
+ foreach ($albums as $album_id) {
+ $medias[] = array(
+ 'object_type' => 'album',
+ 'object_id' => $album_id
+ );
+ }
return array('album' => $this->get_albums());
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'song') {
+ $songs = $this->get_songs();
+ foreach ($songs as $song_id) {
+ $medias[] = array(
+ 'object_type' => 'song',
+ 'object_id' => $song_id
+ );
+ }
+ }
+ return $medias;
+ }
public function get_user_owner()
{
diff --git a/lib/class/broadcast.class.php b/lib/class/broadcast.class.php
index b2e1fb219c..5719ab9c59 100644
--- a/lib/class/broadcast.class.php
+++ b/lib/class/broadcast.class.php
@@ -137,6 +137,19 @@ public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ // Not a media, shouldn't be that
+ $medias = array();
+ if (!$filter_type || $filter_type == 'broadcast') {
+ $medias[] = array(
+ 'object_type' => 'broadcast',
+ 'object_id' => $this->id
+ );
+ }
+ return $medias;
+ }
public function get_user_owner()
{
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 9bc22d3fdf..da90f83533 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -204,6 +204,7 @@ public function show_objects($object_ids = null, $argument = null)
break;
case 'video':
Video::build_cache($object_ids);
+ $video_type = 'video';
$box_title = T_('Videos');
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
@@ -245,22 +246,22 @@ public function show_objects($object_ids = null, $argument = null)
break;
case 'tvshow_episode':
$box_title = T_('Episodes');
- $video_type = 'TVShow_Episode';
+ $video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'movie':
$box_title = T_('Movies');
- $video_type = 'Movie';
+ $video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'clip':
$box_title = T_('Clips');
- $video_type = 'Clip';
+ $video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'personal_video':
$box_title = T_('Personal Videos');
- $video_type = 'Personal_Video';
+ $video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
default:
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index ddec5666e2..02d755db1e 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -836,8 +836,8 @@ public function gather_art_item($type, $id)
$parent = $libitem->get_parent();
if ($parent != null) {
- if (!Art::has_db($parent['id'], $parent['type'])) {
- $this->gather_art_item($parent['type'], $parent['id']);
+ if (!Art::has_db($parent['object_id'], $parent['object_type'])) {
+ $this->gather_art_item($parent['object_type'], $parent['object_id']);
}
}
}
@@ -1676,23 +1676,4 @@ public static function export($type, $catalog_id = '')
} // export
- private static function is_class_typeof($classname, $typeofname)
- {
- if (class_exists($classname)) {
- return in_array($typeofname, array_map('strtolower', class_implements($classname)));
- }
-
- return false;
- }
-
- public static function is_library_item($classname)
- {
- return self::is_class_typeof($classname, 'library_item');
- }
-
- public static function is_media($classname)
- {
- return self::is_class_typeof($classname, 'media');
- }
-
} // end of catalog class
diff --git a/lib/class/channel.class.php b/lib/class/channel.class.php
index bbb42779e7..0a5b8f5036 100644
--- a/lib/class/channel.class.php
+++ b/lib/class/channel.class.php
@@ -20,7 +20,7 @@
*
*/
-class Channel extends database_object implements library_item
+class Channel extends database_object implements media, library_item
{
public $id;
public $is_private;
@@ -193,7 +193,7 @@ public function get_keywords()
public function get_fullname()
{
- return $this->f_name;
+ return $this->name;
}
public function get_parent()
@@ -205,6 +205,18 @@ public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'channel') {
+ $medias[] = array(
+ 'object_type' => 'channel',
+ 'object_id' => $this->id
+ );
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -419,4 +431,20 @@ public static function play_url($oid, $additional_params='')
return $channel->get_stream_proxy_url() . '?rt=' . time() . '&filename=' . urlencode($channel->name) . '.' . $channel->stream_type . $additional_params;
}
+ public function get_stream_types()
+ {
+ // Transcode is mandatory to keep a consistant stream
+ return array('transcode');
+ }
+
+ public function get_stream_name()
+ {
+ return $this->get_fullname();
+ }
+
+ public function set_played($user, $agent)
+ {
+ // Do nothing
+ }
+
} // end of channel class
diff --git a/lib/class/clip.class.php b/lib/class/clip.class.php
index 6dea7c06b4..0bc74d4948 100644
--- a/lib/class/clip.class.php
+++ b/lib/class/clip.class.php
@@ -126,7 +126,7 @@ public function get_keywords()
public function get_parent()
{
if ($this->artist) {
- return array('type' => 'artist', 'id' => $this->artist);
+ return array('object_type' => 'artist', 'object_id' => $this->artist);
}
return null;
diff --git a/lib/class/core.class.php b/lib/class/core.class.php
index b5df1f96f0..ccc730d737 100644
--- a/lib/class/core.class.php
+++ b/lib/class/core.class.php
@@ -246,4 +246,28 @@ public static function is_session_started()
}
return false;
}
+
+ private static function is_class_typeof($classname, $typeofname)
+ {
+ if (class_exists($classname)) {
+ return in_array($typeofname, array_map('strtolower', class_implements($classname)));
+ }
+
+ return false;
+ }
+
+ public static function is_playable_item($classname)
+ {
+ return self::is_class_typeof($classname, 'playable_item');
+ }
+
+ public static function is_library_item($classname)
+ {
+ return self::is_class_typeof($classname, 'library_item');
+ }
+
+ public static function is_media($classname)
+ {
+ return self::is_class_typeof($classname, 'media');
+ }
} // Core
diff --git a/lib/class/library_item.interface.php b/lib/class/library_item.interface.php
index c04fa1bf7a..76d415fc77 100644
--- a/lib/class/library_item.interface.php
+++ b/lib/class/library_item.interface.php
@@ -26,23 +26,10 @@
* work, this lists all required functions and the expected
* input
*/
-interface library_item
+interface library_item extends playable_item
{
- /**
- * format
- *
- * Creates member variables for output
- */
- public function format();
-
public function get_keywords();
- public function get_fullname();
-
- public function get_parent();
-
- public function get_childrens();
-
public function get_user_owner();
public function get_default_art_kind();
diff --git a/lib/class/live_stream.class.php b/lib/class/live_stream.class.php
index 724ff03b7f..d92fc828d2 100644
--- a/lib/class/live_stream.class.php
+++ b/lib/class/live_stream.class.php
@@ -95,6 +95,18 @@ public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'live_stream') {
+ $medias[] = array(
+ 'object_type' => 'live_stream',
+ 'object_id' => $this->id
+ );
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -251,5 +263,10 @@ public static function gc()
{
}
+
+ public function set_played($user, $agent)
+ {
+ // Do nothing
+ }
} //end of radio class
diff --git a/lib/class/media.interface.php b/lib/class/media.interface.php
index b7c24e2ee6..ca3396fe8c 100644
--- a/lib/class/media.interface.php
+++ b/lib/class/media.interface.php
@@ -59,5 +59,7 @@ public function get_transcode_settings($target = null);
* Get the complete name to display for the stream.
*/
public function get_stream_name();
+
+ public function set_played($user, $agent);
} // end interface
diff --git a/lib/class/movie.class.php b/lib/class/movie.class.php
index 2db33e9fbd..ca1599abfa 100644
--- a/lib/class/movie.class.php
+++ b/lib/class/movie.class.php
@@ -23,7 +23,7 @@
class Movie extends Video
{
public $original_name;
- public $description;
+ public $summary;
public $year;
public $video;
@@ -63,9 +63,9 @@ public static function gc()
*/
public static function insert($data, $gtypes = array(), $options = array())
{
- $sql = "INSERT INTO `movie` (`id`,`original_name`,`description`, `year`) " .
+ $sql = "INSERT INTO `movie` (`id`,`original_name`,`summary`, `year`) " .
"VALUES (?, ?, ?, ?)";
- Dba::write($sql, array($data['id'], $data['original_name'], $data['description'], $data['year']));
+ Dba::write($sql, array($data['id'], $data['original_name'], $data['summary'], $data['year']));
return $data['id'];
@@ -79,8 +79,8 @@ public function update($data)
{
parent::update($data);
- $sql = "UPDATE `movie` SET `original_name` = ?, `description` = ?, `year` = ? WHERE `id` = ?";
- Dba::write($sql, array($data['original_name'], $data['description'], $data['year'], $this->id));
+ $sql = "UPDATE `movie` SET `original_name` = ?, `summary` = ?, `year` = ? WHERE `id` = ?";
+ Dba::write($sql, array($data['original_name'], $data['summary'], $data['year'], $this->id));
return $this->id;
diff --git a/lib/class/personal_video.class.php b/lib/class/personal_video.class.php
index 2a4081da6c..1fbbbc7bf3 100644
--- a/lib/class/personal_video.class.php
+++ b/lib/class/personal_video.class.php
@@ -23,7 +23,7 @@
class Personal_Video extends Video
{
public $location;
- public $description;
+ public $summary;
public $video;
public $f_location;
@@ -64,9 +64,9 @@ public static function gc()
*/
public static function insert($data, $gtypes = array(), $options = array())
{
- $sql = "INSERT INTO `personal_video` (`id`,`location`,`description`) " .
+ $sql = "INSERT INTO `personal_video` (`id`,`location`,`summary`) " .
"VALUES (?, ?, ?)";
- Dba::write($sql, array($data['id'], $data['location'], $data['description']));
+ Dba::write($sql, array($data['id'], $data['location'], $data['summary']));
return $data['id'];
@@ -80,8 +80,8 @@ public function update($data)
{
parent::update($data);
- $sql = "UPDATE `personal_video` SET `location` = ?, `description` = ? WHERE `id` = ?";
- Dba::write($sql, array($data['location'], $data['description'], $this->id));
+ $sql = "UPDATE `personal_video` SET `location` = ?, `summary` = ? WHERE `id` = ?";
+ Dba::write($sql, array($data['location'], $data['summary'], $this->id));
return $this->id;
diff --git a/lib/class/playable_item.interface.php b/lib/class/playable_item.interface.php
new file mode 100644
index 0000000000..35e37e68c7
--- /dev/null
+++ b/lib/class/playable_item.interface.php
@@ -0,0 +1,66 @@
+f_name;
- }
-
- public function get_parent()
- {
- return null;
- }
-
- public function get_childrens()
- {
- $childrens = array();
- $items = $this->get_items();
- foreach ($items as $item) {
- if (!in_array($item['object_type'], $childrens)) {
- $childrens[$item['object_type']] = array();
- }
- $childrens[$item['object_type']][] = $item['object_id'];
- }
-
- return $childrens;
- }
-
- public function get_user_owner()
- {
- return $this->user;
- }
-
- public function get_default_art_kind()
- {
- return 'default';
- }
-
/**
* get_track
* Returns the single item on the playlist and all of it's information, restrict
diff --git a/lib/class/playlist_object.abstract.php b/lib/class/playlist_object.abstract.php
index 5da43cde91..c4b2036176 100644
--- a/lib/class/playlist_object.abstract.php
+++ b/lib/class/playlist_object.abstract.php
@@ -24,7 +24,7 @@
* playlist_object
* Abstracting out functionality needed by both normal and smart playlists
*/
-abstract class playlist_object extends database_object
+abstract class playlist_object extends database_object implements library_item
{
// Database variables
public $id;
@@ -35,6 +35,8 @@ abstract class playlist_object extends database_object
public $f_type;
public $f_name;
public $f_user;
+
+ public abstract function get_items();
/**
* format
@@ -69,6 +71,59 @@ public function has_access()
}
} // has_access
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = $this->get_items();
+ if ($filter_type) {
+ $nmedias = array();
+ foreach ($medias as $media) {
+ if ($media['object_type'] == $filter_type) {
+ $nmedias[] = $media;
+ }
+ }
+ }
+ return $medias;
+ }
+
+ public function get_keywords()
+ {
+ return array();
+ }
+
+ public function get_fullname()
+ {
+ return $this->f_name;
+ }
+
+ public function get_parent()
+ {
+ return null;
+ }
+
+ public function get_childrens()
+ {
+ $childrens = array();
+ $items = $this->get_items();
+ foreach ($items as $item) {
+ if (!in_array($item['object_type'], $childrens)) {
+ $childrens[$item['object_type']] = array();
+ }
+ $childrens[$item['object_type']][] = $item['object_id'];
+ }
+
+ return $this->get_items();
+ }
+
+ public function get_user_owner()
+ {
+ return $this->user;
+ }
+
+ public function get_default_art_kind()
+ {
+ return 'default';
+ }
} // end playlist_object
diff --git a/lib/class/search.class.php b/lib/class/search.class.php
index 90b7a763c1..10bbd15e1b 100644
--- a/lib/class/search.class.php
+++ b/lib/class/search.class.php
@@ -25,7 +25,7 @@
* Search-related voodoo. Beware tentacles.
*/
-class Search extends playlist_object implements library_item
+class Search extends playlist_object
{
public $searchtype;
public $rules;
@@ -622,45 +622,6 @@ public function format()
$this->f_name_link = '
' . $this->f_name . ' ';
}
- public function get_keywords()
- {
- return array();
- }
-
- public function get_fullname()
- {
- return $this->f_name;
- }
-
- public function get_parent()
- {
- return null;
- }
-
- public function get_childrens()
- {
- $childrens = array();
- $items = $this->get_items();
- foreach ($items as $item) {
- if (!in_array($item['object_type'], $childrens)) {
- $childrens[$item['object_type']] = array();
- }
- $childrens[$item['object_type']][] = $item['object_id'];
- }
-
- return $childrens;
- }
-
- public function get_user_owner()
- {
- return $this->user;
- }
-
- public function get_default_art_kind()
- {
- return 'default';
- }
-
/**
* get_items
*
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 945bfa037f..432d97038c 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -508,16 +508,20 @@ public function get_album_artist_name($album_artist_id=0)
/**
* set_played
* this checks to see if the current object has been played
- * if not then it sets it to played
+ * if not then it sets it to played. In any case it updates stats.
*/
- public function set_played()
+ public function set_played($user, $agent)
{
+ Stats::insert('song', $this->id, $user, $agent);
+ Stats::insert('album', $this->id, $user, $agent);
+ Stats::insert('artist', $this->id, $user, $agent);
+
if ($this->played) {
return true;
}
/* If it hasn't been played, set it! */
- self::update_played('1',$this->id);
+ self::update_played('1', $this->id);
return true;
@@ -976,13 +980,25 @@ public function get_fullname()
public function get_parent()
{
- return array('type' => 'album', 'id' => $this->album);
+ return array('object_type' => 'album', 'object_id' => $this->album);
}
public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'song') {
+ $medias[] = array(
+ 'object_type' => 'song',
+ 'object_id' => $this->id
+ );
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -1263,7 +1279,7 @@ public function show_custom_play_actions()
{
$actions = Song::get_custom_play_actions();
foreach ($actions as $action) {
- echo Ajax::button('?page=stream&action=directplay&playtype=song&song_id=' . $this->id . '&custom_play_action=' . $action['index'], $action['icon'], T_($action['title']), $action['icon'] . '_song_' . $this->id);
+ echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $this->id . '&custom_play_action=' . $action['index'], $action['icon'], T_($action['title']), $action['icon'] . '_song_' . $this->id);
}
}
diff --git a/lib/class/song_preview.class.php b/lib/class/song_preview.class.php
index 4a4b8452d7..9a64e6a3c8 100644
--- a/lib/class/song_preview.class.php
+++ b/lib/class/song_preview.class.php
@@ -20,7 +20,7 @@
*
*/
-class Song_Preview extends database_object implements media
+class Song_Preview extends database_object implements media, playable_item
{
public $id;
public $file;
@@ -219,6 +219,34 @@ public function format()
return true;
} // format
+
+ public function get_fullname()
+ {
+ return $this->f_name;
+ }
+
+ public function get_parent()
+ {
+ // Wanted album is not part of the library, cannot return it.
+ return null;
+ }
+
+ public function get_childrens()
+ {
+ return array();
+ }
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'song_preview') {
+ $medias[] = array(
+ 'object_type' => 'song_preview',
+ 'object_id' => $this>-id
+ );
+ }
+ return $medias;
+ }
/**
* play_url
@@ -259,6 +287,11 @@ public function get_stream_name()
{
return $this->title;
}
+
+ public function set_played($user, $agent)
+ {
+ // Do nothing
+ }
public static function get_song_previews($album_mbid)
{
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index b860a21b88..7e8683a2c6 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -338,9 +338,15 @@ public static function validate_type($type)
public static function get_newest_sql($type, $catalog=0)
{
$type = self::validate_type($type);
+
+ $base_type = 'song';
+ if ($type == 'video') {
+ $base_type = $type;
+ $type = $type . '`.`id';
+ }
- $sql = "SELECT DISTINCT(`$type`) as `id`, MIN(`addition_time`) AS `real_atime` FROM `song` ";
- $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
+ $sql = "SELECT DISTINCT(`$type`) as `id`, MIN(`addition_time`) AS `real_atime` FROM `" . $base_type . "` ";
+ $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `" . $base_type . "`.`catalog` ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "WHERE `catalog`.`enabled` = '1' ";
}
@@ -348,6 +354,7 @@ public static function get_newest_sql($type, $catalog=0)
$sql .= "AND `catalog` = '" . scrub_in($catalog) ."' ";
}
$sql .= "GROUP BY `$type` ORDER BY `real_atime` DESC ";
+
return $sql;
}
diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php
index c5181babbf..af17953724 100644
--- a/lib/class/tag.class.php
+++ b/lib/class/tag.class.php
@@ -91,7 +91,7 @@ public static function build_map_cache($type, $ids)
{
if (!is_array($ids) OR !count($ids)) { return false; }
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$idlist = '(' . implode(',',$ids) . ')';
@@ -131,7 +131,7 @@ public static function build_map_cache($type, $ids)
*/
public static function add($type, $id, $value, $user=false)
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
if (!is_numeric($id)) { return false; }
@@ -254,7 +254,7 @@ public static function add_tag_map($type,$object_id,$tag_id,$user='')
{
$uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
$tag_id = intval($tag_id);
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$id = intval($object_id);
@@ -361,7 +361,7 @@ public static function tag_exists($value)
*/
public static function tag_map_exists($type,$object_id,$tag_id,$user)
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$sql = "SELECT * FROM `tag_map` LEFT JOIN `tag` ON `tag`.`id` = `tag_map`.`tag_id` " .
@@ -380,7 +380,7 @@ public static function tag_map_exists($type,$object_id,$tag_id,$user)
*/
public static function get_top_tags($type, $object_id, $limit = 10)
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$object_id = intval($object_id);
@@ -410,7 +410,7 @@ public static function get_top_tags($type, $object_id, $limit = 10)
*/
public static function get_object_tags($type, $id)
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
@@ -433,7 +433,7 @@ public static function get_object_tags($type, $id)
*/
public static function get_tag_objects($type,$tag_id,$count='',$offset='')
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$limit_sql = "";
@@ -609,7 +609,7 @@ public function count($type='')
*/
public function remove_map($type,$object_id)
{
- if (!Catalog::is_library_item($type))
+ if (!Core::is_library_item($type))
return false;
$sql = "DELETE FROM `tag_map` WHERE `tag_id` = ? AND `object_type` = ? AND `object_id` = ? AND `user` = ?";
@@ -648,6 +648,21 @@ public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if ($filter_type) {
+ $ids = Tag::get_tag_objects($filter_type, $this->id);
+ foreach ($ids as $id) {
+ $medias[] = array(
+ 'object_type' => $filter_type,
+ 'object_id' => $id
+ );
+ }
+ }
+ return $medias;
+ }
public function get_user_owner()
{
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php
index a4865c82fd..0c17f047d7 100644
--- a/lib/class/tmp_playlist.class.php
+++ b/lib/class/tmp_playlist.class.php
@@ -321,6 +321,13 @@ public function add_object($object_id,$object_type)
return true;
} // add_object
+
+ public function add_medias($medias)
+ {
+ foreach ($medias as $media) {
+ $this->add_object($media['object_id'], $media['object_type']);
+ }
+ }
/**
* vote_active
diff --git a/lib/class/tvshow.class.php b/lib/class/tvshow.class.php
index 857af18ddc..2140c92a90 100644
--- a/lib/class/tvshow.class.php
+++ b/lib/class/tvshow.class.php
@@ -25,7 +25,7 @@ class TVShow extends database_object implements library_item
/* Variables from DB */
public $id;
public $name;
- public $description;
+ public $summary;
public $year;
public $tags;
@@ -212,6 +212,21 @@ public function get_childrens()
{
return array('tvshow_season' => $this->get_seasons());
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'video') {
+ $episodes = $this->get_episodes();
+ foreach ($episodes as $episode_id) {
+ $medias[] = array(
+ 'object_type' => 'video',
+ 'object_id' => $episode_id
+ );
+ }
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -301,8 +316,8 @@ public function update($data)
} // end if it changed
}
- $sql = 'UPDATE `tvshow` SET `name` = ?, `year` = ?, `description` = ? WHERE `id` = ?';
- Dba::write($sql, array($data['name'], $data['year'], $data['description'], $current_id));
+ $sql = 'UPDATE `tvshow` SET `name` = ?, `year` = ?, `summary` = ? WHERE `id` = ?';
+ Dba::write($sql, array($data['name'], $data['year'], $data['summary'], $current_id));
$override_childs = false;
if ($data['apply_childs'] == 'checked') {
diff --git a/lib/class/tvshow_episode.class.php b/lib/class/tvshow_episode.class.php
index 9bd8765435..b67996a78b 100644
--- a/lib/class/tvshow_episode.class.php
+++ b/lib/class/tvshow_episode.class.php
@@ -25,7 +25,7 @@ class TVShow_Episode extends Video
public $original_name;
public $season;
public $episode_number;
- public $description;
+ public $summary;
public $f_link;
public $f_season;
@@ -107,9 +107,9 @@ public static function insert($data, $gtypes = array(), $options = array())
*/
public static function create($data)
{
- $sql = "INSERT INTO `tvshow_episode` (`id`, `original_name`, `season`, `episode_number`, `description`) " .
+ $sql = "INSERT INTO `tvshow_episode` (`id`, `original_name`, `season`, `episode_number`, `summary`) " .
"VALUES (?, ?, ?, ?, ?)";
- Dba::write($sql, array($data['id'], $data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['description']));
+ Dba::write($sql, array($data['id'], $data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary']));
return $data['id'];
@@ -122,9 +122,8 @@ public static function create($data)
public function update($data)
{
parent::update($data);
-
- $sql = "UPDATE `tvshow_episode` SET `original_name` = ?, `season` = ?, `episode_number` = ?, `description` = ? WHERE `id` = ?";
- Dba::write($sql, array($data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['description'], $this->id));
+ $sql = "UPDATE `tvshow_episode` SET `original_name` = ?, `season` = ?, `episode_number` = ?, `summary` = ? WHERE `id` = ?";
+ Dba::write($sql, array($data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary'], $this->id));
return $this->id;
@@ -182,7 +181,13 @@ public function get_keywords()
public function get_parent()
{
- return array('type' => 'tvshow_season', 'id' => $this->season);
+ return array('object_type' => 'tvshow_season', 'object_id' => $this->season);
}
+ public function get_release_item_art()
+ {
+ return array('object_type' => 'tvshow_season',
+ 'object_id' => $this->season
+ );
+ }
}
diff --git a/lib/class/tvshow_season.class.php b/lib/class/tvshow_season.class.php
index ff66fe7383..840508997f 100644
--- a/lib/class/tvshow_season.class.php
+++ b/lib/class/tvshow_season.class.php
@@ -167,13 +167,28 @@ public function get_fullname()
public function get_parent()
{
- return array('type' => 'tvshow', 'id' => $this->tvshow);
+ return array('object_type' => 'tvshow', 'object_id' => $this->tvshow);
}
public function get_childrens()
{
return array('tvshow_episode' => $this->get_episodes());
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'video') {
+ $episodes = $this->get_episodes();
+ foreach ($episodes as $episode_id) {
+ $medias[] = array(
+ 'object_type' => 'video',
+ 'object_id' => $episode_id
+ );
+ }
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -246,8 +261,8 @@ public static function check($tvshow, $season_number, $readonly = false)
*/
public function update($data)
{
- $sql = 'UPDATE `tvshow_season` SET `season_number` = ? WHERE `id` = ?';
- Dba::write($sql, array($data['season_number'], $this->id));
+ $sql = 'UPDATE `tvshow_season` SET `season_number` = ?, `tvshow` = ? WHERE `id` = ?';
+ Dba::write($sql, array($data['season_number'], $data['tvshow'], $this->id));
return $this->id;
} // update
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index e3a261d39c..ca43e043b1 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -2712,13 +2712,14 @@ public static function update_370008()
*/
public static function update_370009()
{
- $sql = "ALTER TABLE `video` ADD `release_date` int(11) unsigned NULL AFTER `enabled`";
+ $sql = "ALTER TABLE `video` ADD `release_date` int(11) unsigned NULL AFTER `enabled`, " .
+ "`played` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `enabled`";
Dba::write($sql);
$sql = "CREATE TABLE `tvshow` (" .
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
"`name` varchar(80) NOT NULL," .
- "`description` varchar(256) NULL," .
+ "`summary` varchar(256) NULL," .
"`year` int(11) unsigned NULL," .
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
Dba::write($sql);
@@ -2735,14 +2736,14 @@ public static function update_370009()
"`original_name` varchar(80) NULL," .
"`season` int(11) unsigned NOT NULL," .
"`episode_number` int(11) unsigned NOT NULL," .
- "`description` varchar(256) NULL," .
+ "`summary` varchar(256) NULL," .
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
Dba::write($sql);
$sql = "CREATE TABLE `movie` (" .
"`id` int(11) unsigned NOT NULL," .
"`original_name` varchar(80) NULL," .
- "`description` varchar(256) NULL," .
+ "`summary` varchar(256) NULL," .
"`year` int(11) unsigned NULL," .
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
Dba::write($sql);
@@ -2750,7 +2751,7 @@ public static function update_370009()
$sql = "CREATE TABLE `personal_video` (" .
"`id` int(11) unsigned NOT NULL," .
"`location` varchar(256) NULL," .
- "`description` varchar(256) NULL," .
+ "`summary` varchar(256) NULL," .
"PRIMARY KEY (`id`)) ENGINE = MYISAM";
Dba::write($sql);
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index b2aaa1567d..43adadad73 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -694,46 +694,44 @@ public function update_last_seen()
* update_user_stats
* updates the playcount mojo for this specific user
*/
- public function update_stats($song_id, $agent = '')
+ public function update_stats($media_type, $media_id, $agent = '')
{
- debug_event('user.class.php', 'Updating stats for {'.$song_id.'} {'.$agent.'}...', '5');
- $song_info = new Song($song_id);
- $song_info->format();
+ debug_event('user.class.php', 'Updating stats for {'.$media_type.'/'.$media_id.'} {'.$agent.'}...', '5');
+ $media = new $media_type($media_id);
+ $media->format();
$user = $this->id;
- if (!strlen($song_info->file)) { return false; }
+ // We shouldn't test on file only
+ if (!strlen($media->file)) { return false; }
$this->set_preferences();
// If pthreads available, we call save_songplay in a new thread to quickly return
if (class_exists("Thread", false)) {
- debug_event('user.class.php', 'Calling save_songplay plugins in a new thread...', '5');
- $thread = new scrobbler_async($GLOBALS['user'], $song_info);
+ debug_event('user.class.php', 'Calling save_mediaplay plugins in a new thread...', '5');
+ $thread = new scrobbler_async($GLOBALS['user'], $media);
if ($thread->start()) {
//$thread->join();
} else {
debug_event('user.class.php', 'Error when starting the thread.', '1');
}
} else {
- User::save_songplay($GLOBALS['user'], $song_info);
+ User::save_mediaplay($GLOBALS['user'], $media);
}
- // Do this last so the 'last played checks are correct'
- Stats::insert('song', $song_id, $user, $agent);
- Stats::insert('album', $song_info->album, $user, $agent);
- Stats::insert('artist', $song_info->artist, $user, $agent);
+ $media->set_played($user, $agent);
return true;
} // update_stats
- public static function save_songplay($user, $song_info)
+ public static function save_mediaplay($user, $media)
{
- foreach (Plugin::get_plugins('save_songplay') as $plugin_name) {
+ foreach (Plugin::get_plugins('save_mediaplay') as $plugin_name) {
try {
$plugin = new Plugin($plugin_name);
if ($plugin->load($user)) {
- $plugin->_plugin->save_songplay($song_info);
+ $plugin->_plugin->save_mediaplay($media);
}
} catch (Exception $e) {
debug_event('user.class.php', 'Stats plugin error: ' . $e->getMessage(), '1');
diff --git a/lib/class/video.class.php b/lib/class/video.class.php
index bcae4ec133..70093a7eeb 100644
--- a/lib/class/video.class.php
+++ b/lib/class/video.class.php
@@ -24,6 +24,7 @@ class Video extends database_object implements media, library_item
{
public $id;
public $title;
+ public $played;
public $enabled;
public $file;
public $size;
@@ -162,6 +163,18 @@ public function get_childrens()
{
return array();
}
+
+ public function get_medias($filter_type = null)
+ {
+ $medias = array();
+ if (!$filter_type || $filter_type == 'video') {
+ $medias[] = array(
+ 'object_type' => 'video',
+ 'object_id' => $this->id
+ );
+ }
+ return $medias;
+ }
public function get_user_owner()
{
@@ -332,12 +345,22 @@ private static function insert_video_type($data, $gtypes, $options = array())
*/
public function update($data)
{
+ $f_release_date = $data['f_release_date'];
+ $release_date = date_parse_from_format('Y-m-d', $f_release_date);
+
$sql = "UPDATE `video` SET `title` = ?, `release_date` = ? WHERE `id` = ?";
- Dba::write($sql, array($data['title'], $data['release_date'], $this->id));
+ Dba::write($sql, array($data['title'], $release_date, $this->id));
return $this->id;
} // update
+
+ public function get_release_item_art()
+ {
+ return array('object_type' => 'video',
+ 'object_id' => $this->id
+ );
+ }
/*
* generate_preview
@@ -352,5 +375,88 @@ public static function generate_preview($video_id, $overwrite = false)
$artp->insert($image, 'image/png');
}
}
+
+ /**
+ * get_random
+ *
+ * This returns a number of random videos.
+ */
+ public static function get_random($count = 1)
+ {
+ $results = array();
+
+ if (!$count) {
+ $count = 1;
+ }
+
+ $sql = "SELECT DISTINCT(`video`.`id`) FROM `video` ";
+ $where = "WHERE `video`.`enabled` = '1' ";
+ if (AmpConfig::get('catalog_disable')) {
+ $sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `video`.`catalog` ";
+ $where .= "AND `catalog`.`enabled` = '1' ";
+ }
+
+ $sql .= $where;
+ $sql .= "ORDER BY RAND() LIMIT " . intval($count);
+ $db_results = Dba::read($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
+
+ return $results;
+ }
+
+ /**
+ * set_played
+ * this checks to see if the current object has been played
+ * if not then it sets it to played. In any case it updates stats.
+ */
+ public function set_played($user, $agent)
+ {
+ Stats::insert('video', $this->id, $user, $agent);
+
+ if ($this->played) {
+ return true;
+ }
+
+ /* If it hasn't been played, set it! */
+ Video::update_played('1', $this->id);
+
+ return true;
+
+ } // set_played
+
+ /**
+ * update_played
+ * sets the played flag
+ */
+ public static function update_played($new_played,$song_id)
+ {
+ self::_update_item('played',$new_played,$song_id,'25');
+
+ } // update_played
+
+ /**
+ * _update_item
+ * This is a private function that should only be called from within the video class.
+ * It takes a field, value video id and level. first and foremost it checks the level
+ * against $GLOBALS['user'] to make sure they are allowed to update this record
+ * it then updates it and sets $this->{$field} to the new value
+ */
+ private static function _update_item($field, $value, $song_id, $level)
+ {
+ /* Check them Rights! */
+ if (!Access::check('interface',$level)) { return false; }
+
+ /* Can't update to blank */
+ if (!strlen(trim($value))) { return false; }
+
+ $sql = "UPDATE `video` SET `$field` = ? WHERE `id` = ?";
+ Dba::write($sql, array($value, $song_id));
+
+ return true;
+
+ } // _update_item
} // end Video class
diff --git a/lib/class/webplayer.class.php b/lib/class/webplayer.class.php
index 661651bdcd..4c05619f79 100644
--- a/lib/class/webplayer.class.php
+++ b/lib/class/webplayer.class.php
@@ -85,7 +85,7 @@ protected static function get_types($item, $force_type='')
$media = null;
$urlinfo = Stream_URL::parse($item->url);
- if ($urlinfo['id'] && Catalog::is_media($urlinfo['type'])) {
+ if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
$media = new $urlinfo['type']($urlinfo['id']);
} else if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
$media = new Song_Preview($urlinfo['id']);
diff --git a/lib/init-tiny.php b/lib/init-tiny.php
index 9f550af63a..ce87f9f812 100644
--- a/lib/init-tiny.php
+++ b/lib/init-tiny.php
@@ -79,9 +79,10 @@
require_once $prefix . '/lib/themes.php';
require_once $prefix . '/lib/class/localplay_controller.abstract.php';
require_once $prefix . '/lib/class/database_object.abstract.php';
-require_once $prefix . '/lib/class/playlist_object.abstract.php';
require_once $prefix . '/lib/class/media.interface.php';
+require_once $prefix . '/lib/class/playable_item.interface.php';
require_once $prefix . '/lib/class/library_item.interface.php';
+require_once $prefix . '/lib/class/playlist_object.abstract.php';
require_once $prefix . '/modules/horde/Browser.php';
/* Set up the flip class */
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 38c2fa16d4..66efbb0d51 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -274,12 +274,12 @@ function show_artist_select($name='artist', $artist_id=0, $allow_add=false, $son
* This is the same as show_album_select except it's *gasp* for tvshows! How
* inventive!
*/
-function show_tvshow_select($name='tvshow', $tvshow_id=0, $allow_add=false, $tvshow_id=0, $allow_none=false)
+function show_tvshow_select($name='tvshow', $tvshow_id=0, $allow_add=false, $season_id=0, $allow_none=false)
{
static $tvshow_id_cnt = 0;
// Generate key to use for HTML element ID
- if ($tvshow_id) {
- $key = $name . "_select_" . $tvshow_id;
+ if ($season_id) {
+ $key = $name . "_select_" . $season_id;
} else {
$key = $name . "_select_c" . ++$tvshow_id_cnt;
}
@@ -312,6 +312,48 @@ function show_tvshow_select($name='tvshow', $tvshow_id=0, $allow_add=false, $tvs
} // show_tvshow_select
+function show_tvshow_season_select($name='tvshow_season', $season_id, $allow_add=false, $video_id=0, $allow_none=false)
+{
+ if (!$season_id)
+ return false;
+ $season = new TVShow_Season($season_id);
+
+ static $season_id_cnt = 0;
+ // Generate key to use for HTML element ID
+ if ($video_id) {
+ $key = $name . "_select_" . $video_id;
+ } else {
+ $key = $name . "_select_c" . ++$season_id_cnt;
+ }
+
+ echo "
\n";
+
+ if ($allow_none) {
+ echo "\t \n";
+ }
+
+ $sql = "SELECT `id`, `season_number` FROM `tvshow_season` WHERE `tvshow` = ? ORDER BY `season_number`";
+ $db_results = Dba::read($sql, array($season->tvshow));
+
+ while ($r = Dba::fetch_assoc($db_results)) {
+ $selected = '';
+ if ($r['id'] == $season_id) {
+ $selected = "selected=\"selected\"";
+ }
+
+ echo "\t" . scrub_out($r['season_number']) . " \n";
+
+ } // end while
+
+ if ($allow_add) {
+ // Append additional option to the end with value=-1
+ echo "\tAdd New... \n";
+ }
+
+ echo " \n";
+
+}
+
/**
* show_catalog_select
* Yet another one of these buggers. this shows a drop down of all of your
@@ -653,6 +695,7 @@ function show_now_playing()
$web_path = AmpConfig::get('web_path');
$results = Stream::get_now_playing();
+ debug_event('aa',print_r($results, true), 5);
require_once AmpConfig::get('prefix') . '/templates/show_now_playing.inc.php';
} // show_now_playing
diff --git a/modules/plugins/Growl.plugin.php b/modules/plugins/Growl.plugin.php
index 9065b0f520..6789cb3a2c 100644
--- a/modules/plugins/Growl.plugin.php
+++ b/modules/plugins/Growl.plugin.php
@@ -91,8 +91,11 @@ public function upgrade() {
* save_songplay
* This takes care of queueing and then submitting the tracks.
*/
- public function save_songplay($song) {
+ public function save_mediaplay($song) {
+ // Only support songs
+ if (strtolower(get_class($song)) != 'song') return false;
+
// Before we start let's pull the last song submitted by this user
$previous = Stats::get_last_song($this->user_id);
$user = new User($this->user_id);
diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php
index 25296a9f4b..5fbe3e0cc8 100644
--- a/modules/plugins/Lastfm.plugin.php
+++ b/modules/plugins/Lastfm.plugin.php
@@ -102,8 +102,10 @@ public function upgrade() {
* save_songplay
* This takes care of queueing and then submitting the tracks.
*/
- public function save_songplay($song) {
-
+ public function save_mediaplay($song) {
+ // Only support songs
+ if (strtolower(get_class($song)) != 'song') return false;
+
// Let's pull the last song submitted by this user
$previous = Stats::get_last_song($this->user_id);
diff --git a/modules/plugins/Librefm.plugin.php b/modules/plugins/Librefm.plugin.php
index f5d8e94334..a71afe729c 100644
--- a/modules/plugins/Librefm.plugin.php
+++ b/modules/plugins/Librefm.plugin.php
@@ -102,8 +102,11 @@ public function upgrade() {
* save_songplay
* This takes care of queueing and then submitting the tracks.
*/
- public function save_songplay($song) {
-
+ public function save_mediaplay($song) {
+
+ // Only support songs
+ if (strtolower(get_class($song)) != 'song') return false;
+
// Before we start let's pull the last song submitted by this user
$previous = Stats::get_last_song($this->user_id);
diff --git a/play/index.php b/play/index.php
index b42ce4fcd0..484ced00c0 100644
--- a/play/index.php
+++ b/play/index.php
@@ -405,10 +405,7 @@
}
header('ETag: ' . $media->id);
-// Put this song in the now_playing table only if it's a song for now...
-if ($type == 'song') {
- Stream::insert_now_playing($media->id, $uid, $media->time, $sid, get_class($media));
-}
+Stream::insert_now_playing($media->id, $uid, $media->time, $sid, get_class($media));
// Handle Content-Range
@@ -444,6 +441,21 @@
debug_event('play','Starting stream of ' . $media->file . ' with size ' . $media->size, 5);
}
+// Stats registering must be done before play. Do not move it.
+// It can be slow because of scrobbler plugins (lastfm, ...)
+if ($start > 0) {
+ debug_event('play', 'Content-Range doesn\'t start from 0, stats should already be registered previously; not collecting stats', 5);
+} else {
+ if (empty($share_id)) {
+ if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
+ debug_event('play', 'Registering stats for {'.$media->get_stream_name() .'}...', '5');
+ $sessionkey = Stream::$session;
+ $agent = Session::agent($sessionkey);
+ $GLOBALS['user']->update_stats($type, $media->id, $agent);
+ }
+ }
+}
+
if ($transcode || $demo_id) {
header('Accept-Ranges: none');
} else {
@@ -476,23 +488,6 @@
$bytes_streamed = $stream_size;
}
-if ($start > 0) {
- debug_event('play', 'Content-Range doesn\'t start from 0, stats should already be registered previously; not collecting stats', 5);
-} else if ($real_bytes_streamed > 0) {
- // FIXME: support other media types
- if ($type == 'song' && empty($share_id)) {
- if ($_SERVER['REQUEST_METHOD'] != 'HEAD') {
- debug_event('play', 'Registering stats for {'.$media->title.'}...', '5');
- $sessionkey = Stream::$session;
- //debug_event('play', 'Current session key {'.$sessionkey.'}', '5');
- $agent = Session::agent($sessionkey);
- //debug_event('play', 'Current session agent {'.$agent.'}', '5');
- $GLOBALS['user']->update_stats($media->id, $agent);
- $media->set_played();
- }
- }
-}
-
// If this is a democratic playlist remove the entry.
// We do this regardless of play amount.
if ($demo_id && isset($democratic)) { $democratic->delete_from_oid($oid, $type); }
diff --git a/server/ajax.server.php b/server/ajax.server.php
index 03019e77cd..f5bb5c65c7 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -94,102 +94,60 @@
break;
// Handle the users basketcases...
case 'basket':
- switch ($_REQUEST['type']) {
- case 'album':
- foreach ($_REQUEST['id'] as $i) {
- $object = new $_REQUEST['type']($i);
- $songs = $object->get_songs();
- foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id, 'song');
+ $object_type = $_REQUEST['type'];
+ $object_id = $_REQUEST['id'];
+
+ if (Core::is_playable_item($object_type)) {
+ if (!is_array($object_id)) {
+ $object_id = array($object_id);
+ }
+ foreach ($object_id as $id) {
+ $item = new $object_type($id);
+ $medias = $item->get_medias();
+ $GLOBALS['user']->playlist->add_medias($medias);
+ }
+ } else {
+ switch ($_REQUEST['type']) {
+ case 'browse_set':
+ $browse = new Browse($_REQUEST['browse_id']);
+ $objects = $browse->get_saved();
+ foreach ($objects as $object_id) {
+ $GLOBALS['user']->playlist->add_object($object_id, 'song');
}
- }
- break;
- case 'artist':
- case 'tag':
- $object = new $_REQUEST['type']($_REQUEST['id']);
- $songs = $object->get_songs();
- foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id,'song');
- }
- break;
- case 'browse_set':
- $browse = new Browse($_REQUEST['browse_id']);
- $objects = $browse->get_saved();
- foreach ($objects as $object_id) {
- $GLOBALS['user']->playlist->add_object($object_id,'song');
- }
- break;
- case 'album_random':
- $data = explode('_',$_REQUEST['type']);
- $type = $data['0'];
- foreach ($_REQUEST['id'] as $i) {
- $object = new $type($i);
+ break;
+ case 'album_random':
+ $data = explode('_',$_REQUEST['type']);
+ $type = $data['0'];
+ foreach ($_REQUEST['id'] as $i) {
+ $object = new $type($i);
+ $songs = $object->get_random_songs();
+ foreach ($songs as $song_id) {
+ $GLOBALS['user']->playlist->add_object($song_id, 'song');
+ }
+ }
+ break;
+ case 'artist_random':
+ case 'tag_random':
+ $data = explode('_',$_REQUEST['type']);
+ $type = $data['0'];
+ $object = new $type($_REQUEST['id']);
$songs = $object->get_random_songs();
foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id, 'song');
+ $GLOBALS['user']->playlist->add_object($song_id,'song');
}
- }
- break;
- case 'artist_random':
- case 'tag_random':
- $data = explode('_',$_REQUEST['type']);
- $type = $data['0'];
- $object = new $type($_REQUEST['id']);
- $songs = $object->get_random_songs();
- foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id,'song');
- }
- break;
- case 'playlist':
- $playlist = new Playlist($_REQUEST['id']);
- $items = $playlist->get_items();
- foreach ($items as $item) {
- $GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
- }
- break;
- case 'playlist_random':
- $playlist = new Playlist($_REQUEST['id']);
- $items = $playlist->get_random_items();
- foreach ($items as $item) {
- $GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
- }
- break;
- case 'smartplaylist':
- $playlist = new Search($_REQUEST['id'], 'song');
- $items = $playlist->get_items();
- foreach ($items as $item) {
- $GLOBALS['user']->playlist->add_object($item['object_id'],$item['object_type']);
- }
- break;
- case 'clear_all':
- $GLOBALS['user']->playlist->clear();
- break;
- case 'live_stream':
- $object = new Live_Stream($_REQUEST['id']);
- // Confirm its a valid ID
- if ($object->name) {
- $GLOBALS['user']->playlist->add_object($object->id, 'live_stream');
- }
- break;
- case 'video':
- $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'video');
- break;
- case 'album_preview':
- $songs = Song_preview::get_song_previews($_REQUEST['mbid']);
- foreach ($songs as $song) {
- if (!empty($song->file)) {
- $GLOBALS['user']->playlist->add_object($song->id, 'song_preview');
+ break;
+ case 'playlist_random':
+ $playlist = new Playlist($_REQUEST['id']);
+ $items = $playlist->get_random_items();
+ foreach ($items as $item) {
+ $GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
}
- }
- break;
- case 'song_preview':
- $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'song_preview');
- break;
- case 'song':
- default:
- $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'song');
- break;
- } // end switch
+ break;
+ case 'clear_all':
+ $GLOBALS['user']->playlist->clear();
+ break;
+ }
+ }
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
diff --git a/server/edit.server.php b/server/edit.server.php
index d74812c5ff..411f2d35a5 100644
--- a/server/edit.server.php
+++ b/server/edit.server.php
@@ -33,7 +33,11 @@
debug_event('edit.server.php', 'Called for action: {'.$_REQUEST['action'].'}', '5');
-$type = $_GET['type'];
+// Post first
+$type = $_POST['type'];
+if (empty($type)) {
+ $type = $_GET['type'];
+}
$object_id = $_GET['id'];
if (empty($type)) {
@@ -42,7 +46,7 @@
$object_type = implode('_', explode('_', $type, -1));
}
-if (!Catalog::is_library_item($object_type)) {
+if (!Core::is_library_item($object_type)) {
debug_event('edit.server.php', 'Type `' . $type . '` is not based on an item library.', '3');
exit();
}
diff --git a/server/index.ajax.php b/server/index.ajax.php
index 97dcc813f2..a19d5475e5 100644
--- a/server/index.ajax.php
+++ b/server/index.ajax.php
@@ -37,6 +37,16 @@
$results['random_selection'] = '';
}
break;
+ case 'random_videos':
+ $videos = Video::get_random(6, true);
+ if (count($videos) AND is_array($videos)) {
+ ob_start();
+ require_once AmpConfig::get('prefix') . '/templates/show_random_videos.inc.php';
+ $results['random_video_selection'] = ob_get_clean();
+ } else {
+ $results['random_video_selection'] = '';
+ }
+ break;
case 'artist_info':
if (AmpConfig::get('lastfm_api_key') && (isset($_REQUEST['artist']) || isset($_REQUEST['fullname']))) {
if ($_REQUEST['artist']) {
diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php
index 2463c6b584..42fa51ff7e 100644
--- a/server/playlist.ajax.php
+++ b/server/playlist.ajax.php
@@ -82,14 +82,6 @@
$songs[] = $item['object_id'];
}
break;
- case 'album_preview':
- $preview_songs = Song_preview::get_song_previews($item_id);
- foreach ($preview_songs as $song) {
- if (!empty($song->file)) {
- $songs[] = $song->id;
- }
- }
- break;
case 'album':
debug_event('playlist', 'Adding all songs of album(s) {'.$item_id.'}...', '5');
$albums_array = explode(',', $item_id);
diff --git a/server/stream.ajax.php b/server/stream.ajax.php
index a1375262e3..c13ced564b 100644
--- a/server/stream.ajax.php
+++ b/server/stream.ajax.php
@@ -74,48 +74,22 @@
case 'directplay':
debug_event('stream.ajax.php', 'Play type {'.$_REQUEST['playtype'].'}', 5);
- switch ($_REQUEST['playtype']) {
- case 'album':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=album&album_id='.implode(',', $_REQUEST['album_id']);
- break;
- case 'artist':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=artist&artist_id='.$_REQUEST['artist_id'];
- break;
- case 'song':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=single_song&song_id='.$_REQUEST['song_id'];
- if ($_REQUEST['custom_play_action']) {
- $_SESSION['iframe']['target'] .= '&custom_play_action=' . $_REQUEST['custom_play_action'];
- }
- break;
- case 'video':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=single_video&video_id='.$_REQUEST['video_id'];
- break;
- case 'playlist':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=playlist&playlist_id='.$_REQUEST['playlist_id'];
- break;
- case 'smartplaylist':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=smartplaylist&playlist_id='.$_REQUEST['playlist_id'];
- break;
- case 'live_stream':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=live_stream&stream_id='.$_REQUEST['stream_id'];
- break;
- case 'album_preview':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=album_preview&mbid='.$_REQUEST['mbid'];
- break;
- case 'song_preview':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=song_preview&id='.$_REQUEST['id'];
- break;
- case 'channel':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=channel&channel_id='.$_REQUEST['channel_id'];
- break;
- case 'broadcast':
- $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=broadcast&broadcast_id='.$_REQUEST['broadcast_id'];
- break;
+ $object_type = $_REQUEST['object_type'];
+ $object_id = $_REQUEST['object_id'];
+ if (is_array($object_id)) {
+ $object_id = implode(',', $object_id);
}
- if (!empty($_REQUEST['append'])) {
- $_SESSION['iframe']['target'] .= '&append=true';
+
+ if (Core::is_playable_item($object_type)) {
+ $_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=play_item&object_type=' . $object_type . '&object_id=' . $object_id;
+ if ($_REQUEST['custom_play_action']) {
+ $_SESSION['iframe']['target'] .= '&custom_play_action=' . $_REQUEST['custom_play_action'];
+ }
+ if (!empty($_REQUEST['append'])) {
+ $_SESSION['iframe']['target'] .= '&append=true';
+ }
+ $results['rfc3514'] = '';
}
- $results['rfc3514'] = '';
break;
case 'basket':
// Go ahead and see if we should clear the playlist here or not,
diff --git a/stream.php b/stream.php
index 8627d482cf..a7f496efe9 100644
--- a/stream.php
+++ b/stream.php
@@ -76,26 +76,21 @@
break;
} // end switch on type
break;
- case 'single_song':
- $media_ids[] = array(
- 'object_type' => 'song',
- 'object_id' => scrub_in($_REQUEST['song_id']),
- 'custom_play_action' => $_REQUEST['custom_play_action']
- );
- break;
- case 'single_video':
- $media_ids[] = array(
- 'object_type' => 'video',
- 'object_id' => scrub_in($_REQUEST['video_id'])
- );
- break;
- case 'artist':
- $artist = new Artist($_REQUEST['artist_id']);
- $songs = $artist->get_songs();
- foreach ($songs as $song) {
- $media_ids[] = array(
- 'object_type' => 'song',
- 'object_id' => $song);
+ case 'play_item':
+ $object_type = $_REQUEST['object_type'];
+ $object_id = $_REQUEST['object_id'];
+
+ if (Core::is_playable_item($object_type)) {
+ $item = new $object_type($object_id);
+ $media_ids = array_merge($media_ids, $item->get_medias());
+
+ if ($_REQUEST['custom_play_action']) {
+ foreach ($media_ids as $media_id) {
+ if (is_array($media_id)) {
+ $media_id['custom_play_action'] = $_REQUEST['custom_play_action'];
+ }
+ }
+ }
}
break;
case 'artist_random':
@@ -106,38 +101,6 @@
$album = new Album($_REQUEST['album_id']);
$media_ids = $album->get_random_songs();
break;
- case 'album':
- debug_event('stream.php', 'Playing/Adding all songs of album(s) {'.$_REQUEST['album_id'].'}...', '5');
- $albums_array = explode(',', $_REQUEST['album_id']);
-
- foreach ($albums_array as $a) {
- $album = new Album($a);
- $songs = $album->get_songs();
- foreach ($songs as $song) {
- $media_ids[] = array(
- 'object_type' => 'song',
- 'object_id' => $song);
- }
- }
- break;
- case 'playlist':
- $playlist = new Playlist($_REQUEST['playlist_id']);
- $songs = $playlist->get_songs();
- foreach ($songs as $song) {
- $media_ids[] = array(
- 'object_type' => 'song',
- 'object_id' => $song);
- }
- break;
- case 'smartplaylist':
- $playlist = new Search($_REQUEST['playlist_id'], 'song');
- $items = $playlist->get_items();
- foreach ($items as $item) {
- $media_ids[] = array(
- 'object_type' => $item['object_type'],
- 'object_id' => $item['object_id']);
- }
- break;
case 'playlist_random':
$playlist = new Playlist($_REQUEST['playlist_id']);
$media_ids = $playlist->get_random_items();
@@ -171,43 +134,6 @@
);
}
break;
- case 'live_stream':
- $object = new Live_Stream($_REQUEST['stream_id']);
- if ($object->name) {
- $media_ids[] = array(
- 'object_type' => 'live_stream',
- 'object_id' => scrub_in($_REQUEST['stream_id'])
- );
- }
- break;
- case 'album_preview':
- $songs = Song_preview::get_song_previews($_REQUEST['mbid']);
- foreach ($songs as $song) {
- if (!empty($song->file)) {
- $media_ids[] = array(
- 'object_type' => 'song_preview',
- 'object_id' => $song->id);
- }
- }
- break;
- case 'song_preview':
- $media_ids[] = array(
- 'object_type' => 'song_preview',
- 'object_id' => scrub_in($_REQUEST['id'])
- );
- break;
- case 'channel':
- $media_ids[] = array(
- 'object_type' => 'channel',
- 'object_id' => scrub_in($_REQUEST['channel_id'])
- );
- break;
- case 'broadcast':
- $media_ids[] = array(
- 'object_type' => 'broadcast',
- 'object_id' => scrub_in($_REQUEST['broadcast_id'])
- );
- break;
default:
break;
} // end action switch
diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php
index c2aabf6cae..8a0bb70220 100644
--- a/templates/show_album.inc.php
+++ b/templates/show_album.inc.php
@@ -64,14 +64,14 @@
- get_http_album_query_ids('album_id'),'play', T_('Play'),'directplay_full_' . $album->id); ?>
- get_http_album_query_ids('album_id'), T_('Play'),'directplay_full_text_' . $album->id); ?>
+ get_http_album_query_ids('object_id'),'play', T_('Play'),'directplay_full_' . $album->id); ?>
+ get_http_album_query_ids('object_id'), T_('Play'),'directplay_full_text_' . $album->id); ?>
- get_http_album_query_ids('album_id') . '&append=true','play_add', T_('Play last'),'addplay_album_' . $album->id); ?>
- get_http_album_query_ids('album_id') . '&append=true', T_('Play last'),'addplay_album_text_' . $album->id); ?>
+ get_http_album_query_ids('object_id') . '&append=true','play_add', T_('Play last'),'addplay_album_' . $album->id); ?>
+ get_http_album_query_ids('object_id') . '&append=true', T_('Play last'),'addplay_album_text_' . $album->id); ?>
diff --git a/templates/show_album_group_disks.inc.php b/templates/show_album_group_disks.inc.php
index f56a3d0e7f..d3328c240f 100644
--- a/templates/show_album_group_disks.inc.php
+++ b/templates/show_album_group_disks.inc.php
@@ -45,14 +45,14 @@
- get_http_album_query_ids('album_id'), 'play', T_('Play'), 'directplay_full_'); ?>
- get_http_album_query_ids('album_id'), T_('Play'), 'directplay_full_text_'); ?>
+ get_http_album_query_ids('object_id'), 'play', T_('Play'), 'directplay_full_'); ?>
+ get_http_album_query_ids('object_id'), T_('Play'), 'directplay_full_text_'); ?>
- get_http_album_query_ids('album_id') . '&append=true', 'play_add', T_('Play last'), 'addplay_album_'); ?>
- get_http_album_query_ids('album_id') . '&append=true', T_('Play last'), 'addplay_album_text_'); ?>
+ get_http_album_query_ids('object_id') . '&append=true', 'play_add', T_('Play last'), 'addplay_album_'); ?>
+ get_http_album_query_ids('object_id') . '&append=true', T_('Play last'), 'addplay_album_text_'); ?>
diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php
index ee089653c6..5985a48329 100644
--- a/templates/show_album_row.inc.php
+++ b/templates/show_album_row.inc.php
@@ -24,9 +24,9 @@
- get_http_album_query_ids('album_id'), 'play', T_('Play'), 'play_album_' . $libitem->id); ?>
+ get_http_album_query_ids('object_id'), 'play', T_('Play'), 'play_album_' . $libitem->id); ?>
- get_http_album_query_ids('album_id') . '&append=true', 'play_add', T_('Play last'), 'addplay_album_' . $libitem->id); ?>
+ get_http_album_query_ids('object_id') . '&append=true', 'play_add', T_('Play last'), 'addplay_album_' . $libitem->id); ?>
@@ -36,9 +36,9 @@
$name = '[' . $libitem->f_artist . '] ' . scrub_out($libitem->full_name);
?>
-
-
-
+ id, $name, 1, AmpConfig::get('web_path') . '/albums.php?action=show&album=' . $libitem->id);
+ ?>
f_name_link; ?>
diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php
index 04874b8fd8..720713cdf7 100644
--- a/templates/show_artist.inc.php
+++ b/templates/show_artist.inc.php
@@ -83,14 +83,14 @@
- id,'play', T_('Play all'),'directplay_full_' . $artist->id); ?>
- id, T_('Play all'),'directplay_full_text_' . $artist->id); ?>
+ id,'play', T_('Play all'),'directplay_full_' . $artist->id); ?>
+ id, T_('Play all'),'directplay_full_text_' . $artist->id); ?>
- id . '&append=true','play_add', T_('Play all last'),'addplay_artist_' . $artist->id); ?>
- id . '&append=true', T_('Play all last'),'addplay_artist_text_' . $artist->id); ?>
+ id . '&append=true','play_add', T_('Play all last'),'addplay_artist_' . $artist->id); ?>
+ id . '&append=true', T_('Play all last'),'addplay_artist_text_' . $artist->id); ?>
diff --git a/templates/show_artist_row.inc.php b/templates/show_artist_row.inc.php
index 71f05c5a21..78c810ccdc 100644
--- a/templates/show_artist_row.inc.php
+++ b/templates/show_artist_row.inc.php
@@ -24,9 +24,9 @@
- id,'play', T_('Play'),'play_artist_' . $libitem->id); ?>
+ id,'play', T_('Play'),'play_artist_' . $libitem->id); ?>
- id . '&append=true','play_add', T_('Play last'),'addplay_artist_' . $libitem->id); ?>
+ id . '&append=true','play_add', T_('Play last'),'addplay_artist_' . $libitem->id); ?>
diff --git a/templates/show_broadcast_row.inc.php b/templates/show_broadcast_row.inc.php
index 6d353af888..6c5a302197 100644
--- a/templates/show_broadcast_row.inc.php
+++ b/templates/show_broadcast_row.inc.php
@@ -24,7 +24,7 @@
- id,'play', T_('Play'),'play_broadcast_' . $libitem->id); ?>
+ id,'play', T_('Play'),'play_broadcast_' . $libitem->id); ?>
diff --git a/templates/show_channel_row.inc.php b/templates/show_channel_row.inc.php
index 9455d22a57..04ede075e4 100644
--- a/templates/show_channel_row.inc.php
+++ b/templates/show_channel_row.inc.php
@@ -24,7 +24,7 @@
- id,'play', T_('Play'),'play_channel_' . $libitem->id); ?>
+ id,'play', T_('Play'),'play_channel_' . $libitem->id); ?>
diff --git a/templates/show_edit_tvshow_row.inc.php b/templates/show_edit_tvshow_row.inc.php
index 755539547a..39782f6bb9 100644
--- a/templates/show_edit_tvshow_row.inc.php
+++ b/templates/show_edit_tvshow_row.inc.php
@@ -28,8 +28,8 @@
-
-
+
+
diff --git a/templates/show_edit_video_row.inc.php b/templates/show_edit_video_row.inc.php
new file mode 100644
index 0000000000..af192c36af
--- /dev/null
+++ b/templates/show_edit_video_row.inc.php
@@ -0,0 +1,53 @@
+id);
+$libitem->format();
+$video_type = strtolower(get_class($libitem));
+?>
+
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index 66b439e232..de35fa5ddf 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -26,11 +26,19 @@
-
+
+
+
+
+
+
diff --git a/templates/show_live_stream_row.inc.php b/templates/show_live_stream_row.inc.php
index 61918a59c2..d3f92dbdde 100644
--- a/templates/show_live_stream_row.inc.php
+++ b/templates/show_live_stream_row.inc.php
@@ -24,7 +24,7 @@
- id, 'play', T_('Play live stream'),'play_live_stream_' . $libitem->id); ?>
+ id, 'play', T_('Play live stream'),'play_live_stream_' . $libitem->id); ?>
diff --git a/templates/show_lyrics.inc.php b/templates/show_lyrics.inc.php
index 446ef5cdae..939edb9a45 100644
--- a/templates/show_lyrics.inc.php
+++ b/templates/show_lyrics.inc.php
@@ -37,7 +37,7 @@
diff --git a/templates/show_missing_album.inc.php b/templates/show_missing_album.inc.php
index b160efef6b..e03fbcb81b 100644
--- a/templates/show_missing_album.inc.php
+++ b/templates/show_missing_album.inc.php
@@ -50,24 +50,6 @@