Changeset 1099096
- Timestamp:
- 02/25/2015 10:03:29 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
opensearchserver-search/trunk/opensearchserver_admin.php
r1098191 r1099096 234 234 function opensearchserver_reindex_site_with_cron() { 235 235 global $wpdb; 236 opensearchserver_reindex_init();236 $lang = get_option('oss_language', ''); 237 237 opensearchserver_delete_document('*:*'); 238 $contentTypesToKeep = array();239 foreach (get_post_types() as $post_type) {240 if (get_option('oss_index_types_'.$post_type) == 1) {241 $contentTypesToKeep[] = $post_type;242 }243 }244 $sql_query = 'SELECT ID FROM '.$wpdb->posts.' WHERE post_status = \'publish\' AND post_type IN ("'.implode('","', $contentTypesToKeep).'") ORDER BY ID'.$limitSuffix;245 $posts = $wpdb->get_results($sql_query);246 $total_count = count($posts);247 $index = new OSSIndexDocument();248 for ($i = 0; $i < $total_count; $i++) {249 $post = get_post($posts[$i]->ID);250 opensearchserver_add_documents_to_index($index, $lang, $post);251 $index = opensearchserver_checkindex($index, 200, $i, $total_count, FALSE);252 }253 opensearchserver_checkindex($index, 1, $i, $total_count,FALSE);238 $contentTypesToKeep = array(); 239 foreach (get_post_types() as $post_type) { 240 if (get_option('oss_index_types_'.$post_type) == 1) { 241 $contentTypesToKeep[] = $post_type; 242 } 243 } 244 $sql_query = 'SELECT ID FROM '.$wpdb->posts.' WHERE post_status = \'publish\' AND post_type IN ("'.implode('","', $contentTypesToKeep).'") ORDER BY ID'; 245 $posts = $wpdb->get_results($sql_query); 246 $total_count = count($posts); 247 $index = new OSSIndexDocument(); 248 for ($i = 0; $i < $total_count; $i++) { 249 $post = get_post($posts[$i]->ID); 250 opensearchserver_add_documents_to_index($index, $lang, $post); 251 $index = opensearchserver_checkindex($index, 200, $i, $total_count, FALSE); 252 } 253 opensearchserver_checkindex($index, 1, $i, $total_count,FALSE); 254 254 opensearchserver_optimize(); 255 255 opensearchserver_autocompletionBuild(); 256 256 return 1; 257 257 } 258 /* 259 * Function to initialize the variable for reindex. 260 */ 261 function opensearchserver_reindex_init() { 262 global $wpdb; 263 $oss_server_url = get_option('oss_serverurl'); 264 $oss_indexname = get_option('oss_indexname'); 265 $oss_login = get_option('oss_login'); 266 $oss_key = get_option('oss_key'); 267 $lang = get_option('oss_language', ''); 268 $table_name_posts =$wpdb->prefix ."posts"; 269 $table_name_users =$wpdb->prefix ."users"; 270 $index_status=0; 271 $ossEnginePath = config_request_value('ossEnginePath', $oss_server_url, 'engineURL'); 272 $ossEngineConnectTimeOut = config_request_value('ossEngineConnectTimeOut', 5, 'engineConnectTimeOut'); 273 $ossEngineIndex = config_request_value('ossEngineIndex', $oss_indexname, 'engineIndex'); 274 } 258 275 259 /* 276 260 * Function to reindex the website. 277 261 */ 278 function opensearchserver_reindex_site($id, $type, $from = 0, $to = 0) {262 function opensearchserver_reindex_site($id, $type, $from = 0, $to = 0) { 279 263 global $wpdb; 280 opensearchserver_reindex_init();264 $lang = get_option('oss_language', ''); 281 265 if($id) { 282 266 $delete='id:'.$type.'_'.$id; … … 895 879 $post_oss_submit = $_POST['opensearchserver_submit']; 896 880 if($post_oss_submit == 'Synchronize with CRON') { 897 wp_schedule_single_event(time() , 'synchronize_with_cron');881 wp_schedule_single_event(time() + 900, 'synchronize_with_cron'); 898 882 opensearchserver_display_messages('Re indexing has been successfully scheduled with cron will be executed in next 15 minutes.'); 899 883 }else {
Note: See TracChangeset
for help on using the changeset viewer.