root/bbcode.deviantart/files/lib/data/message/bbcode/DeviantArtBBCode.class.php @ 55

Revision 55, 1.7 kB (checked in by d0nut, 6 years ago)

initial release of deviantART bbcode

  • Property svn:executable set to *
Line 
1<?php
2require_once(WCF_DIR.'lib/data/message/bbcode/BBCodeParser.class.php');
3require_once(WCF_DIR.'lib/data/message/bbcode/BBCode.class.php');
4
5/**
6 * BBCode for [deviantart] Tag
7 *
8 * @author      Torben Brodt
9 * @package     com.woltlab.wcf.data.message.bbcode.deviantart
10 * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 */
12class DeviantArtBBCode implements BBCode {
13        protected $code = '<object width="%d" height="%d"><param name="movie" value="http://backend.deviantart.com/embed/view.swf"></param><param name="flashvars" value="id=%d" /><embed src="http://backend.deviantart.com/embed/view.swf" type="application/x-shockwave-flash" width="%d" height="%d" flashvars="id=%d"></embed></object>';
14       
15        protected $width=450, $height=450;
16
17        /**
18         * @see BBCode::getParsedTag()
19         */
20        public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) {
21                if(is_numeric($content)) {
22                // id as input
23                        $id = intval($content);
24                } else if(strpos($content, 'http://') == 0){
25                // url as input
26                        preg_match('/-(\d+)$/', $content, $hits);
27                        $id = intval($hits[1]);
28                } else if(strpos($content, '<object') == 0){
29                // html as input
30                        preg_match('/^<object width\="(\d+)" height\="(\d+)">.+value\="id\=(\d+)"/', $content, $hits);
31                        $width = intval($hits[1]);
32                        $height = intval($hits[2]);
33                        $id = intval($hits[3]);
34               
35                } else {
36                        return;
37                }
38               
39                $width = isset($width) ? $width : $this->width;
40                $height = isset($height) ? $height : $this->height;
41               
42                $code = sprintf($this->code, $width, $height, $id, $width, $height, $id);
43
44                if ($parser->getOutputType() == 'text/html') {
45                        return $code;
46                }
47                else if ($parser->getOutputType() == 'text/plain') {
48                        return $content;
49                }
50        }
51}
52?>
Note: See TracBrowser for help on using the browser.