|
From: FlorinCB <ory...@us...> - 2009-07-11 03:22:24
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv23243/core/includes/sessions/phpbb3 Modified Files: bbcode.php Log Message: some fixes not commited Index: bbcode.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/bbcode.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bbcode.php 25 Feb 2009 10:45:48 -0000 1.7 --- bbcode.php 11 Jul 2009 03:22:06 -0000 1.8 *************** *** 60,63 **** --- 60,69 ---- var $template_bitfield; var $template_filename = ''; + + var $site_url = ''; + var $document_id = ''; + var $access_key = ''; + var $height = 0; + var $width = 0; /** *************** *** 371,375 **** ); break; ! default: if (isset($rowset[$bbcode_id])) --- 377,382 ---- ); break; ! ! default: if (isset($rowset[$bbcode_id])) *************** *** 400,404 **** { // Default template ! $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; } --- 407,411 ---- { // Default template ! $bbcode_tpl = ($rowset[$bbcode_id]['second_pass_replace']) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; } *************** *** 487,491 **** } } ! return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false); } --- 494,499 ---- } } ! ! return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false); } *************** *** 503,508 **** 'size' => array('{SIZE}' => '$1', '{TEXT}' => '$2'), 'img' => array('{URL}' => '$1'), ! 'flash' => array('{WIDTH}' => '$1', '{HEIGHT}' => '$2', '{URL}' => '$3'), 'url' => array('{URL}' => '$1', '{DESCRIPTION}' => '$2'), 'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2') ); --- 511,519 ---- 'size' => array('{SIZE}' => '$1', '{TEXT}' => '$2'), 'img' => array('{URL}' => '$1'), ! 'flash' => array('{WIDTH}' => '$1', '{HEIGHT}' => '$2', '{URL}' => '$3'), ! 'scribd' => array('{WIDTH}' => '$1', '{HEIGHT}' => '$2', '{SCRIBDURL}' => '$3'), ! 'ipaper' => array('{IPAPERID}' => '$1', '{IPAPERKEY}' => '$2', '{WIDTH}' => '$3', '{HEIGHT}' => '$4', '{IPAPERLINK}' => '$5'), 'url' => array('{URL}' => '$1', '{DESCRIPTION}' => '$2'), + 'size' => array('{ID}' => '$1', '{TEXT}' => '$2'), 'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2') ); *************** *** 625,628 **** --- 636,640 ---- return $code; } + /** *************** *** 672,675 **** --- 684,688 ---- function prepare_bbcode_template($bbcode_tpl) { + global $document_id, $access_key, $height, $width; global $lang; *************** *** 718,721 **** --- 731,743 ---- $bbcode_tpl['youtube'] = str_replace('{YOUTUBEID}', '\\1', $bbcode_tpl['youtube']); $bbcode_tpl['youtube'] = str_replace('{YOUTUBELINK}', $lang['Link'], $bbcode_tpl['youtube']); + $bbcode_tpl['ipaper'] = str_replace('{IPAPERID}', '\\1', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{IPAPERKEY}', '\\2', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{WIDTH}', '\\3', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{HEIGHT}', '\\4', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{IPAPERLINK}', '\\5', $bbcode_tpl['ipaper']); + //$bbcode_tpl['scribd'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['scribd']); + //$bbcode_tpl['scribd'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['scribd']); + $bbcode_tpl['scribd'] = str_replace('{SCRIBDID}', '\\1', $bbcode_tpl['scribd']); + $bbcode_tpl['scribd'] = str_replace('{SCRIBDURL}', $lang['Link'], $bbcode_tpl['scribd']); //Stop more bbcode *************** *** 766,770 **** //$text = str_replace(array("\n", "\r"), array('<br />', "\n"), $text); ! $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); --- 788,792 ---- //$text = str_replace(array("\n", "\r"), array('<br />', "\n"), $text); ! $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); *************** *** 790,797 **** $bbcode_tpl = $this->prepare_bbcode_template($bbcode_tpl); } ! // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. $text = $this->bbencode_second_pass_code($text, $uid, $bbcode_tpl); ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text); --- 812,822 ---- $bbcode_tpl = $this->prepare_bbcode_template($bbcode_tpl); } ! // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. $text = $this->bbencode_second_pass_code($text, $uid, $bbcode_tpl); ! ! // [IPAPER] and [/IPAPER] for posting iPaper in your posts. ! $text = $this->bbencode_ipaper_pass_render($text, $uid, $bbcode_tpl); ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text); *************** *** 877,881 **** $patterns[] = "#\[video width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9]):$uid\](.*?)\[/video:$uid\]#si"; $replacements[] = $bbcode_tpl['video']; - $text = preg_replace($patterns, $replacements, $text); // [GVideo]GVideo URL[/GVideo] code.. --- 902,905 ---- *************** *** 883,892 **** $replacements[] = $bbcode_tpl['GVideo']; ! // [youtube]YouTube URL[/youtube] code.. ! $patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is"; $replacements[] = $bbcode_tpl['youtube']; ! //Stop more bbcode $text = preg_replace($patterns, $replacements, $text); --- 907,931 ---- $replacements[] = $bbcode_tpl['GVideo']; ! // [youtube]www.youtube.com[/youtube] ! $patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is"; $replacements[] = $bbcode_tpl['youtube']; ! // [youtube=xxxx://www.youtube.com]Youtube[/youtube] code.. ! //$patterns[] = "#\[youtube=http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})]([^?\n\r\t].*?)\[/youtube\]#is"; ! //$replacements[] = $bbcode_tpl['youtube']; ! ! // [scribd]Scribd URL[/scribd] code.. ! $patterns[] = "#\[scribd\]http://(?:d\.)?scribd.com/ScribdViewer.swf\?document_id=([0-9A-Za-z-_]*)[^[]*\[/scribd\]#is"; ! $replacements[] = $bbcode_tpl['scribd']; ! ! // [scribd]Scribd URL[/scribd] code.. ! $patterns[] = "#\[scribd id=([0-9A-Za-z-_]{8}) key=([0-9A-Za-z-_]{24})\](.*?)\[/scribd\]#is"; ! $replacements[] = $bbcode_tpl['scribd']; ! ! // [ipaper]Scribd URL[/ipaper] code.. ! $patterns[] = "#\[ipaper\]http://(?:d\.)?scribd.com/ScribdViewer.swf\?document_id=([0-9A-Za-z-_]*)\&access_key=([0-9A-Za-z-_]*)[^[]*\[/ipaper\]#is"; ! $replacements[] = $bbcode_tpl['ipaper']; + //Stop more bbcode $text = preg_replace($patterns, $replacements, $text); *************** *** 937,945 **** // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. $text = $this->bbencode_first_pass_pda($text, $uid, '[code]', '[/code]', '', true, ''); ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = $this->bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, ''); $text = $this->bbencode_first_pass_pda($text, $uid, '/\[quote=\\\\"(.*?)\\\\"\]/is', '[/quote]', '', false, '', "[quote:$uid=\\\"\\1\\\"]"); // [list] and [list=x] for (un)ordered lists. $open_tag = array(); --- 976,991 ---- // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. $text = $this->bbencode_first_pass_pda($text, $uid, '[code]', '[/code]', '', true, ''); ! // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $text = $this->bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, ''); $text = $this->bbencode_first_pass_pda($text, $uid, '/\[quote=\\\\"(.*?)\\\\"\]/is', '[/quote]', '', false, '', "[quote:$uid=\\\"\\1\\\"]"); + // [ipaper] and [/ipaper] for posting scribd embed bbcode in your posts. + $text = $this->bbencode_first_pass_pda($text, $uid, '[ipaper]', '[/ipaper]', '', true, ''); + + // [scribd] and [/scribd] for posting scribd embed bbcode in your posts. + $text = $this->bbencode_first_pass_pda($text, $uid, '[scribd]', '[/scribd]', '', false, ''); + $text = $this->bbencode_first_pass_pda($text, $uid, '/\[scribd\\\\id=([0-9A-Za-z-_]{8})\\\\key=([0-9A-Za-z-_]{24})\](.*?)\]/is', '[/scribd]', '', false, '', "[scribd:$uid=\\\id=\\1\\\key=\\2\\\]"); + // [list] and [list=x] for (un)ordered lists. $open_tag = array(); *************** *** 978,982 **** // [stream]Sound URL[/stream] code.. $text = preg_replace("#\[stream\](.*?)\[/stream\]#si", "[stream:$uid]\\1[/stream:$uid]", $text); ! // [flash width=X height=X]Flash URL[/flash] code.. $text = preg_replace("#\[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/flash\]#si","[flash width=\\1 height=\\2:$uid\]\\3[/flash:$uid]", $text); --- 1024,1031 ---- // [stream]Sound URL[/stream] code.. $text = preg_replace("#\[stream\](.*?)\[/stream\]#si", "[stream:$uid]\\1[/stream:$uid]", $text); ! ! // [scribd width=X height=X]Scribd URL[/scribd] code.. ! $text = preg_replace("#\[scribd width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/scribd\]#si","[scribd width=\\1 height=\\2:$uid\]\\3[/scribd:$uid]", $text); ! // [flash width=X height=X]Flash URL[/flash] code.. $text = preg_replace("#\[flash width=([0-6]?[0-9]?[0-9]) height=([0-4]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/flash\]#si","[flash width=\\1 height=\\2:$uid\]\\3[/flash:$uid]", $text); *************** *** 990,994 **** return substr($text, 1);; ! } // bbencode_first_pass() /** --- 1039,1044 ---- return substr($text, 1);; ! } // bbencode_first_pass() ! /** *************** *** 1303,1308 **** } // bbencode_second_pass_code() - //phpBB Temporary code ends /** --- 1353,1524 ---- } // bbencode_second_pass_code() + + /** + * Rewritten by Florin C Bodin - July 10, 2009. + * Description: Pass Embed Scibd iPaper in a post Pass + * Version: 0.2 + * Original Author: Stuart Marsh + * Author URI: http://www.beardygeek.com + * This should be used before displaying the message. + */ + function bbencode_ipaper_pass_render($text, $uid, $bbcode_tpl) + { + global $document_id, $access_key, $height, $width; + global $lang; + + $params = array('document_id','access_key','height','width'); + + $ipaper_start_html = $bbcode_tpl['ipaper_open']; + $ipaper_end_html = $bbcode_tpl['ipaper_close']; + + // First, do all the 1st-level matches. + $match_count = preg_match_all("#\[ipaper:1:$uid\](.*?)\[/ipaper:1:$uid\]#si", $text, $matches); + + for ($i = 0; $i < $match_count; $i++) + { + + $before_replace = $matches[1][$i]; + $after_replace = $matches[1][$i]; + + //Remove ipaper open and close bbcode tags. + $before_replace = str_replace(array($ipaper_start_html, $ipaper_end_html), "", $before_replace); + $after_replace = str_replace(array($ipaper_start_html, $ipaper_end_html), "", $after_replace); + $after_replace = str_replace(array('”','″'), '', $after_replace); + + // Then, do the 2nd-level matches. + $total = preg_match_all("|([^?&#=]+)=([^?&#=]+)(#{0,}[^?&#=]*)|", $after_replace, $attributes, PREG_SET_ORDER); + + if ($total) + { + $this->ipaper_head(); + } + + $arguments[] = array(); + + foreach ((array) $attributes as $elem) + { + if(!in_array($elem[$i], $params)) + { + $arguments[$elem[1]] = $elem[2]; + } + } + + if ((!array_key_exists('document_id', $arguments)) && (!array_key_exists('access_key', $arguments))) + { + return '<div style="background-color:#f99; padding:10px;">Error: Required parameter "docId" or "access_key" is missing!</div>'; + } + + // First, do all the 1st-level matches. + if (array_key_exists('document_id', $arguments)) + { + $document_id = $arguments['document_id']; + } + else + { + $document_id = ''; + } + + if (array_key_exists('access_key', $arguments)) + { + $access_key = $arguments['access_key']; + } + else + { + $access_key = 'key-'; + } + + if (array_key_exists('height', $arguments)) + { + $height = $arguments['height']; + } + else + { + $height = 600; + } + + if (array_key_exists('width', $arguments)) + { + $width = $arguments['width']; + } + else + { + $width = 400; + } + + $after_replace = ''; + $after_replace .= "\n".'<p id="embedded_flash" style="text-align: center;"><a href="http://www.scribd.com">Scribd</a></p>'."\n"; + $after_replace .= '<script type="text/javascript">iPaper('.$document_id.', \''.$access_key.'\', '.$height.', '.$width.');</script>'."\n"; + + $str_to_match = "[ipaper:1:$uid]" . $before_replace . "[/ipaper:1:$uid]"; + + $replacement = $ipaper_start_html . $after_replace . $ipaper_end_html; + + $text = str_replace($str_to_match, $replacement, $text); + + } + + // Now, do all the non-first-level matches. These are simple. + $text = str_replace("[ipaper:$uid]", $ipaper_start_html, $text); + $text = str_replace("[/ipaper:$uid]", $ipaper_end_html, $text); + + return $text; + + } //bbencode_ipaper_pass_render() + + + function ipaper_head() + { + // ------------------------------------------------------------------------- + // Extend page with additional header or footer data + // Examples: + // $mx_page->add_css_file(); // Include style dependent *.css file, eg module_path/template_path/template/theme.css + // $mx_page->add_js_file( 'includes/js.js' ); // Relative to module_root + // $mx_page->add_header_text( 'header text' ); + // $mx_page->add_footer_text( 'includes/test.txt', true ); // Relative to module_root + // Note: Included text from file (last example), will evaluate $theme and $mx_block->info variables. + // ------------------------------------------------------------------------- + + global $document_id, $access_key, $height, $width; + global $mx_page; + + $addional_header_text = ""; + + $header_text = '<script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script>'."\n"; + $header_text = '<script type="text/javascript">'."\n"; + $header_text = '<!--'."\n"; + $header_text = 'function iPaper(docId, access_key, height, width) {'."\n"; + $header_text = 'var scribd_doc = scribd.Document.getDoc(docId, access_key);'."\n"; + $header_text = 'scribd_doc.addParam(\'height\', height);'."\n"; + $header_text = 'scribd_doc.addParam(\'width\', width);'."\n"; + $header_text = 'scribd_doc.write(\'embedded_flash\');'."\n"; + $header_text = '}'."\n"; + $header_text = '//-->'."\n"; + $header_text = '</script>'; + + $addional_header_text .= "\n"."\n".$header_text; + + + if (is_object($mx_page)) + { + $mx_page->add_header_text($header_text); + + die("test"); + } + else + { + echo '<script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script>'."\n"; + echo '<script type="text/javascript">'."\n"; + echo '<!--'."\n"; + echo 'function iPaper(docId, access_key, height, width) {'."\n"; + echo 'var scribd_doc = scribd.Document.getDoc(docId, access_key);'."\n"; + echo 'scribd_doc.addParam(\'height\', height);'."\n"; + echo 'scribd_doc.addParam(\'width\', width);'."\n"; + echo 'scribd_doc.write(\'embedded_flash\');'."\n"; + echo '}'."\n"; + echo '//-->'."\n"; + echo '</script>'; + } + } /** *************** *** 1389,1392 **** --- 1605,1609 ---- $mytext = $this->bbencode_second_pass($mytext, $bbcode_uid, $bbcode_bitfield); } + if ($smilies_on && $phpbb3_text) { *************** *** 1396,1402 **** { $mytext = $this->smilies_pass($mytext); } ! $mytext = str_replace("\n", "\n<br />\n", $mytext); ! return $this->make_clickable($mytext); } --- 1613,1626 ---- { $mytext = $this->smilies_pass($mytext); + } + + //$mytext = str_replace("\n", "\n<br />\n", $mytext); + + if ($mytext != '') + { + $mytext = $this->make_clickable($mytext); } ! ! return $mytext; } |