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: namespace Xoops\Core\Text\Sanitizer;
13:
14: use Xoops\Core\Text\Sanitizer;
15:
16: /**
17: * XOOPS Text/Sanitizer extension
18: *
19: * @category Sanitizer\ExtensionAbstract
20: * @package Xoops\Core\Text
21: * @author Kazumi Ono <onokazu@xoops.org>
22: * @author Goghs Cheng (http://www.eqiao.com, http://www.devbeez.com/)
23: * @author Taiwen Jiang <phppp@users.sourceforge.net>
24: * @author Richard Griffith <richard@geekwright.com>
25: * @copyright 2000-2015 XOOPS Project (http://xoops.org)
26: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
27: * @link http://xoops.org
28: */
29: abstract class ExtensionAbstract extends SanitizerComponent
30: {
31: /**
32: * Register extension with the supplied sanitizer instance
33: *
34: * was load()
35: *
36: * @return void
37: */
38: abstract public function registerExtensionProcessing();
39:
40: /**
41: * Provide button and javascript code used by the DhtmlTextArea
42: *
43: * was encode()
44: *
45: * @param string $textAreaId dom element id
46: *
47: * @return string[] editor button as HTML, supporting javascript
48: */
49: public function getDhtmlEditorSupport($textAreaId)
50: {
51: return array('', '');
52: }
53:
54: /**
55: * Convenience method to create a button for the editor
56: *
57: * @param string $textAreaId id of element passed to onclick
58: * @param string $imageName button image
59: * @param string $altText text for alt attribute
60: * @param string $onclick javascript function should expect arguments as
61: * ($textAreaId, $varArgs1, $varArgs2 ...)
62: * @param string $varArgs variable number of strings passed to onclick function
63: *
64: * @return string
65: */
66: protected function getEditorButtonHtml($textAreaId, $imageName, $altText, $onclick, $varArgs)
67: {
68: $input = func_get_args();
69: $prompts = array_slice($input, 4);
70: $altText = $this->ts->escapeForJavascript($altText);
71: $url = \Xoops::getInstance()->url('images/form/' . $imageName);
72:
73: $buttonCode = '<img src="' . $url .'"'
74: . ' alt="' . $altText .'" title="' . $altText . '"'
75: . ' onclick="' . $onclick . '(\'' . $textAreaId . '\'';
76: foreach ($prompts as $prompt) {
77: $buttonCode .= ', \'' . $this->ts->escapeForJavascript($prompt) . '\'';
78: }
79: $buttonCode .= ');" /> ';
80:
81: return $buttonCode;
82: }
83: }
84: