本文整理汇总了PHP中qa_when_to_html函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_when_to_html函数的具体用法?PHP qa_when_to_html怎么用?PHP qa_when_to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_when_to_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cs_events
function cs_events($limit = 10, $events_type = false)
{
if (!$events_type) {
$events_type = array('q_post', 'a_post', 'c_post', 'a_select', 'badge_awarded');
}
// query last 3 events
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT datetime,ipaddress,handle,event,params FROM ^eventlog WHERE event IN ("q_post", "a_post", "c_post") ORDER BY datetime DESC LIMIT #', $limit));
if (empty($posts)) {
return;
}
$postids = '';
$i = 1;
foreach ($posts as $post) {
$params = preg_replace('/\\s+/', '&', $post['params']);
parse_str($params, $data);
$postids .= ($i != 1 ? ', ' : '') . $data['postid'];
$i++;
}
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.handle FROM ^posts, ^users WHERE (^posts.userid=^users.userid AND ^posts.postid IN (' . $postids . ')) AND ^posts.type IN ("Q", "A", "C") ORDER BY ^posts.created DESC'));
$o = '<ul class="ra-activity">';
foreach ($posts as $p) {
$event_name = '';
$event_icon = '';
if ($p['type'] == 'Q') {
$event_name = qa_lang('cleanstrap/asked');
$event_icon = 'icon-question';
} else {
if ($p['type'] == 'A') {
$event_name = qa_lang('cleanstrap/answered');
$event_icon = 'icon-answer';
} else {
$event_name = qa_lang('cleanstrap/commented');
$event_icon = 'icon-chat';
}
}
$username = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : htmlspecialchars($p['handle']);
$usernameLink = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : '<a href="' . qa_path_html('user/' . $p['handle']) . '">' . $p['handle'] . '</a>';
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$time = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
$o .= '<li class="event-item">';
$o .= '<div class="event-inner">';
$o .= '<div class="event-icon pull-left ' . $event_icon . '"></div>';
$o .= '<div class="event-content">';
$o .= '<p class="title"><strong class="avatar" data-handle="' . $p['handle'] . '" data-id="' . $p['userid'] . '">' . @$usernameLink . '</strong> <span class="what">' . $event_name . '</span></p>';
if ($p['type'] == 'Q') {
$o .= '<a class="event-title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate($p['title'], 100) . '</a>';
} elseif ($p['type'] == 'A') {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
} else {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
}
$o .= '<span class="time">' . $time . '</span>';
$o .= '</div>';
$o .= '</div>';
$o .= '</li>';
}
$o .= '</ul>';
return $o;
}
示例2: cs_user_post_list
function cs_user_post_list($handle, $type, $limit)
{
$userid = qa_handle_to_userid($handle);
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$post = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ^posts.userid=# ORDER BY ^posts.created DESC LIMIT #', $type, $userid, $limit));
$output = '<ul class="question-list users-post-widget post-type-' . $type . '">';
if (count($post) > 0) {
foreach ($post as $p) {
if ($type == 'Q') {
$what = qa_lang_html('cleanstrap/asked');
} elseif ($type == 'A') {
$what = qa_lang_html('cleanstrap/answered');
} elseif ('C') {
$what = qa_lang_html('cleanstrap/commented');
}
$handle = $p['handle'];
$output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
if ($type == 'Q') {
$output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span>' . qa_lang_html('cleanstrap/ans') . '</span></div>';
} elseif ($type == 'A') {
$output .= '<div class="big-ans-count pull-left icon-answer"></div>';
} elseif ($type == 'C') {
$output .= '<div class="big-ans-count pull-left icon-comment icon-comments"></div>';
}
$output .= '<div class="list-right">';
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
if ($type == 'Q') {
$output .= '<h5><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></h5>';
} elseif ($type == 'A') {
$output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>';
} else {
$output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>';
}
$output .= '<div class="list-date"><span class="icon-clock">' . $when . '</span>';
$output .= '<span class="icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span></div>';
$output .= '</div>';
$output .= '</li>';
}
} else {
if ($type == 'Q') {
$what = 'questions';
} elseif ($type == 'A') {
$what = 'answers';
} elseif ('C') {
$what = 'comments';
}
$output .= '<li class="no-post-found">' . qa_lang('cleanstrap/no_' . $what) . ' </li>';
}
$output .= '</ul>';
echo $output;
}
示例3: carousel_item
function carousel_item($type, $limit, $col_item = 1)
{
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$post = qa_db_query_sub('SELECT * FROM ^postmetas, ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ( ^postmetas.postid = ^posts.postid and ^postmetas.title = "featured_question" ) ORDER BY ^posts.created DESC LIMIT #', $type, $limit);
$output = '<div class="item"><div class="row">';
$i = 1;
while ($p = mysql_fetch_array($post)) {
if ($type == 'Q') {
$what = qa_lang('cleanstrap/asked');
} elseif ($type == 'A') {
$what = qa_lang('cleanstrap/answered');
} elseif ('C') {
$what = qa_lang('cleanstrap/commented');
}
$handle = $p['handle'];
if ($type == 'Q') {
$link_header = '<a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">';
} elseif ($type == 'A') {
$link_header = '<a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">';
} else {
$link_header = '<a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">';
}
$output .= '<div class="slider-item col-sm-' . 12 / $col_item . '">';
$output .= '<div class="slider-item-inner">';
$featured_img = get_featured_thumb($p['postid']);
if ($featured_img) {
$output .= $link_header . '<div class="featured-image">' . $featured_img . '</div></a>';
}
if ($type == 'Q') {
$output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span> ans</span></div>';
} elseif ($type == 'A') {
$output .= '<div class="big-ans-count pull-left vote">' . $p['netvotes'] . '<span>' . qa_lang('cleanstrap/vote') . '</span></div>';
}
$output .= '<h5>' . $link_header . cs_truncate(qa_html($p['title']), 50) . '</a></h5>';
$output .= '<div class="meta">';
$when = qa_when_to_html(strtotime($p['created']), 7);
$avatar = cs_get_avatar($handle, 15, false);
if ($avatar) {
$output .= '<img src="' . $avatar . '" />';
}
$output .= '<span class="icon-time">' . implode(' ', $when) . '</span>';
$output .= '<span class="vote-count">' . $p['netvotes'] . ' ' . qa_lang('cleanstrap/votes') . '</span></div>';
$output .= '</div>';
$output .= '</div>';
if ($col_item == $i) {
$output .= '</div></div><div class="item active"><div class="row">';
}
$i++;
}
$output .= '</div></div>';
return $output;
}
示例4: cs_post_list
function cs_post_list($type, $limit, $return = false)
{
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.* FROM ^posts, ^users WHERE ^posts.userid=^users.userid AND ^posts.type=$ ORDER BY ^posts.created DESC LIMIT #', $type, $limit));
$output = '<ul class="posts-list">';
foreach ($posts as $p) {
if ($type == 'Q') {
$what = qa_lang_html('cleanstrap/asked');
} elseif ($type == 'A') {
$what = qa_lang_html('cleanstrap/answered');
} elseif ('C') {
$what = qa_lang_html('cleanstrap/commented');
}
$handle = $p['handle'];
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
$output .= '<li>';
$output .= cs_get_post_avatar($p, $p['userid'], 30, true);
$output .= '<div class="post-content">';
if ($type == 'Q') {
$output .= '<a class="title question" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a>';
} elseif ($type == 'A') {
$output .= '<a class="title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
} else {
$output .= '<a class="title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
}
$output .= '<div class="meta">';
//$output .= '<span><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what . '</span>';
if ($type == 'Q') {
$output .= '<span>' . qa_lang_sub('cleanstrap/x_answers', $p['acount']) . '</span>';
}
$output .= '<span class="time icon-time">' . $when . '</span>';
$output .= '<span class="vote-count icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span>';
$output .= '</div>';
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
if ($return) {
return $output;
}
echo $output;
}
示例5: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$widget_opt = @$themeobject->current_widget['param']['options'];
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
if (@$qa_content['q_view']['raw']['type'] != 'Q') {
// question might not be visible, etc...
return;
}
$questionid = $qa_content['q_view']['raw']['postid'];
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
$questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, (int) $widget_opt['count']));
$minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
foreach ($questions as $key => $question) {
if ($question['score'] < $minscore) {
unset($questions[$key]);
}
}
$titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title');
if (@$themeobject->current_widget['param']['locations']['show_title']) {
$themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/related_questions') . '</h3>');
}
$themeobject->output('<div class="ra-rq-widget">');
$themeobject->output('<ul>');
foreach ($questions as $p) {
$timeCode = qa_when_to_html($p['created'], 7);
$when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
$themeobject->output('<li>' . cs_get_post_avatar($p, $p['userid'], 30, true));
$themeobject->output('<div class="post-content">');
$themeobject->output('<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '">' . qa_html($p['title']) . '</a>');
$themeobject->output('<div class="meta">');
$themeobject->output('<span>' . qa_lang_sub('cleanstrap/x_answers', $p['acount']) . '</span>');
$themeobject->output('<span class="time icon-time">' . $when . '</span>');
$themeobject->output('<span class="vote-count icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span>');
$themeobject->output('</div>');
$themeobject->output('</div>');
$themeobject->output('</li>');
}
$themeobject->output('</ul>');
$themeobject->output('</div>');
}
示例6: qa_any_to_q_html_fields
$htmloptions['answersview'] = false;
$htmloptions['viewsview'] = false;
$htmloptions['updateview'] = false;
$htmloptions['contentview'] = true;
$htmloptions['flagsview'] = true;
$htmloptions['elementid'] = $elementid;
$htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) {
// link directly to relevant content
$htmlfields['url'] = $htmlfields['what_url'];
}
$htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) {
$updated = @$question[isset($question['opostid']) ? 'oupdated' : 'updated'];
if (isset($updated)) {
$htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']);
}
}
$buttons = array();
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
if (!qa_user_post_permit_error('permit_hide_show', $question)) {
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons['reshow'] = array('tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_reshow" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/reshow_button'), 'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)));
}
if (!qa_user_post_permit_error('permit_delete_hidden', $question) && !$dependcounts[$qhiddenpostid[$key]]) {
// Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
$buttons['delete'] = array('tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)));
}
if (count($buttons)) {
$htmlfields['form'] = array('style' => 'light', 'buttons' => $buttons);
}
示例7: qa_other_to_q_html_fields
function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'app/updates.php';
$fields = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options);
switch ($question['obasetype'] . '-' . @$question['oupdatetype']) {
case 'Q-':
$langstring = 'main/asked';
break;
case 'Q-' . QA_UPDATE_VISIBLE:
if (@$question['opersonal']) {
$langstring = $question['hidden'] ? 'misc/your_q_hidden' : 'misc/your_q_reshown';
} else {
$langstring = $question['hidden'] ? 'main/hidden' : 'main/reshown';
}
break;
case 'Q-' . QA_UPDATE_CLOSED:
if (@$question['opersonal']) {
$langstring = isset($question['closedbyid']) ? 'misc/your_q_closed' : 'misc/your_q_reopened';
} else {
$langstring = isset($question['closedbyid']) ? 'main/closed' : 'main/reopened';
}
break;
case 'Q-' . QA_UPDATE_TAGS:
$langstring = @$question['opersonal'] ? 'misc/your_q_retagged' : 'main/retagged';
break;
case 'Q-' . QA_UPDATE_CATEGORY:
$langstring = @$question['opersonal'] ? 'misc/your_q_recategorized' : 'main/recategorized';
break;
case 'A-':
$langstring = @$question['opersonal'] ? 'misc/your_q_answered' : 'main/answered';
break;
case 'A-' . QA_UPDATE_SELECTED:
$langstring = @$question['opersonal'] ? 'misc/your_a_selected' : 'main/answer_selected';
break;
case 'A-' . QA_UPDATE_VISIBLE:
if (@$question['opersonal']) {
$langstring = $question['ohidden'] ? 'misc/your_a_hidden' : 'misc/your_a_reshown';
} else {
$langstring = $question['ohidden'] ? 'main/hidden' : 'main/answer_reshown';
}
break;
case 'A-' . QA_UPDATE_CONTENT:
$langstring = @$question['opersonal'] ? 'misc/your_a_edited' : 'main/answer_edited';
break;
case 'Q-' . QA_UPDATE_FOLLOWS:
$langstring = @$question['opersonal'] ? 'misc/your_a_questioned' : 'main/asked_related_q';
break;
case 'C-':
$langstring = 'main/commented';
break;
case 'C-' . QA_UPDATE_C_FOR_Q:
$langstring = @$question['opersonal'] ? 'misc/your_q_commented' : 'main/commented';
break;
case 'C-' . QA_UPDATE_C_FOR_A:
$langstring = @$question['opersonal'] ? 'misc/your_a_commented' : 'main/commented';
break;
case 'C-' . QA_UPDATE_FOLLOWS:
$langstring = @$question['opersonal'] ? 'misc/your_c_followed' : 'main/commented';
break;
case 'C-' . QA_UPDATE_TYPE:
$langstring = @$question['opersonal'] ? 'misc/your_c_moved' : 'main/comment_moved';
break;
case 'C-' . QA_UPDATE_VISIBLE:
if (@$question['opersonal']) {
$langstring = $question['ohidden'] ? 'misc/your_c_hidden' : 'misc/your_c_reshown';
} else {
$langstring = $question['ohidden'] ? 'main/hidden' : 'main/comment_reshown';
}
break;
case 'C-' . QA_UPDATE_CONTENT:
$langstring = @$question['opersonal'] ? 'misc/your_c_edited' : 'main/comment_edited';
break;
case 'Q-' . QA_UPDATE_CONTENT:
default:
$langstring = @$question['opersonal'] ? 'misc/your_q_edited' : 'main/edited';
break;
}
$fields['what'] = qa_lang_html($langstring);
if (@$question['opersonal']) {
$fields['what_your'] = true;
}
if ($question['obasetype'] != 'Q' || @$question['oupdatetype'] == QA_UPDATE_FOLLOWS) {
$fields['what_url'] = qa_q_path_html($question['postid'], $question['title'], false, $question['obasetype'], $question['opostid']);
}
if (@$options['contentview'] && !empty($question['ocontent'])) {
$viewer = qa_load_viewer($question['ocontent'], $question['oformat']);
$fields['content'] = $viewer->get_html($question['ocontent'], $question['oformat'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow']));
}
if (@$options['whenview']) {
$fields['when'] = qa_when_to_html($question['otime'], @$options['fulldatedays']);
}
if (@$options['whoview']) {
$isbyuser = qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => @$question['ocookieid']), $userid, $cookieid);
$fields['who'] = qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? @$question['oip'] : null, false, @$question['oname']);
if (isset($question['opoints'])) {
if (@$options['pointsview']) {
//.........这里部分代码省略.........
示例8: qa_content_prepare
}
}
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml);
$qa_content['error'] = @$errors['page'];
if (isset($loginuserid) && $loginuserid != $useraccount['userid'] && !QA_FINAL_EXTERNAL_USERS) {
$favoritemap = qa_get_favorite_non_qs_map();
$favorite = @$favoritemap['user'][$useraccount['userid']];
$qa_content['favorite'] = qa_favorite_form(QA_ENTITY_USER, $useraccount['userid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle));
}
$qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
// General information about the user, only available if we're using internal user management
if (!QA_FINAL_EXTERNAL_USERS) {
$membertime = qa_time_to_string(qa_opt('db_time') - $useraccount['created']);
$joindate = qa_when_to_html($useraccount['created'], 0);
$qa_content['form_profile'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('avatar' => array('type' => 'image', 'style' => 'tall', 'label' => '', 'html' => qa_get_user_avatar_html($useraccount['flags'], $useraccount['email'], $useraccount['handle'], $useraccount['avatarblobid'], $useraccount['avatarwidth'], $useraccount['avatarheight'], qa_opt('avatar_profile_size')), 'id' => 'avatar'), 'removeavatar' => null, 'duration' => array('type' => 'static', 'label' => qa_lang_html('users/member_for'), 'value' => qa_html($membertime . ' (' . qa_lang_sub('main/since_x', $joindate['data']) . ')'), 'id' => 'duration'), 'level' => array('type' => 'static', 'label' => qa_lang_html('users/member_type'), 'tags' => 'name="level"', 'value' => qa_html(qa_user_level_string($useraccount['level'])), 'note' => $useraccount['flags'] & QA_USER_FLAGS_USER_BLOCKED && isset($maxlevelassign) ? qa_lang_html('users/user_blocked') : '', 'id' => 'level')));
if (empty($qa_content['form_profile']['fields']['avatar']['html'])) {
unset($qa_content['form_profile']['fields']['avatar']);
}
// Private message link
if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) {
$qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array('^1' => '<a href="' . qa_path_html('message/' . $handle) . '">', '^2' => '</a>'));
}
// Levels editing or viewing (add category-specific levels)
if ($userediting) {
if (isset($maxlevelassign)) {
$qa_content['form_profile']['fields']['level']['type'] = 'select';
$showlevels = array(QA_USER_LEVEL_BASIC);
if (qa_opt('moderate_users')) {
$showlevels[] = QA_USER_LEVEL_APPROVED;
示例9: get_full_post
function get_full_post($post, $options, $usershtml)
{
$fields['raw'] = $post;
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
$fields['netvotes_raw'] = (int) $post['netvotes'];
$postid = $post['postid'];
$isquestion = $post['basetype'] == 'Q';
$isanswer = $post['basetype'] == 'A';
$isbyuser = @$post['userid'] == $userid;
$anchor = urlencode(qa_anchor($post['basetype'], $postid));
$elementid = isset($options['elementid']) ? $options['elementid'] : $anchor;
$microformats = false;
$isselected = @$options['isselected'];
// content
if (@$options['contentview'] && !empty($post['content'])) {
$viewer = qa_load_viewer($post['content'], $post['format']);
$fields['content'] = $viewer->get_html($post['content'], $post['format'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow']));
}
if ($post['hidden']) {
$fields['vote_state'] = 'disabled';
} elseif ($isbyuser) {
$fields['vote_state'] = 'disabled';
} elseif (@$post['uservote'] > 0) {
$fields['vote_state'] = 'voted_up';
} elseif (@$post['uservote'] < 0) {
$fields['vote_state'] = 'voted_down';
} else {
if (strpos($options['voteview'], '-uponly-level')) {
$fields['vote_state'] = 'up_only';
} else {
$fields['vote_state'] = 'enabled';
}
}
// Created when and by whom
$fields['meta_order'] = qa_lang_html('main/meta_order');
// sets ordering of meta elements which can be language-specific
if (@$options['whatview']) {
$fields['what'] = qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented'));
if (@$options['whatlink'] && !$isquestion) {
$fields['what_url'] = qa_path_html(qa_request(), array('show' => $postid), null, null, qa_anchor($post['basetype'], $postid));
}
}
if (isset($post['created']) && @$options['whenview']) {
$fields['when'] = qa_when_to_html($post['created'], @$options['fulldatedays']);
}
if (@$options['whoview']) {
$fields['who'] = qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microformats);
if (isset($post['points'])) {
if (@$options['pointsview']) {
$fields['who']['points'] = $post['points'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($post['points'])));
}
if (isset($options['pointstitle'])) {
$fields['who']['title'] = qa_get_points_title_html($post['points'], $options['pointstitle']);
}
}
if (isset($post['level'])) {
$fields['who']['level'] = qa_html(qa_user_level_string($post['level']));
}
}
$isselected = @$options['isselected'];
// Updated when and by whom
if (isset($post['opostid'])) {
// updated meta
switch ($post['obasetype'] . '-' . @$post['oupdatetype']) {
case 'Q-':
$langstring = 'main/asked';
break;
case 'Q-' . QA_UPDATE_VISIBLE:
$langstring = $post['hidden'] ? 'main/hidden' : 'main/reshown';
break;
case 'Q-' . QA_UPDATE_CLOSED:
$langstring = isset($post['closedbyid']) ? 'main/closed' : 'main/reopened';
break;
case 'Q-' . QA_UPDATE_TAGS:
$langstring = 'main/retagged';
break;
case 'Q-' . QA_UPDATE_CATEGORY:
$langstring = 'main/recategorized';
break;
case 'A-':
$langstring = 'main/answered';
break;
case 'A-' . QA_UPDATE_SELECTED:
$langstring = 'main/answer_selected';
break;
case 'A-' . QA_UPDATE_VISIBLE:
$langstring = $post['ohidden'] ? 'main/hidden' : 'main/answer_reshown';
break;
case 'A-' . QA_UPDATE_CONTENT:
$langstring = 'main/answer_edited';
break;
case 'Q-' . QA_UPDATE_FOLLOWS:
$langstring = 'main/asked_related_q';
break;
case 'C-':
$langstring = 'main/commented';
break;
case 'C-' . QA_UPDATE_TYPE:
$langstring = 'main/comment_moved';
//.........这里部分代码省略.........
示例10: qa_post_html_defaults
$htmloptions = qa_post_html_defaults('Q');
$htmloptions['voteview'] = false;
$htmloptions['tagsview'] = !isset($question['opostid']);
$htmloptions['answersview'] = false;
$htmloptions['updateview'] = false;
$htmloptions['contentview'] = true;
$htmloptions['flagsview'] = true;
$htmloptions['elementid'] = $elementid;
$htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) {
// link directly to relevant content
$htmlfields['url'] = $htmlfields['what_url'];
}
$htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) {
$htmlfields['when_2'] = qa_when_to_html($question[isset($question['opostid']) ? 'oupdated' : 'updated'], @$htmloptions['fulldatedays']);
}
$buttons = array();
if ($allowhideshow) {
$buttons['reshow'] = array('tags' => 'NAME="admin_' . qa_html($qhiddenpostid[$key]) . '_reshow" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/reshow_button'));
}
if ($allowdeletehidden && !$dependcounts[$qhiddenpostid[$key]]) {
$buttons['delete'] = array('tags' => 'NAME="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/delete_button'));
}
if (count($buttons)) {
$htmlfields['form'] = array('style' => 'light', 'buttons' => $buttons);
}
$qa_content['q_list']['qs'][] = $htmlfields;
}
} else {
$qa_content['title'] = qa_lang_html('admin/no_hidden_found');
示例11: array
$qa_content['q_list']['qs'] = array();
if (count($questions)) {
$qa_content['q_list']['title'] = qa_lang_html_sub('misc/recent_activity_from_x', qa_html($ip));
foreach ($questions as $question) {
$htmloptions = qa_post_html_defaults('Q');
$htmloptions['tagsview'] = false;
$htmloptions['voteview'] = false;
$htmloptions['ipview'] = false;
$htmloptions['answersview'] = false;
$htmloptions['updateview'] = false;
$htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) {
// link directly to relevant content
$htmlfields['url'] = $htmlfields['what_url'];
}
$hasother = isset($question['opostid']);
if ($question[$hasother ? 'ohidden' : 'hidden'] && !isset($question[$hasother ? 'oupdatetype' : 'updatetype'])) {
$htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) {
$htmlfields['when_2'] = qa_when_to_html($question[$hasother ? 'oupdated' : 'updated'], @$htmloptions['fulldatedays']);
}
}
$qa_content['q_list']['qs'][] = $htmlfields;
}
} else {
$qa_content['q_list']['title'] = qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip));
}
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
示例12: process_request
function process_request($request)
{
// get all variables
preg_match($this->reqmatch, $request, $matches);
$post_type = $matches[1];
$handle = $matches[2];
$start = (int) qa_get('start');
$pagesize = qa_opt('page_size_qs');
$hidecss = qa_opt($this->cssopt) === '1';
// regular page request
$qa_content = qa_content_prepare();
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
// display CSS for stat summary
if (!$hidecss) {
$qa_content['custom'] = "<style>\n" . ".qa-useract-page-links { margin: 16px 0; color: #555753; font-size: 16px; text-align: center; }\n" . ".qa-useract-page-links > a { font-weight: bold; }\n" . ".qa-useract-stats { margin: 8px 0; text-align: center; }\n" . ".qa-useract-stat { display: inline-block; margin: 0 16px 8px; }\n" . ".qa-useract-count { font-size: 18px; font-weight: bold; }\n" . ".qa-useract-wrapper .qa-q-item-main { width: 658px; }\n" . ".qa-useract-wrapper .qa-a-count { height: auto; border: 1px solid #ebeaca; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius:8px; }\n" . ".qa-useract-wrapper .qa-a-snippet { margin-top: 2px; color: #555753; }\n" . ".qa-useract-wrapper .qa-q-item-meta { float: none; }\n" . "</style>\n\n";
}
// list of questions by this user
if ($post_type === 'questions') {
$qa_content['title'] = qa_lang_html_sub('useractivity/questions_by', $handle);
list($userid, $count, $sel_count) = $this->_questions_stats($handle);
// get questions
$columns = 'postid, categoryid, type, LEFT(type,1) AS basetype, INSTR(type,"_HIDDEN")>0 AS hidden, acount, selchildid, closedbyid, upvotes, downvotes, netvotes, hotness, flagcount, BINARY title AS title, BINARY tags AS tags, UNIX_TIMESTAMP(created) AS created';
$sql_questions = 'SELECT ' . $columns . ' FROM ^posts WHERE type="Q" AND userid=# ORDER BY created DESC LIMIT #,#';
$result = qa_db_query_sub($sql_questions, $userid, $start, $pagesize);
$questions = qa_db_read_all_assoc($result);
$htmloptions = qa_post_html_defaults('Q');
$htmloptions['whoview'] = false;
$htmloptions['avatarsize'] = 0;
// html for stats
$qa_content['custom'] .= '<div class="qa-useract-stats">' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/question') : qa_lang_html('useractivity/questions')) . '</div>' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_given') : qa_lang_html('useractivity/best_answers_given')) . '</div>' . '</div>';
// create html for question list
$qa_content['q_list']['qs'] = array();
foreach ($questions as $question) {
$qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), null, null, $htmloptions);
}
// pagination
$qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null);
return $qa_content;
} else {
if ($post_type === 'answers') {
$qa_content['title'] = qa_lang_html_sub('useractivity/answers_by', $handle);
// userid and answer count
$sql_count = 'SELECT u.userid, count(a.postid) AS qs, sum(q.selchildid=a.postid) AS selected ' . 'FROM ^posts a, ^posts q, ^users u ' . 'WHERE a.parentid=q.postid AND u.userid=a.userid AND a.type="A" AND q.type="Q" AND u.handle=$';
$result = qa_db_query_sub($sql_count, $handle);
$row = qa_db_read_one_assoc($result);
$userid = $row['userid'];
$count = $row['qs'];
$sel_count = $row['selected'];
// get answers
$columns = 'q.postid AS qpostid, BINARY q.title AS qtitle, q.selchildid AS qselid, q.netvotes AS qvotes, a.postid AS apostid, BINARY a.content AS acontent, a.netvotes AS avotes, UNIX_TIMESTAMP(a.created) AS acreated, a.format';
$sql_answers = 'SELECT ' . $columns . ' FROM ^posts a, ^posts q WHERE a.parentid=q.postid AND a.type="A" AND q.type="Q" AND a.userid=# ORDER BY a.created DESC LIMIT #,#';
$result = qa_db_query_sub($sql_answers, $userid, $start, $pagesize);
$answers = qa_db_read_all_assoc($result);
$qa_content['custom'] .= '<div class="qa-useract-stats">' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/answer') : qa_lang_html('useractivity/answers')) . '</div>' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_received') : qa_lang_html('useractivity/best_answers_received')) . '</div>' . '</div>';
$qa_content['custom_2'] = '<div class="qa-useract-wrapper">';
foreach ($answers as $ans) {
// to avoid ugly content, convert answer to HTML then strip the tags and remove any URLs
$ans['acontent'] = qa_viewer_html($ans['acontent'], $ans['format']);
$ans['acontent'] = strip_tags($ans['acontent']);
$ans['acontent'] = preg_replace('#\\shttp://[^\\s]+#', '', $ans['acontent']);
$ans['acontent'] = qa_substr($ans['acontent'], 0, 100);
if (strlen($ans['acontent']) == 100) {
$ans['acontent'] .= '...';
}
// question url
$ans['qurl'] = qa_path_html(qa_q_request($ans['qpostid'], $ans['qtitle']));
// answer date
$ans['acreated'] = qa_when_to_html($ans['acreated'], qa_opt('show_full_date_days'));
// html content
$qa_content['custom_2'] .= $this->_answer_tmpl($ans);
}
$qa_content['custom_2'] .= '</div>';
// pagination
$qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null);
return $qa_content;
}
}
}
示例13: getAllForumEvents
//.........这里部分代码省略.........
if ($postType == "Q_HIDDEN") {
$qTitle = '';
} else {
// question has correct postid to link
// $questionTitle = (isset($data['title'])) ? $data['title'] : "";
$getQtitle = mysql_fetch_array(qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = # LIMIT 1", $postid));
$qTitle = isset($getQtitle[0]) ? $getQtitle[0] : "";
// get correct public URL
// $activity_url = qa_path_html(qa_q_request($getPostType[1], $qTitle), null, qa_opt('site_url'), null, null);
$activity_url = qa_path_html(qa_q_request($postid, $qTitle), null, qa_opt('site_url'), null, null);
$linkToPost = $activity_url;
}
}
}
} elseif ($row['event'] == 'badge_awarded') {
$toURL = str_replace("\t", "&", $row['params']);
parse_str($toURL, $data);
$badge = qa_get_badge_type_by_slug($data['badge_slug']);
$badge_type = $badge['slug'];
$badge_name = qa_opt('badge_' . $data['badge_slug'] . '_name');
$var = qa_opt('badge_' . $data['badge_slug'] . '_var');
$qTitle = $badge_name . ' - ' . qa_badge_desc_replace($data['badge_slug'], $var, false);
$linkToPost = qa_path_html('user/' . $row['handle']);
}
$username = is_null($row['handle']) ? _ra_lang('Anonymous') : htmlspecialchars($row['handle']);
$usernameLink = is_null($row['handle']) ? _ra_lang('Anonymous') : '<a target="_blank" class="qa-user-link" href="' . qa_opt('site_url') . 'user/' . $row['handle'] . '">' . ra_name($row['handle']) . '</a>';
// set event name and css class
$eventName = '';
if ($row['event'] == "q_post") {
$eventName = _ra_lang('asked');
} else {
if ($row['event'] == "a_post") {
$eventName = _ra_lang('answered');
} else {
if ($row['event'] == "c_post") {
$eventName = _ra_lang('commented');
} else {
if ($row['event'] == "a_select") {
$eventName = _ra_lang('selected an answer');
} else {
if ($row['event'] == "badge_awarded") {
$eventName = _ra_lang('earned a badge');
}
}
}
}
}
// set event icon class
if ($row['event'] == "q_post") {
$event_icon = 'icon-question question';
} else {
if ($row['event'] == "a_post") {
$event_icon = 'icon-chat3 ans';
} else {
if ($row['event'] == "c_post") {
$event_icon = 'icon-chat2 comment';
} else {
if ($row['event'] == "a_select") {
$event_icon = 'icon-checkmark selected';
} else {
if ($row['event'] == "badge_awarded") {
$event_icon = 'icon-badge badge-icon ' . @$badge_type;
}
}
}
}
}
$timeCode = implode(' ', qa_when_to_html($row['unix_time'], qa_opt('show_full_date_days')));
$time = '<span class="time">' . $timeCode . '</span>';
// if question title is empty, question got possibly deleted, do not show frontend!
if ($qTitle == '') {
continue;
}
$qTitleShort = mb_substr($qTitle, 0, 22, 'utf-8');
// shorten question title to 22 chars
$qTitleShort2 = strlen($qTitle) > 50 ? htmlspecialchars(mb_substr($qTitle, 0, 50, 'utf-8')) . '…' : htmlspecialchars($qTitle);
// shorten question title
$listAllEvents .= '<li class="event-item">';
$listAllEvents .= '<div class="event-icon pull-left ' . $event_icon . '"></div>';
$listAllEvents .= '<div class="event-inner">';
$listAllEvents .= '<div class="avatar pull-left" data-handle="' . @$row['handle'] . '" data-id="' . qa_handle_to_userid($row['handle']) . '">' . ra_get_avatar(@$row['handle'], 40) . '</div>';
$listAllEvents .= '<div class="event-content">';
$listAllEvents .= '<h4>' . $usernameLink . ' ' . $eventName . ' ' . $time . '</h4>';
if ($row['event'] == "badge_awarded") {
$listAllEvents .= '<h5 class="event-title">' . $qTitleShort2 . '</h5>';
} else {
$listAllEvents .= '<a class="event-title" href="' . $linkToPost . '">' . $qTitleShort2 . '</a>';
}
$listAllEvents .= '</div>';
$listAllEvents .= '</div>';
$listAllEvents .= '</li>';
$countEvents++;
if ($countEvents >= $limit) {
break;
}
}
}
$listAllEvents .= '</ul>';
return $listAllEvents;
}
示例14: header
/* don't allow this page to be requested directly from browser */
if (!defined('QA_VERSION')) {
header('Location: /');
exit;
}
/* layout of question page question */
if (defined('QA_WORDPRESS_INTEGRATE_PATH')) {
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$handle = qa_post_userid_to_handle($args['raw']['userid']);
} else {
$handle = $args['raw']['handle'];
}
$user_link = qa_path_html('user/' . $handle);
$user_data = ra_user_data($handle);
$created = implode('', qa_when_to_html($args['raw']['created'], qa_opt('show_full_date_days')));
?>
<div class="question qa-q-view <?php
echo (@$args['hidden'] ? ' qa-q-view-hidden' : '') . rtrim(' ' . @$args['classes']);
?>
"<?php
rtrim(' ' . @$args['tags']);
?>
>
<?php
$context->post_tags($args, 'qa-q-view');
?>
<div class="vote-float clearfix">
<div class="vote-c pull-left">
<?php
示例15: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$AdsPos = (int) qa_opt('tw_ads_pos');
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
$sort = 'created';
$userid = qa_get_logged_in_userid();
$questions = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, '', null, false, false, (int) qa_opt('tw_recent_number')));
$hotquestions = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'hotness', 0, '', null, false, false, (int) qa_opt('tw_popular_number')));
$themeobject->output('
<ul class="tabs nav nav-tabs">
<li><a href="#tab1" class="active">' . qa_opt('tw_popular_lable') . '</a></li>
<li><a href="#tab2">' . qa_opt('tw_recent_lable') . '</a></li>
</ul>
<div class="tab-content" id="tab1">
<ul class="popular">
');
$thumb = '';
$i = 0;
foreach ($hotquestions as $question) {
$i++;
$questionid = $question['postid'];
$questionlink = qa_path_html(qa_q_request($questionid, $question['title']), null, qa_opt('site_url'));
$q_time = qa_when_to_html($question['created'], 7);
$when = @$q_time['prefix'] . ' ' . @$q_time['data'] . ' ' . @$q_time['suffix'];
// get question content
$result = qa_db_query_sub('SELECT content FROM ^posts WHERE postid=#', $questionid);
$postinfo = qa_db_read_one_assoc($result, 'postid');
if (qa_opt('tw_thumbnail_enable')) {
// get thumbnail
$doc = new DOMDocument();
@$doc->loadHTML($postinfo['content']);
$xpath = new DOMXPath($doc);
$src = $xpath->evaluate("string(//img/@src)");
$default_thumbnail = qa_opt('tw_thumbnail');
if (empty($src) && !empty($default_thumbnail)) {
$src = qa_opt('tw_thumbnail');
}
$thumb = '';
if (!empty($src)) {
$thumb = '<div class="tab-div-thumb"><a class="tab-link-thumbnail" href="' . $questionlink . '"><img class="tab-thumbnail" width="60" height="50" src="' . $src . '"></a></div>';
}
}
$themeobject->output('<li>' . $thumb);
$themeobject->output('<div class="tab-div-body"><a class="tab-link" href="' . $questionlink . '"><p class="tab-link-header">' . $question['title'] . '</p></a>');
$themeobject->output('<span class="tab-time">' . $when . '</span></div></li>');
$ads_content = qa_opt('tw_ads');
if ($i == $AdsPos && !empty($ads_content)) {
$themeobject->output('<div class="tab-ads">' . qa_opt('tw_ads') . '</div>');
}
}
$themeobject->output('
</ul>
</div>
<div class="tab-content" id="tab2" style="display: none;">
<ul class="recent">
');
$i = 0;
foreach ($questions as $question) {
$i++;
$questionid = $question['postid'];
$questionlink = qa_path_html(qa_q_request($questionid, $question['title']), null, qa_opt('site_url'));
$q_time = qa_when_to_html($question['created'], 7);
$when = @$q_time['prefix'] . ' ' . @$q_time['data'] . ' ' . @$q_time['suffix'];
// get question content
$result = qa_db_query_sub('SELECT content FROM ^posts WHERE postid=#', $questionid);
$postinfo = qa_db_read_one_assoc($result, 'postid');
if (qa_opt('tw_thumbnail_enable')) {
// get thumbnail
$doc = new DOMDocument();
@$doc->loadHTML($postinfo['content']);
$xpath = new DOMXPath($doc);
$src = $xpath->evaluate("string(//img/@src)");
$default_thumbnail = qa_opt('tw_thumbnail');
if (empty($src) && !empty($default_thumbnail)) {
$src = qa_opt('tw_thumbnail');
}
$thumb = '';
if (!empty($src)) {
$thumb = '<div class="tab-div-thumb"><a class="tab-link-thumbnail" href="' . $questionlink . '"><img class="tab-thumbnail" width="60" height="50" src="' . $src . '"></a></div>';
}
}
$themeobject->output('<li>' . $thumb);
$themeobject->output('<div class="tab-div-body"><a class="tab-link" href="' . $questionlink . '"><p class="tab-link-header">' . $question['title'] . '</p></a>');
$themeobject->output('<span class="tab-time">' . $when . '</span></div></li>');
$ads_content = qa_opt('tw_ads');
if ($i == $AdsPos && !empty($ads_content)) {
$themeobject->output('<div class="tab-ads">' . qa_opt('tw_ads') . '</div>');
}
}
$themeobject->output('
</ul>
</div>
');
}