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

Revision 139, 1.9 kB (checked in by d0nut, 5 years ago)

here is the code of deviantart bbcode 1.1 - packagerelease was two weeks ago, sorry.

  • 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-3.0.html>
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 && preg_match('/-(\d+)$/', $content, $hits)){
25                // url as input
26                        $id = intval($hits[1]);
27                } else if(strpos($content, '<object') !== false){
28                // html as input
29                        preg_match('/^<object width\="(\d+)" height\="(\d+)">.+value\="id\=(\d+)"/', $content, $hits);
30                        $width = intval($hits[1]);
31                        $height = intval($hits[2]);
32                        $id = intval($hits[3]);
33               
34                } else {
35                        return;
36                }
37               
38                // overwrite width/height from attribute
39                if(isset($openingTag['attributes'][0])) {
40                        list($width,$height) = explode("x", $openingTag['attributes'][0]);
41                }
42               
43                $width = isset($width) ? $width : $this->width;
44                $height = isset($height) ? $height : $this->height;
45               
46                $code = sprintf($this->code, $width, $height, $id, $width, $height, $id);
47
48                if ($parser->getOutputType() == 'text/html') {
49                        return $code;
50                }
51                else if ($parser->getOutputType() == 'text/plain') {
52                        return $content;
53                }
54        }
55}
56?>
Note: See TracBrowser for help on using the browser.