コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: widget_posts.php プロジェクト: microbye/CleanStrap
 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;
 }
コード例 #4
0
ファイル: widget_ticker.php プロジェクト: microbye/CleanStrap
    function cs_relative_post_list($limit, $slug, $type, $return = false, $avatar_size)
    {
        require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
        if (!empty($slug)) {
            if ($type == 'Category') {
                $post_type = 'Q';
                $categories = explode("/", $slug);
                if (count($categories)) {
                    $category_bread_crup = implode(" > ", $categories);
                    $category_link = implode("/", $categories);
                    $categories = array_reverse($categories);
                    $slug = implode("/", $categories);
                }
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
							AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) 
							ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, $limit));
                //refresh every 15 minutes
                $title = 'Questions in <a href="' . qa_path_html('questions/' . qa_strtolower($category_link)) . '">' . $category_bread_crup . '</a>';
            } elseif ($type == 'Tags') {
                $post_type = 'Q';
                $title = 'Questions in <a href="' . qa_path_html('tag/' . qa_strtolower($slug)) . '">' . $slug . '</a>';
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
						AND ^posts.postid IN (SELECT postid FROM ^posttags WHERE 
							wordid=(SELECT wordid FROM ^words WHERE word=$ OR word=$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC)
						ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, qa_strtolower($slug), $limit));
            } else {
                // Relative to Keyword
                require_once QA_INCLUDE_DIR . 'qa-app-search.php';
                $keyword = $slug;
                $userid = qa_get_logged_in_userid();
                $title = 'Posts About <a href="' . qa_path_html('search/' . qa_strtolower($keyword)) . '">' . $keyword . '</a>';
                //$post=qa_get_search_results($keyword, 0, $limit, $userid , false, false);
                $words = qa_string_to_words($keyword);
                $posts = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($keyword), 0, false, $limit));
                $output = '<h3 class="widget-title">' . $title . '</h3>';
                $output .= '<ul class="question-list">';
                foreach ($posts as $post) {
                    $post_type = $post['type'];
                    if ($post_type == 'Q') {
                        $what = qa_lang('cleanstrap/asked');
                    } elseif ($post_type == 'A') {
                        $what = qa_lang('cleanstrap/answered');
                    } elseif ('C') {
                        $what = qa_lang('cleanstrap/commented');
                    }
                    $handle = qa_post_userid_to_handle($post['userid']);
                    $avatar = cs_get_post_avatar($post, $avatar_size);
                    $output .= '<li id="q-list-' . $post['postid'] . '" class="question-item">';
                    $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . $post['userid'] . '">' . $avatar . '</div>';
                    $output .= '<div class="list-right">';
                    if ($post_type == 'Q') {
                        $output .= '<a class="title" href="' . qa_q_path_html($post['postid'], $post['title']) . '" title="' . $post['title'] . '">' . cs_truncate(strip_tags($post['title']), 70) . '</a>';
                    } elseif ($post_type == 'A') {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#a' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    } else {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#c' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    }
                    $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
                    if ($post_type == 'Q') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                        $output .= ' <span class="ans-count">' . $post['acount'] . ' ans</span>';
                    } elseif ($post_type == 'A') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                    }
                    $output .= '</div></div>';
                    $output .= '</li>';
                }
                $output .= '</ul>';
                if ($return) {
                    return $output;
                }
                echo $output;
                return;
            }
        } else {
            return;
        }
        $output = '<h3 class="widget-title">' . $title . '</h3>';
        $output .= '<ul class="question-list">';
        foreach ($posts as $p) {
            if (empty($p['userid'])) {
                $p['userid'] = NULL;
            }
            // to prevent error for anonymous posts while calling qa_post_userid_to_handle()
            if ($post_type == 'Q') {
                $what = qa_lang_html('cleanstrap/asked');
            } elseif ($post_type == 'A') {
                $what = qa_lang_html('cleanstrap/answered');
            } elseif ('C') {
                $what = qa_lang_html('cleanstrap/commented');
            }
            $handle = qa_post_userid_to_handle($p['userid']);
            $avatar = cs_get_avatar($handle, 35, false);
            $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
            $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . (isset($avatar) ? '<img src="' . $avatar . '" />' : '') . '</div>';
            $output .= '<div class="list-right">';
            if ($post_type == 'Q') {
                $output .= '<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate(qa_html($p['title']), 70) . '</a>';
            } elseif ($post_type == 'A') {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            } else {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            }
            $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
            if ($post_type == 'Q') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
                $output .= ' <span class="ans-count">' . $p['acount'] . ' ans</span>';
            } elseif ($post_type == 'A') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
            }
            $output .= '</div></div>';
            $output .= '</li>';
        }
        $output .= '</ul>';
        if ($return) {
            return $output;
        }
        echo $output;
    }
コード例 #5
0
 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;
 }