Plugin Directory

Changeset 1056834


Ignore:
Timestamp:
12/30/2014 11:33:48 AM (11 years ago)
Author:
naveenann
Message:

Custom fields update

Location:
opensearchserver-search/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • opensearchserver-search/trunk/index.php

    r1045670 r1056834  
    152152  delete_option('oss_index_from');
    153153  delete_option('oss_index_to');
    154   delete_option('oss_custom_field');
    155154  delete_option('oss_enable_translation_wpml');
    156155  delete_option('oss_advanced_query_settings_not_automatic');
     
    166165          delete_option($check_taxonomy_name);
    167166    }
     167  $custom_field_lables = opensearchserver_get_all_custom_fields();
     168    foreach($custom_field_lables as $custom_field_label => $key) {
     169      $check_custom_field_label = 'oss_custom_field_'.strtolower(str_replace(' ', '_', $custom_field_label));
     170      delete_option($check_custom_field_label);
     171  }
    168172}
    169173
  • opensearchserver-search/trunk/opensearchserver_admin.php

    r1056819 r1056834  
    2929function opensearchserver_create_index() {
    3030  $indexName = get_option('oss_indexname');
    31   $custom_fields = get_option('oss_custom_field');
    3231  $oss_api = opensearchserver_getapi_instance();
    3332  $index_list = $oss_api->indexList();
     
    3837
    3938  $oss_api->createIndex($indexName);
    40   opensearchserver_create_schema($custom_fields);
    41   opensearchserver_query_template($custom_fields);
     39  opensearchserver_create_schema();
     40  opensearchserver_query_template();
    4241  opensearchserver_spellcheck_query_template();
    4342  $autocompletion = opensearchserver_getautocomplete_instance();
     
    6059*/
    6160
    62 function opensearchserver_create_schema($custom_fields) {
     61function opensearchserver_create_schema() {
    6362  $schema = opensearchserver_getschema_instance();
    6463  $schema_xml = $schema->getSchema();
     
    133132 * Function to update the query template
    134133*/
    135 function opensearchserver_query_template($custom_fields) {
     134function opensearchserver_query_template() {
    136135  $query_template = opensearchserver_getsearchtemplate_instance();
    137136  $oss_query = stripcslashes(get_option('oss_query'));
     
    171170    }
    172171  }
    173   if (isset($custom_fields) && $custom_fields != null) {
    174     $custom_fields_array = explode(',', $custom_fields);
    175     foreach ($custom_fields_array as $field) {
    176       $field = opensearchserver_clean_field($field);
    177       if (strlen($field) > 0) {
    178         $query_template->setReturnField('search','custom_'.$field);
    179       }
    180     }
    181   }
    182172}
    183173
     
    246236  $oss_login =  get_option('oss_login');
    247237  $oss_key = get_option('oss_key');
    248   $custom_fields = get_option('oss_custom_field');
    249238  $lang = get_option('oss_language', '');
    250239  $table_name_posts =$wpdb->prefix ."posts";
     
    258247    opensearchserver_delete_document($delete);
    259248    $index = new OSSIndexDocument();
    260     opensearchserver_add_documents_to_index($index, $lang, get_post($id), $custom_fields);
     249    opensearchserver_add_documents_to_index($index, $lang, get_post($id));
    261250    opensearchserver_checkindex($index);
    262251  } else {
     
    280269    for ($i = 0; $i < $total_count; $i++) {
    281270      $post = get_post($posts[$i]->ID);
    282       opensearchserver_add_documents_to_index($index, $lang, $post, $custom_fields);
     271      opensearchserver_add_documents_to_index($index, $lang, $post);
    283272      $index = opensearchserver_checkindex($index, 200, $i, $total_count);
    284273    }
     
    374363}
    375364
    376 function opensearchserver_add_documents_to_index(OSSIndexDocument $index, $lang, $post, $customFields) {
     365function opensearchserver_add_documents_to_index(OSSIndexDocument $index, $lang, $post) {
    377366  $user = opensearchserver_get_user_cache($post->post_author);
    378367  $content = $post->post_content;
     
    490479   * action "oss_index_document"
    491480   */
    492   do_action('oss_index_document', $document, $index, $lang, $post, $customFields);
     481  do_action('oss_index_document', $document, $index, $lang, $post);
    493482 
    494483  //free memory
     
    737726    $oss_filter_language_field_wpml = isset($_POST['oss_filter_language_field_wpml']) ? $_POST['oss_filter_language_field_wpml'] : NULL;
    738727    update_option('oss_filter_language_field_wpml', $oss_filter_language_field_wpml);
    739    
    740     //some options needs to post changes to OSS
    741     if(!opensearchserver_is_query_settings_not_automatic() || (isset($_POST['oss_query_settings_post_to_oss']) && $_POST['oss_query_settings_post_to_oss'] == 1)) {
    742         $custom_fields = get_option('oss_custom_field');   
    743         opensearchserver_query_template($custom_fields);
    744     }
    745    
     728    //some options needs to post changes to OSS
     729    if(!opensearchserver_is_query_settings_not_automatic() || (isset($_POST['oss_query_settings_post_to_oss']) && $_POST['oss_query_settings_post_to_oss'] == 1)) {
     730      opensearchserver_query_template();
     731    }
    746732    opensearchserver_display_messages('OpenSearchServer Query Settings have been updated.');
    747733}
  • opensearchserver-search/trunk/opensearchserver_search_functions.php

    r1021525 r1056834  
    368368}
    369369
    370 function opensearchserver_get_custom_fields() {
    371   return explode(",",get_option('oss_custom_field'));
    372 }
    373370
    374371/**
Note: See TracChangeset for help on using the changeset viewer.