本文整理汇总了PHP中parse_message::parse_poll方法的典型用法代码示例。如果您正苦于以下问题:PHP parse_message::parse_poll方法的具体用法?PHP parse_message::parse_poll怎么用?PHP parse_message::parse_poll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parse_message
的用法示例。
在下文中一共展示了parse_message::parse_poll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_parse_poll
/**
* @dataProvider get_test_polls
*/
public function test_parse_poll($poll, $expected, $warn_msg = array())
{
$this->prepare_s9e_services();
$message_parser = new parse_message('Me[i]s[/i]sage');
// Add some default values
$poll += array('poll_length' => 123, 'poll_start' => 123, 'poll_last_vote' => 123, 'poll_vote_change' => true, 'enable_bbcode' => true, 'enable_urls' => true, 'enable_smilies' => true, 'img_status' => true);
$message_parser->parse_poll($poll);
$this->assertSame($expected, array_intersect_key($poll, $expected));
$this->assertSame('<r>Me<I><s>[i]</s>s<e>[/i]</e></I>sage</r>', $message_parser->parse(true, true, true, true, true, true, true, false));
$this->assertSame($warn_msg, $message_parser->warn_msg);
}
示例2: isset
if ($vc_response) {
$error[] = $vc_response;
}
}
// check form
if (($submit || $preview) && !check_form_key('posting')) {
$error[] = $user->lang['FORM_INVALID'];
}
// Parse subject
if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || $mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)) {
$error[] = $user->lang['EMPTY_SUBJECT'];
}
$post_data['poll_last_vote'] = isset($post_data['poll_last_vote']) ? $post_data['poll_last_vote'] : 0;
if ($post_data['poll_option_text'] && ($mode == 'post' || $mode == 'edit' && $post_id == $post_data['topic_first_post_id']) && $auth->acl_get('f_poll', $forum_id)) {
$poll = array('poll_title' => $post_data['poll_title'], 'poll_length' => $post_data['poll_length'], 'poll_max_options' => $post_data['poll_max_options'], 'poll_option_text' => $post_data['poll_option_text'], 'poll_start' => $post_data['poll_start'], 'poll_last_vote' => $post_data['poll_last_vote'], 'poll_vote_change' => $post_data['poll_vote_change'], 'enable_bbcode' => $post_data['enable_bbcode'], 'enable_urls' => $post_data['enable_urls'], 'enable_smilies' => $post_data['enable_smilies'], 'img_status' => $img_status);
$message_parser->parse_poll($poll);
$post_data['poll_options'] = isset($poll['poll_options']) ? $poll['poll_options'] : array();
$post_data['poll_title'] = isset($poll['poll_title']) ? $poll['poll_title'] : '';
/* We reset votes, therefore also allow removing options
if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size))
{
$message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS'];
}*/
} else {
if ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) {
// The user removed all poll options, this is equal to deleting the poll.
$poll = array('poll_title' => '', 'poll_length' => 0, 'poll_max_options' => 0, 'poll_option_text' => '', 'poll_start' => 0, 'poll_last_vote' => 0, 'poll_vote_change' => 0, 'poll_options' => array());
$post_data['poll_options'] = array();
$post_data['poll_title'] = '';
$post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0;
} else {
示例3: save_raw_post_func
//.........这里部分代码省略.........
$post_data['poll_option_text'] = implode("\n", $post_data['poll_options']);
//$post_data['poll_max_options'] = request_var('poll_max_options', 1);
//$post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0;
// Parse Attachments - before checksum is calculated
$message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);
// Grab md5 'checksum' of new message
$message_md5 = md5($message_parser->message);
// Check checksum ... don't re-parse message if the same
$update_message = $mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN ? true : false;
// Parse message
if ($update_message) {
if (sizeof($message_parser->warn_msg)) {
trigger_error(join("\n", $message_parser->warn_msg));
}
$message_parser->parse($post_data['enable_bbcode'], $config['allow_post_links'] ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']);
} else {
$message_parser->bbcode_bitfield = $post_data['bbcode_bitfield'];
}
// Validate username
if ($post_data['username'] && !$user->data['is_registered'] || $mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
if (($result = validate_username($post_data['username'], !empty($post_data['post_username']) ? $post_data['post_username'] : '')) !== false) {
$user->add_lang('ucp');
trigger_error($result . '_USERNAME');
}
}
// Parse subject
if (utf8_clean_string($post_data['post_subject']) === '' && $post_data['topic_first_post_id'] == $post_id) {
trigger_error('EMPTY_SUBJECT');
}
$post_data['poll_last_vote'] = isset($post_data['poll_last_vote']) ? $post_data['poll_last_vote'] : 0;
if ($post_data['poll_option_text'] && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) {
$poll = array('poll_title' => $post_data['poll_title'], 'poll_length' => $post_data['poll_length'], 'poll_max_options' => $post_data['poll_max_options'], 'poll_option_text' => $post_data['poll_option_text'], 'poll_start' => $post_data['poll_start'], 'poll_last_vote' => $post_data['poll_last_vote'], 'poll_vote_change' => $post_data['poll_vote_change'], 'enable_bbcode' => $post_data['enable_bbcode'], 'enable_urls' => $post_data['enable_urls'], 'enable_smilies' => $post_data['enable_smilies'], 'img_status' => $img_status);
$message_parser->parse_poll($poll);
$post_data['poll_options'] = isset($poll['poll_options']) ? $poll['poll_options'] : '';
$post_data['poll_title'] = isset($poll['poll_title']) ? $poll['poll_title'] : '';
} else {
$poll = array();
}
// Check topic type
if ($post_data['topic_type'] != POST_NORMAL && $post_data['topic_first_post_id'] == $post_id) {
switch ($post_data['topic_type']) {
case POST_GLOBAL:
case POST_ANNOUNCE:
$auth_option = 'f_announce';
break;
case POST_STICKY:
$auth_option = 'f_sticky';
break;
default:
$auth_option = '';
break;
}
if (!$auth->acl_get($auth_option, $forum_id)) {
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
// Another case would be a mod not having sticky permissions for example but edit permissions.
// To prevent non-authed users messing around with the topic type we reset it to the original one.
$post_data['topic_type'] = $post_data['orig_topic_type'];
}
}
// DNSBL check
if ($config['check_dnsbl']) {
if (($dnsbl = $user->check_dnsbl('post')) !== false) {
trigger_error(sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]));
}
}
示例4: array
function run_tool()
{
global $user, $db, $config, $template;
// Prevent some errors from missing language strings.
$user->add_lang('posting');
$step = request_var('step', 0);
$limit = 500;
$start = $step * $limit;
$i = 0;
if (!class_exists('parse_message'))
{
global $phpbb_root_path, $phpEx; // required!
include(PHPBB_ROOT_PATH . "includes/message_parser." . PHP_EXT);
}
$bbcode_status = ($config['allow_bbcode']) ? true : false;
$img_status = ($bbcode_status) ? true : false;
$flash_status = ($bbcode_status && $config['allow_post_flash']) ? true : false;
$sql = 'SELECT * FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
WHERE t.topic_id = p.topic_id
ORDER BY p.post_id ASC';
$result = $db->sql_query_limit($sql, $limit, $start);
while ($row = $db->sql_fetchrow($result))
{
$i++;
// This should make the text the same as it would be coming from a new post submitted
decode_message($row['post_text'], $row['bbcode_uid']);
$row['post_text'] = html_entity_decode($row['post_text']);
set_var($row['post_text'], $row['post_text'], 'string', true);
$message_parser = new parse_message();
$message_parser->message = $row['post_text'];
$message_parser->parse((($bbcode_status) ? $row['enable_bbcode'] : false), (($config['allow_post_links']) ? $row['enable_magic_url'] : false), $row['enable_smilies'], $img_status, $flash_status, true, $config['allow_post_links']);
if ($row['poll_title'] && $row['post_id'] == $row['topic_first_post_id'])
{
$row['poll_option_text'] = '';
$sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id = ' . $row['topic_id'];
$result2 = $db->sql_query($sql);
while ($row2 = $db->sql_fetchrow($result2))
{
$row['poll_option_text'] .= $row2['poll_option_text'] . "\n";
}
$db->sql_freeresult($result2);
$poll = array(
'poll_title' => $row['poll_title'],
'poll_length' => $row['poll_length'],
'poll_max_options' => $row['poll_max_options'],
'poll_option_text' => $row['poll_option_text'],
'poll_start' => $row['poll_start'],
'poll_last_vote' => $row['poll_last_vote'],
'poll_vote_change' => $row['poll_vote_change'],
'enable_bbcode' => $row['enable_bbcode'],
'enable_urls' => $row['enable_magic_url'],
'enable_smilies' => $row['enable_smilies'],
'img_status' => $img_status,
);
$message_parser->parse_poll($poll);
}
$sql_data = array(
'post_text' => $message_parser->message,
'post_checksum' => md5($message_parser->message),
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
'bbcode_uid' => $message_parser->bbcode_uid,
);
$sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data) . '
WHERE post_id = ' . $row['post_id'];
$db->sql_query($sql);
if ($row['poll_title'] && $row['post_id'] == $row['topic_first_post_id'])
{
$sql_data = array(
'poll_title' => str_replace($row['bbcode_uid'], $message_parser->bbcode_uid, $poll['poll_title']),
);
$sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data) . '
WHERE topic_id = ' . $row['topic_id'];
$db->sql_query($sql);
$sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' WHERE topic_id = ' . $row['topic_id'];
$result2 = $db->sql_query($sql);
while ($row2 = $db->sql_fetchrow($result2))
{
$sql_data = array(
'poll_option_text' => str_replace($row['bbcode_uid'], $message_parser->bbcode_uid, $row2['poll_option_text']),
);
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data) . '
WHERE topic_id = ' . $row['topic_id'] . '
AND poll_option_id = ' . $row2['poll_option_id'];
//.........这里部分代码省略.........