Advertisement
ajayver

Q2A Mouseover plugin old

Feb 24th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.     Question2Answer (c) Gideon Greenspan
  5.  
  6.     http://www.question2answer.org/
  7.  
  8.    
  9.     File: qa-plugin/mouseover-layer/qa-mouseover-layer.php
  10.     Version: See define()s at top of qa-include/qa-base.php
  11.     Description: Theme layer class for mouseover layer plugin
  12.  
  13.  
  14.     This program is free software; you can redistribute it and/or
  15.     modify it under the terms of the GNU General Public License
  16.     as published by the Free Software Foundation; either version 2
  17.     of the License, or (at your option) any later version.
  18.    
  19.     This program is distributed in the hope that it will be useful,
  20.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.     GNU General Public License for more details.
  23.  
  24.     More about this license: http://www.question2answer.org/license.php
  25. */
  26.  
  27.     class qa_html_theme_layer extends qa_html_theme_base {
  28.        
  29.         function q_list($q_list)
  30.         {
  31.             if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on
  32.  
  33.             //  Collect the question ids of all items in the question list (so we can do this in one DB query)
  34.    
  35.                 $postids=array();
  36.                 foreach ($q_list['qs'] as $question)
  37.                     if (isset($question['raw']['postid']))
  38.                         $postids[]=$question['raw']['postid'];
  39.                
  40.                 if (count($postids)) {
  41.  
  42.                 //  Retrieve the content for these questions from the database and put into an array
  43.                
  44.                     $result=qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
  45.                     $postinfo=qa_db_read_all_assoc($result, 'postid');
  46.                    
  47.                 //  Get the regular expression fragment to use for blocked words and the maximum length of content to show
  48.                    
  49.                     $blockwordspreg=qa_get_block_words_preg();
  50.                     $maxlength=qa_opt('mouseover_content_max_len');
  51.                    
  52.                 //  Now add the popup to the title for each question
  53.        
  54.                     foreach ($q_list['qs'] as $index => $question) {
  55.                         $thispost=@$postinfo[$question['raw']['postid']];
  56.                        
  57.                         if (isset($thispost)) {
  58.                             $text=$thispost['content'];
  59.                             $text=qa_shorten_string_line($text, $maxlength);
  60.                             $q_list['qs'][$index]['content']=$text;
  61.                         }
  62.                     }
  63.                 }
  64.             }
  65.            
  66.             qa_html_theme_base::q_list($q_list); // call back through to the default function
  67.         }
  68.  
  69.     }
  70.    
  71.  
  72. /*
  73.     Omit PHP closing tag to help avoid accidental output
  74. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement