|
From: Florin C B. <ory...@us...> - 2013-04-26 14:14:35
|
Update of /cvsroot/mxbb/core/modules/mx_phpbb3blocks In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11612 Modified Files: mx_announce.php Log Message: phpBB3 bbcode update Index: mx_announce.php =================================================================== RCS file: /cvsroot/mxbb/core/modules/mx_phpbb3blocks/mx_announce.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mx_announce.php 18 Apr 2013 00:43:13 -0000 1.7 --- mx_announce.php 26 Apr 2013 14:14:33 -0000 1.8 *************** *** 114,117 **** --- 114,134 ---- $attach_array = $attach_list = $post_list = $posts = $attachments = $extensions = array(); + // Was a highlight request part of the URI? + $highlight_match = $highlight = ''; + if ($hilit_words) + { + foreach (explode(' ', trim($hilit_words)) as $word) + { + if (trim($word)) + { + $word = str_replace('\*', '\w+?', preg_quote($word, '#')); + $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word); + $highlight_match .= (($highlight_match != '') ? '|' : '') . $word; + } + } + + $highlight = urlencode($hilit_words); + } + $time_now = time(); $min_topic_time = time() - ( $announce_nbr_days * 86400 ); *************** *** 160,181 **** $postrow = array(); ! while( $row = $db->sql_fetchrow($result) ) { ! // Do post have an attachment? If so, add them to the list / ! if ($row['post_attachment'] && $board_config['allow_attachments']) { ! $attach_list = $row['post_id']; ! $attach_list_forums = $row['forum_id']; ! if ($row['post_approved']) { ! $has_attachments = true; } } - $postrow[] = $row; } $total_posts = count($postrow); $db->sql_freeresult($result); ! if (!intval($total_posts)) { --- 177,240 ---- $postrow = array(); ! while($row = $db->sql_fetchrow($result)) { ! if ($phpbb_auth->acl_get('f_read', $row['forum_id']) || $row['forum_id'] == 0) { ! // Do post have an attachment? If so, add them to the list / ! if ($row['post_attachment'] && $board_config['allow_attachments']) ! { ! $attach_list = $row['post_id']; ! $attach_list_forums = $row['forum_id']; ! if ($row['post_approved']) ! { ! $has_attachments = true; ! } ! } ! $postrow[] = $row; ! $post_list[$i++] = $row['post_id']; ! ! // store all data for now // ! $rowset[$row['post_id']] = array( ! 'post_id' => $row['post_id'], ! 'post_text' => $row['post_text'], ! 'topic_id' => $row['topic_id'], ! 'forum_id' => $row['forum_id'], ! 'post_id' => $row['post_id'], ! 'poster_id' => $row['poster_id'], ! 'topic_replies' => $row['topic_replies'], ! 'topic_title' => $row['topic_title'], ! 'topic_type' => $row['topic_type'], ! 'topic_status' => $row['topic_status'], ! 'username' => $row['username'], ! 'user_colour' => $row['user_colour'], ! 'poll_title' => ($row['poll_title']) ? true : false, ! 'post_time' => $mx_user->format_date($row['post_time']), ! 'topic_time' => $mx_user->format_date($row['topic_time']), ! 'post_approved' => $row['post_approved'], ! 'post_attachment' => $row['post_attachment'], ! 'bbcode_bitfield' => $row['bbcode_bitfield'], ! 'bbcode_uid' => $row['bbcode_uid'], ! 'enable_bbcode' => $row['enable_bbcode'], ! 'bbcode_options' => (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) + (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) + (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0), ! ); ! ! // Define the global bbcode bitfield, will be used to load bbcodes ! $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); ! ! // build a list of allowed posts containing attachments // ! if ($row['post_attachment'] && $board_config['allow_attachments']) { ! $attach_array[$j++] = $row['post_id']; ! $extensions .= $mx_backend->obtain_attach_extensions($row['forum_id']); } } } + $db->sql_freeresult($result); + $total_posts = count($postrow); $db->sql_freeresult($result); ! ! //If there are no posts: hide block if (!intval($total_posts)) { *************** *** 185,241 **** } ! for( $i = 0; $i < $total_posts; $i++ ) { $poster_id = $postrow[$i]['user_id']; $poster = mx_get_username_string('username', $poster_id, $postrow[$i]['username'], $postrow[$i]['topic_first_poster_colour']); $post_date = $mx_user->format_date($postrow[$i]['post_time']); - - $title = $postrow[$i]['topic_title']; $bbcode_uid = $postrow[$i]['bbcode_uid']; ! $title = $mx_bbcode->decode($title, $bbcode_uid); ! $message = $postrow[$i]['post_text']; - $bbcode_uid = $postrow[$i]['bbcode_uid']; ! $bbcode_bitfield = $postrow[$i]['bbcode_bitfield'] ? $postrow[$i]['bbcode_bitfield'] : true; ! // build a list of allowed posts containing attachments // ! if ($postrow[$i]['post_attachment'] && $board_config['allow_attachments']) { ! //global $mx_cache; ! $attach_array[$j++] = $postrow[$i]['post_id']; ! ! $extensions .= $mx_cache->obtain_attach_extensions($postrow[$i]['forum_id']); ! } ! // Pull attachment data ! if (sizeof($attach_list)) { ! if ($phpbb_auth->acl_get('u_download')) ! { ! $sql = 'SELECT * ! FROM ' . ATTACHMENTS_TABLE . ' ! WHERE ' . $db->sql_in_set('post_msg_id', $attach_array) . ' ! ORDER BY filetime DESC'; ! $result = $db->sql_query($sql, $block_cache_time); ! ! while($row = $db->sql_fetchrow($result)) ! { ! $attachments[$row['post_msg_id']][] = $row; ! } ! $db->sql_freeresult($result); ! } ! else ! { ! $display_notice = true; ! } ! } ! $message = $mx_bbcode->decode($message, $bbcode_uid, true, $bbcode_bitfield); ! $message = $mx_text_formatting->truncate_text($message, $announce_truncate, true); ! $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $postrow[$i]['topic_title']) : $postrow[$i]['topic_title']; $replies = $postrow[$i]['topic_replies']; $topic_type = $postrow[$i]['topic_type']; ! if ( $topic_type == POST_ANNOUNCE ) { --- 244,330 ---- } ! // Pull attachment data ! if (sizeof($attach_list)) { + if ($phpbb_auth->acl_get('u_download')) + { + $sql = 'SELECT * + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_msg_id', $attach_array) . ' + ORDER BY filetime DESC'; + $result = $db->sql_query($sql, $block_cache_time); + + while($row = $db->sql_fetchrow($result)) + { + $attachments[$row['post_msg_id']][] = $row; + } + $db->sql_freeresult($result); + } + else + { + $display_notice = true; + } + } + + // Instantiate BBCode if need be + if ($bbcode_bitfield !== '') + { + $mx_bbcode = new mx_bbcode(base64_encode($bbcode_bitfield)); + } + + for ($i = 0; $i < $total_posts; $i++) + { + if (!isset($rowset[$post_list[$i]])) + { + continue; + } + + //Do do: Do we use row insted of postrow[] to simplify the code ? + $row =& $rowset[$post_list[$i]]; + //Prepare variables $poster_id = $postrow[$i]['user_id']; $poster = mx_get_username_string('username', $poster_id, $postrow[$i]['username'], $postrow[$i]['topic_first_poster_colour']); $post_date = $mx_user->format_date($postrow[$i]['post_time']); $bbcode_uid = $postrow[$i]['bbcode_uid']; ! $bbcode_bitfield = $postrow[$i]['bbcode_bitfield'] ? $postrow[$i]['bbcode_bitfield'] : false; ! ! $title = $postrow[$i]['topic_title']; ! //Replacement for phpBB3::generate_text_for_display() ! $title = $mx_bbcode->decode($title, $bbcode_uid, false, $bbcode_bitfield); ! ! // Replace naughty words such as farty pants: Moved to MX_BBCode decode() ! //$postrow[$i]['post_subject'] = mx_censor_text($postrow[$i]['post_subject']); ! $message = $postrow[$i]['post_text']; ! // Size the message to max length ! $message = $mx_text_formatting->truncate_text($message, $announce_truncate, true); ! //Replacement for phpBB3::generate_text_for_display() ! $message = $mx_bbcode->decode($message, $bbcode_uid, true, $bbcode_bitfield); ! //$message = phpBB3::generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']); ! ! // Assign inline attachments ! $update_count = array(); ! if (!empty($attachments[$postrow[$i]['post_id']])) { ! parse_attachments($postrow[$i]['forum_id'], $message, $attachments[$postrow[$i]['post_id']], $update_count); ! } ! ! ! // Highlight active words (primarily for search) ! /* ! if ($highlight_match) { ! $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message); ! $postrow[$i]['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $postrow[$i]['post_subject']); ! } ! */ ! $topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, $postrow[$i]['topic_title']) : $postrow[$i]['topic_title']; $replies = $postrow[$i]['topic_replies']; $topic_type = $postrow[$i]['topic_type']; ! if ( $topic_type == POST_ANNOUNCE ) { *************** *** 475,479 **** --- 564,580 ---- } */ + if (!empty($attachments[$row['post_id']])) + { + foreach ($attachments[$row['post_id']] as $attachment) + { + $template->assign_block_vars('postrow.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + unset($rowset[$post_list[$i]]); + unset($attachments[$row['post_id']]) } + unset($rowset, $postrow); $template->set_filenames(array( *************** *** 484,488 **** 'BLOCK_SIZE' => (!empty($block_size) ? $block_size : '100%'), 'U_PHPBB_ROOT_PATH' => PHPBB_URL, ! 'TEMPLATE_ROOT_PATH' => TEMPLATE_ROOT_PATH )); --- 585,593 ---- 'BLOCK_SIZE' => (!empty($block_size) ? $block_size : '100%'), 'U_PHPBB_ROOT_PATH' => PHPBB_URL, ! 'TEMPLATE_ROOT_PATH' => TEMPLATE_ROOT_PATH, ! ! 'S_ANNOUNCEMENTS_COUNT_ASKED' => sizeof($posts), ! 'S_ANNOUNCEMENTS_COUNT_RETURNED' => sizeof($post_list), ! 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $mx_user->theme['imageset_path'] . '/imageset/' . $mx_user->data['user_lang'] )); |