diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-19 08:50:35 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-19 08:50:35 +0000 |
commit | bc36b9d282aff16dfc794819919897103c94b9bd (patch) | |
tree | 1d3cec755afbf08a595c4164d47a219b2dfa7ed3 | |
parent | d560bb1c7b7e675ad72af0731df18757bf9d5700 (diff) | |
download | ampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.gz ampache-bc36b9d282aff16dfc794819919897103c94b9bd.tar.bz2 ampache-bc36b9d282aff16dfc794819919897103c94b9bd.zip |
added some basic random functionality, need to make the advanced page
-rw-r--r-- | lib/class/ajax.class.php | 2 | ||||
-rw-r--r-- | lib/class/random.class.php | 48 | ||||
-rwxr-xr-x | locale/base/gather-messages.sh | 18 | ||||
-rwxr-xr-x | locale/base/merge-messages.sh | 18 | ||||
-rw-r--r-- | locale/base/messages.po | 21 | ||||
-rw-r--r-- | random.php (renamed from randomplay.php) | 24 | ||||
-rw-r--r-- | server/ajax.server.php | 4 | ||||
-rw-r--r-- | server/random.ajax.php | 61 | ||||
-rw-r--r-- | templates/sidebar_home.inc.php | 7 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 6 |
10 files changed, 189 insertions, 20 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index e8496e75..2139959e 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -122,7 +122,7 @@ class Ajax { } // If we pass a source put it in the ID - $string = "<span id=\"$source\" $class_txt>$text</span>\n"; + $string = "<div id=\"$source\" $class_txt>$text</div>\n"; $string .= self::observe($source,'click',$ajax_string); diff --git a/lib/class/random.class.php b/lib/class/random.class.php index 58be0463..b2081539 100644 --- a/lib/class/random.class.php +++ b/lib/class/random.class.php @@ -39,6 +39,54 @@ class Random { } // constructor /** + * album + * This returns the ID of a random album, nothing special + */ + public static function album() { + + $sql = "SELECT `id` FROM `album` ORDER BY RAND() LIMIT 1"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // album + + /** + * artist + * This returns the ID of a random artist, nothing special here for now + */ + public static function artist() { + + $sql = "SELECT `id` FROM `artist` ORDER BY RAND() LIMIT 1"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // artist + + /** + * playlist + * This returns a random Playlist with songs little bit of extra + * logic require + */ + public static function playlist() { + + $sql = "SELECT `playlist`.`id` FROM `playlist` LEFT JOIN `playlist_data` " . + " ON `playlist`.`id`=`playlist_data`.`playlist` WHERE `playlist_data`.`object_id` IS NOT NULL " . + " ORDER BY RAND()"; + $db_results = Dba::query($sql); + + $results = Dba::fetch_assoc($db_results); + + return $results['id']; + + } // playlist + + /** * play_url * This generates a random play url based on the passed type * and returns it diff --git a/locale/base/gather-messages.sh b/locale/base/gather-messages.sh index bab2b7a8..8d0814f2 100755 --- a/locale/base/gather-messages.sh +++ b/locale/base/gather-messages.sh @@ -1,4 +1,22 @@ #!/bin/sh +# +# 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. +# + find ../../ -name *.php > /tmp/filelist find ../../ -name *.inc >> /tmp/filelist diff --git a/locale/base/merge-messages.sh b/locale/base/merge-messages.sh index 0d3525db..7b11147d 100755 --- a/locale/base/merge-messages.sh +++ b/locale/base/merge-messages.sh @@ -1,4 +1,22 @@ #!/bin/sh +# +# 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. +# + msgmerge -N ../de_DE/LC_MESSAGES/messages.po ./messages.po --output-file=../de_DE/LC_MESSAGES/messages.po msgmerge -N ../es_ES/LC_MESSAGES/messages.po ./messages.po --output-file=../es_ES/LC_MESSAGES/messages.po diff --git a/locale/base/messages.po b/locale/base/messages.po index 05b19ea8..e4ecff22 100644 --- a/locale/base/messages.po +++ b/locale/base/messages.po @@ -1,8 +1,21 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # +# 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. +# + #, fuzzy msgid "" msgstr "" diff --git a/randomplay.php b/random.php index a3cfb6d6..1ede94e0 100644 --- a/randomplay.php +++ b/random.php @@ -1,13 +1,13 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + 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 - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. + as published by the Free Software Foundation; version 2 + of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,18 +20,16 @@ */ -/*! - @header Index of Ampache - @discussion Do most of the dirty work of displaying the mp3 catalog +require_once 'lib/init.php'; -*/ -require_once('lib/init.php'); - - -show_template('header'); -$action = scrub_in($_REQUEST['action']); +show_header(); -show_template('show_random_play'); +switch ($_REQUEST['action']) { + default: + case 'advanced': + + break; +} // end switch show_footer(); ?> diff --git a/server/ajax.server.php b/server/ajax.server.php index 9010ea5d..ab77dd65 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -45,6 +45,10 @@ switch ($_REQUEST['page']) { require_once Config::get('prefix') . '/server/browse.ajax.php'; exit; break; + case 'random': + require_once Config::get('prefix') . '/server/random.ajax.php'; + exit; + break; default: // A taste of compatibility break; diff --git a/server/random.ajax.php b/server/random.ajax.php new file mode 100644 index 00000000..c64e5807 --- /dev/null +++ b/server/random.ajax.php @@ -0,0 +1,61 @@ +<?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. + +*/ + +/** + * Sub-Ajax page, requires AJAX_INCLUDE as one + */ +if (AJAX_INCLUDE != '1') { exit; } + +switch ($_REQUEST['action']) { + case 'album': + $album_id = Random::album(); + $album = new Album($album_id); + $songs = $album->get_songs(); + foreach ($songs as $song_id) { + $GLOBALS['user']->playlist->add_object($song_id,'song'); + } + $results['rightbar'] = ajax_include('rightbar.inc.php'); + break; + case 'artist': + $artist_id = Random::artist(); + $artist = new Artist($artist_id); + $songs = $artist->get_songs(); + foreach ($songs as $song_id) { + $GLOBALS['user']->playlist->add_object($song_id,'song'); + } + $results['rightbar'] = ajax_include('rightbar.inc.php'); + break; + case 'playlist': + $playlist_id = Random::playlist(); + $playlist = new Playlist($playlist_id); + $items = $playlist->get_items(); + foreach ($items as $item) { + $GLOBALS['user']->playlist->add_object($item['object_id'],$item['type']); + } + $results['rightbar'] = ajax_include('rightbar.inc.php'); + break; + default: + break; +} // switch on action; + +// We always do this +echo xml_from_array($results); +?> diff --git a/templates/sidebar_home.inc.php b/templates/sidebar_home.inc.php index 4d97d6f9..0c711f95 100644 --- a/templates/sidebar_home.inc.php +++ b/templates/sidebar_home.inc.php @@ -6,4 +6,11 @@ <li id="sb_home_info_AddStationRadio"><a href="<?php echo $web_path; ?>/radio.php?action=show_create"><?php echo _('Add Radio Station'); ?></a></li> </ul> </li> + <li><h4><?php echo _('Random'); ?></h4> + <ul class="sb3" id="sb_home_random"> + <li id="sb_home_random_album"><?php echo Ajax::text('?page=random&action=album',_('Album'),'sb_home_random_album'); ?></li> + <li id="sb_home_random_artist"><?php echo Ajax::text('?page=random&action=artist',_('Artist'),'sb_home_random_artist'); ?></li> + <li id="sb_home_random_playlist"><?php echo Ajax::text('?page=random&action=playlist',_('Playlist'),'sb_home_random_playlist'); ?></li> + <li id="sb_home_random_advanced"><a href="<?php echo $web_path; ?>/random.php?action=advanced"><?php echo _('Advanced'); ?></a></li> + </ul> </ul> diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index af2480f2..67dc63ae 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -282,11 +282,13 @@ h3#content_title span { } * html #sidebar-page ul.sb3 li{display:inline;} /* fix ie6 */ #sidebar-page .sb3 a{ padding:0.1em;border-bottom:1px dotted #c0c0c0;} +#sidebar-page .sb3 div{ padding:0.1em;border-bottom:1px dotted #c0c0c0; cursor:pointer; } + #sidebar-page a{ display:block; } -#sidebar-page a:hover{ +#sidebar-page a:hover, #sidebar-page div:hover{ background:#99ccff; color:#fff; } @@ -527,7 +529,7 @@ span.list-header:hover { margin:5px 0; padding-left:0px; } -.text-action span { +.text-action div { text-decoration: underline; cursor: pointer; display:block; |