Changeset 1025
- Timestamp:
- 03/04/07 19:09:14 (2 years ago)
- Files:
-
- trunk/src/lyceum/wp-includes/classes.php (modified) (4 diffs)
- trunk/src/lyceum/wp-includes/template-functions-links.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/lyceum/wp-includes/classes.php
r1024 r1025 427 427 428 428 // If a search pattern is specified, load the posts that match 429 $search_join = false; 429 430 if (!empty($q['s'])) { 431 $search_join = true; 430 432 $q['s'] = addslashes_gpc($q['s']); 431 433 $search = ' AND ('; … … 434 436 $q['s'] = str_replace('"', ' ', $q['s']); 435 437 $q['s'] = trim($q['s']); 436 /*if ($q['exact']) {438 if ($q['exact']) { 437 439 $n = ''; 438 440 } else { … … 442 444 $s_array = explode(' ',$q['s']); 443 445 $q['search_terms'] = $s_array; 444 $search .= '( (post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';446 $search .= '(textdata LIKE \''.$n.$s_array[0].$n.'\')'; 445 447 for ( $i = 1; $i < count($s_array); $i = $i + 1) { 446 $search .= ' AND ( (post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';447 } 448 $search .= ' OR ( post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_contentLIKE \''.$n.$q['s'].$n.'\')';448 $search .= ' AND (textdata LIKE \''.$n.$s_array[$i].$n.'\')'; 449 } 450 $search .= ' OR (textdata LIKE \''.$n.$q['s'].$n.'\')'; 449 451 $search .= ')'; 450 452 } else { 451 $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))'; 452 } 453 */ 454 // this is just raw basic functionality to work with new search table, need to add a lot more features 455 // (at least create parallel user-facing search syntax as wordpress) 456 $thesearchterms = $q['s']; 457 /* not sure why this isn't working with the MATCH AGAINST notation 458 note: this version uses subquereis, which requires mysql 4.1 459 $search = " 460 AND (`$wpdb->posts`.`ID` IN ( 461 SELECT DISTINCT `post_id` 462 FROM `$wpdb->postsearch` 463 WHERE MATCH `textdata` AGAINST ('$thesearchterms' IN BOOLEAN MODE) 464 ))";*/ 465 466 // this will work most of the time 467 $searchresults = $wpdb->get_col(" 468 SELECT DISTINCT `post_id` 469 FROM `$wpdb->postsearch` 470 WHERE `textdata` LIKE '%$thesearchterms%' 471 "); 472 473 $searchresults = implode(',',$searchresults); 474 475 if ($searchresults) 476 $search = " 477 AND (`$wpdb->posts`.`ID` IN ($searchresults))"; 453 $search = ' AND (textdata LIKE \''.$n.$q['s'].$n.'\')'; 454 } 478 455 } 479 456 … … 649 626 650 627 $where .= $blogblog; 628 if ($search_join) 629 $join .= " INNER JOIN $wpdb->postsearch ON ($wpdb->post2cat.post_id = $wpdb->postsearch.post_id) "; 651 630 // Apply filters on where and join prior to paging so that any 652 631 // manipulations to them are reflected in the paging by day queries. trunk/src/lyceum/wp-includes/template-functions-links.php
r1003 r1025 492 492 preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 493 493 $fromwhere = $matches[1]; 494 $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");494 $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere"); 495 495 $max_page = $max_num_pages = ceil($numposts / $posts_per_page); 496 496 } … … 536 536 preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 537 537 $fromwhere = $matches[1]; 538 $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");538 $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere"); 539 539 $max_num_pages = ceil($numposts / $posts_per_page); 540 540 }
