|
From: <rgr...@us...> - 2014-01-30 02:53:08
|
Revision: 12279
http://sourceforge.net/p/xoops/svn/12279
Author: rgriffith
Date: 2014-01-30 02:53:06 +0000 (Thu, 30 Jan 2014)
Log Message:
-----------
Add [soundcloud] BB code as supplied by iHackCode
See: http://xoops.org/modules/newbb/viewtopic.php?post_id=356724#forumpost356724
Usage: [soundcode]https://soundcloud.com/(user)/(track)[/soundcode]
Modified Paths:
--------------
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/config.php
Added Paths:
-----------
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/index.html
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/soundcloud.php
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/config.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/config.php 2014-01-26 11:40:49 UTC (rev 12278)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/config.php 2014-01-30 02:53:06 UTC (rev 12279)
@@ -31,6 +31,7 @@
"wiki" => is_dir(XOOPS_ROOT_PATH . '/modules/mediawiki/'),
"mms" => 0,
"rtsp" => 0,
+ "soundcloud" => 1,
"ul" => 1,
"li" => 1),
Added: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/index.html
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/index.html (rev 0)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/index.html 2014-01-30 02:53:06 UTC (rev 12279)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/soundcloud.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/soundcloud.php (rev 0)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/textsanitizer/soundcloud/soundcloud.php 2014-01-30 02:53:06 UTC (rev 12279)
@@ -0,0 +1,63 @@
+<?php
+
+class MytsSoundcloud extends MyTextSanitizerExtension
+{
+ public 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);
+ }
+
+ public function load(&$ts)
+ {
+ $ts->callbackPatterns[] = "/\[soundcloud\](http[s]?:\/\/[^\"'<>]*)(.*)\[\/soundcloud\]/sU";
+ $ts->callbacks[] = __CLASS__ . "::myCallback";
+
+ }
+
+ public static function myCallback($match)
+ {
+ $url = $match[1] . $match[2];
+ $config = parent::loadConfig(dirname(__FILE__));
+ if (!preg_match("/^http[s]?:\/\/(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">'
+ . '</param><param name="allowscriptaccess" value="always"></param>'
+ . '<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>'
+ . '<a href="'.$url.'">'.$url.'</a>';
+
+ return $code;
+ }
+
+// public static function decode($url1, $url2)
+// {
+// }
+
+}
|