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\Extensions;
13:
14: use Xoops\Core\Text\Sanitizer;
15: use Xoops\Core\Text\Sanitizer\ExtensionAbstract;
16:
17: /**
18: * TextSanitizer extension
19: *
20: * @category Sanitizer
21: * @package Xoops\Core\Text
22: * @author Taiwen Jiang <phppp@users.sourceforge.net>
23: * @copyright 2000-2015 XOOPS Project (http://xoops.org)
24: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
25: * @link http://xoops.org
26: */
27: class Iframe extends ExtensionAbstract
28: {
29: /**
30: * @var array default configuration values
31: */
32: protected static $defaultConfiguration = [
33: 'enabled' => false,
34: 'template' => '<iframe src="%1$s" width="100%%" height="%2$d" scrolling="auto" frameborder="yes" marginwidth="0" marginheight="0" sandbox></iframe>',
35: ];
36:
37: /**
38: * Register extension with the supplied sanitizer instance
39: *
40: * @return void
41: */
42: public function registerExtensionProcessing()
43: {
44: $this->shortcodes->addShortcode(
45: 'iframe',
46: function ($attributes, $content, $tagName) {
47: $height = (int) ltrim($attributes[0], '=');
48: $height = $height <10 ? 200 : $height;
49: $url = trim($content);
50: $template = $this->config['template'];
51: $newContent = sprintf($template, $url, $height);
52: return $newContent;
53: }
54: );
55: }
56: }
57: