We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit cf803867 authored by P. J. McDermott's avatar P. J. McDermott

Finish code cleanup under nixtape/api/.

parent c4076546
......@@ -34,7 +34,9 @@ class API {
* @param array $params parameters
* @param array $required required params
*/
if (empty($required) || empty($params)) return false;
if (empty($required) || empty($params)) {
return false;
}
if (count(array_diff_key($params, $required) > 0)) {
$this->giveError(6);
}
......@@ -46,6 +48,6 @@ class API {
*/
global $xml;
return (XML::error('failed', $error, $this->api_error[$error]));
return XML::error('failed', $error, $this->api_error[$error]);
}
}
......@@ -32,7 +32,7 @@ class ArtistXML {
* @param string $lang A 2 character ISO 639 alpha-2 code indicating the language to return the information in
* @return A SimpleXMLElement containing the artist's information
*/
public static function getInfo($artistName, $api_key=false, $mbid=false, $lang='en') {
public static function getInfo($artistName, $api_key = false, $mbid = false, $lang = 'en') {
// We assume $api_key is valid and set at this point
if (!isset($artistName) && !isset($mbid)) {
......
......@@ -74,8 +74,7 @@ class UserXML {
try {
$user = new User($username);
$res = $user->getTopTracks(20, $timestamp);
}
catch (Exception $e) {
} catch (Exception $e) {
$err = 1;
}
......@@ -161,12 +160,12 @@ class UserXML {
$album = $track->addChild('album', repamp($row['album']));
$album->addAttribute('mbid', $row['album_mbid']);
$track->addChild('url', Server::getTrackURL($row['artist'], $row['album'], $row['track']));
$date = $track->addChild('date', gmdate("d M Y H:i", $row['time']) . " GMT");
$date = $track->addChild('date', gmdate('d M Y H:i', $row['time']) . ' GMT');
$date->addAttribute('uts', $row['time']);
$track->addChild('streamable', null);
}
public static function getTopTags($u, $limit=10) {
public static function getTopTags($u, $limit = 10) {
global $base_url;
try {
......@@ -190,7 +189,7 @@ class UserXML {
return $xml;
}
public static function getLovedTracks($u, $limit=50) {
public static function getLovedTracks($u, $limit = 50) {
try {
$user = new User($u);
......@@ -211,7 +210,7 @@ class UserXML {
return $xml;
}
public static function getBannedTracks($u, $limit=50) {
public static function getBannedTracks($u, $limit = 50) {
try {
$user = new User($u);
......@@ -237,7 +236,7 @@ class UserXML {
$track_node->addChild('name', repamp($track->name));
$track_node->addChild('mbid', $track->mbid);
$track_node->addChild('url', $track->getURL());
$date = $track_node->addChild('date', gmdate("d M Y H:i", $row['time']) . " GMT");
$date = $track_node->addChild('date', gmdate('d M Y H:i', $row['time']) . ' GMT');
$date->addAttribute('uts', $row['time']);
try {
$artist = new Artist($row['artist']);
......@@ -248,7 +247,7 @@ class UserXML {
} catch (Exception $e) {}
}
public static function getNeighbours($u, $limit=50) {
public static function getNeighbours($u, $limit = 50) {
try {
$user = new User($u);
$res = $user->getNeighbours($limit);
......@@ -266,7 +265,7 @@ class UserXML {
$highest_match = $res[0]['shared_artists'];
foreach($res as $row) {
foreach ($res as $row) {
$neighbour = $row['user'];
$user_node = $root->addChild('user', null);
$user_node->addChild('name', repamp($neighbour->name));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment