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

[BUGFIX] Fixe some code style issues

This commit is contained in:
René Bigler 2015-10-29 23:09:52 +01:00
parent 4a52b1e3c4
commit 04d8ce9c11
12 changed files with 95 additions and 48 deletions

View file

@ -32,7 +32,7 @@ abstract class DatabaseObject
{ {
protected $id; protected $id;
//private $originalData; //private $originalData;
/** /**
* *
* @var array Stores relation between SQL field name and class name so we * @var array Stores relation between SQL field name and class name so we

View file

@ -54,12 +54,11 @@ class Core
$possiblePaths = self::getNamespacedPaths($class); $possiblePaths = self::getNamespacedPaths($class);
} }
foreach($possiblePaths as $path) { foreach ($possiblePaths as $path) {
if(is_file($path) && Core::is_readable($path)) { if (is_file($path) && Core::is_readable($path)) {
require_once($path); require_once($path);
self::executeAutoCall($class); self::executeAutoCall($class);
} } else {
else {
debug_event('autoload', "'$class' not found!", 1); debug_event('autoload', "'$class' not found!", 1);
} }
} }
@ -69,7 +68,8 @@ class Core
* Execute _auto_init if availlable * Execute _auto_init if availlable
* @param string $class * @param string $class
*/ */
private static function executeAutoCall($class) { private static function executeAutoCall($class)
{
$autocall = array($class, '_auto_init'); $autocall = array($class, '_auto_init');
if (is_callable($autocall)) { if (is_callable($autocall)) {
call_user_func($autocall); call_user_func($autocall);
@ -83,7 +83,8 @@ class Core
* @param array $add * @param array $add
* @return array * @return array
*/ */
private static function insertInArray(array $array, $position, array $add) { private static function insertInArray(array $array, $position, array $add)
{
return array_slice($array, 0, $position, true) + return array_slice($array, 0, $position, true) +
$add + $add +
array_slice($array, $position, null, true); array_slice($array, $position, null, true);
@ -94,7 +95,8 @@ class Core
* @param string $class * @param string $class
* @return string * @return string
*/ */
private static function getNamespacedPaths($class) { private static function getNamespacedPaths($class)
{
$possiblePaths = array(); $possiblePaths = array();
$namespaceParts = explode('\\', $class); $namespaceParts = explode('\\', $class);
$possiblePaths[] = AmpConfig::get('prefix') . '/modules/' . implode('/', $namespaceParts) . '.php'; $possiblePaths[] = AmpConfig::get('prefix') . '/modules/' . implode('/', $namespaceParts) . '.php';
@ -111,7 +113,8 @@ class Core
* @param string $class * @param string $class
* @return string * @return string
*/ */
private static function getNonNamespacedPaths($class) { private static function getNonNamespacedPaths($class)
{
$possiblePaths = array(); $possiblePaths = array();
$possiblePaths[] = AmpConfig::get('prefix') . '/lib/class/' . $possiblePaths[] = AmpConfig::get('prefix') . '/lib/class/' .
strtolower($class) . '.class.php'; strtolower($class) . '.class.php';

View file

@ -188,7 +188,7 @@ class Dba
return $result; return $result;
} }
public static function fetch_object($resource, $class = 'stdClass', $finish = true) public static function fetch_object($resource, $class = 'stdClass', $finish = true)
{ {
if (!$resource) { if (!$resource) {
return array(); return array();

View file

@ -501,3 +501,4 @@ class Preference extends database_object
$_SESSION['userdata']['uid'] = $user_id; $_SESSION['userdata']['uid'] = $user_id;
} // init } // init
} // end Preference class } // end Preference class

View file

@ -290,7 +290,7 @@ class Song extends database_object implements media, library_item
/** /**
* Aliases used in insert function * Aliases used in insert function
*/ */
const aliases = array( public static $aliases = array(
'mb_trackid','mbid','mb_albumid','mb_albumid_group','mb_artistid','mb_albumartistid','genre','publisher' 'mb_trackid','mbid','mb_albumid','mb_albumid_group','mb_artistid','mb_albumartistid','genre','publisher'
); );
@ -870,7 +870,7 @@ class Song extends database_object implements media, library_item
} else { } else {
$newSongData = $new_song->$key; $newSongData = $new_song->$key;
} }
// If it's a stringie thing // If it's a stringie thing
if (in_array($key, $string_array)) { if (in_array($key, $string_array)) {
$songData = self::clean_string_field_value($songData); $songData = self::clean_string_field_value($songData);
@ -898,12 +898,12 @@ class Song extends database_object implements media, library_item
private static function clean_string_field_value($value) private static function clean_string_field_value($value)
{ {
$value = trim(stripslashes(preg_replace('/\s+/', ' ', $value))); $value = trim(stripslashes(preg_replace('/\s+/', ' ', $value)));
// Strings containing only UTF-8 BOM = empty string // Strings containing only UTF-8 BOM = empty string
if (strlen($value) == 2 && (ord($value[0]) == 0xFF || ord($value[0]) == 0xFE)) { if (strlen($value) == 2 && (ord($value[0]) == 0xFF || ord($value[0]) == 0xFE)) {
$value = ""; $value = "";
} }
return $value; return $value;
} }
@ -2026,3 +2026,4 @@ class Song extends database_object implements media, library_item
return $deleted; return $deleted;
} }
} // end of song class } // end of song class

View file

@ -518,9 +518,9 @@ class Update
$version[] = array('version' => '370039','description' => $update_string); $version[] = array('version' => '370039','description' => $update_string);
$update_string = "- Add basic metadata tables<br />"; $update_string = "- Add basic metadata tables<br />";
$version[] = array('version' => '370040', 'description' => $update_string); $version[] = array('version' => '370040', 'description' => $update_string);
return $version; return $version;
} }
/** /**

View file

@ -417,8 +417,8 @@ class vainfo
$info['art'] = $info['art'] ?: trim($tags['art']); $info['art'] = $info['art'] ?: trim($tags['art']);
// Add rest of the tags without typecast to the array // Add rest of the tags without typecast to the array
foreach($tags as $tag => $value) { foreach ($tags as $tag => $value) {
if(!isset($info[$tag])) { if (!isset($info[$tag])) {
$info[$tag] = trim($value); $info[$tag] = trim($value);
} }
} }
@ -1022,7 +1022,7 @@ class vainfo
* 3. title.[date].Season #[#] Episode #[#].ext * 3. title.[date].Season #[#] Episode #[#].ext
* 4. title.[date].###.ext (maximum of 9 seasons) * 4. title.[date].###.ext (maximum of 9 seasons)
* parse directory path for name, season and episode numbers * parse directory path for name, season and episode numbers
* /TV shows/show name [(year)]/[season ]##/##.Episode.Title.ext * /TV shows/show name [(year)]/[season ]##/##.Episode.Title.ext
* parse movie names: * parse movie names:
* title.[date].ext * title.[date].ext
* /movie title [(date)]/title.ext * /movie title [(date)]/title.ext

View file

@ -410,3 +410,4 @@ function create_preference_input($name,$value)
} }
} // create_preference_input } // create_preference_input

View file

@ -869,3 +869,4 @@ class Catalog_local extends Catalog
} }
} }
} // end of local catalog class } // end of local catalog class

View file

@ -87,7 +87,7 @@ switch ($_REQUEST['action']) {
case 'edit_object': case 'edit_object':
// Scrub the data, walk recursive through array // Scrub the data, walk recursive through array
$entities = function(&$data) use (&$entities) { $entities = function(&$data) use (&$entities) {
foreach($data as $key => $value) { foreach ($data as $key => $value) {
$data[$key] = is_array($value) ? $entities($value) : unhtmlentities(scrub_in($value)); $data[$key] = is_array($value) ? $entities($value) : unhtmlentities(scrub_in($value));
} }
return $data; return $data;

View file

@ -24,7 +24,8 @@
if ($libitem->enabled || Access::check('interface','50')) { if ($libitem->enabled || Access::check('interface','50')) {
?> ?>
<td class="cel_play"> <td class="cel_play">
<span class="cel_play_content"><?php echo '<b>'.$playlist_track.'</b>'; ?></span> <span class="cel_play_content"><?php echo '<b>'.$playlist_track.'</b>';
?></span>
<div class="cel_play_hover"> <div class="cel_play_hover">
<?php if (AmpConfig::get('directplay')) { <?php if (AmpConfig::get('directplay')) {
?> ?>
@ -34,31 +35,42 @@ if ($libitem->enabled || Access::check('interface','50')) {
?> ?>
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $libitem->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $libitem->id); <?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $libitem->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $libitem->id);
?> ?>
<?php <?php
}
?>
<?php
} }
?> ?>
<?php
} ?>
</div> </div>
</td> </td>
<td class="cel_song"><?php echo $libitem->f_link; ?></td> <td class="cel_song"><?php echo $libitem->f_link;
?></td>
<td class="cel_add"> <td class="cel_add">
<span class="cel_item_add"> <span class="cel_item_add">
<?php echo Ajax::button('?action=basket&type=song&id=' . $libitem->id,'add', T_('Add to temporary playlist'),'playlist_add_' . $libitem->id); ?> <?php echo Ajax::button('?action=basket&type=song&id=' . $libitem->id,'add', T_('Add to temporary playlist'),'playlist_add_' . $libitem->id);
?>
<?php if (Access::check('interface', '25')) { <?php if (Access::check('interface', '25')) {
?> ?>
<a id="<?php echo 'add_playlist_'.$libitem->id ?>" onclick="showPlaylistDialog(event, 'song', '<?php echo $libitem->id ?>')"> <a id="<?php echo 'add_playlist_'.$libitem->id ?>" onclick="showPlaylistDialog(event, 'song', '<?php echo $libitem->id ?>')">
<?php echo UI::get_icon('playlist_add', T_('Add to existing playlist')); <?php echo UI::get_icon('playlist_add', T_('Add to existing playlist'));
?> ?>
</a> </a>
<?php <?php
} ?>
}
?>
</span> </span>
</td> </td>
<td class="cel_artist"><?php echo $libitem->f_artist_link; ?></td> <td class="cel_artist"><?php echo $libitem->f_artist_link;
<td class="cel_album"><?php echo $libitem->f_album_link; ?></td> ?></td>
<td class="cel_tags"><?php echo $libitem->f_tags; ?></td> <td class="cel_album"><?php echo $libitem->f_album_link;
<td class="cel_time"><?php echo $libitem->f_time; ?></td> ?></td>
<td class="cel_tags"><?php echo $libitem->f_tags;
?></td>
<td class="cel_time"><?php echo $libitem->f_time;
?></td>
<?php if (User::is_registered()) { <?php if (User::is_registered()) {
?> ?>
<?php if (AmpConfig::get('ratings')) { <?php if (AmpConfig::get('ratings')) {
@ -66,7 +78,8 @@ if ($libitem->enabled || Access::check('interface','50')) {
<td class="cel_rating" id="rating_<?php echo $libitem->id; <td class="cel_rating" id="rating_<?php echo $libitem->id;
?>_song"><?php Rating::show($libitem->id,'song'); ?>_song"><?php Rating::show($libitem->id,'song');
?></td> ?></td>
<?php <?php
} }
?> ?>
<?php if (AmpConfig::get('userflags')) { <?php if (AmpConfig::get('userflags')) {
@ -74,11 +87,14 @@ if ($libitem->enabled || Access::check('interface','50')) {
<td class="cel_userflag" id="userflag_<?php echo $libitem->id; <td class="cel_userflag" id="userflag_<?php echo $libitem->id;
?>_song"><?php Userflag::show($libitem->id,'song'); ?>_song"><?php Userflag::show($libitem->id,'song');
?></td> ?></td>
<?php <?php
}
?>
<?php
} }
?> ?>
<?php
} ?>
<td class="cel_action"> <td class="cel_action">
<?php if (AmpConfig::get('download')) { <?php if (AmpConfig::get('download')) {
?> ?>
@ -88,25 +104,32 @@ if ($libitem->enabled || Access::check('interface','50')) {
<?php echo UI::get_icon('download', T_('Download')); <?php echo UI::get_icon('download', T_('Download'));
?> ?>
</a> </a>
<?php <?php
} ?>
}
?>
<?php if (Access::check('interface', '25')) { <?php if (Access::check('interface', '25')) {
?> ?>
<?php if (AmpConfig::get('share')) { <?php if (AmpConfig::get('share')) {
?> ?>
<?php Share::display_ui('song', $libitem->id, false); <?php Share::display_ui('song', $libitem->id, false);
?> ?>
<?php <?php
}
?>
<?php
} }
?> ?>
<?php
} ?>
<?php if (get_class($playlist) == "Playlist" && $playlist->has_access()) { <?php if (get_class($playlist) == "Playlist" && $playlist->has_access()) {
?> ?>
<?php echo Ajax::button('?page=playlist&action=delete_track&playlist_id=' . $playlist->id . '&track_id=' . $object['track_id'],'delete', T_('Delete'),'track_del_' . $object['track_id']); <?php echo Ajax::button('?page=playlist&action=delete_track&playlist_id=' . $playlist->id . '&track_id=' . $object['track_id'],'delete', T_('Delete'),'track_del_' . $object['track_id']);
?> ?>
<?php <?php
} ?>
}
?>
</td> </td>
<?php if (Access::check('interface', '50') && get_class($playlist) == "Playlist") { <?php if (Access::check('interface', '50') && get_class($playlist) == "Playlist") {
?> ?>
@ -114,6 +137,7 @@ if ($libitem->enabled || Access::check('interface','50')) {
<?php echo UI::get_icon('drag', T_('Reorder')); <?php echo UI::get_icon('drag', T_('Reorder'));
?> ?>
</td> </td>
<?php <?php
} }
} ?> } ?>

View file

@ -43,6 +43,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
</div> </div>
</dd> </dd>
<?php <?php
} }
?> ?>
@ -61,9 +62,11 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
</div> </div>
</dd> </dd>
<?php <?php
} }
?> ?>
<?php <?php
} ?> } ?>
<?php if (AmpConfig::get('waveform')) { <?php if (AmpConfig::get('waveform')) {
?> ?>
@ -82,6 +85,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
</div> </div>
</dd> </dd>
<?php <?php
} ?> } ?>
<?php $rowparity = UI::flip_class(); ?> <?php $rowparity = UI::flip_class(); ?>
<dt class="<?php echo $rowparity; ?>"><?php echo T_('Action'); ?></dt> <dt class="<?php echo $rowparity; ?>"><?php echo T_('Action'); ?></dt>
@ -95,6 +99,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $song->id); <?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&append=true','play_add', T_('Play last'),'addplay_song_' . $song->id);
?> ?>
<?php <?php
} }
?> ?>
<?php if (Stream_Playlist::check_autoplay_next()) { <?php if (Stream_Playlist::check_autoplay_next()) {
@ -102,11 +107,13 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
<?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&playnext=true','play_next', T_('Play next'),'nextplay_song_' . $song->id); <?php echo Ajax::button('?page=stream&action=directplay&object_type=song&object_id=' . $song->id . '&playnext=true','play_next', T_('Play next'),'nextplay_song_' . $song->id);
?> ?>
<?php <?php
} }
?> ?>
<?php echo $song->show_custom_play_actions(); <?php echo $song->show_custom_play_actions();
?> ?>
<?php <?php
} ?> } ?>
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add', T_('Add to temporary playlist'),'add_song_' . $song->id); ?> <?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add', T_('Add to temporary playlist'),'add_song_' . $song->id); ?>
<?php if (Access::check('interface','25')) { <?php if (Access::check('interface','25')) {
@ -120,6 +127,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?> ?>
</a> </a>
<?php <?php
} }
?> ?>
<?php if (AmpConfig::get('share')) { <?php if (AmpConfig::get('share')) {
@ -127,9 +135,11 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
<?php Share::display_ui('song', $song->id, false); <?php Share::display_ui('song', $song->id, false);
?> ?>
<?php <?php
} }
?> ?>
<?php <?php
} ?> } ?>
<?php if (Access::check_function('download')) { <?php if (Access::check_function('download')) {
?> ?>
@ -141,6 +151,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?>"><?php echo UI::get_icon('download', T_('Download')); ?>"><?php echo UI::get_icon('download', T_('Download'));
?></a> ?></a>
<?php <?php
} ?> } ?>
<?php if (Access::check('interface','50')) { <?php if (Access::check('interface','50')) {
?> ?>
@ -151,9 +162,11 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?>"><?php echo UI::get_icon('statistics', T_('Graphs')); ?>"><?php echo UI::get_icon('statistics', T_('Graphs'));
?></a> ?></a>
<?php <?php
} }
?> ?>
<?php <?php
} ?> } ?>
<?php if (Access::check('interface','50') || ($libitem->user_upload == $GLOBALS['user']->id && AmpConfig::get('upload_allow_edit'))) { <?php if (Access::check('interface','50') || ($libitem->user_upload == $GLOBALS['user']->id && AmpConfig::get('upload_allow_edit'))) {
?> ?>
@ -162,6 +175,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?> ?>
</a> </a>
<?php <?php
} ?> } ?>
<?php if (Access::check('interface','75') || ($song->user_upload == $GLOBALS['user']->id && AmpConfig::get('upload_allow_edit'))) { <?php if (Access::check('interface','75') || ($song->user_upload == $GLOBALS['user']->id && AmpConfig::get('upload_allow_edit'))) {
?> ?>
@ -171,6 +185,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?> ?>
</span> </span>
<?php <?php
} ?> } ?>
<?php if (Catalog::can_remove($song)) { <?php if (Catalog::can_remove($song)) {
?> ?>
@ -181,6 +196,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
?> ?>
</a> </a>
<?php <?php
} ?> } ?>
</dd> </dd>
<?php <?php
@ -241,13 +257,13 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
foreach ($songprops as $key => $value) { foreach ($songprops as $key => $value) {
if (trim($value)) { if (trim($value)) {
$rowparity = UI::flip_class(); $rowparity = UI::flip_class();
echo "<dt class=\"".$rowparity."\">" . T_($key) . "</dt><dd class=\"".$rowparity."\">" . $value . "</dd>"; echo "<dt class=\"".$rowparity."\">" . T_($key) . "</dt><dd class=\"".$rowparity."\">" . $value . "</dd>";
} }
} }
if(Song::isCustomMetadataEnabled()) { if (Song::isCustomMetadataEnabled()) {
foreach($song->getMetadata() as $metadata) { foreach ($song->getMetadata() as $metadata) {
$rowparity = UI::flip_class(); $rowparity = UI::flip_class();
echo '<dt class="' . $rowparity . '">' . $metadata->getField()->getName() . '</dt>'; echo '<dt class="' . $rowparity . '">' . $metadata->getField()->getName() . '</dt>';
echo '<dd class="' . $rowparity . '">' . $metadata->getData() . '</dd>'; echo '<dd class="' . $rowparity . '">' . $metadata->getData() . '</dd>';