1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-06 03:49:56 +02:00

Fix #173. Fix rating. Fix plenty of Warnings.

This commit is contained in:
SUTJael 2014-03-27 15:28:58 +01:00
parent c174c2b9aa
commit 7e4e12f53b
23 changed files with 258 additions and 178 deletions

View file

@ -81,18 +81,25 @@ switch ($_GET['thumb']) {
break; break;
} // define size based on thumbnail } // define size based on thumbnail
switch ($_GET['type']) { $image = '';
$typeManaged = false;
if (isset($_GET['type'])) {
switch ($_GET['type']) {
case 'popup': case 'popup':
$typeManaged = true;
require_once AmpConfig::get('prefix') . '/templates/show_big_art.inc.php'; require_once AmpConfig::get('prefix') . '/templates/show_big_art.inc.php';
break; break;
// If we need to pull the data out of the session
case 'session': case 'session':
// If we need to pull the data out of the session
Session::check(); Session::check();
$filename = scrub_in($_REQUEST['image_index']); $filename = scrub_in($_REQUEST['image_index']);
$image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album'); $image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album');
$mime = $_SESSION['form']['images'][$filename]['mime']; $mime = $_SESSION['form']['images'][$filename]['mime'];
$typeManaged = true;
break; break;
default: }
}
if (!$typeManaged) {
$media = new $type($_GET['id']); $media = new $type($_GET['id']);
$filename = $media->name; $filename = $media->name;
@ -109,17 +116,12 @@ switch ($_GET['type']) {
$thumb_data = $art->get_thumb($size); $thumb_data = $art->get_thumb($size);
} }
$mime = $thumb_data $mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime;
? $thumb_data['thumb_mime'] $image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw;
: $art->raw_mime;
$image = $thumb_data
? $thumb_data['thumb']
: $art->raw;
} }
break; }
} // end switch type
if ($image) { if (!empty($image)) {
$extension = Art::extension($mime); $extension = Art::extension($mime);
$filename = scrub_out($filename . '.' . $extension); $filename = scrub_out($filename . '.' . $extension);

View file

@ -32,7 +32,9 @@ UI::show_header();
$action = isset($_REQUEST['action']) ? scrub_in($_REQUEST['action']) : null; $action = isset($_REQUEST['action']) ? scrub_in($_REQUEST['action']) : null;
session_start(); if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$_SESSION['catalog'] = 0; $_SESSION['catalog'] = 0;
/** /**

View file

@ -379,13 +379,13 @@ class Album extends database_object
* get_album_suite * get_album_suite
* gets the album ids with the same musicbrainz identifier * gets the album ids with the same musicbrainz identifier
*/ */
public function get_album_suite() public function get_album_suite($catalog = '')
{ {
$results = array(); $results = array();
$catalog_where = ""; $catalog_where = "";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`"; $catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
if ($catalog) { if (!empty($catalog)) {
$catalog_where .= " AND `catalog`.`id` = '$catalog'"; $catalog_where .= " AND `catalog`.`id` = '$catalog'";
} }
if (AmpConfig::get('catalog_disable')) { if (AmpConfig::get('catalog_disable')) {

View file

@ -72,9 +72,11 @@ class Browse extends Query
*/ */
public function get_supplemental_objects() public function get_supplemental_objects()
{ {
$objects = $_SESSION['browse']['supplemental'][$this->id]; $objects = isset($_SESSION['browse']['supplemental'][$this->id]) ? $_SESSION['browse']['supplemental'][$this->id] : '';
if (!is_array($objects)) { $objects = array(); } if (!is_array($objects)) {
$objects = array();
}
return $objects; return $objects;

View file

@ -387,7 +387,7 @@ class Preference extends database_object
*/ */
public static function load_from_session($uid=-1) public static function load_from_session($uid=-1)
{ {
if (is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) { if (isset($_SESSION['userdata']['preferences']) && is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) {
AmpConfig::set_by_array($_SESSION['userdata']['preferences'], true); AmpConfig::set_by_array($_SESSION['userdata']['preferences'], true);
return true; return true;
} }

View file

@ -1011,7 +1011,7 @@ class Query
*/ */
private function get_join_sql() private function get_join_sql()
{ {
if (!is_array($this->_state['join'])) { if (!isset($this->_state['join']) || !is_array($this->_state['join'])) {
return ''; return '';
} }
@ -1033,7 +1033,7 @@ class Query
*/ */
public function get_having_sql() public function get_having_sql()
{ {
$sql = $this->_state['having']; $sql = isset($this->_state['having']) ? $this->_state['having'] : '';
return $sql; return $sql;
@ -1049,7 +1049,7 @@ class Query
{ {
$sql = $this->get_base_sql(); $sql = $this->get_base_sql();
if (!$this->_state['custom']) { if (!isset($this->_state['custom']) || !$this->_state['custom']) {
$filter_sql = $this->get_filter_sql(); $filter_sql = $this->get_filter_sql();
$join_sql = $this->get_join_sql(); $join_sql = $this->get_join_sql();
$having_sql = $this->get_having_sql(); $having_sql = $this->get_having_sql();
@ -1074,7 +1074,7 @@ class Query
*/ */
private function post_process($data) private function post_process($data)
{ {
$tags = $this->_state['filter']['tag']; $tags = isset($this->_state['filter']['tag']) ? $this->_state['filter']['tag'] : '';
if (!is_array($tags) || sizeof($tags) < 2) { if (!is_array($tags) || sizeof($tags) < 2) {
return $data; return $data;

View file

@ -122,14 +122,14 @@ class Rating extends database_object
$user_id = $GLOBALS['user']->id; $user_id = $GLOBALS['user']->id;
} }
$key = 'rating_' . $type . '_user' . $user_id; $key = 'rating_' . $this->type . '_user' . $user_id;
if (parent::is_cached($key, $this->id)) { if (parent::is_cached($key, $this->id)) {
return parent::get_from_cache($key, $this->id); return parent::get_from_cache($key, $this->id);
} }
$sql = "SELECT `rating` FROM `rating` WHERE `user` = ? ". $sql = "SELECT `rating` FROM `rating` WHERE `user` = ? ".
"AND `object_id` = ? AND `object_type` = ?"; "AND `object_id` = ? AND `object_type` = ?";
$db_results = Dba::read($sql, array($user_id, $this->id, $type)); $db_results = Dba::read($sql, array($user_id, $this->id, $this->type));
$rating = 0; $rating = 0;
@ -149,8 +149,8 @@ class Rating extends database_object
*/ */
public function get_average_rating() public function get_average_rating()
{ {
if (parent::is_cached('rating_' . $type . '_all', $id)) { if (parent::is_cached('rating_' . $this->type . '_all', $this->id)) {
return parent::get_from_cache('rating_' . $type . '_user', $id); return parent::get_from_cache('rating_' . $this->type . '_user', $this->id);
} }
$sql = "SELECT AVG(`rating`) as `rating` FROM `rating` WHERE " . $sql = "SELECT AVG(`rating`) as `rating` FROM `rating` WHERE " .
@ -159,7 +159,7 @@ class Rating extends database_object
$results = Dba::fetch_assoc($db_results); $results = Dba::fetch_assoc($db_results);
parent::add_to_cache('rating_' . $type . '_all', $id, $results['rating']); parent::add_to_cache('rating_' . $this->type . '_all', $this->id, $results['rating']);
return $results['rating']; return $results['rating'];
} // get_average_rating } // get_average_rating

View file

@ -204,10 +204,16 @@ class Session
break; break;
} // end switch on data type } // end switch on data type
$username = '';
if (isset($data['username'])) {
$username = $data['username']; $username = $data['username'];
}
$ip = $_SERVER['REMOTE_ADDR'] ? inet_pton($_SERVER['REMOTE_ADDR']) : '0'; $ip = $_SERVER['REMOTE_ADDR'] ? inet_pton($_SERVER['REMOTE_ADDR']) : '0';
$type = $data['type']; $type = $data['type'];
$value = '';
if (isset($data['value'])) {
$value = $data['value']; $value = $data['value'];
}
$agent = (!empty($data['agent'])) ? $data['agent'] : substr($_SERVER['HTTP_USER_AGENT'], 0, 254); $agent = (!empty($data['agent'])) ? $data['agent'] : substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
if ($type == 'stream') { if ($type == 'stream') {

View file

@ -185,6 +185,10 @@ class Song extends database_object implements media
} }
$db_results = Dba::read($sql); $db_results = Dba::read($sql);
$artists = array();
$albums = array();
$tags = array();
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
if (AmpConfig::get('show_played_times')) { if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('song', $row['id']); $row['object_cnt'] = Stats::get_object_count('song', $row['id']);
@ -200,7 +204,7 @@ class Song extends database_object implements media
Artist::build_cache($artists); Artist::build_cache($artists);
Album::build_cache($albums); Album::build_cache($albums);
Tag::build_cache($tags); Tag::build_cache($tags);
Tag::build_map_cache('song',$song_ids); Tag::build_map_cache('song', $song_ids);
Art::build_cache($albums); Art::build_cache($albums);
// If we're rating this then cache them as well // If we're rating this then cache them as well
@ -824,8 +828,10 @@ class Song extends database_object implements media
$this->fill_ext_info(); $this->fill_ext_info();
// Format the filename // Format the filename
preg_match("/^.*\/(.*?)$/",$this->file, $short); preg_match("/^.*\/(.*?)$/", $this->file, $short);
if (is_array($short) && isset($short[1])) {
$this->f_file = htmlspecialchars($short[1]); $this->f_file = htmlspecialchars($short[1]);
}
// Format the album name // Format the album name
$this->f_album_full = $this->get_album_name(); $this->f_album_full = $this->get_album_name();

View file

@ -243,7 +243,7 @@ END;
*/ */
private static function _find_icon($name) private static function _find_icon($name)
{ {
if ($url = self::$_icon_cache[$name]) { if (isset(self::$_icon_cache[$name]) && $url = self::$_icon_cache[$name]) {
return $url; return $url;
} }

View file

@ -180,24 +180,42 @@ function create_preference_input($name,$value)
case 'share_social': case 'share_social':
case 'broadcast_by_default': case 'broadcast_by_default':
case 'album_group': case 'album_group':
if ($value == '1') { $is_true = "selected=\"selected\""; } else { $is_false = "selected=\"selected\""; } $is_true = '';
$is_false = '';
if ($value == '1') {
$is_true = "selected=\"selected\""; }
else {
$is_false = "selected=\"selected\"";
}
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
echo "\t<option value=\"1\" $is_true>" . T_("Enable") . "</option>\n"; echo "\t<option value=\"1\" $is_true>" . T_("Enable") . "</option>\n";
echo "\t<option value=\"0\" $is_false>" . T_("Disable") . "</option>\n"; echo "\t<option value=\"0\" $is_false>" . T_("Disable") . "</option>\n";
echo "</select>\n"; echo "</select>\n";
break; break;
case 'play_type': case 'play_type':
if ($value == 'localplay') { $is_local = 'selected="selected"'; } elseif ($value == 'democratic') { $is_vote = 'selected="selected"'; } elseif ($value == 'web_player') { $is_web_player = 'selected="selected"'; } else { $is_stream = "selected=\"selected\""; } $is_localplay = '';
$is_democratic = '';
$is_web_player = '';
$is_stream = '';
if ($value == 'localplay') {
$is_localplay = 'selected="selected"';
} elseif ($value == 'democratic') {
$is_democratic = 'selected="selected"';
} elseif ($value == 'web_player') {
$is_web_player = 'selected="selected"';
} else {
$is_stream = "selected=\"selected\"";
}
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
echo "\t<option value=\"\">" . T_('None') . "</option>\n"; echo "\t<option value=\"\">" . T_('None') . "</option>\n";
if (AmpConfig::get('allow_stream_playback')) { if (AmpConfig::get('allow_stream_playback')) {
echo "\t<option value=\"stream\" $is_stream>" . T_('Stream') . "</option>\n"; echo "\t<option value=\"stream\" $is_stream>" . T_('Stream') . "</option>\n";
} }
if (AmpConfig::get('allow_democratic_playback')) { if (AmpConfig::get('allow_democratic_playback')) {
echo "\t<option value=\"democratic\" $is_vote>" . T_('Democratic') . "</option>\n"; echo "\t<option value=\"democratic\" $is_democratic>" . T_('Democratic') . "</option>\n";
} }
if (AmpConfig::get('allow_localplay_playback')) { if (AmpConfig::get('allow_localplay_playback')) {
echo "\t<option value=\"localplay\" $is_local>" . T_('Localplay') . "</option>\n"; echo "\t<option value=\"localplay\" $is_localplay>" . T_('Localplay') . "</option>\n";
} }
echo "\t<option value=\"web_player\" $is_web_player>" . _('Web Player') . "</option>\n"; echo "\t<option value=\"web_player\" $is_web_player>" . _('Web Player') . "</option>\n";
echo "</select>\n"; echo "</select>\n";
@ -236,7 +254,18 @@ function create_preference_input($name,$value)
echo "</select>\n"; echo "</select>\n";
break; break;
case 'localplay_level': case 'localplay_level':
if ($value == '25') { $is_user = 'selected="selected"'; } elseif ($value == '100') { $is_admin = 'selected="selected"'; } elseif ($value == '50') { $is_manager = 'selected="selected"'; } $is_user = '';
$is_admin = '';
$is_manager = '';
if ($value == '25') {
$is_user = 'selected="selected"';
}
elseif ($value == '100') {
$is_admin = 'selected="selected"';
}
elseif ($value == '50') {
$is_manager = 'selected="selected"';
}
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
echo "<option value=\"0\">" . T_('Disabled') . "</option>\n"; echo "<option value=\"0\">" . T_('Disabled') . "</option>\n";
echo "<option value=\"25\" $is_user>" . T_('User') . "</option>\n"; echo "<option value=\"25\" $is_user>" . T_('User') . "</option>\n";
@ -272,14 +301,35 @@ function create_preference_input($name,$value)
echo "</select>\n"; echo "</select>\n";
break; break;
case 'show_lyrics': case 'show_lyrics':
if ($value == '1') { $is_true = "selected=\"selected\""; } else { $is_false = "selected=\"selected\""; } $is_true = '';
$is_false = '';
if ($value == '1') {
$is_true = "selected=\"selected\"";
} else {
$is_false = "selected=\"selected\"";
}
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
echo "\t<option value=\"1\" $is_true>" . T_("Enable") . "</option>\n"; echo "\t<option value=\"1\" $is_true>" . T_("Enable") . "</option>\n";
echo "\t<option value=\"0\" $is_false>" . T_("Disable") . "</option>\n"; echo "\t<option value=\"0\" $is_false>" . T_("Disable") . "</option>\n";
echo "</select>\n"; echo "</select>\n";
break; break;
case 'album_sort': case 'album_sort':
if ($value == 'year_asc') { $is_sort_year_asc = 'selected="selected"'; } elseif ($value == 'year_desc') { $is_sort_year_desc = 'selected="selected"'; } elseif ($value == 'name_asc') { $is_sort_name_asc = 'selected="selected"'; } elseif ($value == 'name_desc') { $is_sort_name_desc = 'selected="selected"'; } else { $is_sort_default = 'selected="selected"'; } $is_sort_year_asc = '';
$is_sort_year_desc = '';
$is_sort_name_asc = '';
$is_sort_name_desc = '';
$is_sort_default = '';
if ($value == 'year_asc') {
$is_sort_year_asc = 'selected="selected"';
} elseif ($value == 'year_desc') {
$is_sort_year_desc = 'selected="selected"';
} elseif ($value == 'name_asc') {
$is_sort_name_asc = 'selected="selected"';
} elseif ($value == 'name_desc') {
$is_sort_name_desc = 'selected="selected"';
} else {
$is_sort_default = 'selected="selected"';
}
echo "<select name=\"$name\">\n"; echo "<select name=\"$name\">\n";
echo "\t<option value=\"default\" $is_sort_default>" . T_('Default') . "</option>\n"; echo "\t<option value=\"default\" $is_sort_default>" . T_('Default') . "</option>\n";

View file

@ -347,7 +347,7 @@ function show_playlist_select($name,$selected='',$style='')
function xoutput_headers() function xoutput_headers()
{ {
$output = $_REQUEST['xoutput'] ?: 'xml'; $output = (isset($_REQUEST['xoutput']) && $_REQUEST['xoutput']) ?: 'xml';
if ($output == 'xml') { if ($output == 'xml') {
header("Content-type: text/xml; charset=" . AmpConfig::get('site_charset')); header("Content-type: text/xml; charset=" . AmpConfig::get('site_charset'));
header("Content-Disposition: attachment; filename=ajax.xml"); header("Content-Disposition: attachment; filename=ajax.xml");
@ -363,7 +363,7 @@ function xoutput_headers()
function xoutput_from_array($array, $callback = false, $type = '') function xoutput_from_array($array, $callback = false, $type = '')
{ {
$output = $_REQUEST['xoutput'] ?: 'xml'; $output = (isset($_REQUEST['xoutput']) && $_REQUEST['xoutput']) ?: 'xml';
if ($output == 'xml') { if ($output == 'xml') {
return xml_from_array($array, $callback, $type); return xml_from_array($array, $callback, $type);
} elseif ($output == 'raw') { } elseif ($output == 'raw') {

View file

@ -216,9 +216,9 @@ class AmpacheLastfm {
// If we don't have the other stuff try to get it before giving up // If we don't have the other stuff try to get it before giving up
if (!$data['lastfm_host'] || !$data['lastfm_port'] || !$data['lastfm_url'] || !$data['lastfm_challenge']) { if (!$data['lastfm_host'] || !$data['lastfm_port'] || !$data['lastfm_url'] || !$data['lastfm_challenge']) {
debug_event($this->name,'Running Handshake, missing information','3'); debug_event($this->name, 'Running Handshake, missing information', '1');
if (!$this->set_handshake($this->user_id)) { if (!$this->set_handshake($this->user_id)) {
debug_event($this->name,'Handshake failed, you lose','3'); debug_event($this->name, 'Handshake failed, you lose', '3');
return false; return false;
} }
} }

View file

@ -139,7 +139,7 @@ class Ampachelibrefm {
if (!$scrobbler->submit_tracks()) { if (!$scrobbler->submit_tracks()) {
debug_event($this->name,'Error Submit Failed: ' . $scrobbler->error_msg,'3'); debug_event($this->name,'Error Submit Failed: ' . $scrobbler->error_msg,'3');
if ($scrobbler->reset_handshake) { if ($scrobbler->reset_handshake) {
debug_event($this->name,'Re-running Handshake due to error','3'); debug_event($this->name, 'Re-running Handshake due to error', '1');
$this->set_handshake($this->user_id); $this->set_handshake($this->user_id);
// Try try again // Try try again
if ($scrobbler->submit_tracks()) { if ($scrobbler->submit_tracks()) {

View file

@ -338,7 +338,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('ratings')) { if (AmpConfig::get('ratings')) {
echo " <div id='rating_" . $_GET['object_id'] . "_" . $_GET['object_type'] . "'>"; echo " <div id='rating_" . $_GET['object_id'] . "_" . $_GET['object_type'] . "'>";
Rating::show($_GET['object_id'], $_GET['object_type']); Rating::show($_GET['object_id'], $_GET['object_type']);
echo "</div>"; echo "</div> |";
} }
if (AmpConfig::get('userflags')) { if (AmpConfig::get('userflags')) {
echo " <div id='userflag_" . $_GET['object_id'] . "_" . $_GET['object_type'] . "'>"; echo " <div id='userflag_" . $_GET['object_id'] . "_" . $_GET['object_type'] . "'>";

View file

@ -24,7 +24,10 @@
* Sub-Ajax page, requires AJAX_INCLUDE * Sub-Ajax page, requires AJAX_INCLUDE
*/ */
require_once '../lib/init.php'; require_once '../lib/init.php';
session_start();
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (!defined('AJAX_INCLUDE')) { exit; } if (!defined('AJAX_INCLUDE')) { exit; }
@ -34,10 +37,9 @@ if (isset($_REQUEST['browse_id'])) {
$browse_id = null; $browse_id = null;
} }
$list_uid = scrub_in($_REQUEST['uid']);
$browse = new Browse($browse_id); $browse = new Browse($browse_id);
if ($_REQUEST['show_header']) { if (isset($_REQUEST['show_header']) && $_REQUEST['show_header']) {
$browse->set_show_header($_REQUEST['show_header'] == 'true'); $browse->set_show_header($_REQUEST['show_header'] == 'true');
} }

View file

@ -19,37 +19,42 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
*/ */
session_start();
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
?> ?>
<?php $allowed_filters = Browse::get_allowed_filters($browse->get_type()); ?> <?php $allowed_filters = Browse::get_allowed_filters($browse->get_type()); ?>
<li><h4><?php echo T_('Filters'); ?></h4> <li>
<div class="sb3"> <h4><?php echo T_('Filters'); ?></h4>
<?php if (in_array('starts_with',$allowed_filters)) { ?> <div class="sb3">
<?php if (in_array('starts_with',$allowed_filters)) { ?>
<form id="multi_alpha_filter_form" method="post" action="javascript:void(0);"> <form id="multi_alpha_filter_form" method="post" action="javascript:void(0);">
<label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo T_('Starts With'); ?></label> <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo T_('Starts With'); ?></label>
<input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php $browse->set_catalog($_SESSION['catalog']); echo scrub_out($browse->get_filter('starts_with'));?>" onKeyUp="delayRun(this, '400', 'ajaxState', '<?php echo Ajax::url('?page=browse&action=browse&browse_id=' . $browse->id . '&key=starts_with'); ?>', 'multi_alpha_filter');"> <input type="text" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php $browse->set_catalog($_SESSION['catalog']); echo scrub_out($browse->get_filter('starts_with'));?>" onKeyUp="delayRun(this, '400', 'ajaxState', '<?php echo Ajax::url('?page=browse&action=browse&browse_id=' . $browse->id . '&key=starts_with'); ?>', 'multi_alpha_filter');">
</form> </form>
<?php } // end if alpha_match ?> <?php } // end if alpha_match ?>
<?php if (in_array('minimum_count',$allowed_filters)) { ?> <?php if (in_array('minimum_count',$allowed_filters)) { ?>
<input id="mincountCB" type="checkbox" value="1" /> <input id="mincountCB" type="checkbox" value="1" />
<label id="mincountLabel" for="mincountCB"><?php echo T_('Minimum Count'); ?></label><br /> <label id="mincountLabel" for="mincountCB"><?php echo T_('Minimum Count'); ?></label><br />
<?php echo Ajax::observe('mincountCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=min_count&value=1', '')); ?> <?php echo Ajax::observe('mincountCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=min_count&value=1', '')); ?>
<?php } ?> <?php } ?>
<?php if (in_array('rated',$allowed_filters)) { ?> <?php if (in_array('rated',$allowed_filters)) { ?>
<input id="ratedCB" type="checkbox" value="1" /> <input id="ratedCB" type="checkbox" value="1" />
<label id="ratedLabel" for="ratedCB"><?php echo T_('Rated'); ?></label><br /> <label id="ratedLabel" for="ratedCB"><?php echo T_('Rated'); ?></label><br />
<?php echo Ajax::observe('ratedCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=rated&value=1', '')); ?> <?php echo Ajax::observe('ratedCB', 'click', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=rated&value=1', '')); ?>
<?php } ?> <?php } ?>
<?php if (in_array('unplayed',$allowed_filters)) { ?> <?php if (in_array('unplayed',$allowed_filters)) { ?>
<input id="unplayedCB" type="checkbox" <?php echo $string = $browse->get_filter('unplayed') ? 'checked="checked"' : ''; ?>/> <input id="unplayedCB" type="checkbox" <?php echo $string = $browse->get_filter('unplayed') ? 'checked="checked"' : ''; ?>/>
<label id="unplayedLabel" for="unplayedCB"><?php echo T_('Unplayed'); ?></label><br /> <label id="unplayedLabel" for="unplayedCB"><?php echo T_('Unplayed'); ?></label><br />
<?php } ?> <?php } ?>
<?php if (in_array('playlist_type',$allowed_filters)) { ?> <?php if (in_array('playlist_type',$allowed_filters)) { ?>
<input id="show_allplCB" type="checkbox" <?php echo $string = $browse->get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/> <input id="show_allplCB" type="checkbox" <?php echo $string = $browse->get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/>
<label id="show_allplLabel" for="showallplCB"><?php echo T_('All Playlists'); ?></label><br /> <label id="show_allplLabel" for="showallplCB"><?php echo T_('All Playlists'); ?></label><br />
<?php echo Ajax::observe('show_allplCB','click',Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=playlist_type&value=1','')); ?> <?php echo Ajax::observe('show_allplCB','click',Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id . '&key=playlist_type&value=1','')); ?>
<?php } // if playlist_type ?> <?php } // if playlist_type ?>
<?php if (in_array('object_type',$allowed_filters)) { ?> <?php if (in_array('object_type',$allowed_filters)) { ?>
<?php $string = 'otype_' . $browse->get_filter('object_type'); ${$string} = 'selected="selected"'; ?> <?php $string = 'otype_' . $browse->get_filter('object_type'); ${$string} = 'selected="selected"'; ?>
<input id="typeSongRadio" type="radio" name="object_type" value="1" <?php echo $otype_song; ?>/> <input id="typeSongRadio" type="radio" name="object_type" value="1" <?php echo $otype_song; ?>/>
<label id="typeSongLabel" for="typeSongRadio"><?php echo T_('Song Title'); ?></label><br /> <label id="typeSongLabel" for="typeSongRadio"><?php echo T_('Song Title'); ?></label><br />
@ -60,10 +65,10 @@ session_start();
<input id="typeArtistRadio" type="radio" name="object_type" value="1" /> <input id="typeArtistRadio" type="radio" name="object_type" value="1" />
<label id="typeArtistLabel" for="typeArtistRadio"><?php echo T_('Artist'); ?></label><br /> <label id="typeArtistLabel" for="typeArtistRadio"><?php echo T_('Artist'); ?></label><br />
<?php echo Ajax::observe('typeArtistRadio','click',Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=artist','')); ?> <?php echo Ajax::observe('typeArtistRadio','click',Ajax::action('?page=tag&action=browse_type&browse_id=' . $browse->id . '&type=artist','')); ?>
<?php } ?> <?php } ?>
<?php if (in_array('catalog',$allowed_filters)) { ?> <?php if (in_array('catalog',$allowed_filters)) { ?>
<form method="post" id="catalog_choice" action="javascript.void(0);"> <form method="post" id="catalog_choice" action="javascript.void(0);">
<label id="catalogLabel" for="catalog_select"><?php echo T_('Catalog'); ?></label><br /> <label id="catalogLabel" for="catalog_select"><?php echo T_('Catalog'); ?></label><br />
<select id="catalog_select" name="catalog_key"> <select id="catalog_select" name="catalog_key">
<option value="0">All</option> <option value="0">All</option>
@ -84,12 +89,12 @@ session_start();
?> ?>
</select> </select>
<?php echo Ajax::observe('catalog_select', 'change', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id,'catalog_select', 'catalog_choice')); ?> <?php echo Ajax::observe('catalog_select', 'change', Ajax::action('?page=browse&action=browse&browse_id=' . $browse->id,'catalog_select', 'catalog_choice')); ?>
</form> </form>
<?php } ?> <?php } ?>
<?php if (in_array('show_art',$allowed_filters)) { ?> <?php if (in_array('show_art',$allowed_filters)) { ?>
<?php echo T_('Toggle Artwork'); ?>&nbsp;<input id="show_artCB" type="checkbox" <?php echo Art::is_enabled() ? 'checked="checked"' : ''; ?>/> <?php echo T_('Toggle Artwork'); ?>&nbsp;<input id="show_artCB" type="checkbox" <?php echo Art::is_enabled() ? 'checked="checked"' : ''; ?>/>
<?php echo Ajax::observe('show_artCB','click',Ajax::action('?page=browse&action=show_art&browse_id=' . $browse->id, '')); ?> <?php echo Ajax::observe('show_artCB','click',Ajax::action('?page=browse&action=show_art&browse_id=' . $browse->id, '')); ?>
<?php } // if show_art ?> <?php } // if show_art ?>
</div> </div>
</li> </li>

View file

@ -27,7 +27,7 @@
* to layout this page. * to layout this page.
*/ */
if ($is_header) { if (isset($is_header) && $is_header) {
$is_header = false; $is_header = false;
} else { } else {
$is_header = true; $is_header = true;

View file

@ -125,10 +125,10 @@ if (AmpConfig::get('show_played_times')) {
<?php } ?> <?php } ?>
<?php if (Access::check('interface','50')) { ?> <?php if (Access::check('interface','50')) { ?>
<li> <li>
<a id="<?php echo 'edit_album_'.$c_album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', '', '')"> <a id="<?php echo 'edit_album_'.$album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', '', '')">
<?php echo UI::get_icon('edit', T_('Edit')); ?> <?php echo UI::get_icon('edit', T_('Edit')); ?>
</a> </a>
<a id="<?php echo 'edit_album_'.$c_album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', '', '')"> <a id="<?php echo 'edit_album_'.$album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', '', '')">
<?php echo T_('Edit Album'); ?> <?php echo T_('Edit Album'); ?>
</a> </a>
</li> </li>

View file

@ -177,7 +177,7 @@ if (!$isVideo && !$isRadio && !$is_share) {
echo "var lyricsobj = '<a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/song.php?action=show_lyrics&song_id=' + currenti.attr('data-song_id') + '\');\">" . T_('Show Lyrics') . "</a>';"; echo "var lyricsobj = '<a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/song.php?action=show_lyrics&song_id=' + currenti.attr('data-song_id') + '\');\">" . T_('Show Lyrics') . "</a>';";
echo "var actionsobj = '|';"; echo "var actionsobj = '|';";
if (AmpConfig::get('sociable')) { if (AmpConfig::get('sociable')) {
echo "actionsobj += ' <a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=song&id=' + currenti.attr('data-song_id') + '\');\">" . UI::get_icon('comment', T_('Post Shout')) . "</a>';"; echo "actionsobj += ' <a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=song&id=' + currenti.attr('data-song_id') + '\');\">" . UI::get_icon('comment', T_('Post Shout')) . "</a> |';";
} }
echo "actionsobj += '<div id=\'action_buttons\'></div>';"; echo "actionsobj += '<div id=\'action_buttons\'></div>';";
if (AmpConfig::get('waveform')) { if (AmpConfig::get('waveform')) {

View file

@ -30,19 +30,21 @@ if (Preference::has_access('play_type')) {
<form method="post" id="play_type_form" action="javascript.void(0);"> <form method="post" id="play_type_form" action="javascript.void(0);">
<select id="play_type_select" name="type"> <select id="play_type_select" name="type">
<?php if (AmpConfig::get('allow_stream_playback')) { ?> <?php if (AmpConfig::get('allow_stream_playback')) { ?>
<option value="stream" <?php echo $is_stream; ?>><?php echo T_('Stream'); ?></option> <option value="stream" <?php if (isset($is_stream)) { echo $is_stream; } ?>><?php echo T_('Stream'); ?></option>
<?php } if (AmpConfig::get('allow_localplay_playback')) { ?> <?php } if (AmpConfig::get('allow_localplay_playback')) { ?>
<option value="localplay" <?php echo $is_localplay; ?>><?php echo T_('Localplay'); ?></option> <option value="localplay" <?php if (isset($is_localplay)) {echo $is_localplay; } ?>><?php echo T_('Localplay'); ?></option>
<?php } if (AmpConfig::get('allow_democratic_playback')) { ?> <?php } if (AmpConfig::get('allow_democratic_playback')) { ?>
<option value="democratic" <?php echo $is_democratic; ?>><?php echo T_('Democratic'); ?></option> <option value="democratic" <?php if (isset($is_democratic)) {echo $is_democratic; } ?>><?php echo T_('Democratic'); ?></option>
<?php } ?> <?php } ?>
<option value="web_player" <?php echo $is_web_player; ?>><?php echo T_('Web Player'); ?></option> <option value="web_player" <?php if (isset($is_web_player)) { echo $is_web_player; } ?>><?php echo T_('Web Player'); ?></option>
</select> </select>
<?php echo Ajax::observe('play_type_select','change',Ajax::action('?page=stream&action=set_play_type','play_type_select','play_type_form')); ?> <?php echo Ajax::observe('play_type_select','change',Ajax::action('?page=stream&action=set_play_type','play_type_select','play_type_form')); ?>
</form> </form>
<?php <?php
} // if they have access } // if they have access
// Else just show what it currently is // Else just show what it currently is
else { echo T_(ucwords(AmpConfig::get('play_type'))); } else {
echo T_(ucwords(AmpConfig::get('play_type')));
}
?> ?>
</div> </div>

View file

@ -125,7 +125,7 @@ UI::show_box_top(T_('Recently Played') . $link, 'box box_recently_played');
<?php } ?> <?php } ?>
<?php if (!count($data)) { ?> <?php if (!count($data)) { ?>
<tr> <tr>
<td colspan=""><span class="nodata"><?php echo T_('No recently item found'); ?></span></td> <td colspan="8"><span class="nodata"><?php echo T_('No recently item found'); ?></span></td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>

View file

@ -20,9 +20,10 @@
* *
*/ */
if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; } if (!$_SESSION['state']['sidebar_tab']) {
$_SESSION['state']['sidebar_tab'] = 'home';
}
$class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab']; $class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab'];
${$class_name} = ' active';
// List of buttons ( id, title, icon, access level) // List of buttons ( id, title, icon, access level)
$sidebar_items[] = array('id'=>'home', 'title' => T_('Home'), 'icon'=>'home', 'access'=>5); $sidebar_items[] = array('id'=>'home', 'title' => T_('Home'), 'icon'=>'home', 'access'=>5);
@ -31,34 +32,36 @@ $sidebar_items[] = array('id'=>'preferences', 'title' => T_('Preferences'), 'ico
$sidebar_items[] = array('id'=>'modules','title' => T_('Modules'),'icon'=>'plugin','access'=>100); $sidebar_items[] = array('id'=>'modules','title' => T_('Modules'),'icon'=>'plugin','access'=>100);
$sidebar_items[] = array('id'=>'admin', 'title' => T_('Admin'), 'icon'=>'admin', 'access'=>100); $sidebar_items[] = array('id'=>'admin', 'title' => T_('Admin'), 'icon'=>'admin', 'access'=>100);
$web_path = AmpConfig::get('web_path'); $web_path = AmpConfig::get('web_path');
?> ?>
<ul id="sidebar-tabs"> <ul id="sidebar-tabs">
<?php <?php
foreach ($sidebar_items as $item) { foreach ($sidebar_items as $item) {
if (Access::check('interface',$item['access'])) { if (Access::check('interface', $item['access'])) {
$li_params = "id='sb_tab_" . $item['id'] . "' class='sb1" . ${'sidebar_'.$item['id'] } . "'";
?><li <?php echo $li_params; ?>>
<?php
// Button
echo Ajax::button("?page=index&action=sidebar&button=".$item['id'],$item['icon'],$item['title'],'sidebar_'.$item['id']);
// Include subnav if it's the selected one $active = ('sidebar_'.$item['id'] == $class_name) ? ' active' : '';
// so that it's generated inside its parent li $li_params = "id='sb_tab_" . $item['id'] . "' class='sb1" . $active . "'";
?>
<li <?php echo $li_params; ?>>
<?php
echo Ajax::button("?page=index&action=sidebar&button=".$item['id'], $item['icon'], $item['title'], 'sidebar_'.$item['id']);
if ($item['id']==$_SESSION['state']['sidebar_tab']) { if ($item['id']==$_SESSION['state']['sidebar_tab']) {
?><div id="sidebar-page" class="sidebar-page-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>"><?php ?>
require_once AmpConfig::get('prefix') . '/templates/sidebar_' . $_SESSION['state']['sidebar_tab'] . '.inc.php'; <div id="sidebar-page" class="sidebar-page-<?php echo AmpConfig::get('ui_fixed') ? 'fixed' : 'float'; ?>">
?></div><?php <?php require_once AmpConfig::get('prefix') . '/templates/sidebar_' . $_SESSION['state']['sidebar_tab'] . '.inc.php'; ?>
} </div>
?></li><?php <?php
}
} }
?> ?>
<li id="sb_tab_logout" class="sb1"> </li>
<?php
}
}
?>
<li id="sb_tab_logout" class="sb1">
<a target="_top" href="<?php echo AmpConfig::get('web_path'); ?>/logout.php" id="sidebar_logout" > <a target="_top" href="<?php echo AmpConfig::get('web_path'); ?>/logout.php" id="sidebar_logout" >
<?php echo UI::get_icon('logout', T_('Logout')); ?> <?php echo UI::get_icon('logout', T_('Logout')); ?>
</a> </a>
</li> </li>
</ul> </ul>