| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        modules
 
     | 
  
  
    | 
      5
     | 
    
       * @package         news
 
     | 
  
  
    | 
      6
     | 
    
       * @author          WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2004-2009, Ryan Djurovich
 
     | 
  
  
    | 
      8
     | 
    
       * @copyright       2009-2010, Website Baker Org. e.V.
 
     | 
  
  
    | 
      9
     | 
    
       * @link			http://www.websitebaker2.org/
 
     | 
  
  
    | 
      10
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      11
     | 
    
       * @platform        WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      12
     | 
    
       * @requirements    PHP 4.3.4 and higher
 
     | 
  
  
    | 
      13
     | 
    
       * @version         $Id: search.php 1289 2010-02-10 15:13:21Z kweitzel $
 
     | 
  
  
    | 
      14
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/trunk/wb/modules/news/search.php $
 
     | 
  
  
    | 
      15
     | 
    
       * @lastmodified    $Date: 2010-02-10 16:13:21 +0100 (Wed, 10 Feb 2010) $
 
     | 
  
  
    | 
      16
     | 
    
       *
 
     | 
  
  
    | 
      17
     | 
    
       */
 
     | 
  
  
    | 
      18
     | 
    
      
 
     | 
  
  
    | 
      19
     | 
    
      function news_search($func_vars) {
     | 
  
  
    | 
      20
     | 
    
      	extract($func_vars, EXTR_PREFIX_ALL, 'func');
 
     | 
  
  
    | 
      21
     | 
    
      
 
     | 
  
  
    | 
      22
     | 
    
      	// how many lines of excerpt we want to have at most
 
     | 
  
  
    | 
      23
     | 
    
      	$max_excerpt_num = $func_default_max_excerpt;
 
     | 
  
  
    | 
      24
     | 
    
      	// do we want excerpt from comments?
 
     | 
  
  
    | 
      25
     | 
    
      	$excerpt_from_comments = true; // TODO: make this configurable
 
     | 
  
  
    | 
      26
     | 
    
      	$divider = ".";
 
     | 
  
  
    | 
      27
     | 
    
      	$result = false;
 
     | 
  
  
    | 
      28
     | 
    
      
 
     | 
  
  
    | 
      29
     | 
    
      	// fetch all active news-posts (from active groups) in this section.
 
     | 
  
  
    | 
      30
     | 
    
      	$t = time();
 
     | 
  
  
    | 
      31
     | 
    
      	$table_posts = TABLE_PREFIX."mod_news_posts";
 
     | 
  
  
    | 
      32
     | 
    
      	$table_groups = TABLE_PREFIX."mod_news_groups";
 
     | 
  
  
    | 
      33
     | 
    
      	$query = $func_database->query("
     | 
  
  
    | 
      34
     | 
    
      		SELECT p.post_id, p.title, p.content_short, p.content_long, p.link, p.posted_when, p.posted_by
 
     | 
  
  
    | 
      35
     | 
    
      		FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id
 
     | 
  
  
    | 
      36
     | 
    
      		WHERE p.section_id='$func_section_id' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )
 
     | 
  
  
    | 
      37
     | 
    
      		AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
 
     | 
  
  
    | 
      38
     | 
    
      		ORDER BY p.post_id DESC
 
     | 
  
  
    | 
      39
     | 
    
      	");
 
     | 
  
  
    | 
      40
     | 
    
      	// now call print_excerpt() for every single post
 
     | 
  
  
    | 
      41
     | 
    
      	if($query->numRows() > 0) {
     | 
  
  
    | 
      42
     | 
    
      		while($res = $query->fetchRow()) {
     | 
  
  
    | 
      43
     | 
    
      			$text = $res['title'].$divider.$res['content_short'].$divider.$res['content_long'].$divider;
 
     | 
  
  
    | 
      44
     | 
    
      			// fetch comments and add to $text
 
     | 
  
  
    | 
      45
     | 
    
      			if($excerpt_from_comments) {
     | 
  
  
    | 
      46
     | 
    
      				$table = TABLE_PREFIX."mod_news_comments";
 
     | 
  
  
    | 
      47
     | 
    
      				$commentquery = $func_database->query("
     | 
  
  
    | 
      48
     | 
    
      					SELECT title, comment
 
     | 
  
  
    | 
      49
     | 
    
      					FROM $table
 
     | 
  
  
    | 
      50
     | 
    
      					WHERE post_id='{$res['post_id']}'
     | 
  
  
    | 
      51
     | 
    
      					ORDER BY commented_when ASC
 
     | 
  
  
    | 
      52
     | 
    
      				");
 
     | 
  
  
    | 
      53
     | 
    
      				if($commentquery->numRows() > 0) {
     | 
  
  
    | 
      54
     | 
    
      					while($c_res = $commentquery->fetchRow()) {
     | 
  
  
    | 
      55
     | 
    
      						$text .= $c_res['title'].$divider.$c_res['comment'].$divider;
 
     | 
  
  
    | 
      56
     | 
    
      					}
 
     | 
  
  
    | 
      57
     | 
    
      				}
 
     | 
  
  
    | 
      58
     | 
    
      			}
 
     | 
  
  
    | 
      59
     | 
    
      			$mod_vars = array(
 
     | 
  
  
    | 
      60
     | 
    
      				'page_link' => $res['link'], // use direct link to news-item
 
     | 
  
  
    | 
      61
     | 
    
      				'page_link_target' => "",
 
     | 
  
  
    | 
      62
     | 
    
      				'page_title' => $func_page_title,
 
     | 
  
  
    | 
      63
     | 
    
      				'page_description' => $res['title'], // use news-title as description
 
     | 
  
  
    | 
      64
     | 
    
      				'page_modified_when' => $res['posted_when'],
 
     | 
  
  
    | 
      65
     | 
    
      				'page_modified_by' => $res['posted_by'],
 
     | 
  
  
    | 
      66
     | 
    
      				'text' => $text,
 
     | 
  
  
    | 
      67
     | 
    
      				'max_excerpt_num' => $max_excerpt_num
 
     | 
  
  
    | 
      68
     | 
    
      			);
 
     | 
  
  
    | 
      69
     | 
    
      			if(print_excerpt2($mod_vars, $func_vars)) {
     | 
  
  
    | 
      70
     | 
    
      				$result = true;
 
     | 
  
  
    | 
      71
     | 
    
      			}
 
     | 
  
  
    | 
      72
     | 
    
      		}
 
     | 
  
  
    | 
      73
     | 
    
      	}
 
     | 
  
  
    | 
      74
     | 
    
      	
 
     | 
  
  
    | 
      75
     | 
    
      	// now fetch group-titles - ignore those without (active) postings
 
     | 
  
  
    | 
      76
     | 
    
      	$table_groups = TABLE_PREFIX."mod_news_groups";
 
     | 
  
  
    | 
      77
     | 
    
      	$table_posts = TABLE_PREFIX."mod_news_posts";
 
     | 
  
  
    | 
      78
     | 
    
      	$query = $func_database->query("
     | 
  
  
    | 
      79
     | 
    
      		SELECT DISTINCT g.title, g.group_id
 
     | 
  
  
    | 
      80
     | 
    
      		FROM $table_groups AS g INNER JOIN $table_posts AS p ON g.group_id = p.group_id
 
     | 
  
  
    | 
      81
     | 
    
      		WHERE g.section_id='$func_section_id' AND g.active = '1' AND p.active = '1'
 
     | 
  
  
    | 
      82
     | 
    
      	");
 
     | 
  
  
    | 
      83
     | 
    
      	// now call print_excerpt() for every single group, too
 
     | 
  
  
    | 
      84
     | 
    
      	if($query->numRows() > 0) {
     | 
  
  
    | 
      85
     | 
    
      		while($res = $query->fetchRow()) {
     | 
  
  
    | 
      86
     | 
    
      			$mod_vars = array(
 
     | 
  
  
    | 
      87
     | 
    
      				'page_link' => $func_page_link,
 
     | 
  
  
    | 
      88
     | 
    
      				'page_link_target' => "&g=".$res['group_id'],
 
     | 
  
  
    | 
      89
     | 
    
      				'page_title' => $func_page_title,
 
     | 
  
  
    | 
      90
     | 
    
      				'page_description' => $func_page_description,
 
     | 
  
  
    | 
      91
     | 
    
      				'page_modified_when' => $func_page_modified_when,
 
     | 
  
  
    | 
      92
     | 
    
      				'page_modified_by' => $func_page_modified_by,
 
     | 
  
  
    | 
      93
     | 
    
      				'text' => $res['title'].$divider,
 
     | 
  
  
    | 
      94
     | 
    
      				'max_excerpt_num' => $max_excerpt_num
 
     | 
  
  
    | 
      95
     | 
    
      			);
 
     | 
  
  
    | 
      96
     | 
    
      			if(print_excerpt2($mod_vars, $func_vars)) {
     | 
  
  
    | 
      97
     | 
    
      				$result = true;
 
     | 
  
  
    | 
      98
     | 
    
      			}
 
     | 
  
  
    | 
      99
     | 
    
      		}
 
     | 
  
  
    | 
      100
     | 
    
      	}
 
     | 
  
  
    | 
      101
     | 
    
      	return $result;
 
     | 
  
  
    | 
      102
     | 
    
      }
 
     | 
  
  
    | 
      103
     | 
    
      
 
     | 
  
  
    | 
      104
     | 
    
      ?>
 
     |