/class/textsanitizer/mp3/mp3.php

https://gitlab.com/VoyaTrax/vtCMS3 · PHP · 75 lines · 40 code · 7 blank · 28 comment · 3 complexity · a6372b8029019da1f80bdf1748b6cc68 MD5 · raw file

  1. <?php
  2. /*
  3. You may not change or alter any portion of this comment or credits
  4. of supporting developers from this source code or any supporting source code
  5. which is considered copyrighted (c) material of the original comment or credit authors.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. */
  10. /**
  11. * TextSanitizer extension
  12. *
  13. * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
  14. * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
  15. * @package class
  16. * @subpackage textsanitizer
  17. * @since 2.3.0
  18. * @author Taiwen Jiang <phppp@users.sourceforge.net>
  19. * @version $Id: mp3.php 8271 2011-11-11 19:46:00Z trabis $
  20. */
  21. defined('XOOPS_ROOT_PATH') or die('Restricted access');
  22. class MytsMp3 extends MyTextSanitizerExtension
  23. {
  24. /**
  25. * @param int $textarea_id
  26. * @return array
  27. */
  28. public function encode($textarea_id)
  29. {
  30. $code = "<img src='{$this->image_path}/mp3.gif' alt='" . _XOOPS_FORM_ALTMP3 . "' onclick='xoopsCodeMp3(\"{$textarea_id}\",\"" . htmlspecialchars(_XOOPS_FORM_ENTERMP3URL, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"'/>&nbsp;";
  31. $javascript = <<<EOF
  32. function xoopsCodeMp3(id, enterMp3Phrase)
  33. {
  34. var selection = xoopsGetSelect(id);
  35. if (selection.length > 0) {
  36. var text = selection;
  37. } else {
  38. var text = prompt(enterMp3Phrase, "");
  39. }
  40. var domobj = xoopsGetElementById(id);
  41. if ( text.length > 0 ) {
  42. var result = "[mp3]" + text + "[/mp3]";
  43. xoopsInsertText(domobj, result);
  44. }
  45. domobj.focus();
  46. }
  47. EOF;
  48. return array(
  49. $code, $javascript
  50. );
  51. }
  52. public function load(MyTextSanitizer &$ts)
  53. {
  54. $ts->patterns[] = "/\[mp3\](.*?)\[\/mp3\]/es";
  55. $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
  56. return true;
  57. }
  58. /**
  59. * @param string $url
  60. * @return string
  61. */
  62. public function decode($url)
  63. {
  64. $rp = "<embed flashvars=\"playerID=1&amp;bg=0xf8f8f8&amp;leftbg=0x3786b3&amp;lefticon=0x78bee3&amp;rightbg=0x3786b3&amp;rightbghover=0x78bee3&amp;righticon=0x78bee3&amp;righticonhover=0x3786b3&amp;text=0x666666&amp;slider=0x3786b3&amp;track=0xcccccc&amp;border=0x666666&amp;loader=0x78bee3&amp;loop=no&amp;soundFile={$url}\" quality='high' menu='false' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" . XOOPS_URL . "/images/form/player.swf' width=290 height=24 type='application/x-shockwave-flash'></embed>";
  65. return $rp;
  66. }
  67. }