| 1 | <?php |
|---|
| 2 | require_once(WCF_DIR.'lib/data/message/bbcode/BBCodeParser.class.php'); |
|---|
| 3 | require_once(WCF_DIR.'lib/data/message/bbcode/BBCode.class.php'); |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * BBCode for [gadget] Tag |
|---|
| 7 | * |
|---|
| 8 | * @author Torben Brodt |
|---|
| 9 | * @package com.woltlab.wcf.data.message.bbcode.gadget |
|---|
| 10 | * @license GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> |
|---|
| 11 | */ |
|---|
| 12 | class GadgetBBCode implements BBCode { |
|---|
| 13 | /** |
|---|
| 14 | * @see BBCode::getParsedTag() |
|---|
| 15 | */ |
|---|
| 16 | public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { |
|---|
| 17 | $params = isset($openingTag['attributes'][0]) ? explode(',', $openingTag['attributes'][0]) : array('100%'); |
|---|
| 18 | $pos = strpos($params[0], '%'); |
|---|
| 19 | $width = $pos === false ? intval($params[0]).'px' : intval(substr($params[0],0,$pos)).'%'; |
|---|
| 20 | |
|---|
| 21 | $myid = StringUtil::getRandomID(); |
|---|
| 22 | |
|---|
| 23 | $code = "<!-- Include the Google Friend Connect javascript library. --> |
|---|
| 24 | <script type=\"text/javascript\" src=\"http://www.google.com/friendconnect/script/friendconnect.js\"></script> |
|---|
| 25 | |
|---|
| 26 | <!-- Define the div tag where the gadget will be inserted. --> |
|---|
| 27 | <div id=\"div-".$myid."\" style=\"width:".$width.";border:1px solid #cccccc;\"></div> |
|---|
| 28 | <!-- Render the gadget into a div. --> |
|---|
| 29 | <script type=\"text/javascript\"> |
|---|
| 30 | var skin = {}; |
|---|
| 31 | skin['BORDER_COLOR'] = '#cccccc'; |
|---|
| 32 | skin['ENDCAP_BG_COLOR'] = '#e0ecff'; |
|---|
| 33 | skin['ENDCAP_TEXT_COLOR'] = '#333333'; |
|---|
| 34 | skin['ENDCAP_LINK_COLOR'] = '#0000cc'; |
|---|
| 35 | skin['ALTERNATE_BG_COLOR'] = '#ffffff'; |
|---|
| 36 | skin['CONTENT_BG_COLOR'] = '#ffffff'; |
|---|
| 37 | skin['CONTENT_LINK_COLOR'] = '#0000cc'; |
|---|
| 38 | skin['CONTENT_TEXT_COLOR'] = '#333333'; |
|---|
| 39 | skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc'; |
|---|
| 40 | skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666'; |
|---|
| 41 | skin['CONTENT_HEADLINE_COLOR'] = '#333333'; |
|---|
| 42 | google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */); |
|---|
| 43 | google.friendconnect.container.renderOpenSocialGadget( |
|---|
| 44 | { id: 'div-".$myid."', |
|---|
| 45 | url:'".$content."', |
|---|
| 46 | site: '".GOOGLE_FRIENDCONNECT."'}, |
|---|
| 47 | skin); |
|---|
| 48 | </script>"; |
|---|
| 49 | |
|---|
| 50 | if ($parser->getOutputType() == 'text/html') { |
|---|
| 51 | return $code; |
|---|
| 52 | } |
|---|
| 53 | else if ($parser->getOutputType() == 'text/plain') { |
|---|
| 54 | return $content; |
|---|
| 55 | } |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | ?> |
|---|