|
From: FlorinCB <ory...@us...> - 2009-07-11 03:22:14
|
Update of /cvsroot/mxbb/core/includes In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv23243/core/includes Modified Files: mx_functions_bbcode.php mx_functions_tools.php Log Message: some fixes not commited Index: mx_functions_tools.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_tools.php,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** mx_functions_tools.php 8 Dec 2008 23:57:18 -0000 1.52 --- mx_functions_tools.php 11 Jul 2009 03:22:06 -0000 1.53 *************** *** 165,171 **** if ($text != '' && $bbcode_uid != '') { ! $text = ($this->bbcode_on) ? $mx_bbcode->bbencode_second_pass($text, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $text); } ! if ( $text != '' ) { --- 165,173 ---- if ($text != '' && $bbcode_uid != '') { ! //$text = ($this->bbcode_on) ? $mx_bbcode->bbencode_second_pass($text, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $text); ! $text = ($this->bbcode_on) ? $mx_bbcode->decode($text, $bbcode_uid): preg_replace("/\:$bbcode_uid/si", '', $text); } ! ! /* if ( $text != '' ) { *************** *** 183,187 **** } } ! // // Highlight active words (primarily for search) --- 185,190 ---- } } ! */ ! // // Highlight active words (primarily for search) Index: mx_functions_bbcode.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_bbcode.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** mx_functions_bbcode.php 6 Nov 2008 00:45:27 -0000 1.17 --- mx_functions_bbcode.php 11 Jul 2009 03:22:06 -0000 1.18 *************** *** 121,125 **** //Start more bbcode $bbcode_tpl['stream'] = str_replace('{URL}', '\\1', $bbcode_tpl['stream']); ! //$bbcode_tpl['web'] = str_replace('{URL}', '\\1', $bbcode_tpl['web']); $bbcode_tpl['flash'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['flash']); $bbcode_tpl['flash'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['flash']); --- 121,125 ---- //Start more bbcode $bbcode_tpl['stream'] = str_replace('{URL}', '\\1', $bbcode_tpl['stream']); ! $bbcode_tpl['web'] = str_replace('{URL}', '\\1', $bbcode_tpl['web']); $bbcode_tpl['flash'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['flash']); $bbcode_tpl['flash'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['flash']); *************** *** 132,135 **** --- 132,141 ---- $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('{HEIGHT}', '\\3', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{WIDTH}', '\\4', $bbcode_tpl['ipaper']); + $bbcode_tpl['ipaper'] = str_replace('{IPAPERLINK}', $lang['Link'], $bbcode_tpl['ipaper']); + $bbcode_tpl['scribd'] = str_replace('{SCRIBDURL}', $lang['Link'], $bbcode_tpl['scribd']); //Stop more bbcode *************** *** 269,278 **** $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); --- 275,299 ---- $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\](.*?)\[/scribd\]#si"; ! $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); *************** *** 323,331 **** // [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(); --- 344,359 ---- // [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(); *************** *** 361,369 **** //Start more bbcode $text = str_replace('url:' . $uid, 'url', $text); - $text = str_replace('web:' . $uid, 'web', $text); // [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); --- 389,399 ---- //Start more bbcode $text = str_replace('url:' . $uid, 'url', $text); // [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); *************** *** 377,381 **** return substr($text, 1);; ! } // bbencode_first_pass() /** --- 407,411 ---- return substr($text, 1);; ! } // bbencode_first_pass() /** *************** *** 692,695 **** --- 722,837 ---- //phpBB Temporary code ends + + /** + * 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() /** |