PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 7 This program is distributed in the hope that it will be useful,
 8 but WITHOUT ANY WARRANTY; without even the implied warranty of
 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10*/
11
12/**
13 * TextSanitizer extension
14 *
15 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17 * @package         class
18 * @subpackage      textsanitizer
19 * @since           2.3.0
20 * @author          Taiwen Jiang <phppp@users.sourceforge.net>
21 * @version         $Id: mp3.php 8271 2011-11-11 19:46:00Z trabis $
22 */
23
24defined('XOOPS_ROOT_PATH') or die('Restricted access');
25
26class MytsMp3 extends MyTextSanitizerExtension
27{
28    /**
29     * @param int $textarea_id
30     * @return array
31     */
32    public function encode($textarea_id)
33    {
34        $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;";
35        $javascript = <<<EOF
36            function xoopsCodeMp3(id, enterMp3Phrase)
37            {
38                var selection = xoopsGetSelect(id);
39                if (selection.length > 0) {
40                    var text = selection;
41                } else {
42                    var text = prompt(enterMp3Phrase, "");
43                }
44                var domobj = xoopsGetElementById(id);
45                if ( text.length > 0 ) {
46                    var result = "[mp3]" + text + "[/mp3]";
47                    xoopsInsertText(domobj, result);
48                }
49                domobj.focus();
50            }
51EOF;
52
53        return array(
54            $code, $javascript
55        );
56    }
57
58    public function load(MyTextSanitizer &$ts)
59    {
60        $ts->patterns[] = "/\[mp3\](.*?)\[\/mp3\]/es";
61        $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
62
63        return true;
64    }
65
66    /**
67     * @param string $url
68     * @return string
69     */
70    public function decode($url)
71    {
72        $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>";
73        return $rp;
74    }
75}