public function q_list($q_list)
 {
     if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
         // first check it is not an empty list and the feature is turned on
         // Collect the question ids of all items in the question list (so we can do this in one DB query)
         $postids = array();
         foreach ($q_list['qs'] as $question) {
             if (isset($question['raw']['postid'])) {
                 $postids[] = $question['raw']['postid'];
             }
         }
         if (!empty($postids)) {
             // Retrieve the content for these questions from the database
             $maxlength = qa_opt('mouseover_content_max_len');
             $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
             $postinfo = qa_db_read_all_assoc($result, 'postid');
             // Get the regular expression fragment to use for blocked words and the maximum length of content to show
             $blockwordspreg = qa_get_block_words_preg();
             // Now add the popup to the title for each question
             foreach ($q_list['qs'] as $index => $question) {
                 if (isset($postinfo[$question['raw']['postid']])) {
                     $thispost = $postinfo[$question['raw']['postid']];
                     $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                     $text = preg_replace('/\\s+/', ' ', $text);
                     // Remove duplicated blanks, new line characters, tabs, etc
                     $text = qa_shorten_string_line($text, $maxlength);
                     $title = isset($question['title']) ? $question['title'] : '';
                     $q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title);
                 }
             }
         }
     }
     parent::q_list($q_list);
     // call back through to the default function
 }
Пример #2
0
 function q_list($q_list)
 {
     if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) {
         // first check it is not an empty list and the feature is turned on
         //	Collect the question ids of all items in the question list (so we can do this in one DB query)
         $postids = array();
         foreach ($q_list['qs'] as $question) {
             if (isset($question['raw']['postid'])) {
                 $postids[] = $question['raw']['postid'];
             }
         }
         if (count($postids)) {
             //	Retrieve the content for these questions from the database and put into an array
             $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
             $postinfo = qa_db_read_all_assoc($result, 'postid');
             //	Get the regular expression fragment to use for blocked words and the maximum length of content to show
             $blockwordspreg = qa_get_block_words_preg();
             $maxlength = qa_opt('mouseover_content_max_len');
             //	Now add the popup to the title for each question
             foreach ($q_list['qs'] as $index => $question) {
                 $thispost = @$postinfo[$question['raw']['postid']];
                 if (isset($thispost)) {
                     $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                     $text = qa_shorten_string_line($text, $maxlength);
                     $q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>';
                 }
             }
         }
     }
     qa_html_theme_base::q_list($q_list);
     // call back through to the default function
 }
Пример #3
0
 public function q_list($q_list)
 {
     if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
         // first check it is not an empty list and the feature is turned on
         // Collect the question ids of all items in the question list (so we can do this in one DB query)
         $postids = array();
         foreach ($q_list['qs'] as $question) {
             if (isset($question['raw']['postid'])) {
                 $postids[] = $question['raw']['postid'];
             }
         }
         if (!empty($postids)) {
             // Retrieve the content for these questions from the database and put into an array fetching
             // the minimal amount of characters needed to determine the string should be shortened or not
             $maxlength = qa_opt('mouseover_content_max_len');
             $result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
             $postinfo = qa_db_read_all_assoc($result, 'postid');
             // Get the regular expression fragment to use for blocked words and the maximum length of content to show
             $blockwordspreg = qa_get_block_words_preg();
             // Now add the popup to the title for each question
             foreach ($q_list['qs'] as $index => $question) {
                 if (isset($postinfo[$question['raw']['postid']])) {
                     $thispost = $postinfo[$question['raw']['postid']];
                     $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                     $text = qa_shorten_string_line($text, $maxlength);
                     $title = isset($question['title']) ? $question['title'] : '';
                     $q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
                 }
             }
         }
     }
     qa_html_theme_base::q_list($q_list);
     // call back through to the default function
 }
Пример #4
0
 function q_list($q_list)
 {
     if (qa_opt('it_layout_lists') == 'qlist') {
         qa_html_theme_base::q_list($q_list);
         return;
     }
     if (count(@$q_list['qs'])) {
         // first check it is not an empty list and the feature is turned on
         //	Collect the question ids of all items in the question list (so we can do this in one DB query)
         $postids = array();
         foreach ($q_list['qs'] as $question) {
             if (isset($question['raw']['postid'])) {
                 $postids[] = $question['raw']['postid'];
             }
         }
         if (count($postids)) {
             //	Retrieve favourite count
             $userid = qa_get_logged_in_userid();
             $result = qa_db_query_sub('SELECT userid,entityid FROM ^userfavorites WHERE entitytype=$ AND entityid IN (#)', 'Q', $postids);
             while ($row = mysqli_fetch_row($result)) {
                 if ($row[0] == $userid) {
                     // loged in user favorited this post
                     $faved_post[$row[1]] = 1;
                 }
                 if (isset($favs[$row[1]])) {
                     $favs[$row[1]] = $favs[$row[1]] + 1;
                 } else {
                     $favs[$row[1]] = 1;
                 }
             }
             //	Retrieve comment count
             $result = qa_db_query_sub('SELECT postid,parentid FROM ^posts WHERE type=$ AND parentid IN (#)', 'C', $postids);
             $comment_list = qa_db_read_all_assoc($result, 'postid');
             foreach ($comment_list as $key => $value) {
                 if (isset($comments[$value['parentid']])) {
                     $comments[$value['parentid']] = $comments[$value['parentid']] + 1;
                 } else {
                     $comments[$value['parentid']] = 1;
                 }
             }
             if (qa_opt('it_excerpt_field_enable') or qa_opt('it_enable_except')) {
                 //	Get the regular expression fragment to use for blocked words and the maximum length of content to show
                 $blockwordspreg = qa_get_block_words_preg();
                 if (qa_opt('it_excerpt_field_enable')) {
                     $maxlength = qa_opt('it_excerpt_field_length');
                     //	Retrieve Excerpt Text for all questions
                     $result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_excerpt_text');
                     $excerpt_text = qa_db_read_all_assoc($result, 'postid');
                     // set excerpt from field info
                     foreach ($q_list['qs'] as $index => $question) {
                         // from field
                         if (!empty($excerpt_text[$question['raw']['postid']]['content'])) {
                             $text = qa_viewer_text($excerpt_text[$question['raw']['postid']]['content'], '', array('blockwordspreg' => $blockwordspreg));
                             $text = qa_shorten_string_line($text, $maxlength);
                             $q_list['qs'][$index]['excerpt'] = qa_html($text);
                             // from post content
                         } elseif (qa_opt('it_enable_except')) {
                             // Retrieve the content for these questions from the database and put into an array
                             $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
                             $postinfo = qa_db_read_all_assoc($result, 'postid');
                             $thispost = @$postinfo[$question['raw']['postid']];
                             if (isset($thispost)) {
                                 $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                                 $text = qa_shorten_string_line($text, $maxlength);
                                 $q_list['qs'][$index]['excerpt'] = qa_html($text);
                             }
                         }
                     }
                 } else {
                     // qa_opt('it_enable_except')  ==> excerpt from question content instead of excerpt field
                     $maxlength = qa_opt('it_except_len');
                     $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
                     $postinfo = qa_db_read_all_assoc($result, 'postid');
                     foreach ($q_list['qs'] as $index => $question) {
                         $thispost = @$postinfo[$question['raw']['postid']];
                         if (isset($thispost)) {
                             $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
                             $text = qa_shorten_string_line($text, $maxlength);
                             $q_list['qs'][$index]['excerpt'] = qa_html($text);
                         }
                     }
                 }
             }
             //	Retrieve featured images for all list questions
             if (qa_opt('it_feature_img_enable')) {
                 $result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_featured_image');
                 $featured_images = qa_db_read_all_assoc($result, 'postid');
             }
             //	Now meta information for each question
             foreach ($q_list['qs'] as $index => $question) {
                 if (qa_opt('it_feature_img_enable')) {
                     $featured_image = @$featured_images[$question['raw']['postid']]['content'];
                     if (isset($featured_image)) {
                         $q_list['qs'][$index]['featured'] = qa_opt('it_featured_url_abs') . 'featured/' . $featured_image;
                     }
                 }
                 if (isset($comments[$question['raw']['postid']])) {
                     $q_list['qs'][$index]['comments'] = $comments[$question['raw']['postid']];
                 } else {
                     $q_list['qs'][$index]['comments'] = 0;
                 }
                 $q_list['qs'][$index]['favourited'] = 0;
                 if (isset($favs[$question['raw']['postid']])) {
                     $q_list['qs'][$index]['favourites'] = $favs[$question['raw']['postid']];
                     if (isset($faved_post[$question['raw']['postid']])) {
                         $q_list['qs'][$index]['favourited'] = 1;
                     }
                 } else {
                     $q_list['qs'][$index]['favourites'] = 0;
                 }
             }
         }
     }
     if (isset($q_list['qs'])) {
         $this->output('<div class="qa-q-list row' . ($this->list_vote_disabled($q_list['qs']) ? ' qa-q-list-vote-disabled' : '') . '">', '');
         $this->q_list_items($q_list['qs']);
         $this->output('</div> <!-- END qa-q-list -->', '');
     }
 }