https://www.icyphoenix.com/viewtopic.php?f=28&t=2284&p=16466#p16466 ----------------------------------- omarska Wed 13 Jun, 2007 13:01 Add LastFM Charts To Icy Phoenix ----------------------------------- Hi people! Here is the mod for Icy Phoenix, which will show your (or someone else's) LastFM charts in posts. It will add new button in posting screen, and it will add new bbcode tag ([b][lastfm type=chart_type color=chart_color]LastFM username[/lastfm][/b]) to your Icy Phoenix. Mod is based on [b][youtube] and [flash][/b] tags by MG, and is tested on fresh IP 1.1.0.15a. While first version of the mod only accepted username as input (while other parameters were hardcoded), this release brings selection of chart type and color while posting. At the moment, you have to enter these parameters manually (there is list of available parameters in helpscreen during code insertion), but I want to make radiobuttons or dropdown list where you can choose from available options. I expect your help in doing this guys, because I'm not very skilled in php :wink: . [b]If anybody could give me some hint on how to do this I would be extremly grateful.[/b] I provided premodded installation, because there is more than few files to be edited. Also, I wrote installation procedure by phpbb standards, so you can install mod even if you changed some of the files after Icy Phoenix installation. This is the first mod I have ever made, so try not to be too harsh, guys :oops: . If I made some mistake in code itself, or in a way I presented this mod, please point me in the right direction. Thanx for all the effort you put in this community, in helping us, and for keeping Icy Phoenix best phpbb system around. [codeblock]############################################################## ## MOD Title: LastFM Chart ## MOD Author: Gandalf < gandalf@omarska.net > http://www.omarska.net ## MOD Description: Adds a button and bbcode tag that enables users to display LastFM Charts in posts ## ## MOD Version: 0.4 ## ## Installation Level: Easy ## Installation Time: ~10 Minutes ## Files To Edit: templates/mg_themes/bbcb_mg.tpl ## language/lang_english/bbcb_mg.js ## language/lang_english/lang_bbcb_mg.php ## includes/bbcb_mg.php ## includes/bbcb_mg_small.php ## includes/bbcode.php ## Included Files: lastfm.gif ## ## ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## Author Notes: ## ## Note: ## This mod is for all users that would like to add LastFM playlists to their posts ## ############################################################## ## MOD History: ## ## 2007-06-16 - Version 0.4 ## Added selection of chart type and color ## Added some lang vars ## Removed album_bbcode.php editing ## Optimized code changes ## 2007-06-13 - Version 0.1 ## Mod created ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ COPY ]------------------------------------------ # copy lastfm.gif to images/bbcb_mg/images/gif/ # #-----[ OPEN ]------------------------------------------ # templates/mg_themes/bbcb_mg.tpl # #-----[ FIND ]------------------------------------------ # {L_BBCB_MG_YOUTUBE} # #-----[ AFTER, ADD ]------------------------------------ # {L_BBCB_MG_LASTFM} # #-----[ OPEN ]------------------------------------------ # language/lang_english/bbcb_mg.js # #-----[ FIND ]------------------------------------------ # s_youtube_insert = 'Please write YouTube file ID'; # #-----[ AFTER, ADD ]------------------------------------ # s_lastfm_insert = 'Please write LastFM username'; s_lastfm_insert_error = 'You didn't specify LastFM username'; s_lastfm_t_insert = 'Please specify chart type. Available types: recenttracks, weeklyartistchart, weeklytrackchart, topartists, toptracks'; s_lastfm_t_error = 'You didn't specify chart type'; s_lastfm_c_insert = 'Please specify chart color. Available colors: red, blue, black, grey'; s_lastfm_c_error = 'You didn't specify chart color'; s_lastfm_insert_tip = 'username'; s_lastfm_t_insert_tip = 'recenttracks'; s_lastfm_c_insert_tip = 'red'; # #-----[ FIND ]------------------------------------------ # s_youtube_help = 'Insert YouTube video file: [youtube]YouTube ID[/youtube]'; # #-----[ AFTER, ADD ]------------------------------------ # s_lastfm_help = 'Insert LastFM Chart: [lastfm type=chart_type color=chart_color]LastFM username[/lastfm]'; # #-----[ FIND ]------------------------------------------ # var youtube = 0; # #-----[ AFTER, ADD ]------------------------------------ # var lastfm = 0; # #-----[ FIND ]------------------------------------------ # '[youtube]','[/youtube]', # #-----[ AFTER, ADD ]------------------------------------ # '[lastfm type=recenttracks color=red]','[/lastfm]', # #-----[ FIND ]------------------------------------------ # function BBCyoutube() { var FoundErrors = ''; var enterURL = prompt(s_youtube_insert, s_id_insert_tip); if (!enterURL) { FoundErrors += s_id_insert_error; } if (FoundErrors) { alert(s_gen_error + FoundErrors); return; } var ToAdd = "[youtube]"+enterURL+"[/youtube]"; PostWrite(ToAdd); } # #-----[ AFTER, ADD ]------------------------------------ # function BBClastfm() { var FoundErrors = ''; var enterFURL = prompt(s_lastfm_insert, s_lastfm_insert_tip); if (!enterFURL) { FoundErrors += s_lastfm_insert_error; } var enterT = prompt(s_lastfm_t_insert, s_lastfm_t_insert_tip); if (!enterT) { FoundErrors += s_lastfm_t_error; } var enterC = prompt(s_lastfm_c_insert, s_lastfm_c_insert_tip); if (!enterC) { FoundErrors += s_lastfm_c_error; } if (FoundErrors) { alert(s_gen_error + FoundErrors); return; } var ToAdd = "[lastfm type="+enterT+" color="+enterC+"]"+enterFURL+"[/lastfm]"; PostWrite(ToAdd); } # #-----[ OPEN ]------------------------------------------ # language/lang_english/lang_bbcb_mg.php # #-----[ FIND ]------------------------------------------ # $lang['bbcb_mg_youtube'] = 'YouTube'; # #-----[ AFTER, ADD ]------------------------------------ # $lang['bbcb_mg_lastfm'] = 'LastFM'; # #-----[ FIND ]------------------------------------------ # $lang['s_flash_h_error'] = 'You didn't specify Flash file height'; # #-----[ AFTER, ADD ]------------------------------------ # $lang['s_lastfm_insert'] = 'Please specify LastFM username'; $lang['s_lastfm_insert_error'] = 'You didn't specify LastFM username'; $lang['s_lastfm_t_insert'] = 'Please specify chart type. Available types: recenttracks, weeklyartistchart, weeklytrackchart, topartists, toptracks'; $lang['s_lastfm_t_error'] = 'You didn't specify chart type'; $lang['s_lastfm_c_insert'] = 'Please specify chart color. Available colors: red, blue, black, grey'; $lang['s_lastfm_c_error'] = 'You didn't specify chart color'; # #-----[ FIND ]------------------------------------------ # $lang['s_youtube_help'] = 'Insert YouTube file: [youtube]YouTube ID[/youtube]'; # #-----[ AFTER, ADD ]------------------------------------ # $lang['s_lastfm_help'] = 'Insert LastFm Chart: [lastfm type=chart_type color=chart_color]LastFM username[/lastfm]'; # #-----[ OPEN ]------------------------------------------ # includes/bbcode.php # #-----[ FIND ]------------------------------------------ # 'youtube' => array( 'nested' => true, 'inurl' => true, 'allow_empty' => false, ), # #-----[ AFTER, ADD ]------------------------------------ # 'lastfm' => array( 'nested' => true, 'inurl' => true, 'allow_empty' => false, ), # #-----[ FIND ]------------------------------------------ # if($this->is_sig) { return $error; } if(isset($item['params']['param'])) { $content = $item['params']['param']; } $content = $this->process_text($content); # #-----[ AFTER, ADD ]------------------------------------ # if(isset($item['params']['type'])) { $type = $item['params']['type']; { $type = $this->process_text($type); } } if(isset($item['params']['color'])) { $color = $item['params']['color']; { $color = $this->process_text($color); } } # #-----[ FIND ]------------------------------------------ # // FLASH, SWF, VIDEO, REAL, QUICK, STREAM, EMFF, YOUTUBE, GOOGLEVIDEO if( ($tag === 'flash') || ($tag === 'swf') || ($tag === 'video') || ($tag === 'ram') || ($tag === 'quick') || ($tag === 'stream') || ($tag === 'emff') || ($tag === 'mp3') || ($tag === 'youtube') || ($tag === 'googlevideo') ) { # #-----[ REPLACE WITH ]------------------------------------ # // FLASH, SWF, VIDEO, REAL, QUICK, STREAM, EMFF, YOUTUBE, LASTFM, GOOGLEVIDEO if( ($tag === 'flash') || ($tag === 'swf') || ($tag === 'video') || ($tag === 'ram') || ($tag === 'quick') || ($tag === 'stream') || ($tag === 'emff') || ($tag === 'mp3') || ($tag === 'youtube') || ($tag === 'lastfm') || ($tag === 'googlevideo') ) { # #-----[ FIND ]------------------------------------------ # if ( ($tag === 'flash') || ($tag === 'swf') ) { $html = ' '; } # #-----[ AFTER, ADD ]------------------------------------ # elseif ($tag === 'lastfm') { $html = ''; } # #-----[ OPEN ]------------------------------------------ # includes/bbcb_mg_small.php # #-----[ FIND ]------------------------------------------ # 'L_BBCB_MG_YOUTUBE' => $lang['bbcb_mg_youtube'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_BBCB_MG_LASTFM' => $lang['bbcb_mg_lastfm'], # #-----[ FIND ]------------------------------------------ # 'L_FLASH_H_ERROR' => $lang['s_flash_h_error'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_LASTFM_INSERT' => $lang['s_lastfm_insert'], 'L_LASTFM_INSERT_ERROR' => $lang['s_lastfm_insert_error'], 'L_LASTFM_T_INSERT' => $lang['s_lastfm_t_insert'], 'L_LASTFM_T_ERROR' => $lang['s_lastfm_t_error'], 'L_LASTFM_C_INSERT' => $lang['s_lastfm_c_insert'], 'L_LASTFM_C_ERROR' => $lang['s_lastfm_c_error'], # #-----[ FIND ]------------------------------------------ # 'L_YOUTUBE_HELP' => $lang['s_youtube_help'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_LASTFM_HELP' => $lang['s_lastfm_help'], # #-----[ OPEN ]------------------------------------------ # includes/bbcb_mg.php # #-----[ FIND ]------------------------------------------ # 'L_BBCB_MG_YOUTUBE' => $lang['bbcb_mg_youtube'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_BBCB_MG_LASTFM' => $lang['bbcb_mg_lastfm'], # #-----[ FIND ]------------------------------------------ # 'L_FLASH_H_ERROR' => $lang['s_flash_h_error'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_LASTFM_INSERT' => $lang['s_lastfm_insert'], 'L_LASTFM_INSERT_ERROR' => $lang['s_lastfm_insert_error'], 'L_LASTFM_T_INSERT' => $lang['s_lastfm_t_insert'], 'L_LASTFM_T_ERROR' => $lang['s_lastfm_t_error'], 'L_LASTFM_C_INSERT' => $lang['s_lastfm_c_insert'], 'L_LASTFM_C_ERROR' => $lang['s_lastfm_c_error'], # #-----[ FIND ]------------------------------------------ # 'L_YOUTUBE_HELP' => $lang['s_youtube_help'], # #-----[ AFTER, ADD ]------------------------------------ # 'L_LASTFM_HELP' => $lang['s_lastfm_help'], # #-----[ SAVE/CLOSE ALL FILES ]-------------------------- # # EoM[/codeblock] Button image [img]http://www.icyphoenix.com/files/images/1353/lastfm.png[/img] Final result [img]http://www.icyphoenix.com/files/images/1353/lastfm_final.png[/img] Below is premodded installation. Unpack to IP root directory, overwriting all files. [b][color=red]WARNING[/color][/b]: only use premodded files if you haven't changed following files (IP 1.1.0.15a): [b]templates/mg_themes/bbcb_mg.tpl language/lang_english/bbcb_mg.js language/lang_english/lang_bbcb_mg.php includes/bbcb_mg.php includes/bbcb_mg_small.php includes/bbcode.php[/b] Also if you have installed first version of the Mod using premodded files, just overwrite existing files.