-
Notifications
You must be signed in to change notification settings - Fork 3
/
grooveshark.php
1425 lines (1368 loc) · 76.1 KB
/
grooveshark.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: Grooveshark for Wordpress
Plugin URI: http://www.grooveshark.com/wordpress
Description: Search for <a href="http://www.grooveshark.com">Grooveshark</a> songs and add links to a song or song widgets to your blog posts.
Author: Roberto Sanchez and Vishal Agarwala
Version: 1.4.1
Author URI: http://www.grooveshark.com
*/
/*
Copyright 2010 Escape Media Group (email: [email protected])
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'GSAPI.php';
function gs_json_encode($content) {
if (!extension_loaded('json')) {
if (!class_exists('GS_Services_JSON')) {
require_once('GSJSON.php');
}
$json = new GS_Services_JSON;
return $json->encode($content);
} else {
return json_encode($content);
}
}
// Checks to see if the options for this plugin exists. If not, the options are added
if (get_option('gs_options') == FALSE) {
add_option('gs_options',array(
'token' => '', // auth token used for API login
'userID' => 0, // GS userID used for favorites/playlists
'username' => '', // GS username used for API login
'numberOfSongs' => 30, // restrict results returned for search
'displayPhrase' => 'Grooveshark Song Link', // Display phrase precedes song/playlist name as a cue to readers
'widgetWidth' => 250, // width of the GS widget used to embed songs in posts
'widgetHeight' => 176, // height of the GS widget
'colorScheme' => 'default', // color scheme used for the GS widget
'sidebarPlaylists' => array('id' => '', 'embed' => ''), // Save the playlist id and embed code for the sidebar playlist
'userPlaylists' => array(),
'dashboardPlaylists' => array(), // Save playlists to display on the dashboard
'musicComments' => 0, // Toggle the option to enable music comments
'commentDisplayOption' => 'widget', // Display music in comments as widget/link
'commentWidgetWidth' => 200, // Width of music widgets in comments
'commentWidgetHeight' => 0, // Height of music widgets in comments (0 for autoadjust)
'commentDisplayPhrase' => 'Grooveshark Song Link', // Display phrase for music comment links
'commentPlaylistName' => 'Blog Playlist', // Names of playlists saved using music comments
'commentColorScheme' => 0, // Color scheme of music comment playlists
'commentSongLimit' => 1, // Limit the number of songs that can be added to comment widgets (0 for no limit, also limit only applies to widget)
'javascriptPos' => 'head',
'gsRssOption' => 0,
'sidebarRss' => array()));
}
// Sets up a sessionID for use with the rest of the script when making API calls
if (isset($_POST['sessionID']) and $_POST['sessionID'] != 0) {
GSAPI::getInstance($_POST['sessionID']);
} else {
GSAPI::getInstance();
}
$gs_options = get_option('gs_options');
if (empty($gs_options['javascriptPos'])) {
// This is an update, reset a few essential options to ensure a smooth transition
$gs_options['commentDisplayOption'] = 'widget';
$gs_options['includePlaylist'] = 1;
$gs_options['displayPhrase'] = 'Grooveshark Song Link';
$gs_options['javascriptPos'] = 'head';
$gs_options['gsRssOption'] = 0;
update_option('gs_options', $gs_options);
}
add_action('admin_menu','addGroovesharkBox');
function addGroovesharkBox()
{
// Adds the GS "Add Music" box to the post edit and page edit pages
if( function_exists('add_meta_box')) {
add_meta_box('groovesharkdiv','Add Music','groovesharkBox','post','advanced','high');
add_meta_box('groovesharkdiv','Add Music','groovesharkBox','page','advanced','high');
} else {
add_action('dbx_post_advanced','oldGroovesharkBox');
add_action('dbx_page_advanced','oldGroovesharkBox');
}
}
// The code for the "Add Music" box below the content editing text area.
function groovesharkBox()
{
// Get a GSAPI object for API calls in the groovesharkBox() function
$gsapi = GSAPI::getInstance();
$sessionID = $gsapi->getSessionID();
$siteurl = get_option('siteurl'); // used to provide links to js/images
$version = get_bloginfo('version'); // used to load fixes specific to certain WP versions
$isVersion26 = stripos($version, '2.6') !== false;
$isVersion25 = stripos($version, '2.5') !== false;
// The basic code to display the postbox. The ending tags for div are at the end of the groovesharkBox() function
print "
<input type='hidden' name='isSmallBox' id='isSmallBox' value='0' />
<input type='hidden' name='songIDs' id='songIDs' value='0' />
<input type='hidden' name='gsTagStatus' id='gsTagStatus' value='0' />
<input type='hidden' name='gsSessionID' value='$sessionID' id='gsSessionID' />
<input type='hidden' name='gsBlogUrl' value='$siteurl' id='gsBlogUrl' />
<input type='hidden' name='wpVersion' value='$version' id='wpVersion' />
<input type='hidden' name='gstabledata' id='gstabledata' />
<input type='hidden' id='gsDataStore' />
<div id='jsPlayerReplace'></div>
<!--[if IE 7]>
<div id='IE7'>
<![endif]-->
<div id='gsInfo'>
<p>Add music to your posts. Go to the <a href='$siteurl/wp-admin/options-general.php?page=grooveshark.php' target='_blank'>settings page</a> for more music options.</p>
<div id='apContainer'></div>
</div>";
// Retrieves the saved options for this plugin
$gs_options = get_option('gs_options');
$username = $gs_options['username'];
$token = $gs_options['token'];
print "<link type='text/css' rel='stylesheet' href='" . get_bloginfo('wpurl') . "/wp-content/plugins/grooveshark/css/grooveshark.css' />\n
<input type='hidden' name='gsUsername' id='gsUsername' value='$username' />\n
<input type='hidden' name='gsToken' id='gsToken' value='$token' />\n
<!--[if IE]><link type='text/css' rel='stylesheet' href='" . get_bloginfo('wpurl') . "/wp-content/plugins/grooveshark/css/grooveshark-ie.css' /><![endif]-->\n
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js'></script>
<script type='text/javascript' src='$siteurl/wp-content/plugins/grooveshark/js/grooveshark.full.js'></script>
<script type='text/javascript' src='$siteurl/wp-content/plugins/grooveshark/js/grooveshark.js'></script>";
// Sets up the tabs for "search," "favorites," and "playlists."
$tabClass = 'gsTabActive27';
$tabClass2 = 'gsTabInactive27';
$tabContainerClass = 'gsTabContainer27';
$songClass = 'gsSongBox27';
$versionClass = 'gs27';
if ($isVersion26 || $isVersion25) {
$tabContainerClass = 'gsTabContainer26';
$tabClass = 'gsTabActive26';
$tabClass2 = 'gsTabInactive26';
$songClass = 'gsSongBox26';
$versionClass = 'gs26';
}
print "<div id='gsSongSelection'>
<ul class='$tabContainerClass'>
<li><a id='search-option' class='$tabClass' href='#'>Search</a></li>
<li><a id='favorites-option' class='$tabClass2' href='#'>Favorites</a></li>
<li><a id='playlists-option' class='$tabClass2' href='#'>Playlists</a></li>
<div class='clear' style='height:0'></div>
</ul>
<div class='clear' style='height:0'></div>";
$userID = $gs_options['userID'];
$token = $gs_options['token'];
//Check if the user has registered (0 for no, 1 for yes and logged in)
$userCheck = 0;
if ((($userID != '') && ($userID != 0))) {
$userCheck = 1;
}
// The keywords search div
print "
<div id='songs-search' class='$songClass' style='display: block;'>
<div id='searchInputWrapper'>
<div id='searchInput'>
<input tabindex='100' id='gs-query' type='text' name='gs-query' value='Search For A Song' class='empty' />
<input type='hidden' name='gsLimit' value='{$gs_options['numberOfSongs']}' id='gsLimit' />
</div>
</div>
<div id='searchButton'>
<input tabindex='101' type='button' name='editPage-1' id='gsSearchButton' value='Search' class='button gsMainButton'/>
</div>
<div class='clear' style='height:0;'></div>
</div>
<div class='clear' style='height:0'></div>
<div id='search-results-container' class='$versionClass' style='display:none;'>
<div id='search-results-header'>
<h4 id='queryResult'></h4>
</div>
<div id='search-results-wrapper'>
<table id='save-music-choice-search' style='display:none'></table>
</div>
</div>
";
// The favorites div (hidden by default)
print "<div id='songs-favorites' class='$songClass' style='display: none;'>";
if ($userID == 0) {
// User most be logged in to access their favorites
print "<p>Search for your favorite songs on Grooveshark. To use this feature, you must provide your Grooveshark login information in the Settings page, then refresh this page.</p>";
} else {
print "<table id='save-music-choice-favorites'>";
$username = $gs_options['username'];
$result = $gsapi->authenticateUser($username, $token);
$songsArray = $gsapi->userGetFavoriteSongs(); // Gets the user's favorite songs
if (isset($songsArray['error'])) {
// There was a problem getting the user's favorite songs
print "<tr><td colspan='3'>Error Code " . $songsArray['error'] . ". If this problem persists, you can e-mail [email protected] for support.";
} else {
// Get all favorite songs as rows in the table
foreach ($songsArray as $id => $songInfo) {
// Get necessary song information
$songName = $songInfo['SongName'];
$artistName = $songInfo['ArtistName'];
$songID = $songInfo['SongID'];
// Set a limit to how long song strings should be depending on WP versions (where boxes have smaller widths)
// Should come up with a dynamic width system but this is good enough for most users
$stringLimit = ($isVersion26 || $isVersion25) ? 71 : 78;
// Sets up the name that is displayed in song list
$songNameComplete = (strlen("$songName by $artistName") > $stringLimit)
? substr($songName, 0, $stringLimit - 3 - strlen($artistName)) . "… by $artistName"
: "$songName by $artistName";
// Replaces all single and double quotes with the html character entities
$songNameComplete = preg_replace("/\'/", "‘", $songNameComplete, -1);
$songNameComplete = preg_replace("/\"/", """, $songNameComplete, -1);
$songName = preg_replace("/\'/", "‘", $songName, -1);
$songName = preg_replace("/\"/", """, $songName, -1);
$artistName = preg_replace("/\"/", """, $artistName, -1);
$artistName = preg_replace("/\'/", "‘", $artistName, -1);
// Sets up alternating row colors depending on WP version
if ($id % 2) {
$rowClass = 'gsTr1';
} else {
$rowClass = ($isVersion26 || $isVersion25) ? 'gsTr26' : 'gsTr27';
}
print "<tr class='$rowClass'>
<td class='gsTableButton'><a title='Add This Song To Your Post' class='gsAdd gsSong-$songID' name='$songNameComplete::$songID' style='cursor: pointer' id='gsSong-$songID'></a></td>
<td class='gsTableButton'><a title='Play This Song' class='gsPlay' name='$songID' style='cursor: pointer'></a></td>
<td>$songNameComplete</td>
</tr>";
}
}
print "</table>";
}
print "</div>"; // End favorites div
//The playlists div (hidden by default)
// Get the user's saved playlists and display them here
print "<div id='songs-playlists' class='$songClass' style='display: none;'>";
if ($userID == 0) {
// User must be logged in to access their playlists
print "<p>Search for your playlists on Grooveshark. To use this feature, you must provide your Grooveshark login information in the Settings page, then refresh this page.</p>";
} else {
// NOTE: User should already be logged in from favorites div, so call to authenticateUser necessary
$gs_options = gsUpdateUserPlaylists($gs_options, $gsapi);
$userPlaylists = $gs_options['userPlaylists'];
print "<table id='save-music-choice-playlists'>";
if (!empty($userPlaylists)) {
$colorId = 0;
foreach ($userPlaylists as $playlistID => $playlistData) {
// print a table row containing current playlist's data
// Prepare style information
if ($colorId % 2) {
$rowClass = 'gsTr1';
} else {
$rowClass = ($isVersion26 || $isVersion25) ? 'gsTr26' : 'gsTr27';
}
$colorId++;
// First, remove the entry in the array that does not correspond to a song
$playlistInfo = $playlistData['playlistInfo'];
unset($playlistData['playlistInfo']);
// prepare the songs list
$songString = array();
foreach ($playlistData as $songID => $songData) {
$songNameComplete = $songData['songName'] . ' by ' . $songData['artistName'];
if (strlen($songNameComplete) > 78) {
// Cap string length at 78
$songNameComplete = substr($songData['songName'], 0, 75 - strlen($songData['artistName'])) . '… by ' . $songData['artistName'];
}
$songString[] = array('songID' => $songID, 'songName' => $songData['songName'], 'artistName' => $songData['artistName'], 'songNameComplete' => $songNameComplete);
}
$jsonSongString = gs_json_encode($songString);
print "<tr class='$rowClass'>
<td class='gsTableButton'><a title='Add This Playlist To Your Post' class='gsAdd gsPlaylistAdd' name='$playlistID' style='cursor: pointer'><span style='display:none'>$jsonSongString</span></a></td>
<td class='gsTableButton'><a title='Show All Songs In This Playlist' class='gsShow' name='$playlistID' style='cursor: pointer'></a></td>
<td>{$playlistInfo['name']} ({$playlistInfo['numSongs']})</td>
</tr>";
$alt = 0;
foreach ($songString as $song) {
if ($alt % 2) {
$trClass = 'gsTr1';
} else {
$trClass = 'gsTr27';
}
$alt++;
print "<tr class='child-$playlistID playlistRevealedSong $trClass' style='display:none;'>
<td class='gsTableButton'>
<a class='gsAdd gsSong-{$song['songID']}' style='cursor:pointer;' name='{$song['songNameComplete']}::{$song['songID']}' title='Add This Song To Your Post' id='gsSong-{$song['songID']}'></a>
</td>
<td class='gsTableButton'>
<a class='gsPlay' style='cursor:pointer;' name='{$song['songID']}' title='Play This Song'></a>
</td>
<td>{$song['songNameComplete']}</td>
</tr>";
}
}
} else {
print "<tr><td>No playlists were found. When you create playlists on Grooveshark, they will show up here. If you do have playlists on Grooveshark, reload this page.</td></tr>";
}
print "</table>";
}
print "</div>"; // End playlist div
//The selected songs div: dynamically updated with the songs the user wants to add to their post
print "
<div id='selected-song' class='$songClass'>
<div id='selected-songs-header'>
<a title='Remove All Your Selected Songs' href='#' id='clearSelected'>Clear All</a>
<h4 id='selectedCount'>Selected Songs (0):</h4>
</div>
<table id='selected-songs-table'></table>
</div>
</div>"; // Ends selected songs div and the song selection (search, favorites, playlists, selected) div
//The appearance div: customizes options for displaying the widget
$widgetWidth = (!isset($gs_options['widgetWidth'])) ? 250 : $gs_options['widgetWidth'];
$widgetHeight = (!isset($gs_options['widgetHeight'])) ? 400 : $gs_options['widgetHeight'];
$displayPhrase = ((!isset($gs_options['displayPhrase'])) || ($gs_options['displayPhrase'] == '')) ? 'Grooveshark' : $gs_options['displayPhrase'];
print "
<a title='Toggle Showing Appearance Options' id='jsLink' href='#'>↓ Appearance</a>
<div id='gsAppearance' class='gsAppearanceHidden'>
<h2 id='gsAppearanceHead'>Customize the Appearance of Your Music</h2>
<ul class='gsAppearanceOptions'>
<li>
<span class='key'>Display Music As:</span>
<span class='value' id='gsAppearanceRadio'>
<input tabindex='103' type='radio' name='displayChoice' value='link' /> Link<br/>
<input tabindex='103' type='radio' name='displayChoice' value='widget' checked /> Widget
</span>
</li>
<li>
<span class='key'>Position Music At:</span>
<span class='value'>
<input id='gsPosition' tabindex='104' type='radio' name='positionChoice' value='beginning' /> Beginning of Post<br/>
<input tabindex='104' type='radio' name='positionChoice' value='end' checked /> End of Post
</span>
</li>
</ul>
<ul id='gsDisplayLink' style='display:none;' class='gsAppearanceOptions'>
<li>
<span class='key'><label for='playlistsName'>Playlist Name:</label></span>
<span class='value'>
<input tabindex='105' type='text' name='playlistsName' id='playlistsName' value='Grooveshark Playlist' /><span id='displayPhrasePlaylistExample'>Example: \"$displayPhrase: Grooveshark Playlist\"</span>
</span>
</li>
<li>
<span class='key'><label for='displayPhrase'>Link Display Phrase:</label></span>
<span class='value'>
<input tabindex='106' type='text' name='displayPhrase' id='displayPhrase' value='$displayPhrase' /><span id='displayPhraseExample'>Example: \"$displayPhrase: song by artist\"</span>
</span>
</li>
</ul>
<div id='gsDisplayWidget'>
<ul class='gsAppearanceOptions'>
<li>
<span class='key'>Add to Dashboard:</span>
<span class='value'>
<input tabindex='105' type='radio' name='dashboardChoice' value='yes' id='gsDashboardChoice' /> Yes (will replace current Grooveshark Dashboard)<br />
<input tabindex='105' type='radio' name='dashboardChoice' value='no' checked /> No
</span>
</li>
</ul>
<h2 id='singleAppearance'>Appearance of Single-Song Widgets</h2>
<ul class='gsAppearanceOptions'>
<li>
<span class='key'><label for='widgetTheme'>Widget Theme:</label></span>
<span class='value'>
<select tabindex='107' type='text' id='widgetTheme' name='widgetTheme'>
<option value='metal' selected='selected'>Metal</option>
<option value='wood'>Wood</option>
<option value='grass'>Grass</option>
<option value='water'>Water</option>
</select>
<span>See Preview Below</span>
</span>
</li>
<li>
<span class='key'><label for='singleWidgetWidth'>Widget Width:</label></span>
<span class='value'>
<input tabindex='108' type='text' name='singleWidgetWidth' id='singleWidgetWidth' value='250'/><span>Range: 150px to 1000px</span>
<div class='clear'></div>
<br />
<div class='gsWidgetPreviewContainer' id='gsSingleWidgetPreview'>
</div>
</span>
</li>
</ul>
<h2 id='playlistAppearance'>Appearance of Multi-Song Widgets</h2>
<ul class='gsAppearanceOptions'>
<li>
<span class='key'><label for='widgetWidth'>Widget Width:</label></span>
<span class='value'>
<input tabindex='107' type='text' name='widgetWidth' id='widgetWidth' value='250'/><span>Range: 150px to 1000px</span>
</span>
</li>
<li>
<span class='key'><label for='widgetHeight'>Widget Height:</label></span>
<span class='value'>
<input tabindex='108' type='text' name='widgetHeight' id='widgetHeight' value='176'/><span>Range: 150px to 1000px</span>
</span>
</li>
<li>
<span class='key'><label>Color Scheme:</label></span>
<span class='value'>
<select tabindex='109' type='text' id='colors-select' name='colorsSelect'>
";
// Customize the color scheme of the widget
$colorScheme = $gs_options['colorScheme']; //use this to save the user's colorscheme preferences
$colorsArray = array("Default","Walking on the Sun","Neon Disaster","Golf Course","Creamcicle at the Beach Party","Toy Boat","Wine and Chocolate Covered Strawberries","Japanese Kite","Eggs and Catsup","Shark Bait","Sesame Street","Robot Food","Asian Haircut","Goth Girl","I Woke Up And My House Was Gone","Too Drive To Drunk","She Said She Was 18","Lemon Party","Hipster Sneakers","Blue Moon I Saw You Standing Alone","Monkey Trouble In Paradise");
foreach ($colorsArray as $id => $colorOption) {
print "<option value='$id' ";
if ($i == $colorScheme) {
print "selected ";
}
print ">$colorOption</option>";
}
print "
</select>
<span>See Preview Below (Preview has 37-song limit)</span>
<div class='clear'></div>
<br/>
<div class='gsColorBlockContainer'>
Base
<div style='background-color: #777777' id='base-color' class='gsColorBlock'></div>
</div>
<div class='gsColorBlockContainer'>
Primary
<div style='background-color: rgb(255,255,255)' id='primary-color' class='gsColorBlock'></div>
</div>
<div class='gsColorBlockContainer'>
Secondary
<div style='background-color: rgb(102,102,102)' id='secondary-color' class='gsColorBlock'></div>
</div>
</span>
</li>
</ul>
<div class='clear'></div>
<div id='gsWidgetExample'></div>
</div>
<div class='clear'></div>
</div>
";
//Closes the Grooveshark box div: gives two display options and the save button
print "
<table id='gsSave'>
<tr>
<td>
<input tabindex='110' type='button' class='button-primary button' value='Save Music' id='gs-save-post' name='save' onclick='gsAppendToContent(this)'/>
<span id='gsCommentStatusMessage' style='display:none; background-color:#ffcccc; color:#001111; font-size:1.15em; margin-left:10px;'></span>
</td>
</tr>
</table>
<!--[if IE 7]>
</div>
<![endif]-->";
}
function oldGroovesharkBox()
{
print "<div class='dbx-b-ox-wrapper'>
<fieldset id='groovesharkdiv' class='dbx-box'>
<div class='dbx-h-andle-wrapper'>
<h3 class='dbx-handle'>
Add Music
</h3>
</div>
<div class='dbx-c-ontent-wrapper'>
<div class='dbx-content'>";
groovesharkBox();
print "</div>
</div>
</fieldset>
</div>";
}
function gsUpdateUserPlaylists($gs_options, $gsapi) {
// updates the saved user playlists
$userPlaylists = $gs_options['userPlaylists'];
$apiPlaylists = $gsapi->userGetPlaylists();
foreach ($apiPlaylists as $apiPlaylistData) {
$apiPlaylistID = $apiPlaylistData['PlaylistID'];
$playlistName = $apiPlaylistData['Name'];
$apiModifiedTime = $apiPlaylistData['TSModified'];
$apiTimeData = date_parse($apiModifiedTime);
$apiTimestamp = mktime($apiTimeData['hour'], $apiTimeData['minute'], $apiTimeData['second'], $apiTimeData['month'], $apiTimeData['day'], $apiTimeData['year']);
$modifiedTime = $apiTimestamp;
if (!empty($userPlaylists[$apiPlaylistID])) {
// update modified time
$modifiedTime = $userPlaylists[$apiPlaylistID]['playlistInfo']['modifiedTime'];
}
if ((empty($userPlaylists[$apiPlaylistID])) || ((int)$apiTimestamp > (int)$modifiedTime)) {
// new playlist or modified playlist
$userPlaylists[$apiPlaylistID] = array();
$numberOfSongs = 0;
$playlistSongs = $gsapi->playlistGetSongs($apiPlaylistID);
if (empty($playlistSongs['error'])) {
// Add the songs
foreach ($playlistSongs as $song) {
if (!empty($song['SongID']) && !empty($song['SongName']) && !empty($song['ArtistName'])) {
$numberOfSongs++;
$userPlaylists[$apiPlaylistID][$song['SongID']] = array('songName' => $song['SongName'], 'artistName' => $song['ArtistName']);
}
}
}
if (!empty($userPlaylists[$apiPlaylistID])) {
$userPlaylists[$apiPlaylistID]['playlistInfo'] = array('name' => $playlistName, 'numSongs' => $numberOfSongs, 'modifiedTime' => $apiTimestamp);
} else {
unset($userPlaylists[$apiPlaylistID]);
}
}
}
$gs_options['userPlaylists'] = $userPlaylists;
update_option('gs_options', $gs_options);
return $gs_options;
}
function add_gs_options_page()
{
add_options_page('Grooveshark Options', 'Grooveshark', 'edit_dashboard', basename(__FILE__), 'grooveshark_options_page');
//add_plugins_page('Grooveshark Options', 'Grooveshark', 'admin', 'Grooveshark', 'grooveshark_options_page');
}
// Registers the action to add the options page for the plugin.
add_action('admin_menu', 'add_gs_options_page');
// Code for Sidebar Widget
function groovesharkSidebarContent($args) {
$gs_options = get_option('gs_options'); // Embed code is saved in the gs_options array
if (!empty($gs_options['sidebarPlaylists'])) {
print $args['before_widget'] . $args['before_title'] . 'Grooveshark Sidebar' . $args['after_title'] . $gs_options['sidebarPlaylists']['embed'] . $args['after_widget'];
}
}
function groovesharkDashboardContent($args) {
$gs_options = get_option('gs_options');
if (!empty($gs_options['dashboardPlaylists'])) {
print $gs_options['dashboardPlaylists']['embed'];
}
}
function groovesharkRssContent($args) {
$gs_options = get_option('gs_options');
$wpurl = get_bloginfo('wpurl');
if (!empty($gs_options['sidebarRss']) && ($gs_options['gsRssOption'] === 1)) {
include('gsRss.php');
}
}
// Widget code
function groovesharkSidebarInit() {
$gs_options = get_option('gs_options');
wp_register_sidebar_widget('groovesharkSidebar', 'Grooveshark Sidebar', 'groovesharkSidebarContent', array('description' => 'Add music to your Wordpress Sidebar using a Grooveshark Widget'));
//register_widget_control('groovesharkSidebar', 'groovesharkSidebarOptions', 600);
wp_register_widget_control('groovesharkSidebar', 'Grooveshark Sidebar', 'groovesharkSidebarOptions', array('width' => 600));
}
function groovesharkDashboardInit() {
$gs_options = get_option('gs_options');
if (!empty($gs_options['dashboardPlaylists'])) {
if (function_exists('wp_add_dashboard_widget')) {
wp_add_dashboard_widget('groovesharkDashboard', 'Grooveshark Dashboard', 'groovesharkDashboardContent');
}
}
}
function groovesharkRssInit() {
$gs_options = get_option('gs_options');
if ($gs_options['gsRssOption'] == 1) {
wp_register_sidebar_widget('groovesharkRss', 'Grooveshark RSS', 'groovesharkRssContent', array('description' => 'Display an RSS feed to your favorite and recent songs on Grooveshark and link to them on your Wordpress Sidebar'));
//register_widget_control('groovesharkRss', 'groovesharkRssOptions', 400);
wp_register_widget_control('groovesharkRss', 'Grooveshark RSS', 'groovesharkRssOptions', array('width' => 400));
}
}
function groovesharkRssOptions() {
$gs_options = get_option('gs_options');
$didSave = 0;
print "<input type='hidden' id='groovesharkSidebarRssBox' value=''/>";
if (isset($_POST['groovesharkRss-submit'])) {
// Update the saved options
$didSave = 1;
if (isset($_POST['gsFavoritesFeed'])) {
$gs_options['sidebarRss']['favorites']['title'] = ($_POST['gsFavoritesTitle'] != '') ? $_POST['gsFavoritesTitle'] : 'My Favorite Songs 2';
$gs_options['sidebarRss']['favorites']['url'] = "http://api.grooveshark.com/feeds/1.0/users/" . strtolower($gs_options['username']) . "/recent_favorite_songs.rss";
} else {
$gs_options['sidebarRss']['favorites'] = array();
}
if (isset($_POST['gsRecentFeed'])) {
$gs_options['sidebarRss']['recent']['title'] = ($_POST['gsRecentTitle'] != '') ? $_POST['gsRecentTitle'] : 'My Recent Songs';
$gs_options['sidebarRss']['recent']['url'] = "http://api.grooveshark.com/feeds/1.0/users/" . strtolower($gs_options['username']) . "/recent_listens.rss";
} else {
$gs_options['sidebarRss']['recent'] = array();
}
$gs_options['sidebarRss']['count'] = $_POST['gsNumberOfItems'];
$gs_options['sidebarRss']['displayContent'] = isset($_POST['gsDisplayContent']) ? 1 : 0;
update_option('gs_options', $gs_options);
}
// Have the configuration options here
print "<h3>Grooveshark RSS Widget</h3>";
if ($gs_options['userID'] == 0) {
print "<h4>You must save your login information to display your Grooveshark RSS feeds in the <a href='" . get_option('siteurl') . "/wp-admin/options-general.php?page=grooveshark.php' target='_blank'>settings page</a>, then refresh this page.</h4>";
} else {
if ($didSave) {
print "<h4>Your RSS settings have been saved.</h4>";
} else {
print "<h4>Choose how you want your Grooveshark RSS feeds to appear on your sidebar</h4>";
}
print "<input name='groovesharkRss-submit' type='hidden' value='1' />
<ul>
<li class='gsTr26'><label><input type='checkbox' name='gsFavoritesFeed' " . (empty($gs_options['sidebarRss']['favorites']) ? '' : " checked='checked'") . "/> Enable Favorites Feed?</label></li>
<li><label>Title for Favorites Feed: <input type='text' name='gsFavoritesTitle' value='" . (empty($gs_options['sidebarRss']['favorites']) ? '' : $gs_options['sidebarRss']['favorites']['title']) ."'/></label></li>
<li class='gsTr26'><label><input type='checkbox' name='gsRecentFeed' " . (empty($gs_options['sidebarRss']['recent']) ? '' : " checked='checked'") . "/> Enable Recent Songs Feed?</label></li>
<li><label>Title for Recent Songs Feed: <input type='text' name='gsRecentTitle' value='" . (empty($gs_options['sidebarRss']['recent']) ? '' : $gs_options['sidebarRss']['recent']['title']) . "'/></label></li>
<li class='gsTr26'><label>How many items would you like to display: <select name='gsNumberOfItems' type='text'>";
for ($i = 0; $i <= 20; $i++) {
print "<option value='$i' " . ($gs_options['sidebarRss']['count'] == $i ? "selected='selected'" : '') . ">$i</option>";
}
print "</select></label></li>
<li><label><input type='checkbox' name='gsDisplayContent' " . ($gs_options['sidebarRss']['displayContent'] ? "checked='checked'" : '' ) . "/> Display Item Content?</label></li>
</ul>";
}
}
function gsGetColors($colorScheme) {
switch ($colorScheme) {
case 1:
$color1 = 'CCA20C';
$color2 = '4D221C';
$color3 = 'CC7C0C';
break;
case 2:
$color1 = '87FF00';
$color2 = '0088FF';
$color3 = 'FF0054';
break;
case 3:
$color1 = 'FFED90';
$color2 = '359668';
$color3 = 'A8D46F';
break;
case 4:
$color1 = 'F0E4CC';
$color2 = 'F38630';
$color3 = 'A7DBD8';
break;
case 5:
$color1 = 'FFFFFF';
$color2 = '377D9F';
$color3 = 'F6D61F';
break;
case 6:
$color1 = '450512';
$color2 = 'D9183D';
$color3 = '8A0721';
break;
case 7:
$color1 = 'B4D5DA';
$color2 = '813B45';
$color3 = 'B1BABF';
break;
case 8:
$color1 = 'E8DA5E';
$color2 = 'FF4746';
$color3 = 'FFFFFF';
break;
case 9:
$color1 = '993937';
$color2 = '5AA3A0';
$color3 = 'B81207';
break;
case 10:
$color1 = 'FFFFFF';
$color2 = '009609';
$color3 = 'E9FF24';
break;
case 11:
$color1 = 'FFFFFF';
$color2 = '7A7A7A';
$color3 = 'D6D6D6';
break;
case 12:
$color1 = 'FFFFFF';
$color2 = 'D70860';
$color3 = '9A9A9A';
break;
case 13:
$color1 = '000000';
$color2 = 'FFFFFF';
$color3 = '620BB3';
break;
case 14:
$color1 = '4B3120';
$color2 = 'A6984D';
$color3 = '716627';
break;
case 15:
$color1 = 'F1CE09';
$color2 = '000000';
$color3 = 'FFFFFF';
break;
case 16:
$color1 = 'FFBDBD';
$color2 = 'DD1122';
$color3 = 'FFA3A3';
break;
case 17:
$color1 = 'E0DA4A';
$color2 = 'FFFFFF';
$color3 = 'F9FF34';
break;
case 18:
$color1 = '579DD6';
$color2 = 'CD231F';
$color3 = '74BF43';
break;
case 19:
$color1 = 'B2C2E6';
$color2 = '012C5F';
$color3 = 'FBF5D3';
break;
case 20:
$color1 = '60362A';
$color2 = 'E8C28E';
$color3 = '482E24';
break;
default:
$color1 = '000000';
$color2 = 'FFFFFF';
$color3 = '666666';
break;
}
return array($color1, $color2, $color3);
}
function groovesharkSidebarOptions() {
$gsapi = GSAPI::getInstance();
$gs_options = get_option('gs_options');
$didSave = 0;
$wpurl = get_bloginfo('wpurl');
$siteurl = get_option('siteurl'); // used to provide links to js/images
print "<link type='text/css' rel='stylesheet' href='$wpurl/wp-content/plugins/grooveshark/css/grooveshark.css'></link>\n
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js'></script>\n
<script type='text/javascript' src='$wpurl/wp-content/plugins/grooveshark/js/grooveshark.sidebar.js'></script>";
print "<input type='hidden' id='groovesharkSidebarOptionsBox' value='' />
<input type='hidden' id='gsBlogUrl' value='$siteurl' />
<input type='hidden' id='gsSessionID' value='" . $gsapi->getSessionID() . "' />";
if (isset($_POST['groovesharkWidget-submit'])) {
// Update the saved options
if (isset($_POST['gsClearSidebar']) || !isset($_POST['songsInfoArray'])) {
$gs_options['sidebarPlaylists'] = array();
$didSave = 2;
} else {
$playlistID = 0;
if (count($_POST['songsInfoArray']) == 1) {
$embedCode = $gsapi->songGetWidgetEmbedCode($_POST['songsInfoArray'][0], $_POST['sidebarWidgetWidth'], $_POST['widgetTheme']);
// single song widget
} else {
$colorScheme = (int)$_POST['colorsSelect'];
$colors = gsGetColors($colorScheme);
$color1 = $colors[0];
$color2 = $colors[1];
$color3 = $colors[2];
$embedCode = $gsapi->playlistGetWidgetEmbedCode($_POST['songsInfoArray'], $_POST['sidebarWidgetWidth'], $_POST['sidebarWidgetHeight'], 'Sidebar Widget', $color2, $color1, $color1, $color3, $color2, $color1, $color3, $color2, $color2, $color1, $color3, $color2, $color2, $color3, $color2);
}
$gs_options['sidebarPlaylists'] = array('id' => $playlistID, 'embed' => $embedCode);
$didSave = 1;
}
update_option('gs_options', $gs_options);
}
print "<h3 class='groovesharkHeader'>Grooveshark Sidebar</h3>";
if ($didSave == 1) {
print "<p>Your music has been saved.</p>";
} elseif ($didSave == 2) {
print "<p>Your sidebar has been cleared.</p>";
} else {
print "<p>Add music to your Wordpress Sidebar</p>";
}
print "<input type='hidden' name='myHiddenData' id='myHiddenData' />
<div id='apContainer'></div>";
print "<div id='gsSongSelection'>
<ul class='gsTabContainer27'>
<li><a id='search-option' class='gsTabActive26' onclick='gsToggleSongSelect(this)' href='javascript:;'>Search</a></li>
<li><a id='favorites-option' class='gsTabInactive27' onclick='gsToggleSongSelect(this)' href='javascript:;'>Favorites</a></li>
<li><a id='playlists-option' class='gsTabInactive27' onclick='gsToggleSongSelect(this)' href='javascript:;'>Playlists</a></li>
<div class='clear' style='height:0'></div>
</ul>
<div id='songs-search' class='gsSongBox26' style='display: block;'>
<div id='searchInputWrapper'>
<div id='searchInput'>
<input tabindex='100' id='gs-query' type='text' name='gs-query' value='Search For A Song' class='empty' onfocus='if (this.className == \"empty\") {this.className = \"\"; this.value = \"\";}' onkeydown='if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {gsEnterSearch(this); return false;} else {gsUpdateValue(this); return true;}'/>
<input type='hidden' name='gsLimit' value='{$gs_options['numberOfSongs']}' id='gsLimit' />
</div>
</div>
<div id='searchButton'>
<input tabindex='101' type='button' name='editPage-1' id='gsSearchButton' value='Search' class='button gsMainButton' onclick='gsSearch(this)'/>
</div>
<div class='clear' style='height:0;'></div>
</div>
<div class='clear' style='height:0'></div>
<div id='search-results-container' class='gs26' style='display:none;'>
<div id='search-results-header'>
<h4 id='queryResult'></h4>
</div>
<div id='search-results-wrapper'>
<table id='save-music-choice-search' style='display:none'></table>
</div>
</div>
";
// The favorites div (hidden by default)
print "<div id='songs-favorites' class='gsSongBox26' style='display: none;'>";
if (($gs_options['username'] . $gs_options['token']) == '') {
// User most be logged in to access their favorites
print "<p>Search your favorite songs on Grooveshark. To use this feature, you must provide your login information in the <a href='" . get_option('siteurl') . "/wp-admin/options-general.php?page=grooveshark.php' target='_blank'>settings page</a>, then refresh this page.</p>";
} else {
print "<table id='save-music-choice-favorites'>";
$username = $gs_options['username'];
$result = $gsapi->authenticateUser($username, $gs_options['token']);
$songsArray = $gsapi->userGetFavoriteSongs(); // Gets the user's favorite songs
if (isset($songsArray['error'])) {
// There was a problem getting the user's favorite songs
print "<tr><td colspan='3'>Error Code " . $songsArray['error'] . ". If this problem persists, you can e-mail [email protected] for support.";
} else {
// Get all favorite songs as rows in the table
foreach ($songsArray as $id => $songInfo) {
// Get necessary song information
$songName = $songInfo['SongName'];
$artistName = $songInfo['ArtistName'];
$songID = $songInfo['SongID'];
// Set a limit to how long song strings should be depending on WP versions (where boxes have smaller widths)
// Should come up with a dynamic width system but this is good enough for most users
// Sets up the name that is displayed in song list
$songNameComplete = (strlen("$songName by $artistName") > 78)
? substr($songName, 0, 75 - strlen($artistName)) . "… by $artistName"
: "$songName by $artistName";
// Replaces all single and double quotes with the html character entities
$songNameComplete = preg_replace("/\'/", "‘", $songNameComplete, -1);
$songNameComplete = preg_replace("/\"/", """, $songNameComplete, -1);
$songName = preg_replace("/\'/", "‘", $songName, -1);
$songName = preg_replace("/\"/", """, $songName, -1);
$artistName = preg_replace("/\"/", """, $artistName, -1);
$artistName = preg_replace("/\'/", "‘", $artistName, -1);
// Sets up alternating row colors depending on WP version
if ($id % 2) {
$rowClass = 'gsTr1';
} else {
$rowClass = 'gsTr26';
}
print "<tr class='$rowClass'>
<td class='gsTableButton'><a title='Add This Song To Your Post' class='gsAdd gsSong-$songID' onclick='addToSelected(this)' name='$songNameComplete::$songID' style='cursor: pointer' id='gsSong-$songID'></a></td>
<td class='gsTableButton'><a title='Play This Song' class='gsPlay' onclick='toggleSong(this)' name='$songID' style='cursor: pointer'></a></td>
<td>$songNameComplete</td>
</tr>";
}
}
print "</table>";
}
print "</div>"; // End favorites div
print "<div id='songs-playlists' class='gsSongBox26' style='display:none;'>";
$playlistsTotal = 0;
if (($gs_options['username'] . $gs_options['token']) !== '') {
$gs_options = gsUpdateUserPlaylists($gs_options, $gsapi);
$userPlaylists = $gs_options['userPlaylists'];
// If the user has saved playlists
$colorId = 0;
print "<table id='save-music-choice-playlists'>";
foreach ($userPlaylists as $playlistID => $playlistData) {
// print a table row containing current playlist's data
// Prepare style information
if ($colorId % 2) {
$rowClass = 'gsTr1';
} else {
$rowClass = 'gsTr26';
}
$colorId++;
// First, remove the entry in the array that does not correspond to a song
$playlistInfo = $playlistData['playlistInfo'];
unset($playlistData['playlistInfo']);
// prepare the songs list
$songString = array();
foreach ($playlistData as $songID => $songData) {
$songNameComplete = $songData['songName'] . ' by ' . $songData['artistName'];
if (strlen($songNameComplete) > 78) {
// Cap string length at 78
$songNameComplete = substr($songData['songName'], 0, 75 - strlen($songData['artistName'])) . '… by ' . $songData['artistName'];
}
$songString[] = array('songID' => $songID, 'songName' => $songData['songName'], 'artistName' => $songData['artistName'], 'songNameComplete' => $songNameComplete);
}
$jsonSongString = gs_json_encode($songString);
// Inline events used, since event delegation refuses to work
print "<tr class='$rowClass'>
<td class='gsTableButton'><a title='Add This Playlist To Your Post' class='gsAdd gsPlaylistAdd' onclick='addToSelectedPlaylist(this);' name='$playlistID' style='cursor: pointer'><span style='display:none'>$jsonSongString</span></a></td>
<td class='gsTableButton'><a title='Show All Songs In This Playlist' class='gsShow' name='$playlistID' onclick='showPlaylistSongs(this);' style='cursor: pointer'></a></td>
<td>{$playlistInfo['name']} ({$playlistInfo['numSongs']})</td>
</tr>";
$alt = 0;
foreach ($songString as $song) {
if ($alt % 2) {
$trClass = 'gsTr1';
} else {
$trClass = 'gsTr26';
}
$alt++;
print "<tr class='child-$playlistID playlistRevealedSong $trClass' style='display:none;'>
<td class='gsTableButton'>
<a class='gsAdd gsSong-{$song['songID']}' onclick='addToSelected(this)' style='cursor:pointer;' name='{$song['songNameComplete']}::{$song['songID']}' title='Add This Song To Your Post' id='gsSong-{$song['songID']}'></a>
</td>
<td class='gsTableButton'>
<a class='gsPlay' style='cursor:pointer;' name='{$song['songID']}' title='Play This Song' onclick='toggleSong(this)'></a>
</td>
<td>{$song['songNameComplete']}</td>
</tr>";
}
}
print "</table>";
} else {
// No playlists, notify user on how to save playlists
print "<p>Search your playlists on Grooveshark. To use this feature, you must provide your login information in the <a href='" . get_option('siteurl') . "/wp-admin/options-general.php?page=grooveshark.php' target='_blank'>settings page</a>, then refresh this page.</p>";
}
print "</div>";
print "<div id='selected-song' class='gsSongBox26'>
<div id='selected-songs-header'>
<a title='Remove All Your Selected Songs' href='javascript:;' id='clearSelected' onclick='clearSelected(this)'>Clear All</a>
<h4 id='selectedCount'>Selected Songs (0):</h4>
</div>
<table id='selected-songs-table'></table>
</div>
</div>
<input name='groovesharkWidget-submit' type='hidden' value='1' />
<h3 class='groovesharkHeader'>Appearance Options</h3>
<input type='hidden' id='sidebarDataStore' value='-1'>
<ul class='gsAppearanceOptions'>
<li><span class='key'><label for='gsClearSidebar'>Clear Sidebar:</label></span><span class='value'><input type='checkbox' name='gsClearSidebar' id='gsClearSidebar' /><span style='font-size:12px'>Check this box and Save to clear the Grooveshark Sidebar.</span></span></li>
<li><span class='key'><label for='sidebarWidgetWidth'>Widget Width (px):</label></span><span class='value'><input tabindex='900' type='text' name='sidebarWidgetWidth' id='gsSidebarWidgetWidth' value='200' onchange='gsUpdateSidebarWidth(this)'/></span></li>
<li><span class='key'><label for='sidebarWidgetHeight'>Widget Height (px):</label></span><span class='value'><input tabindex='901' type='text' name='sidebarWidgetHeight' id='gsSidebarWidgetHeight' value='176' onchange='gsUpdateSidebarHeight(this)'/><span>For Multiple Songs</span></span></li>
<li>
<span class='key'><label for='widgetTheme'>Widget Theme:</label></span>
<span class='value'>
<select tabindex='902' type='text' id='widgetTheme' name='widgetTheme' onchange='changeSidebarTheme(this.form.widgetTheme)' onkeyup='changeSidebarTheme(this.form.widgetTheme)'>
<option value='metal' selected='selected'>Metal</option>
<option value='wood'>Wood</option>
<option value='grass'>Grass</option>
<option value='water'>Water</option>
</select>
<span>For Single Songs</span>
<br />
<div class='gsWidgetPreviewContainer' id='gsSingleWidgetPreview'>
<object width='200' height='40'>
<param value='http://listen.grooveshark.com/songWidget.swf' name='movie'></param>
<param value='window' name='wmode'></param>
<param value='always' name='allowScriptAccess'></param>
<param value='hostname=cowbell.grooveshark.com&songID=203993&style=metal' name='flashvars'></param>
<embed width='200' height='40' wmode='window' allowscriptaccess='always' flashvars='hostname=cowbell.grooveshark.com&songID=203993&style=metal' type='application/x-shockwave-flash' src='http://listen.grooveshark.com/songWidget.swf'></embed>
</object>
</div>
</span>
</li>
<li>
<span class='key'><label for='colorsSelect'>Color Scheme:</label></span>
<span class='value'>
<select tabindex='903' type='text' onchange='changeSidebarColor(this.form.colorsSelect)' onkeyup='changeSidebarColor(this.form.colorsSelect)' name='colorsSelect' id='colors-select'>";
// Customize the color scheme of the widget
$colorsArray = array("Default","Walking on the Sun","Neon Disaster","Golf Course","Creamcicle at the Beach Party","Toy Boat","Wine and Chocolate Covered Strawberries","Japanese Kite","Eggs and Catsup","Shark Bait","Sesame Street","Robot Food","Asian Haircut","Goth Girl","I Woke Up And My House Was Gone","Too Drive To Drunk","She Said She Was 18","Lemon Party","Hipster Sneakers","Blue Moon I Saw You Standing Alone","Monkey Trouble In Paradise");
foreach ($colorsArray as $id => $colorOption) {
print "<option value='$id'>$colorOption</option>";
}
print "</select>
<span>For Multiple Songs</span>
<div class='clear'></div>
<br />
<div class='gsColorBlockContainer'>
Base
<div style='background-color: #777777' id='widget-base-color' class='gsColorBlock'></div>
</div>
<div class='gsColorBlockContainer'>
Primary
<div style='background-color: #FFFFFF' id='widget-primary-color' class='gsColorBlock'></div>
</div>
<div class='gsColorBlockContainer'>
Secondary