- Timestamp:
- 01/25/08 20:43:37 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bbcode.google/files/lib/data/message/bbcode/GoogleBBCode.class.php
r151 r192 11 11 */ 12 12 class GoogleBBCode implements BBCode { 13 protected $url = 'http://www.google.%s/search?q=%s';14 protected $defaultlang = 'com';13 protected $url = 'http://www.google.%s/search?q=%s'; 14 protected $defaultlang = 'com'; 15 15 16 /**17 * @see BBCode::getParsedTag()18 */19 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) {16 /** 17 * @see BBCode::getParsedTag() 18 */ 19 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { 20 20 $lang = WCF::getLanguage()->get('wcf.bbcode.google.suffix'); 21 21 $lang = $lang == 'wcf.bbcode.google.suffix' ? $this->defaultlang : $lang; 22 $lang = isset($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : $lang; 23 $url = $content; 22 $lang = isset($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : $lang; 23 if(strpos($lang, 'http://') === false) { 24 $url = $content; 24 25 25 // remove base 26 if(strpos($content, '.google.')) { 27 $var = parse_url($url); 28 parse_str($var['query'], $output); 29 $text = $output['q']; 30 } else { 31 $text = $url; 32 $url = urlencode($url); 33 $url = sprintf($this->url, $lang, $url); 34 } 26 // remove base 27 if(strpos($content, '.google.')) { 28 $var = parse_url($url); 29 parse_str($var['query'], $output); 30 $text = $output['q']; 31 } else { 32 $text = $url; 33 $url = urlencode($url); 34 $url = sprintf($this->url, $lang, $url); 35 } 36 } else { // url format 37 $url = $lang; 38 $text = $content; 39 } 35 40 36 if ($parser->getOutputType() == 'text/html') {37 return '<a href="'.$url.'" class="google" style="background-image:url(\''.RELATIVE_WCF_DIR.'icon/wysiwyg/googleS.png\');background-repeat:no-repeat;background-position:left;padding-left:25px">'.$text.'</a>';38 }39 else if ($parser->getOutputType() == 'text/plain') {40 return $url;41 }42 }41 if ($parser->getOutputType() == 'text/html') { 42 return '<a href="'.$url.'" class="google" style="background-image:url(\''.RELATIVE_WCF_DIR.'icon/wysiwyg/googleS.png\');background-repeat:no-repeat;background-position:left;padding-left:25px">'.$text.'</a>'; 43 } 44 else if ($parser->getOutputType() == 'text/plain') { 45 return $url; 46 } 47 } 43 48 } 44 49 ?>
