summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--images/icon_delete.pngbin363 -> 655 bytes
-rw-r--r--lib/class/genre.class.php22
-rw-r--r--lib/ui.lib.php17
-rw-r--r--server/ajax.server.php107
-rw-r--r--templates/header.inc.php3
-rw-r--r--templates/rightbar.inc.php58
-rw-r--r--templates/show_playlist_bar.inc.php11
-rw-r--r--themes/classic/templates/default.css21
8 files changed, 119 insertions, 120 deletions
diff --git a/images/icon_delete.png b/images/icon_delete.png
index afe22ba9..1514d51a 100644
--- a/images/icon_delete.png
+++ b/images/icon_delete.png
Binary files differ
diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php
index b2eac58a..2886e245 100644
--- a/lib/class/genre.class.php
+++ b/lib/class/genre.class.php
@@ -125,17 +125,15 @@ class Genre {
/**
* get_songs
* This gets all of the songs in this genre and returns an array of song objects
- * @package Genre
- * @catagory Class
*/
- function get_songs() {
+ public function get_songs() {
- $sql = "SELECT song.id FROM song WHERE genre='" . $this->id . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `song`.`id` FROM `song` WHERE `genre`='" . $this->id . "'";
+ $db_results = Dba::query($sql);
$results = array();
- while ($r = mysql_fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
@@ -147,19 +145,15 @@ class Genre {
* get_random_songs
* This is the same as get_songs except it returns a random assortment of songs from this
* genre
- * @package Genre
- * @catagory Class
*/
- function get_random_songs() {
-
- $limit = rand(1,$this->get_song_count());
+ public function get_random_songs() {
- $sql = "SELECT song.id FROM song WHERE genre='" . $this->id . "' ORDER BY RAND() LIMIT $limit";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `song`.`id` FROM `song` WHERE `genre`='" . $this->id . "' ORDER BY RAND()";
+ $db_results = Dba::query($sql);
$results = array();
- while ($r = mysql_fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index be447091..1476307a 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1411,4 +1411,21 @@ function get_users($sql) {
} // get_users
+/**
+ * ajax_include
+ * This does an ob_start, getcontents, clean
+ * on the specified require, only works if you
+ * don't need to pass data in
+ */
+function ajax_include($include) {
+
+ ob_start();
+ require_once Config::get('prefix') . '/templates/' . $include;
+ $results = ob_get_contents();
+ ob_end_clean();
+
+ return $results;
+
+} // ajax_include
+
?>
diff --git a/server/ajax.server.php b/server/ajax.server.php
index 407a5f3c..65d4c186 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -72,6 +72,17 @@ switch ($action) {
$xml_doc = xml_from_array($results);
echo $xml_doc;
break;
+ case 'current_playlist':
+ switch ($_REQUEST['type']) {
+ case 'delete':
+ $GLOBALS['user']->playlist->delete_track($_REQUEST['id']);
+ break;
+ } // end switch
+
+ $results['topbar-playlist'] = ajax_include('show_playlist_bar.inc.php');
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
+ echo xml_from_array($results);
+ break;
// Handle the users basketcases...
case 'basket':
switch ($_REQUEST['type']) {
@@ -110,10 +121,9 @@ switch ($action) {
break;
} // end switch
- ob_start();
- require_once Config::get('prefix') . '/templates/show_playlist_bar.inc.php';
- $results['topbar-playlist'] = ob_get_contents();
- ob_end_clean();
+ $results['topbar-playlist'] = ajax_include('show_playlist_bar.inc.php');
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
+
echo xml_from_array($results);
break;
/* For changing the current play type FIXME:: need to allow select of any type */
@@ -139,27 +149,6 @@ switch ($action) {
$xml_doc = xml_from_array($results);
echo $xml_doc;
break;
- /* Reloading of the TV Now Playing, formated differently */
- case 'reload_np_tv':
-
- /* Update the Now Playing */
- ob_start();
- require_once(conf('prefix') . '/templates/show_tv_nowplaying.inc.php');
- $results = array();
- $results['tv_np'] = ob_get_contents();
- ob_end_clean();
-
- /* Update the Playlist */
- ob_start();
- $tmp_playlist = get_democratic_playlist(-1);
- $songs = $tmp_playlist->get_items();
- require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php');
- $results['tv_playlist'] = ob_get_contents();
- ob_end_clean();
-
- $xml_doc = xml_from_array($results);
- echo $xml_doc;
- break;
/* Setting ratings */
case 'set_rating':
ob_start();
@@ -171,50 +160,6 @@ switch ($action) {
ob_end_clean();
echo xml_from_array($results);
break;
- /* Activate the Democratic Instance */
- case 'tv_activate':
- if (!$GLOBALS['user']->has_access(100)) { break; }
- $tmp_playlist = new tmpPlaylist();
- /* Pull in the info we need */
- $base_id = scrub_in($_REQUEST['playlist_id']);
-
- /* create the playlist */
- $playlist_id = $tmp_playlist->create('0','vote','song',$base_id);
-
- $playlist = new tmpPlaylist($playlist_id);
- ob_start();
- require_once(conf('prefix') . '/templates/show_tv_adminctl.inc.php');
- $results['tv_control'] = ob_get_contents();
- ob_end_clean();
- $xml_doc = xml_from_array($results);
- echo $xml_doc;
- break;
- /* Admin Actions on the tv page */
- case 'tv_admin':
- if (!$GLOBALS['user']->has_access(100) || !conf('allow_democratic_playback')) { break; }
-
- /* Get the playlist */
- $tmp_playlist = get_democratic_playlist(-1);
-
- ob_start();
-
- /* Switch on the command we need to run */
- switch ($_REQUEST['cmd']) {
- case 'delete':
- $tmp_playlist->delete_track($_REQUEST['track_id']);
- $songs = $tmp_playlist->get_items();
- require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php');
- $results['tv_playlist'] = ob_get_contents();
- break;
- default:
- // Rien a faire
- break;
- } // end switch
-
- ob_end_clean();
- $xml_doc = xml_from_array($results);
- echo $xml_doc;
- break;
/* This can be a positve (1) or negative (-1) vote */
case 'vote':
if (!$GLOBALS['user']->has_access(25) || !conf('allow_democratic_playback')) { break; }
@@ -282,30 +227,6 @@ switch ($action) {
ob_end_clean();
echo xml_from_array($results);
break;
- case 'catalog':
- switch ($_REQUEST['type']) {
- case 'add_files':
- $sql = "SELECT * FROM `update_info` WHERE `key` LIKE 'catalog_add_%'";
- $template = '/templates/show_run_add_catalog.inc.php';
- break;
- case 'update_files':
- case 'clean_files':
- default:
- break;
- } // end switch on type
-
- $db_results = Dba::query($sql);
-
- while ($data = Dba::fetch_assoc($db_results)) {
- ${$data['key']} = $data['value'];
- }
-
- ob_start();
- require_once Config::get('prefix') . $template;
- $results['catalog_update'] = ob_get_contents();
- ob_end_clean();
- echo xml_from_array($results);
- break;
default:
$results['3514'] = '0x1';
echo xml_from_array($results);
diff --git a/templates/header.inc.php b/templates/header.inc.php
index cf0deabd..def957ee 100644
--- a/templates/header.inc.php
+++ b/templates/header.inc.php
@@ -73,6 +73,9 @@ if (Config::get('use_rss')) { ?>
<div id="sidebar"><!-- This is the sidebar -->
<?php require_once Config::get('prefix') . '/templates/sidebar.inc.php'; ?>
</div><!-- End sidebar -->
+ <div id="rightbar"><!-- This is the rightbar -->
+ <?php require_once Config::get('prefix') . '/templates/rightbar.inc.php'; ?>
+ </div>
<!-- I hate IE... -->
<table class="smeg-ie" width="100%"><tr><td>
<div id="content">
diff --git a/templates/rightbar.inc.php b/templates/rightbar.inc.php
new file mode 100644
index 00000000..a9d644bd
--- /dev/null
+++ b/templates/rightbar.inc.php
@@ -0,0 +1,58 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+<?php show_box_top(_('Active Playlist')); ?>
+<ul>
+ <li><a href="<?php echo Config::get('web_path'); ?>/stream.php?action=basket"><?php echo get_user_icon('all'); ?></a></li>
+<?php if (Access::check_function('batch_download')) { ?>
+ <li>
+ <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=tmp_playlist&amp;id=<?php echo $GLOBALS['user']->playlist->id; ?>">
+ <?php echo get_user_icon('batch_download','',_('Batch Download')); ?>
+ </a>
+ </li>
+<?php } ?>
+ <li><span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=basket&amp;type=clear_all');return true;">
+ <?php echo get_user_icon('delete','',_('Clear Playlist')); ?>
+ </span></li>
+</ul>
+<div id="current_playlist">
+<table cellpadding="0" cellspacing="0">
+<?php
+ $objects = $GLOBALS['user']->playlist->get_items();
+ foreach ($objects as $song_id) {
+ $song = new Song($song_id);
+ $song->format();
+?>
+<tr class="<?php echo flip_class(); ?>">
+ <td>
+ <?php echo $song->f_link; ?>
+ </td>
+ <td>
+ <span onclick="ajaxPut('<?php echo Config::get('ajax_url'); ?>?action=current_playlist&amp;type=delete&amp;id=<?php echo $song_id; ?>');return true;">
+ <?php echo get_user_icon('delete','',_('Delete')); ?>
+ </span>
+ </td>
+</tr>
+<?php } if (!count($objects)) { ?>
+ <tr><td class="error"><?php echo _('Not Enough Data'); ?></td></tr>
+<?php } ?>
+</table>
+<?php show_box_bottom(); ?>
diff --git a/templates/show_playlist_bar.inc.php b/templates/show_playlist_bar.inc.php
index fd85dc9d..b2eac864 100644
--- a/templates/show_playlist_bar.inc.php
+++ b/templates/show_playlist_bar.inc.php
@@ -18,19 +18,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$ajax_url = Config::get('ajax_url');
-
// Get the count of the number of items in their playlist
?>
<div>
- <a href="#" onclick="ajaxPut('<?php echo $ajax_url; ?>?action=basket&amp;type=clear_all');return true;">
- <?php echo get_user_icon('disable'); ?>
- </a>
- <a href="<?php echo Config::get('web_path'); ?>/stream.php?action=basket"><?php echo get_user_icon('all'); ?></a>
- <?php if (Access::check_function('batch_download')) { ?>
- <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=tmp_playlist&amp;id=<?php echo $GLOBALS['user']->playlist->id; ?>">
- <?php echo get_user_icon('batch_download','',_('Batch Download')); ?>
- </a>
- <?php } ?>
<?php echo __('There are currently %count% items in your playlist','%count%',$GLOBALS['user']->playlist->count_items()); ?>
</div>
diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css
index 30852a31..62ef22e8 100644
--- a/themes/classic/templates/default.css
+++ b/themes/classic/templates/default.css
@@ -155,8 +155,8 @@ input {
/* Content block */
/************************************************/
#content {
- float:left;
- margin:7px 0 0 135px;
+ position: relative;
+ margin: 0px 220px 20px 135px;
}
h3#content_title{
font: 12px/32px Arial,Helvetica,Sans-Serif;
@@ -167,6 +167,23 @@ h3#content_title span {
text-align:left;
}
+/************************************************/
+/* Rightbar */
+/************************************************/
+#rightbar {
+ position:absolute;
+ right:0px;
+ top:87px;
+ width:250px;
+}
+#rightbar li {
+ list-style:none;
+ float:left;
+ margin-right:3px;
+}
+#current_playlist {
+ clear:left;
+}
/************************************************/
/* Sidebar */