Project

General

Profile

« Previous | Next » 

Revision 1442

Added by Dietmar over 13 years ago

bug fixed in class.database.php methode field_add in call field_exists
update search, pls test, (Tks to Thorn)

View differences:

search.php
21 21

  
22 22
function news_search($func_vars) {
23 23
	extract($func_vars, EXTR_PREFIX_ALL, 'func');
24

  
24
	static $search_sql1 = FALSE;
25
	static $search_sql2 = FALSE;
26
	static $search_sql3 = FALSE;
27
	if(function_exists('search_make_sql_part')) {
28
		if($search_sql1===FALSE)
29
			$search_sql1 = search_make_sql_part($func_search_url_array, $func_search_match, array('`title`','`content_short`','`content_long`'));
30
		if($search_sql2===FALSE)
31
			$search_sql2 = search_make_sql_part($func_search_url_array, $func_search_match, array('`title`','`comment`'));
32
		if($search_sql3===FALSE)
33
			$search_sql3 = search_make_sql_part($func_search_url_array, $func_search_match, array('g.`title`'));
34
	} else {
35
		$search_sql1 = $search_sql2 = $search_sql3 = '1=1';
36
	}
25 37
	// how many lines of excerpt we want to have at most
26 38
	$max_excerpt_num = $func_default_max_excerpt;
27 39
	// do we want excerpt from comments?
......
29 41
	$divider = ".";
30 42
	$result = false;
31 43

  
44
  if($func_time_limit>0) {
45
    $stop_time = time() + $func_time_limit;
46
  }
47

  
32 48
	// fetch all active news-posts (from active groups) in this section.
33 49
	$t = time();
34 50
	$table_posts = TABLE_PREFIX."mod_news_posts";
......
43 59
	// now call print_excerpt() for every single post
44 60
	if($query->numRows() > 0) {
45 61
		while($res = $query->fetchRow()) {
46
			$text = $res['title'].$divider.$res['content_short'].$divider.$res['content_long'].$divider;
62
			$text = '';
63
			// break out if stop-time is reached
64
			if(isset($stop_time) && time()>$stop_time) return($result);
65
			// fetch content
66
			$postquery = $func_database->query("
67
				SELECT title, content_short, content_long
68
				FROM $table_posts
69
				WHERE post_id='{$res['post_id']}' AND $search_sql1
70
			");
71
			if($postquery->numRows() > 0) {
72
				if($p_res = $postquery->fetchRow()) {
73
					$text = $p_res['title'].$divider.$p_res['content_short'].$divider.$p_res['content_long'].$divider;
74
				}
75
			}
47 76
			// fetch comments and add to $text
48 77
			if($excerpt_from_comments) {
49 78
				$table = TABLE_PREFIX."mod_news_comments";
50 79
				$commentquery = $func_database->query("
51 80
					SELECT title, comment
52 81
					FROM $table
53
					WHERE post_id='{$res['post_id']}'
82
					WHERE post_id='{$res['post_id']}' AND $search_sql2
54 83
					ORDER BY commented_when ASC
55 84
				");
56 85
				if($commentquery->numRows() > 0) {
57 86
					while($c_res = $commentquery->fetchRow()) {
87
						// break out if stop-time is reached
88
						if(isset($stop_time) && time()>$stop_time) return($result);
58 89
						$text .= $c_res['title'].$divider.$c_res['comment'].$divider;
59 90
					}
60 91
				}
61 92
			}
62
			$mod_vars = array(
63
				'page_link' => $res['link'], // use direct link to news-item
64
				'page_link_target' => "",
65
				'page_title' => $func_page_title,
66
				'page_description' => $res['title'], // use news-title as description
67
				'page_modified_when' => $res['posted_when'],
68
				'page_modified_by' => $res['posted_by'],
69
				'text' => $text,
70
				'max_excerpt_num' => $max_excerpt_num
71
			);
72
			if(print_excerpt2($mod_vars, $func_vars)) {
73
				$result = true;
93
			if($text) {
94
				$mod_vars = array(
95
					'page_link' => $res['link'], // use direct link to news-item
96
					'page_link_target' => "",
97
					'page_title' => $func_page_title,
98
					'page_description' => $res['title'], // use news-title as description
99
					'page_modified_when' => $res['posted_when'],
100
					'page_modified_by' => $res['posted_by'],
101
					'text' => $text,
102
					'max_excerpt_num' => $max_excerpt_num
103
				);
104
				if(print_excerpt2($mod_vars, $func_vars)) {
105
					$result = true;
106
				}
74 107
			}
75 108
		}
76 109
	}
......
81 114
	$query = $func_database->query("
82 115
		SELECT DISTINCT g.title, g.group_id
83 116
		FROM $table_groups AS g INNER JOIN $table_posts AS p ON g.group_id = p.group_id
84
		WHERE g.section_id='$func_section_id' AND g.active = '1' AND p.active = '1'
117
		WHERE g.section_id='$func_section_id' AND g.active = '1' AND p.active = '1' AND $search_sql3
85 118
	");
86 119
	// now call print_excerpt() for every single group, too
87 120
	if($query->numRows() > 0) {
88 121
		while($res = $query->fetchRow()) {
122
			// break out if stop-time is reached
123
			if(isset($stop_time) && time()>$stop_time) return($result);
89 124
			$mod_vars = array(
90 125
				'page_link' => $func_page_link,
91 126
				'page_link_target' => "&g=".$res['group_id'],

Also available in: Unified diff