Changeset 13197
- Timestamp:
- 10/31/07 10:17:03 (1 year ago)
- Files:
-
- trunk/midcom/midcom.helper.search/viewer.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.search/viewer.php
r12972 r13197 31 31 32 32 // Resultlists, controlled using HTTP GET/POST 33 $this->_request_switch[] = Array ( 'fixed_args' => 'result', 'no_cache' => true, 'handler' => 'result' );33 $this->_request_switch[] = Array ( 'fixed_args' => 'result', 'no_cache' => true, 'handler' => 'result' ); 34 34 35 35 // Advanced search form, no args 36 36 $this->_request_switch['advanced'] = Array ( 'fixed_args' => 'advanced', 'handler' => 'searchform' ); 37 37 } 38 39 38 40 39 /** 41 40 * Search form handler, nothing to do here. … … 71 70 return true; 72 71 } 73 72 74 73 /** 75 74 * Search form show handler, displays the search form, including … … 93 92 if ($GLOBALS['midcom_config']['i18n_multilang_strict']) 94 93 { 95 $final_query .= ' AND (__LANG:"' . $_MIDCOM->i18n->get_current_language() . '" OR __LANG:"")'; 96 } 94 $final_query .= ' AND (__LANG:"' . $_MIDCOM->i18n->get_current_language() . '")'; 95 } 96 } 97 98 /** 99 * Expand arrays of custom rules to end of query 100 * 101 * @param $final_query reference to the query string to be passed on to the indexer. 102 * @param $terms array or string to append 103 */ 104 function append_terms_recursive(&$final_query, $terms) 105 { 106 if (is_array($terms)) 107 { 108 foreach ($terms as $term) 109 { 110 $this->append_terms_recursive($final_query, $term); 111 } 112 return; 113 } 114 if (is_string($terms)) 115 { 116 $final_query .= "{$terms}"; 117 return; 118 } 119 debug_push_class(__CLASS__, __FUNCTION__); 120 debug_add('Don\'t know how to handle terms of type: ' . gettype($terms), MIDCOM_LOG_ERROR); 121 debug_print_r('$terms', $terms); 122 debug_pop(); 123 return; 97 124 } 98 125 … … 157 184 { 158 185 case 'basic': 159 $final_query = $data['query'];186 $final_query = $data['query']; 160 187 $this->add_multilang_terms($final_query); 161 188 debug_add("Final query: {$final_query}"); 162 $result = $indexer->query($final_query);189 $result = $indexer->query($final_query); 163 190 break; 164 191 165 192 case 'advanced': 166 $data['request_topic'] = trim($_REQUEST['topic']);193 $data['request_topic'] = trim($_REQUEST['topic']); 167 194 $data['component'] = trim($_REQUEST['component']); 168 195 $data['lastmodified'] = (integer) trim($_REQUEST['lastmodified']); … … 201 228 } 202 229 $final_query .= "__COMPONENT:{$data['component']}"; 230 } 231 232 // Way to add very custom terms 233 if (isset($_REQUEST['append_terms'])) 234 { 235 $this->append_terms_recursive($final_query, $_REQUEST['append_terms']); 203 236 } 204 237 … … 231 264 if ($count > 0) 232 265 { 233 $results_per_page = $this->_config->get('results_per_page');234 $max_pages = ceil($count / $results_per_page);266 $results_per_page = $this->_config->get('results_per_page'); 267 $max_pages = ceil($count / $results_per_page); 235 268 $page = min($_REQUEST['page'], $max_pages); 236 $first_document_id = ($page - 1) * $results_per_page;269 $first_document_id = ($page - 1) * $results_per_page; 237 270 $last_document_id = min(($count - 1), (($page * $results_per_page) - 1)); 238 239 $data['page'] = $page;271 272 $data['page'] = $page; 240 273 $data['max_pages'] = $max_pages; 241 274 $data['first_document_number'] = $first_document_id + 1; … … 248 281 return true; 249 282 } 250 283 251 284 /** 252 285 * Displays the resultset.
