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

Fix code style

This commit is contained in:
Afterster 2013-11-23 01:11:19 +01:00
parent 619ca48ffe
commit 1745e204cd
17 changed files with 120 additions and 117 deletions

View file

@ -59,7 +59,7 @@ switch ($_REQUEST['action']) {
break;
case 'album':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_sort('name','ASC');
$browse->show_objects();
break;
@ -83,19 +83,19 @@ switch ($_REQUEST['action']) {
break;
case 'artist':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_sort('name','ASC');
$browse->show_objects();
break;
case 'song':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_sort('title','ASC');
$browse->show_objects();
break;
case 'live_stream':
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_sort('name','ASC');
$browse->show_objects();
break;
@ -113,7 +113,7 @@ switch ($_REQUEST['action']) {
$browse->show_objects();
break;
case 'video':
$browse->set_filter('catalog_enabled', '1');
$browse->set_filter('catalog_enabled', '1');
$browse->set_sort('title','ASC');
$browse->show_objects();
break;

View file

@ -128,10 +128,10 @@ class Album extends database_object
"`artist`.`id` AS `artist_id`, `song`.`album`" .
"FROM `song` " .
"INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`album` IN $idlist " .
"AND `catalog`.`enabled` = '1' " .
"GROUP BY `song`.`album`";
"AND `catalog`.`enabled` = '1' " .
"GROUP BY `song`.`album`";
$db_results = Dba::read($sql);
@ -171,9 +171,9 @@ class Album extends database_object
"`artist`.`id` AS `artist_id` " .
"FROM `song` INNER JOIN `artist` " .
"ON `artist`.`id`=`song`.`artist` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`album` = ? " .
"AND `catalog`.`enabled` = '1' " .
"AND `catalog`.`enabled` = '1' " .
"GROUP BY `song`.`album`";
$db_results = Dba::read($sql, array($this->id));
@ -277,14 +277,14 @@ class Album extends database_object
$results = array();
$sql = "SELECT `song`.`id` FROM `song` ";
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sql .= "WHERE `song`.`album` = ? ";
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sql .= "WHERE `song`.`album` = ? ";
$params = array($this->id);
if (strlen($artist)) {
$sql .= "AND `artist` = ? ";
$params[] = $artist;
}
$sql .= "AND `catalog`.`enabled` = '1' ";
$sql .= "AND `catalog`.`enabled` = '1' ";
$sql .= "ORDER BY `song`.`track`, `song`.`title`";
if ($limit) {
$sql .= " LIMIT " . intval($limit);
@ -443,16 +443,16 @@ class Album extends database_object
{
$results = false;
$sql = "SELECT `album`.`id` FROM `album` " .
"LEFT JOIN `song` ON `song`.`album` = `album`.`id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$where = "WHERE `catalog`.`enabled` = '1' ";
$sql = "SELECT `album`.`id` FROM `album` " .
"LEFT JOIN `song` ON `song`.`album` = `album`.`id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$where = "WHERE `catalog`.`enabled` = '1' ";
if ($with_art) {
$sql .= "LEFT JOIN `image` ON (`image`.`object_type` = 'album' AND `image`.`object_id` = `album`.`id`) ";
$where .="AND `image`.`id` IS NOT NULL ";
$where .="AND `image`.`id` IS NOT NULL ";
}
$sql .= $where;
$sql .= $where;
$sql .= "ORDER BY RAND() LIMIT " . intval($count);
$db_results = Dba::read($sql);

View file

@ -146,12 +146,12 @@ class Artist extends database_object
*/
public function get_albums($catalog = null)
{
$catalog_where = "";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$catalog_where = "";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
if ($catalog) {
$catalog_where .= " AND `catalog`.`id` = '$catalog'";
}
$catalog_where .= " AND `catalog`.`enabled` = '1'";
$catalog_where .= " AND `catalog`.`enabled` = '1'";
$results = array();
@ -181,7 +181,7 @@ class Artist extends database_object
public function get_songs()
{
$sql = "SELECT `song`.`id` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`artist`='" . Dba::escape($this->id) . "' AND `catalog`.`enabled` = '1' ORDER BY album, track";
"WHERE `song`.`artist`='" . Dba::escape($this->id) . "' AND `catalog`.`enabled` = '1' ORDER BY album, track";
$db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) {
@ -201,7 +201,7 @@ class Artist extends database_object
$results = array();
$sql = "SELECT `song`.`id` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`artist`='$this->id' AND `catalog`.`enabled` = '1' ORDER BY RAND()";
"WHERE `song`.`artist`='$this->id' AND `catalog`.`enabled` = '1' ORDER BY RAND()";
$db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) {
@ -224,11 +224,11 @@ class Artist extends database_object
} else {
$uid = Dba::escape($this->id);
$sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`artist`='$uid' ";
"WHERE `song`.`artist`='$uid' ";
if ($catalog) {
$sql .= "AND (`song`.`catalog` = '$catalog') ";
}
$sql .= " AND `catalog`.`enabled` = '1'";
$sql .= " AND `catalog`.`enabled` = '1'";
$sql .= "GROUP BY `song`.`artist`";

View file

@ -266,7 +266,7 @@ abstract class Catalog extends database_object
return true;
}
/**
/**
* update_enabled
* sets the enabled flag
*/

View file

@ -101,7 +101,7 @@ class Query
'exact_match',
'alpha_match',
'catalog',
'catalog_enabled'
'catalog_enabled'
),
'artist' => array(
'add_lt',
@ -113,7 +113,7 @@ class Query
'starts_with',
'tag',
'catalog',
'catalog_enabled'
'catalog_enabled'
),
'song' => array(
'add_lt',
@ -125,12 +125,12 @@ class Query
'starts_with',
'tag',
'catalog',
'catalog_enabled'
'catalog_enabled'
),
'live_stream' => array(
'alpha_match',
'starts_with',
'catalog_enabled'
'catalog_enabled'
),
'playlist' => array(
'alpha_match',
@ -321,7 +321,7 @@ class Query
case 'add_gt':
case 'update_lt':
case 'update_gt':
case 'catalog_enabled':
case 'catalog_enabled':
$this->_state['filter'][$key] = intval($value);
break;
case 'exact_match':
@ -1074,10 +1074,10 @@ class Query
$filter_sql = " `song`.`catalog` = '$value' AND ";
}
break;
case 'catalog_enabled':
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
default:
// Rien a faire
break;
@ -1114,7 +1114,7 @@ class Query
$this->set_join('left','`song`','`album`.`id`','`song`.`album`', 100);
$this->set_join('left','`catalog`','`song`.`catalog`','`catalog`.`id`', 100);
$filter_sql = " (`song`.`catalog` = '$value') AND ";
}
}
break;
case 'update_lt':
$this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
@ -1124,11 +1124,11 @@ class Query
$this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`song`', '`song`.`album`', '`album`.`id`', 100);
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
default:
// Rien a faire
break;
@ -1172,11 +1172,11 @@ class Query
$this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`song`', '`song`.`artist`', '`artist`.`id`', 100);
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`song`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
default:
// Rien a faire
break;
@ -1190,10 +1190,10 @@ class Query
case 'starts_with':
$filter_sql = " `live_stream`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`live_stream`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
case 'catalog_enabled':
$this->set_join('left', '`catalog`', '`catalog`.`id`', '`live_stream`.`catalog`', 100);
$filter_sql = " `catalog`.`enabled` = '1' AND ";
break;
default:
// Rien a faire
break;

View file

@ -51,11 +51,11 @@ class Random implements media
public static function artist()
{
$sql = "SELECT `artist`.`id` FROM `artist` " .
"LEFT JOIN `song` ON `song`.`artist` = `artist`.`id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"GROUP BY `artist`.`id` " .
"ORDER BY RAND() LIMIT 1";
"LEFT JOIN `song` ON `song`.`artist` = `artist`.`id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"GROUP BY `artist`.`id` " .
"ORDER BY RAND() LIMIT 1";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
@ -133,9 +133,9 @@ class Random implements media
$results = array();
$sql = "SELECT `song`.`id` FROM `song` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"ORDER BY RAND() LIMIT $limit";
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"ORDER BY RAND() LIMIT $limit";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
@ -162,9 +162,9 @@ class Random implements media
}
$sql = "SELECT `song`.`id` FROM `song` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"$where_sql ORDER BY RAND() LIMIT $limit";
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"$where_sql ORDER BY RAND() LIMIT $limit";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
@ -190,9 +190,9 @@ class Random implements media
}
$sql = "SELECT `song`.`id` FROM `song` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"$where_sql ORDER BY RAND() LIMIT $limit";
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `catalog`.`enabled` = '1' " .
"$where_sql ORDER BY RAND() LIMIT $limit";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
@ -234,10 +234,10 @@ class Random implements media
"FROM `song` ";
if ($search_info) {
$sql .= $search_info['table_sql'];
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
$sql .= ' AND ' . $search_info['where_sql'];
}
break;
@ -248,10 +248,10 @@ class Random implements media
}
if ($search_info) {
$sql .= $search_info['table_sql'];
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
$sql .= ' AND ' . $search_info['where_sql'];
}
$sql .= ' GROUP BY `album`.`id`';
@ -263,10 +263,10 @@ class Random implements media
}
if ($search_info) {
$sql .= $search_info['table_sql'];
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
}
$sql .= " LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$sql .= " WHERE `catalog`.`enabled` = '1'";
if ($search_info) {
$sql .= ' AND ' . $search_info['where_sql'];
}
$sql .= ' GROUP BY `artist`.`id`';

View file

@ -176,9 +176,9 @@ class Song extends database_object implements media
'FROM `song` LEFT JOIN `tag_map` ' .
'ON `tag_map`.`object_id`=`song`.`id` ' .
"AND `tag_map`.`object_type`='song' " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`id` IN $idlist " .
"AND `catalog`.`enabled` = '1' ";
"AND `catalog`.`enabled` = '1' ";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {

View file

@ -116,11 +116,11 @@ class Stats
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
$sql = "SELECT * FROM `object_count` " .
"LEFT JOIN `song` ON `song`.`id` = `object_count`.`object_id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `object_count`.`user` = ? AND `object_count`.`object_type`='song' " .
"AND `catalog`.`enabled` = '1' " .
"ORDER BY `object_count`.`date` DESC LIMIT 1";
"LEFT JOIN `song` ON `song`.`id` = `object_count`.`object_id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `object_count`.`user` = ? AND `object_count`.`object_type`='song' " .
"AND `catalog`.`enabled` = '1' " .
"ORDER BY `object_count`.`date` DESC LIMIT 1";
$db_results = Dba::read($sql, array($user_id));
$results = Dba::fetch_assoc($db_results);
@ -139,10 +139,10 @@ class Stats
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
$sql = "SELECT * FROM `object_count` " .
"LEFT JOIN `song` ON `song`.`id` = `object_count`.`object_id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `object_count`.`user` = ? AND `object_count`.`object_type`='song' AND `object_count`.`date` >= ? " .
"AND `catalog`.`enabled` = '1' " .
"LEFT JOIN `song` ON `song`.`id` = `object_count`.`object_id` " .
"LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `object_count`.`user` = ? AND `object_count`.`object_type`='song' AND `object_count`.`date` >= ? " .
"AND `catalog`.`enabled` = '1' " .
"ORDER BY `object_count`.`date` DESC";
$db_results = Dba::read($sql, array($user_id, $time));
@ -160,7 +160,8 @@ class Stats
* get_top_sql
* This returns the get_top sql
*/
public static function get_top_sql($type, $threshold = '') {
public static function get_top_sql($type, $threshold = '')
{
$type = self::validate_type($type);
/* If they don't pass one, then use the preference */
if (!$threshold) {
@ -304,7 +305,8 @@ class Stats
* get_newest_sql
* This returns the get_newest sql
*/
public static function get_newest_sql($type) {
public static function get_newest_sql($type)
{
$type = self::validate_type($type);
$sql = "SELECT DISTINCT(`$type`) as `id`, MIN(`addition_time`) AS `real_atime` FROM `song` GROUP BY `$type` ORDER BY `real_atime` ";

View file

@ -159,7 +159,8 @@ class Userflag extends database_object
* get_latest_sql
* Get the latest sql
*/
public static function get_latest_sql($type, $user_id=null) {
public static function get_latest_sql($type, $user_id=null)
{
if (is_null($user_id)) {
$user_id = $GLOBALS['user']->id;
}

View file

@ -83,7 +83,7 @@ switch ($page) {
case 'index':
require_once Config::get('prefix') . '/server/index.ajax.php';
exit;
case 'catalog':
case 'catalog':
require_once Config::get('prefix') . '/server/catalog.ajax.php';
exit;
break;

View file

@ -37,7 +37,7 @@ $button_flip_state_id = 'button_flip_state_' . $catalog->id;
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=full_service&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo T_('Update'); ?></a>
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo T_('Gather Art'); ?></a>
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_delete_catalog&amp;catalog_id=<?php echo $catalog->id; ?>"><?php echo T_('Delete'); ?></a>
| <span id="<?php echo($button_flip_state_id); ?>">
<?php echo Ajax::button('?page=catalog&action=flip_state&catalog_id=' . $catalog->id, $icon, T_(ucfirst($icon)),'flip_state_' . $catalog->id); ?>
</span>
| <span id="<?php echo($button_flip_state_id); ?>">
<?php echo Ajax::button('?page=catalog&action=flip_state&catalog_id=' . $catalog->id, $icon, T_(ucfirst($icon)),'flip_state_' . $catalog->id); ?>
</span>
</td>