Revision [16591]

This is an old revision of LastFMAction made by CimNine on 2007-05-17 17:25:47.

 

LastFMAction LastFM Action


See also:
Documentation: LastFMActionInfo.
This is the development page for the LastFMAction LastFM action.
 

With this action you can embed the widgeds of last.fm .

WARNING: Playlist-Feature not implemented yet!!!
WARNING2: May contain one, two bugs, but 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.

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"] }}
 {{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.'&amp;user='.$user.'&amp;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="false";
    }
   
    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&amp;radioURL=user%2F'
.$user.'%2Fneighbours&amp;title='.$user.'%E2%80%99s+Neighbourhood&amp;theme='.$style.'&amp;autostart='.$autostart.'"
        allowScriptAccess="sameDomain">
    </embed>
</object>'
;
} elseif ($src=="plist")
{
    print '<strong>Not implemented yet.</strong>';
    return;
} 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&amp;variable='
.$user.'&amp;file='.$type.'&amp;bgColor='.$style.'&amp;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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki