Commit 996d3cae authored by clint's avatar clint

Don't try to use PEAR class that won't be loaded.

parent 00b71a78
......@@ -32,7 +32,7 @@ $smarty->assign('id', $album->id);
$smarty->assign('artist', $artist);
$smarty->assign('album', $album);
$aAlbumTracks = $album->getTracks();
if (!PEAR::isError($aAlbumTracks )) {
if ($aAlbumTracks) {
$smarty->assign('tracks', $aAlbumTracks);
}
......
......@@ -42,7 +42,7 @@ class ArtistXML {
$artist = new Artist($artistName, $mbid);
if (PEAR::isError($artist)) {
if (!$artist) {
return(XML::error('failed', '7', 'Invalid resource specified'));
}
......@@ -66,7 +66,7 @@ class ArtistXML {
$artist = new Artist($artistName);
if (PEAR::isError($artist)) {
if (!$artist) {
return(XML::error('failed', '7', 'Invalid resource specified'));
}
......
......@@ -27,7 +27,7 @@ class UserXML {
public static function getInfo($username) {
$user = new User($username);
if (PEAR::isError($user)) {
if (!$user) {
return(XML::error('failed', '7', 'Invalid resource specified'));
}
......
......@@ -33,12 +33,12 @@ $smarty->assign('id', $artist->id);
$smarty->assign('bio_summary', $artist->bio_summary);
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud)) {
if ($aTagCloud) {
$smarty->assign('tagcloud', $aTagCloud);
}
$aArtistAlbums = $artist->getAlbums();
if (!PEAR::isError($aArtistAlbums)) {
if ($aArtistAlbums) {
$smarty->assign('albums', $aArtistAlbums);
}
......
......@@ -53,7 +53,7 @@ class Artist {
. 'mbid = ' . $adodb->qstr($mbid) . ' OR '
. 'name = ' . $adodb->qstr($name));
if(!$row) {
return(new PEAR_Error('No such artist: ' . $name));
throw new Exception('No such artist' . $name);
} else {
$this->name = $row['name'];
$this->mbid = $row['mbid'];
......
......@@ -194,10 +194,10 @@ class Group {
, (int)($grp)
, (int)($owner->uniqueid)
, time());
$res = $adodb->Execute($q);
if (PEAR::isError($res))
{
return $res;
try {
$res = $adodb->Execute($q);
} catch (exception $e) {
return null;
}
// Return the newly created group. Callers should check the return value.
......
......@@ -41,7 +41,7 @@ class Server {
* Retrieves a list of recent scrobbles
*
* @param int $number The number of scrobbles to return
* @return An array of scrobbles or a PEAR_Error in case of failure
* @return An array of scrobbles or null in case of failure
*/
static function getRecentScrobbles($number=10, $username=false) {
global $adodb;
......@@ -106,7 +106,7 @@ class Server {
}
}
catch (exception $e) {
return $false;
return null;
}
foreach($res as &$i) {
......@@ -150,7 +150,7 @@ class Server {
* Retrieves a list of popular artists
*
* @param int $number The number of artists to return
* @return An array of artists or a PEAR_Error in case of failure
* @return An array of artists or null in case of failure
*/
static function getTopArtists($number=20) {
global $adodb;
......@@ -160,7 +160,7 @@ class Server {
$data = $adodb->CacheGetAll(720, 'SELECT COUNT(artist) as c, artist FROM Scrobbles GROUP BY artist ORDER BY c DESC LIMIT 20');
}
catch (exception $e) {
return false;
return null;
}
foreach($data as &$i) {
......@@ -176,7 +176,7 @@ class Server {
* Retrieves a list of the currently playing tracks
*
* @param int $number The maximum number of tracks to return
* @return An array of now playing data or a PEAR_Error in case of failure
* @return An array of now playing data or null in case of failure
*/
static function getNowPlaying($number, $username=false) {
global $adodb;
......@@ -233,7 +233,7 @@ class Server {
}
}
catch (exception $e) {
return false;
return null;
}
foreach($data as &$i) {
......
......@@ -53,7 +53,7 @@ class TagCloud {
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$res = $adodb->CacheGetAll(7200,$query);
if (!$res) {
return(new PEAR_Error('ERROR ' . $query));
throw new Exception('ERROR ' . $query);
} else {
foreach($res as $count => &$i) {
$i['size'] = $sizes[(int) ($count/(count($res)/7))];
......
......@@ -55,7 +55,7 @@ class User {
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$row = $adodb->CacheGetRow(7200,$query);
if (!$row) {
return(new PEAR_Error('ERROR ' . $query));
throw new Exception('ERROR ' . $query);
}
}
......@@ -141,11 +141,10 @@ class User {
, time()
, $adodb->qstr($this->name));
$res = $adodb->Execute($q);
if(PEAR::isError($res)) {
try {
$res = $adodb->Execute($q);
} catch (exception $e) {
header('Content-Type: text/plain');
//($res);
exit;
}
......@@ -232,7 +231,7 @@ class User {
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$data = $adodb->CacheGetAll(7200,$query);
if (!$data) {
return(new PEAR_Error('ERROR ' . $query));
throw new Exception('ERROR ' . $query);
}
$maxcount = 0;
......
......@@ -37,29 +37,26 @@ if ($_REQUEST['group']=='new')
{
if ($_REQUEST['new'])
{
$result = Group::create(strtolower($_REQUEST['new']), $this_user);
if ($result instanceof Group)
{
header('Location: ' . $base_url . '/edit_group.php?group=' . $_REQUEST['new']);
exit();
}
elseif (PEAR::isError($result))
{
try {
$result = Group::create(strtolower($_REQUEST['new']), $this_user);
} catch (exception $e) {
$smarty->assign('error', 'Error!');
$smarty->assign('details', $result->getMessage());
$smarty->assign('details', $e->getMessage());
$smarty->display('error.tpl');
die();
}
if ($result instanceof Group) {
header('Location: ' . $base_url . '/edit_group.php?group=' . $_REQUEST['new']);
exit();
}
}
else
{
$smarty->assign('newform', true);
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud))
{
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$smarty->display('edit_group.tpl');
exit();
}
......@@ -163,11 +160,10 @@ if(isset($group->name))
# And display the page.
$smarty->assign('errors', $errors);
$smarty->assign('newform', false);
$aUserTagCloud = $group->tagCloudData();
if (!PEAR::isError ($aTagCloud))
{
try {
$aUserTagCloud = $group->tagCloudData();
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$smarty->display('edit_group.tpl');
}
......
......@@ -27,10 +27,10 @@ require_once('data/Server.php');
require_once('data/TagCloud.php');
// This should be contextual based on the mode= parameter?
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud)) {
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$aTopArtists = Server::getTopArtists(20);
if (!PEAR::isError ($aTopArtists)) {
......
......@@ -29,18 +29,17 @@ if (! $_GET['group'])
{
$smarty->assign('groups', Group::groupList());
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
)
));
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud))
{
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
)
));
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$smarty->display('group-list.tpl');
exit;
}
......@@ -68,10 +67,10 @@ if(isset($group->name)) {
$smarty->assign('homepage', $group->homepage);
$smarty->assign('avatar', $group->getAvatar());
$aUserTagCloud = $group->tagCloudData();
if (!PEAR::isError ($aUserTagCloud)) {
try {
$aUserTagCloud = $group->tagCloudData();
$smarty->assign('group_tagcloud',$aUserTagCloud);
}
} catch (exception $e) {}
$smarty->assign('userlist', $group->getUsers());
......@@ -83,13 +82,13 @@ if(isset($group->name)) {
$smarty->assign('link', $group->getURL());
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
)
));
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $_SERVER['REQUEST_URI']))
)
));
$smarty->assign('profile', true);
$smarty->display('group.tpl');
......
......@@ -23,10 +23,10 @@ require_once('database.php');
require_once('templating.php');
require_once('data/TagCloud.php');
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud)) {
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
if(isset($_GET['tag'])) {
$station = 'librefm://globaltags/' . $_GET['tag'];
......
......@@ -35,10 +35,10 @@ $artist = new Artist($track->artist_name);
$smarty->assign('artist', $artist);
// no idea how this would be track-relevant
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
if (!PEAR::isError ($aTagCloud)) {
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$res = $adodb->GetAll('SELECT * FROM Track WHERE lower(artist_name) = ' . $adodb->qstr(mb_strtolower($track->artist_name, 'UTF-8')) . ' AND lower(name) = ' . $adodb->qstr(mb_strtolower($track->name, 'UTF-8')));
......
......@@ -170,11 +170,10 @@ if(isset($this_user->name))
}
# And display the page.
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $this_user->name);
if (!PEAR::isError ($aTagCloud))
{
try {
$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $this_user->name);
$smarty->assign('tagcloud', $aTagCloud);
}
} catch (exception $e) {}
$smarty->assign('errors', $errors);
$smarty->display('user-edit.tpl');
}
......
......@@ -39,10 +39,10 @@ $user = new User($_GET['user']);
if(isset($user->name)) {
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
if (!PEAR::isError ($aUserTagCloud)) {
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
$smarty->assign('user_tagcloud',$aUserTagCloud);
}
} catch (exception $e) {}
$smarty->assign('isme', ($_SESSION['user']->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
......@@ -50,13 +50,13 @@ if(isset($user->name)) {
$smarty->assign('groups', Group::groupList($user));
$smarty->assign('extra_head_links', array(
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL('groups')))
)
));
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL('groups')))
)
));
$smarty->display('user-groups.tpl');
} else {
......
......@@ -66,28 +66,28 @@ foreach ($index as $subject => $data)
}
}
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
if (!PEAR::isError ($aUserTagCloud)) {
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
$smarty->assign('user_tagcloud',$aUserTagCloud);
}
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
$smarty->assign('profile', true);
$smarty->assign('items', $items);
$smarty->assign('extra_head_links', array(
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Journal)',
'href' => $user->journal_rss
),
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Journal)',
'href' => $user->journal_rss
),
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
$smarty->display('user-journal.tpl');
......@@ -37,43 +37,43 @@ $user = new User($_GET['user']);
if(isset($user->name)) {
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
$aUserScrobbles = $user->getScrobbles(10);
if (!PEAR::isError ($aUserScrobbles)) {
try {
$aUserScrobbles = $user->getScrobbles(10);
$smarty->assign('scrobbles', $aUserScrobbles);
}
} catch (exception $e) {}
try {
$aUserNowPlaying = $user->getNowPlaying(10);
if (!PEAR::isError ($aUserNowPlaying)) {
$smarty->assign('nowplaying', $aUserNowPlaying);
}
} catch (exception $e) {}
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
if (!PEAR::isError ($aUserTagCloud)) {
$smarty->assign('user_tagcloud',$aUserTagCloud);
}
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('sidebar', true);
$smarty->assign('sidebartemplate', 'profile-sidebar.tpl');
$smarty->assign('extra_head_links', array(
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Recent plays)',
'href' => $base_url.'/rdf.php?fmt=rss&page='.urlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
),
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Journal)',
'href' => $user->journal_rss
),
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Recent plays)',
'href' => $base_url.'/rdf.php?fmt=rss&page='.urlencode(str_replace($base_url, '', $user->getURL('recent-tracks')))
),
array(
'rel'=>'alternate',
'type' => 'application/rss+xml' ,
'title' => 'RSS 1.0 Feed (Journal)',
'href' => $user->journal_rss
),
array(
'rel' => 'meta',
'type' => 'application/rdf+xml' ,
'title' => 'FOAF',
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', $user->getURL()))
)
));
$smarty->display('user-profile.tpl');
} else {
......
......@@ -42,14 +42,14 @@ elseif (!$scrobbleCount)
if(isset($user->name)) {
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
try {
$aUserScrobbles = $user->getScrobbles( $scrobbleCount );
if (!PEAR::isError ($aUserScrobbles)) {
$smarty->assign('scrobbles', $aUserScrobbles);
}
} catch (exception $e) {}
try {
$aUserTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable('user'), 'artist', 40, $user->name);
if (!PEAR::isError ($aUserTagCloud)) {
$smarty->assign('user_tagcloud',$aUserTagCloud);
}
} catch (exception $e) {}
$smarty->assign('isme', ($this_user->name == $user->name));
$smarty->assign('me', $user);
$smarty->assign('profile', true);
......
......@@ -42,15 +42,15 @@ if(isset($user->name)) {
# }
$smarty->assign('stat_barwidth', 320);
try {
$aUserPlayStat = Statistic::GeneratePlayStats('Scrobbles', 'artist', 40, $user->name, 300);
if (!PEAR::isError ($aUserPlayStat)) {
$smarty->assign('user_playstats',$aUserPlayStat);
}
} catch (exception $e) {}
try {
$aUserDayStat = Statistic::generatePlayByDays('Scrobbles', 40, $user->name, 300);
if (!PEAR::isError ($aUserDayStat)) {
$smarty->assign('user_daystats',$aUserDayStat);
}
} catch (exception $e) {}
$smarty->assign('toptracks', $user->getTopTracks(40));
......
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