This is the development page for the
LastFM action.
With this action you can embed the widgeds of last.fm .
Changelog
=
v1.0=
=
v1.1=
- fix: autostart from radio doesn't work correctly
- new: playlist widget implemented
=
v1.1.1=
- fix: playlist loaded the wrong widget
- fix: playlist ignored the theme settings
WARNING: May contain one, two bugs, but it works all in all.
actions/lastfm.php
<?php
/*
LastFM plugin created by CimNine.
Licensed under Terms of GPLv2 or newer.
(c) by CimNine.
All rights reserved.
Based on YouTube plugin created by Grant Young.
USE:
{{lastfm src="chart" user="#####" type="recently|otracks|oartists|wtracks|wartists" [float="left|right" style="red|blue|black|grey" width="184" height="140"] }}
{{lastfm src="radio" user="#####" [autostart="false|true" float="left|center|right" style="red|blue|black|grey" size="regular|mini" width="148" height="140"] }}
Provide size OR width&height!
{{lastfm src="plist" user="#####" [float="left|right" style="red|blue|black|grey" size="regular|mini" width="148" height="140"] }}
{{lastfm src="quilt" user="#####" type="album|artist" [float="left|right" style="red|blue|black|grey" size="small|medium|large" orient="hori|vert" width="148" height="140"]}}
Provide size&orient (orientation) OR width&height!
*/
//Check values
if (!
($src) || !
($user)) {
print "<strong>You must provide the kind of LastFM (chart,radio,playlist,quilt) and a username.</strong>";
return;
} else {
if ($style==
"black")
{
$style =
"black";
$bgcolor =
"000000";
} elseif ($style==
"red")
{
$style =
"red";
$bgcolor =
"d01f3c";
} elseif ($style==
"blue")
{
$style =
"blue";
$bgcolor =
"000000";
} else
{
$style =
"grey";
$bgcolor =
"999999";
}
if (!
$float ||
($float !=
"right" &&
$float !=
"left"))
{
$float =
"left";
}
if ($src==
"chart" && !
$type)
{
print "<strong>You must provide a type of playlist (recently,otracks (overall tracks),".
"oartists (overall artists),wtracks (weekly tracks), wartists (weekly artists))</strong>";
return;
}
if ($src==
"radio" && !
$size)
{
$size =
"regular";
}
if ($src==
"quilt")
{
if (!
$type)
{
print "<strong>You must provide a type of quilt (album,artist)</strong>";
return;
}
if (!
$size)
{
$size=
"small";
}
if (!
$orient)
{
$orient=
"vert";
}
}
}
//gen HTML
if ($src==
"chart")
{
//fill size
if (!
$width)
{
$width=
"184";
}
if (!
$height)
{
$height=
"140";
}
//fill kind
//recently|otracks|oartists|wtracks|wartists
if ($type ==
"otracks")
{
$type=
"toptracks";
} elseif ($type ==
"oartists")
{
$type=
"topartists";
} elseif ($type ==
"wtracks")
{
$type=
"weeklytrackchart";
} elseif ($type ==
"wartists")
{
$type=
"weeklyartistchart";
} else
{
$type=
"recenttracks";
}
print '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="184" height="140"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab%23version=7,0,0,0" style="float:'.
$float.
';">
<param name="bgcolor" value="'.
$bgcolor.
'" />
<param name="movie" value="http://panther1.last.fm/widgets/chart/2.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed
src="http://panther1.last.fm/widgets/chart/2.swf" type="application/x-shockwave-flash" name="widgetPlayer"
bgcolor="'.
$bgcolor.
'" width="'.
$width.
'" height="'.
$height.
'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="type='.
$type.
'&user='.
$user.
'&theme='.
$style.
'"
allowScriptAccess="sameDomain">
</embed>
</object>';
} elseif ($src==
"radio")
{
//fill size
if ($size)
{
if ($size==
"mini")
{
$height=
"140";
$width=
"110";
} else
{
$height=
"140";
$width=
"184";
}
} else
{
if (!
$width)
{
$width=
"140";
}
if (!
$height)
{
$height=
"184";
}
}
//correct autostart
if ($autostart !=
"true")
{
$autostart=
"";
}
print '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.
$width.
'" height="'.
$height.
'"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab%23version=7,0,0,0" style="float:'.
$float.
';">
<param name="bgcolor" value="'.
$bgcolor.
'" />
<param name="movie" value="http://panther1.last.fm/widgets/radio/3.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed
src="http://panther1.last.fm/widgets/radio/3.swf" type="application/x-shockwave-flash" name="widgetPlayer"
bgcolor="'.
$bgcolor.
'" width="'.
$width.
'" height="'.
$height.
'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="lfmMode=radio&radioURL=user%2F'.
$user.
'%2Fneighbours&title='.
$user.
'%E2%80%99s+Neighbourhood&theme='.
$style.
'&autostart='.
$autostart.
'"
allowScriptAccess="sameDomain">
</embed>
</object>';
} elseif ($src==
"plist")
{
//fill size
if ($size)
{
if ($size==
"mini")
{
$width=
"110";
} else
{
$width=
"184";
}
$height=
"248";
} else
{
if (!
$width)
{
$width=
"140";
}
if (!
$height)
{
$height=
"184";
}
}
//correct autostart
if ($autostart !=
"true")
{
$autostart=
"";
}
print '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.
$width.
'" height="'.
$height.
'"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab%23version=7,0,0,0" style="float:'.
$float.
';">
<param name="bgcolor" value="'.
$bgcolor.
'" />
<param name="movie" value="http://panther1.last.fm/widgets/playlist/3.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed
src="http://panther1.last.fm/widgets/radio/3.swf" type="application/x-shockwave-flash" name="widgetPlayer"
bgcolor="'.
$bgcolor.
'" width="'.
$width.
'" height="'.
$height.
'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="lfmMode=playlist&resourceType=37&resourceID=570204&radioURL=user%2F'.
$user.
'%2Fplaylist&username='.
$user.
'&title='.
$user.
'%E2%80%99s+Playlist&theme='.
$style.
'&autostart='.
$autostart.
'"
allowScriptAccess="sameDomain">
</embed>
</object>';
} elseif ($src==
"quilt")
{
//fill size
if ($size)
{
if ($orient=
"vert")
{
if ($size==
"small")
{
$height=
"370";
} elseif ($size==
"large")
{
$height=
"640";
} else
{
$height=
"505";
}
$width=
"234";
} else {
if ($size==
"small")
{
$height=
"235";
} elseif ($size==
"large")
{
$height=
"325";
} else
{
$height=
"280";
}
$width=
"510";
}
} else
{
if (!
$width)
{
$width=
"234";
}
if (!
$height)
{
$height=
"505";
}
}
//fill kind
if ($type==
"artist")
{
$type=
"topartists";
} else
{
$type=
"topalbums";
}
print '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.
$width.
'" height="'.
$height.
'"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab%23version=7,0,0,0" style="float:'.
$float.
';">
<param name="bgcolor" value="'.
$bgcolor.
'" />
<param name="movie" value="http://panther1.last.fm/widgets/quilt/6.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed
src="http://panther1.last.fm/widgets/quilt/6.swf" type="application/x-shockwave-flash" name="widgetPlayer"
bgcolor="'.
$bgcolor.
'" width="'.
$width.
'" height="'.
$height.
'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="type=user&variable='.
$user.
'&file='.
$type.
'&bgColor='.
$style.
'&theme='.
$style.
'"
allowScriptAccess="sameDomain">
</embed>
</object>';
} else
{
print "<strong>Can't identify the kind of widget. Please only use chart,radio,plist (playlist),quilt.</strong>";
return;
}
?>
CategoryDevelopmentActions -
CategoryUserContributions