diff options
author | martian <martian@ampache> | 2010-02-09 17:44:44 +0000 |
---|---|---|
committer | martian <martian@ampache> | 2010-02-09 17:44:44 +0000 |
commit | 1b35c20dd0a93b143d8b9542743a743e0db66386 (patch) | |
tree | 0500ae3eec1dfb70b66c3ca30e9a61da2c0daba8 | |
parent | 5e52f0d7ccb6183d7e1b4e5033adad0d08a48eb6 (diff) | |
download | ampache-1b35c20dd0a93b143d8b9542743a743e0db66386.tar.gz ampache-1b35c20dd0a93b143d8b9542743a743e0db66386.tar.bz2 ampache-1b35c20dd0a93b143d8b9542743a743e0db66386.zip |
Adding the bandwidth option to the preferences. This changes the complexity of the UI and toggles album art.
-rw-r--r-- | config/ampache.cfg.php.dist | 12 | ||||
-rw-r--r-- | lib/class/config.class.php | 5 | ||||
-rw-r--r-- | lib/class/preference.class.php | 2 | ||||
-rw-r--r-- | lib/class/song.class.php | 11 | ||||
-rw-r--r-- | lib/class/update.class.php | 17 | ||||
-rw-r--r-- | lib/class/user.class.php | 5 | ||||
-rw-r--r-- | lib/preferences.php | 8 | ||||
-rw-r--r-- | templates/base.css | 4 | ||||
-rw-r--r-- | templates/show_album_row.inc.php | 20 | ||||
-rw-r--r-- | templates/show_albums.inc.php | 6 | ||||
-rw-r--r-- | templates/show_artist.inc.php | 4 | ||||
-rw-r--r-- | templates/show_index.inc.php | 116 | ||||
-rw-r--r-- | templates/show_now_playing_row.inc.php | 9 | ||||
-rw-r--r-- | templates/show_random_albums.inc.php | 8 |
14 files changed, 161 insertions, 66 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index d215bf1d..37c52c82 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -237,13 +237,11 @@ default_auth_level = "admin" ; DEFAULT: true ratings = "true" -; ShoutBox -; Enabling this will allow any user to 'tag' an item and post -; a comment about it which will then be put on the main pages -; shoutbox. Admins are allowed to create 'sticky' shoutbox items -; POSSIBLE VALUES: false true -; DEFAULT: false -;shoutbox = "false" +; Index features +; Vollmer will probably write better stuff here than I will -Vlet +; POSSIBLE VALUES: shout, played, added, now, random +; DEFAULT: hmm +features = "shout, played, added, now, random" ; This options will turn on/off Demo Mode ; If Demo mode is on you can not play songs or update your catalog diff --git a/lib/class/config.class.php b/lib/class/config.class.php index d846f225..64a45522 100644 --- a/lib/class/config.class.php +++ b/lib/class/config.class.php @@ -28,6 +28,11 @@ * config overides and/or local configs (for like dba) * The class should be a static var in the other classes */ + +define('BANDWIDTH_LOW', 0); +define('BANDWIDTH_MEDIUM', 1); +define('BANDWIDTH_HIGH', 2); + class Config { // These are the settings for this specific class diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php index cfc08bf8..04d7f2f7 100644 --- a/lib/class/preference.class.php +++ b/lib/class/preference.class.php @@ -226,7 +226,7 @@ class Preference { $sql = "SELECT `preference`.`name`,`preference`.`description`,`user_preference`.`value` FROM `preference` " . " INNER JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` " . - " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit"; + " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit order by `preference`.`description`"; $db_results = Dba::read($sql); $results = array(); diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 7d30b116..6b68df94 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -918,7 +918,7 @@ class Song extends database_object implements media { * it uses the popular threshold to figure out how many to pull * it will only return unique object */ - public static function get_recently_played($user_id='') { + public static function get_recently_played($user_id='', $limit=null) { if ($user_id) { $user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'"; @@ -931,12 +931,15 @@ class Song extends database_object implements media { "ORDER BY `object_count`.`date` DESC "; $db_results = Dba::read($sql); - $results = array(); + $results = array(); while ($row = Dba::fetch_assoc($db_results)) { if (isset($results[$row['object_id']])) { continue; } - $results[$row['object_id']] = $row; - if (count($results) > Config::get('popular_threshold')) { break; } + $results[$row['object_id']] = $row; + if (!is_null($limit)) + if (count($results) > $limit) { break; } + else + if (count($results) > Config::get('popular_threshold')) { break; } } return $results; diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 106c3480..bda724a4 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1828,12 +1828,21 @@ class Update { $sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )"; $db_results = Dba::write($sql); + + // Now add in the min_object_count preference and the random_method + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES('bandwidth','1','Bandwidth','100','integer','interface')"; + $db_results = Dba::write($sql); + + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results } // update_360002 diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 5608e025..40065922 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -197,7 +197,8 @@ class User extends database_object { $sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " . "FROM preference INNER JOIN user_preference ON user_preference.preference=preference.id " . - "WHERE user_preference.user='$user_id' " . $user_limit; + "WHERE user_preference.user='$user_id' " . $user_limit . " ORDER BY preference.catagory, preference.description"; + $db_results = Dba::read($sql); /* Ok this is crapy, need to clean this up or improve the code FIXME */ @@ -206,7 +207,7 @@ class User extends database_object { $admin = false; if ($type == 'system') { $admin = true; } $type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']); - ksort($type_array[$type]); + //ksort($type_array[$type]); // sorted this via sql and added sub-category sorting - Vlet $results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]); } // end while diff --git a/lib/preferences.php b/lib/preferences.php index 5ea7aba4..5b496ba0 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -257,6 +257,14 @@ function create_preference_input($name,$value) { echo "\t<option value=\"default\"$default>" . _('Default') . "</option>\n"; echo "</select>\n"; break; + case 'bandwidth': + ${"bandwidth_$value"} = ' selected="selected"'; + echo "<select name=\"$name\">\n"; + echo "\t<option value=\"0\"$bandwidth_0>" . _('Low') . "</option>\n"; + echo "\t<option value=\"1\"$bandwidth_1>" . _('Medium') . "</option>\n"; + echo "\t<option value=\"2\"$bandwidth_2>" . _('High') . "</option>\n"; + echo "</select>\n"; + break; case 'transcode': ${$value} = ' selected="selected"'; echo "<select name=\"$name\">\n"; diff --git a/templates/base.css b/templates/base.css index db4d7408..ca508c35 100644 --- a/templates/base.css +++ b/templates/base.css @@ -25,6 +25,7 @@ * Tag Definitions *****************/ +/* why god why!? .tag_size1 { font-size:.6em; } @@ -37,10 +38,11 @@ .tag_size4 { font-size:1.2em; } +*/ a.tag_size1, a.tag_size2, a.tag_size3, a.tag_size4 { text-decoration: none; } -.hover-add:hover { font-weight:900; } +/* .hover-add:hover { font-weight:900; } */ /* why god why!? */ .hover-remove:hover { text-decoration:line-through;} /***************** diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php index ff4256fd..71a1afbc 100644 --- a/templates/show_album_row.inc.php +++ b/templates/show_album_row.inc.php @@ -23,13 +23,17 @@ <?php echo Ajax::button('?action=basket&type=album&id=' . $album->id,'add',_('Add'),'add_album_' . $album->id); ?> <?php echo Ajax::button('?action=basket&type=album_random&id=' . $album->id,'random',_('Random'),'random_album_' . $album->id); ?> </td> -<?php - if (Browse::get_filter('show_art')) { - $name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name); +<?php + if (Config::get('bandwidth') > BANDWIDTH_LOW) { + $name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name); + + // This should not be hard coded, but it will likely break all the themes. + //$image_size = Config::get('bandwidth') == BANDWIDTH_MEDIUM ? 75 : 128; + $image_size = 75; ?> <td class="cel_cover"> <a href="<?php echo Config::get('web_path'); ?>/albums.php?action=show&album=<?php echo $album->id; ?>"> - <img height="75" width="75" alt="<?php echo($name) ?>" title="<?php echo($name) ?>" src="<?php echo Config::get('web_path'); ?>/image.php?id=<?php echo $album->id; ?>&thumb=1" /> + <img height="<?php echo $image_size; ?>" width="<?php echo $image_size; ?>" alt="<?php echo($name) ?>" title="<?php echo($name) ?>" src="<?php echo Config::get('web_path'); ?>/image.php?id=<?php echo $album->id; ?>&thumb=<?php echo Config::get('bandwidth'); ?>" /> </a> </td> <?php } ?> @@ -37,14 +41,12 @@ <td class="cel_artist"><?php echo $album->f_artist_link; ?></td> <td class="cel_songs"><?php echo $album->song_count; ?></td> <td class="cel_year"><?php echo $album->year; ?></td> -<td class="cel_tags"><?php echo $album->f_tags; ?></td> +<td class="cel_tags"><?php echo (strlen($album->f_tags) > 20) ? substr($album->f_tags, 0, 20) . '&hellip' : $album->f_tags; ?></td> <td class="cel_rating" id="rating_<?php echo $album->id; ?>_album"><?php Rating::show($album->id,'album'); ?></td> <td class="cel_action"> - <?php if (Config::get('shoutbox')) { ?> - <a href="<?php echo Config::get('web_path'); ?>/shout.php?action=show_add_shout&type=album&id=<?php echo $album->id; ?>"> + <a href="<?php echo Config::get('web_path'); ?>/shout.php?action=show_add_shout&type=album&id=<?php echo $album->id; ?>"> <?php echo get_user_icon('comment',_('Post Shout')); ?> - </a> - <?php } ?> + </a> <?php if (Access::check_function('batch_download')) { ?> <a href="<?php echo Config::get('web_path'); ?>/batch.php?action=album&id=<?php echo $album->id; ?>"> <?php echo get_user_icon('batch_download',_('Batch Download')); ?> diff --git a/templates/show_albums.inc.php b/templates/show_albums.inc.php index c394b4d9..82436c40 100644 --- a/templates/show_albums.inc.php +++ b/templates/show_albums.inc.php @@ -25,7 +25,7 @@ $ajax_url = Config::get('ajax_url'); <table class="tabledata" cellpadding="0" cellspacing="0"> <colgroup> <col id="col_add" /> - <?php if (Browse::get_filter('show_art')) { ?> + <?php if (Config::get('bandwidth') > BANDWIDTH_LOW) { ?> <col id="col_cover" /> <?php } ?> <col id="col_album" /> @@ -38,7 +38,7 @@ $ajax_url = Config::get('ajax_url'); </colgroup> <tr class="th-top"> <th class="cel_add"><?php echo _('Add'); ?></th> - <?php if (Browse::get_filter('show_art')) { ?> + <?php if (Config::get('bandwidth') > BANDWIDTH_LOW) { ?> <th class="cel_cover"><?php echo _('Cover'); ?></th> <?php } ?> <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=name',_('Album'),'album_sort_name'); ?></th> @@ -69,7 +69,7 @@ $ajax_url = Config::get('ajax_url'); <?php } ?> <tr class="th-bottom"> <th class="cel_add"><?php echo _('Add'); ?></th> - <?php if (Browse::get_filter('show_art')) { ?> + <?php if (Config::get('bandwidth') > BANDWIDTH_LOW) { ?> <th class="cel_cover"><?php echo _('Cover'); ?></th> <?php } ?> <th class="cel_album"><?php echo Ajax::text('?page=browse&action=set_sort&type=album&sort=name',_('Album'),'album_sort_name_bottom'); ?></th> diff --git a/templates/show_artist.inc.php b/templates/show_artist.inc.php index 4e63835d..24033e8b 100644 --- a/templates/show_artist.inc.php +++ b/templates/show_artist.inc.php @@ -60,10 +60,6 @@ if (Config::get('ratings')) { <a href="<?php echo $web_path; ?>/batch.php?action=artist&id=<?php echo $artist->id; ?>"><?php echo _('Download'); ?></a> </li> <?php } ?> -<li> - <input type="checkbox" id="show_artist_artCB" <?php echo $string = Browse::get_filter('show_art') ? 'checked="checked"' : ''; ?>/> <?php echo _('Show Art'); ?> - <?php echo Ajax::observe('show_artist_artCB','click',Ajax::action('?page=browse&action=browse&key=show_art&value=1&type=album','')); ?> -</ul> </div> <?php show_box_bottom(); ?> <?php diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php index f5b2558d..12c7aae8 100644 --- a/templates/show_index.inc.php +++ b/templates/show_index.inc.php @@ -28,32 +28,94 @@ </div><!-- End XSPF Player --> +<? -<div id="now_playing"> - <?php show_now_playing(); ?> -</div> <!-- Close Now Playing Div --> -<!-- Randomly selected albums of the moment --> - <?php echo Ajax::observe('window','load',Ajax::action('?page=index&action=random_albums','random_albums')); ?> -<div id="random_selection"> - <?php show_box_top(_('Albums of the Moment')); echo _('Loading...'); show_box_bottom(); ?> -</div> -<!-- Recently Played --> -<div id="recently_played"> - <?php - $data = Song::get_recently_played(); - Song::build_cache(array_keys($data)); - require_once Config::get('prefix') . '/templates/show_recently_played.inc.php'; - ?> -</div> -<!-- Shoutbox Objects, if shoutbox is enabled --> -<?php if (Config::get('shoutbox')) { ?> -<div id="shout_objects"> - <?php - $shouts = shoutBox::get_top('5'); - if (count($shouts)) { - require_once Config::get('prefix') . '/templates/show_shoutbox.inc.php'; - } - ?> -</div> -<?php } ?> +// Various settings for the 'bandwidth' option +$feature_sets = array + ( + BANDWIDTH_LOW => array('now', 'played'), + BANDWIDTH_MEDIUM => array('now', 'random', 'played'), + BANDWIDTH_HIGH => array('now', 'random', 'shout', 'played', 'added') + ); + +$feature_limits = array ( + BANDWIDTH_LOW => array + ( + 'shout' => 7, + 'played' => 7, + 'added' => 7 + ), + BANDWIDTH_MEDIUM => array + ( + 'shout' => 10, + 'played' => 10, + 'added' => 10 + ), + BANDWIDTH_HIGH => array + ( + 'shout' => 10, + 'played' => 20, + 'added' => 20 + ) + ); + +$features = $feature_sets[Config::get('bandwidth')]; + +foreach ($features as $feature) { + switch ($feature) { + case 'shout': + ?><div id="shout_objects"><? + + $shouts = shoutBox::get_top($feature_limits[Config::get('bandwidth')][$feature]); + + if (count($shouts)) require_once Config::get('prefix') . '/templates/show_shoutbox.inc.php'; + + ?></div><? + + break; + case 'played': + ?><div id="recently_played"><? + + $data = Song::get_recently_played('', $feature_limits[Config::get('bandwidth')][$feature]); + + Song::build_cache(array_keys($data)); + + require_once Config::get('prefix') . '/templates/show_recently_played.inc.php'; + + ?></div><? + + break; + case 'added': + show_box_top("Recently Added Albums"); + + $object_ids = Stats::get_newest('album', $feature_limits[Config::get('bandwidth')][$feature]); + + echo _('Newest Albums'); + + require_once Config::get('prefix') . '/templates/show_albums.inc.php'; + + show_box_bottom(); + + break; + case 'now': + ?><div id="now_playing"><? + + show_now_playing(); + + ?></div><? + + break; + case 'random': + echo Ajax::observe('window','load',Ajax::action('?page=index&action=random_albums','random_albums')); + + ?><div id="random_selection"><? + + show_box_top(_('Albums of the Moment')); echo _('Loading...'); show_box_bottom(); + + ?></div><? + + break; + } +} +?> diff --git a/templates/show_now_playing_row.inc.php b/templates/show_now_playing_row.inc.php index bd1f95cc..66b3639d 100644 --- a/templates/show_now_playing_row.inc.php +++ b/templates/show_now_playing_row.inc.php @@ -23,6 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $title = scrub_out(truncate_with_ellipsis($media->title)); $album = scrub_out(truncate_with_ellipsis($media->f_album_full)); $artist = scrub_out(truncate_with_ellipsis($media->f_artist_full)); + +// This should not be hard coded, but it will likely break all the themes. +//$image_size = Config::get('bandwidth') == BANDWIDTH_MEDIUM ? 75 : 128; +$image_size = 75; + ?> <div class="np_group"> <div class="np_cell cel_username"> @@ -72,11 +77,11 @@ $artist = scrub_out(truncate_with_ellipsis($media->f_artist_full)); </div> </div> -<?php if (Config::get('show_album_art')) { ?> +<?php if (Config::get('bandwidth') > BANDWIDTH_LOW) { ?> <div class="np_group"> <div class="np_cell cel_albumart"> <a target="_blank" href="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&type=popup&sid=<?php echo session_id(); ?>" onclick="popup_art('<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&type=popup&sid=<?php echo session_id(); ?>'); return false;"> - <img align="middle" src="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&thumb=1&sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($media->f_album_full); ?>" title="<?php echo scrub_out($media->f_album_full); ?>" height="75" width="75" /> + <img align="middle" src="<?php echo $web_path; ?>/image.php?id=<?php echo $media->album; ?>&thumb=<?php echo 1; /* This should be dynamic, but until themes are fixed to be more fluid in regards to images, make it static. */ /* Config::get('bandwidth'); */ ?>&sid=<?php echo session_id(); ?>" alt="<?php echo scrub_out($media->f_album_full); ?>" title="<?php echo scrub_out($media->f_album_full); ?>" height="<?php echo $image_size; ?>" width="<?php echo $image_size; ?>" /> </a> </div> </div> diff --git a/templates/show_random_albums.inc.php b/templates/show_random_albums.inc.php index a262a4a1..2dee7f85 100644 --- a/templates/show_random_albums.inc.php +++ b/templates/show_random_albums.inc.php @@ -29,11 +29,15 @@ $button = Ajax::button('?page=index&action=random_albums','random',_('Refresh'), $album = new Album($album_id); $album->format(); $name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name); + + // This should not be hard coded, but it will likely break all the themes. + //$image_size = Config::get('bandwidth') == BANDWIDTH_MEDIUM ? 75 : 128; + $image_size = 75; ?> <div class="random_album"> <a href="<?php echo $web_path; ?>/albums.php?action=show&album=<?php echo $album_id; ?>"> - <?php if (Config::get('show_album_art')) { ?> - <img src="<?php echo $web_path; ?>/image.php?thumb=3&id=<?php echo $album_id; ?>" width="80" height="80" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" /> + <?php if (Config::get('bandwidth') > BANDWIDTH_LOW) { ?> + <img src="<?php echo $web_path; ?>/image.php?thumb=3&id=<?php echo $album_id; ?>&thumb=<?php echo 1; /* This should be dynamic, but until themes are fixed to be more fluid in regards to images, make it static. */ /* Config::get('bandwidth'); */ ?>" width="<?php echo $image_size; ?>" height="<?php echo $image_size; ?>" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" /> <?php } else { ?> <?php echo '[' . $album->f_artist . '] ' . $album->f_name; ?> <?php } ?> |