XOOPS BBCode for SoundCloud. (parts were taken from
http://blog.soundcloud.com/2009/07/28/soundcloud-player-in-forums-5-step-guide-for-soundcloud-bb-code/)
*Download the soundcloud image for the text editor.
download
http://bit.ly/tV7mm (from step 3 in the soundcloud blog) save it as soundcloud.png and upload it to yourdomain.com/images/form
*Go to your site and create a folder called soundcloud in:
yourdomain.com/class/textsanitizer
so it looks like
yourdomain.com/class/textsanitizer/soundcloud
* add two files to it
index.html
le="color: #000000"><?php <script>history.go(-1);</script>
soundcloud.php
<?php class MytsSoundcloud extends MyTextSanitizerExtension { function encode($textarea_id) { $config = parent::loadConfig( dirname(__FILE__) ); $code = "<img src='{$this->image_path}/soundcloud.png' alt='SoundCloud' onclick='xoopsCodeSoundCloud("{$textarea_id}","" . htmlspecialchars('Enter SoundCloud Profile URL', ENT_QUOTES) . "");' onmouseover='style.cursor="hand"'/> "; $javascript = <<<EOH function xoopsCodeSoundCloud(id, enterSoundCloud) { var selection = xoopsGetSelect(id); if (selection.length > 0) { var text = selection; } else { var text = prompt(enterSoundCloud, ""); } var domobj = xoopsGetElementById(id); xoopsInsertText(domobj, "[soundcloud]"+text+"[/soundcloud]"); domobj.focus(); } EOH; return array($code, $javascript); } function load(&$ts) { $ts->patterns[] = "/[soundcloud](http[s]?://[^"'<>]*)(.*)[/soundcloud]/esU"; $ts->replacements[] = __CLASS__ . "::decode('\1\2')"; } function decode($url) { $config = parent::loadConfig(dirname(__FILE__)); if (!preg_match("/^http://(www.)?soundcloud.com/(.*)/i", $url, $matches)) { trigger_error("Not matched: {$url}", E_USER_WARNING); return ""; } $code = '<object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url='.$url.'&g=bb">'; $code .= '</param><param name="allowscriptaccess" value="always"></param>'; $code .= '<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url='.$url.'&g=bb" type="application/x-shockwave-flash" width="100%"></embed></object>'; $code .= '<a href="'.$url.'">'.$url.'</a>'; return $code; } } ?>
I also included the soundcloud.php file here ->>
https://gist.github.com/ihackcode/d46633276fe128d1ffc0 *edit this file yourdomain.com/class/textsanitizer/config.php
enable the soundcloud bbcode in the extensions array by adding this line
"soundcloud" => 1,
Example of including the element in the array
le="color: #000000"><?php "extensions" => array( "iframe" => 0, "image" => 1, "flash" => 1, "youtube" => 1, "mp3" => 0, "wmp" => 0, // If other module is used, please modify the following detection and 'link' in /wiki/config.php "wiki" => is_dir(XOOPS_ROOT_PATH . '/modules/mediawiki/'), "mms" => 0, "rtsp" => 0, "soundcloud" => 1, "ul" => 1, "li" => 1),
now you should be able to use the SoundCloud bbcode.