- Timestamp:
- 10/13/07 01:13:32 (14 months ago)
- Location:
- trunk/gregarius
- Files:
-
- 3 modified
-
cls/search.php (modified) (5 diffs)
-
cls/wrappers/searchform.php (modified) (1 diff)
-
themes/default/web/searchform.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gregarius/cls/search.php
r1760 r1761 30 30 define ('QUERY_PRM','rss_query'); 31 31 define ('QUERY_MATCH_MODE', 'rss_query_match'); 32 define ('QUERY_MATCH_TYPE', 'rss_query_match_type'); 32 33 define ('QUERY_CHANNEL', 'rss_query_channel'); 33 34 define ('QUERY_RESULTS','rss_query_res_per_page'); … … 42 43 define ('QUERY_MATCH_AND','and'); 43 44 define ('QUERY_MATCH_EXACT','exact'); 45 define ('QUERY_MATCH_WITHIN', 'within'); 44 46 45 47 // This is needed for some constants … … 50 52 var $searchTerms = array(); 51 53 var $matchMode; 54 var $matchType; 52 55 var $regMatch = ""; 53 56 … … 95 98 reset($this->searchTerms); 96 99 $match = ($this->matchMode == QUERY_MATCH_AND || $this->matchMode == QUERY_MATCH_EXACT); 100 97 101 foreach ($this->searchTerms as $term) { 98 if ($this->matchMode == QUERY_MATCH_AND) { 99 $match = ((stristr($descr_noTags, $term) || stristr($title_noTags, $term)) && $match); 100 } else if ($this->matchMode == QUERY_MATCH_EXACT) { 101 $match = (preg_match("/\b" . $term . "\b/i", $descr_noTags) || preg_match("/\b" . $term . "\b/i", $title_noTags)); 102 if ($this->matchMode == QUERY_MATCH_AND || $this->matchMode == QUERY_MATCH_EXACT) { 103 if($this->matchType == QUERY_MATCH_WITHIN) { 104 $match = ((stristr($descr_noTags, $term) || stristr($title_noTags, $term)) && $match); 105 } else { 106 $match = ((preg_match("/\b" . $term . "\b/i", $descr_noTags) || preg_match("/\b" . $term . "\b/i", $title_noTags)) && $match); 107 } 102 108 } else { 103 $match = ($match || (stristr($descr_noTags, $term) || stristr($title_noTags, $term))); 104 } 109 if($this->matchType == QUERY_MATCH_WITHIN) { 110 $match = ($match || (stristr($descr_noTags, $term) || stristr($title_noTags, $term))); 111 } else { 112 $match = ($match || (preg_match("/\b" . $term . "\b/i", $descr_noTags) || preg_match("/\b" . $term . "\b/i", $title_noTags))); 113 } 114 } 105 115 } 106 116 … … 132 142 (!array_key_exists(QUERY_MATCH_MODE, $_REQUEST) ? QUERY_MATCH_AND : $_REQUEST[QUERY_MATCH_MODE]), 133 143 RSS_SANITIZER_CHARACTERS_EXT); 134 144 145 $this->matchType = sanitize( 146 (!array_key_exists(QUERY_MATCH_TYPE, $_REQUEST) ? "" : $_REQUEST[QUERY_MATCH_TYPE]), 147 RSS_SANITIZER_CHARACTERS_EXT); 148 135 149 $this->channelId = sanitize( 136 150 ((array_key_exists(QUERY_CHANNEL, $_REQUEST)) ? $_REQUEST[QUERY_CHANNEL] : ALL_CHANNELS_ID), -
trunk/gregarius/cls/wrappers/searchform.php
r1561 r1761 64 64 return ((array_key_exists(QUERY_ORDER_BY,$_REQUEST) && 65 65 $_REQUEST[QUERY_ORDER_BY] == QUERY_ORDER_BY_CHANNEL)?" checked=\"checked\"":""); 66 } 67 68 function rss_search_within() { 69 return ((array_key_exists(QUERY_MATCH_TYPE, $_REQUEST) && 70 $_REQUEST[QUERY_MATCH_TYPE] == QUERY_MATCH_WITHIN)?" checked=\"checked\"":""); 66 71 } 67 72 -
trunk/gregarius/themes/default/web/searchform.php
r1561 r1761 16 16 <input type="radio" id="qry_match_exact" name="<?php echo QUERY_MATCH_MODE ?>" value="<?php echo QUERY_MATCH_EXACT ?>" <?php echo rss_search_exact_checked() ?>/> 17 17 <label for="qry_match_exact"><?php echo __('Exact match') ?></label> 18 </p> 19 20 <p> 21 <label for="qry_match_within"><?php echo __('Search within words') ?></label> 22 <input type="checkbox" id="qry_match_within" name="<?php echo QUERY_MATCH_TYPE ?>" value="<?php echo QUERY_MATCH_WITHIN ?>" <?php echo rss_search_within() ?> /> 18 23 </p> 19 24
