Changeset 707358
- Timestamp:
- 05/03/2013 09:26:40 AM (13 years ago)
- Location:
- opensearchserver-search/trunk
- Files:
-
- 4 edited
-
css/oss-style.css (modified) (2 diffs)
-
opensearchserver_admin.php (modified) (13 diffs)
-
readme.txt (modified) (1 diff)
-
template/opensearchserver_search.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
opensearchserver-search/trunk/css/oss-style.css
r602348 r707358 32 32 } 33 33 34 #oss-keyword { 35 width: 400px; 36 } 37 34 38 #oss-filter { 35 39 margin: 0; … … 63 67 64 68 #oss-submit { 65 background-color: #4D90FE;66 border: 1px solid #3079ED;67 color: #FFFFFF;68 border-bottom-left-radius: 3px;69 border-bottom-right-radius: 3px;70 border-top-left-radius: 3px;71 border-top-right-radius: 3px;72 69 cursor: default; 73 70 display: inline-block; 74 font-weight: bold;75 height: 31px;76 min-width: 54px;77 padding: 0 8px;78 margin-left: 10px;79 text-align: center;80 text-decoration: none;81 71 } 82 72 -
opensearchserver-search/trunk/opensearchserver_admin.php
r685110 r707358 206 206 $index = new OSSIndexDocument(); 207 207 for ($i = 0; $i < $total_count; $i++) { 208 $id = $posts[$i]->ID; 209 opensearchserver_add_documents_to_index($index, $lang, get_post($id), $custom_fields); 210 $index = opensearchserver_checkindex($index, 200, $i, $total_count); 208 $post = get_post($posts[$i]->ID); 209 if (get_option('oss_index_types_'.$post->post_type) == 1) { 210 opensearchserver_add_documents_to_index($index, $lang, $post, $custom_fields); 211 $index = opensearchserver_checkindex($index, 200, $i, $total_count); 212 } 211 213 } 212 214 opensearchserver_checkindex($index, 1, $i, $total_count); … … 248 250 $current = ord($value{$i}); 249 251 if (($current == 0x9) || 250 ($current == 0xA) ||251 ($current == 0xD) ||252 (($current >= 0x20) && ($current <= 0xD7FF)) ||253 (($current >= 0xE000) && ($current <= 0xFFFD)) ||254 (($current >= 0x10000) && ($current <= 0x10FFFF))){252 ($current == 0xA) || 253 ($current == 0xD) || 254 (($current >= 0x20) && ($current <= 0xD7FF)) || 255 (($current >= 0xE000) && ($current <= 0xFFFD)) || 256 (($current >= 0x10000) && ($current <= 0x10FFFF))){ 255 257 $ret .= chr($current); 256 258 } … … 367 369 function opensearchserver_get_fields() { 368 370 return array('none'=>'Select', 369 'title' => 'Title', 370 'content' =>'Content', 371 'url' => 'Url', 372 'user_name' => 'User Name', 373 'user_email' => 'User Email', 374 'user_url' => 'User URL', 375 'id' => 'ID', 376 'type' => 'Type', 377 'timestamp' => 'TimeStamp', 378 'categoriesExact' => 'Categories'); 379 } 380 371 'title' => 'Title', 372 'content' =>'Content', 373 'url' => 'Url', 374 'user_name' => 'User Name', 375 'user_email' => 'User Email', 376 'user_url' => 'User URL', 377 'id' => 'ID', 378 'type' => 'Type', 379 'timestamp' => 'TimeStamp', 380 'categoriesExact' => 'Categories'); 381 } 382 383 function opensearchserver_admin_set_instance_settings() { 384 $oss_url = isset($_POST['oss_serverurl']) ? $_POST['oss_serverurl'] :NULL; 385 $oss_indexname = isset($_POST['oss_indexname']) ? $_POST['oss_indexname'] :NULL; 386 $oss_login = isset($_POST['oss_login']) ? $_POST['oss_login'] :NULL; 387 $oss_key = isset($_POST['oss_key']) ? $_POST['oss_key'] :NULL; 388 update_option('oss_serverurl', $oss_url); 389 update_option('oss_indexname', $oss_indexname); 390 update_option('oss_login', $oss_login); 391 update_option('oss_key', $oss_key); 392 opensearchserver_display_messages('OpenSearchServer Instance Settings has been updated'); 393 } 394 395 function opensearchserver_admin_set_query_settings() { 396 $delete = isset($_POST['oss_delete']) ? $_POST['oss_delete'] :NULL; 397 $delete_action = isset($_POST['opensearchserver_delete']) ? $_POST['opensearchserver_delete'] :NULL; 398 if($delete !=NULL && $delete_action === 'Delete') { 399 $facets = get_option('oss_facet'); 400 foreach ($facets as $key => $facet) { 401 if(trim($facet) == trim($delete)) { 402 unset($facets[$key]); 403 } 404 } 405 update_option('oss_facet', $facets); 406 }else { 407 $oss_query = isset($_POST['oss_query']) ? $_POST['oss_query'] : NULL; 408 if (isset($oss_query)) { 409 $oss_query = trim($oss_query); 410 if (strlen($oss_query) == 0) { 411 $oss_query = opensearchserver_default_query(); 412 } 413 } 414 $oss_facet = isset($_POST['oss_facet']) ? $_POST['oss_facet'] : NULL; 415 $oss_spell = isset($_POST['oss_spell']) ? $_POST['oss_spell'] : NULL; 416 $oss_spell_algo = isset($_POST['oss_spell_algo']) ? $_POST['oss_spell_algo'] : NULL; 417 update_option('oss_query', $oss_query); 418 if($oss_facet != 'none') { 419 if(get_option('oss_facet')) { 420 $facet = get_option('oss_facet'); 421 }else { 422 $facet = array(); 423 } 424 if (!in_array($oss_facet, $facet)) { 425 array_push($facet,$oss_facet); 426 } 427 update_option('oss_facet', $facet); 428 } 429 $oss_multi_filter = isset($_POST['oss_multi_filter']) ? $_POST['oss_multi_filter'] : NULL; 430 update_option('oss_multi_filter', $oss_multi_filter); 431 $oss_facet_behavior = isset($_POST['oss_facet_behavior']) ? $_POST['oss_facet_behavior'] : NULL; 432 update_option('oss_facet_behavior', $oss_facet_behavior); 433 update_option('oss_spell', $oss_spell); 434 update_option('oss_spell_algo', $oss_spell_algo); 435 $oss_language = isset($_POST['oss_language']) ? $_POST['oss_language'] : NULL; 436 update_option('oss_language', $oss_language); 437 $oss_phonetic = isset($_POST['oss_phonetic']) ? $_POST['oss_phonetic'] : NULL; 438 update_option('oss_phonetic', $oss_phonetic); 439 $oss_display_user = isset($_POST['oss_display_user']) ? $_POST['oss_display_user'] : NULL; 440 update_option('oss_display_user', $oss_display_user); 441 $oss_display_category = isset($_POST['oss_display_category']) ? $_POST['oss_display_category'] : NULL; 442 update_option('oss_display_category', $oss_display_category); 443 $oss_display_type = isset($_POST['oss_display_type']) ? $_POST['oss_display_type'] : NULL; 444 update_option('oss_display_type', $oss_display_type); 445 opensearchserver_display_messages('OpenSearchServer Query Settings has been updated.'); 446 } 447 } 448 449 function opensearchserver_admin_set_index_settings() { 450 $post_oss_submit = $_POST['opensearchserver_submit']; 451 if ($post_oss_submit == 'Update Index Settings »') { 452 foreach (get_post_types() as $post_type) { 453 $post_form_type = (int)$_POST['oss_index_types_'.$post_type]; 454 update_option('oss_index_types_'.$post_type, $post_form_type); 455 } 456 opensearchserver_display_messages('OpenSearchServer Index Settings has been updated.'); 457 } else { 458 $is_index_created = opensearchserver_create_index(); 459 opensearchserver_display_messages('Index '.get_option('oss_indexname').' Created successfully'); 460 } 461 } 462 463 function opensearchserver_admin_set_custom_fields_settings() { 464 $oss_custom_field = isset($_POST['oss_custom_field']) ? $_POST['oss_custom_field'] :NULL; 465 update_option('oss_custom_field', $oss_custom_field); 466 opensearchserver_display_messages('OpenSearchServer Custom Fields Settings has been updated.'); 467 } 468 469 function opensearchserver_admin_set_reindex() { 470 $oss_index_from = isset($_POST['oss_index_from']) ? $_POST['oss_index_from'] : NULL; 471 $oss_index_to = isset($_POST['oss_index_to']) ? $_POST['oss_index_to'] : NULL; 472 update_option('oss_index_from', $oss_index_from); 473 update_option('oss_index_to', $oss_index_to); 474 $index_success = opensearchserver_reindex_site(NULL,NULL, $oss_index_from, $oss_index_to); 475 opensearchserver_display_messages('Re indexing has been finished successfully.'); 476 } 381 477 /* 382 478 * The admin page settings actions … … 386 482 $facet_behaviour = array('separate_query'=>'Separate query','no_separate_query'=>'No separate query'); 387 483 $spellcheck_fields = array( 388 'none'=>'Select',389 'title' => 'Title',390 'content' =>'Content');484 'none'=>'Select', 485 'title' => 'Title', 486 'content' =>'Content'); 391 487 $spellcheck_algo = array( 392 'JaroWinklerDistance' => 'JaroWinklerDistance',393 'LevensteinDistance' => 'LevensteinDistance',394 'NGramDistance' => 'NGramDistance');488 'JaroWinklerDistance' => 'JaroWinklerDistance', 489 'LevensteinDistance' => 'LevensteinDistance', 490 'NGramDistance' => 'NGramDistance'); 395 491 $languages = array( 396 '' => 'Undefined',397 'ar' => 'Arabic',398 'zh' => 'Chinese',399 'da' => 'Danish',400 'nl' => 'Dutch',401 'en' => 'English',402 'fi' => 'Finnish',403 'fr' => 'French',404 'de' => 'German',405 'hu' => 'Hungarian',406 'it' => 'Italian',407 'no' => 'Norwegian',408 'pt' => 'Portuguese',409 'ro' => 'Romanian',410 'ru' => 'Russian',411 'es' => 'Spanish',412 'sv' => 'Swedish',413 'tr' => 'Turkish'492 '' => 'Undefined', 493 'ar' => 'Arabic', 494 'zh' => 'Chinese', 495 'da' => 'Danish', 496 'nl' => 'Dutch', 497 'en' => 'English', 498 'fi' => 'Finnish', 499 'fr' => 'French', 500 'de' => 'German', 501 'hu' => 'Hungarian', 502 'it' => 'Italian', 503 'no' => 'Norwegian', 504 'pt' => 'Portuguese', 505 'ro' => 'Romanian', 506 'ru' => 'Russian', 507 'es' => 'Spanish', 508 'sv' => 'Swedish', 509 'tr' => 'Turkish' 414 510 ); 415 511 416 512 417 513 $action = isset($_POST['oss_submit']) ? $_POST['oss_submit'] :NULL; 418 if($action == 'settings') { 419 $oss_url = isset($_POST['oss_serverurl']) ? $_POST['oss_serverurl'] :NULL; 420 $oss_indexname = isset($_POST['oss_indexname']) ? $_POST['oss_indexname'] :NULL; 421 $oss_login = isset($_POST['oss_login']) ? $_POST['oss_login'] :NULL; 422 $oss_key = isset($_POST['oss_key']) ? $_POST['oss_key'] :NULL; 423 update_option('oss_serverurl', $oss_url); 424 update_option('oss_indexname', $oss_indexname); 425 update_option('oss_login', $oss_login); 426 update_option('oss_key', $oss_key); 427 opensearchserver_display_messages('OpenSearchServer Settings has been updated'); 428 } 429 if($action == 'query_settings') { 430 $delete = isset($_POST['oss_delete']) ? $_POST['oss_delete'] :NULL; 431 $delete_action = isset($_POST['opensearchserver_delete']) ? $_POST['opensearchserver_delete'] :NULL; 432 if($delete !=NULL && $delete_action === 'Delete') { 433 $facets = get_option('oss_facet'); 434 foreach ($facets as $key => $facet) { 435 if(trim($facet) == trim($delete)) { 436 unset($facets[$key]); 437 } 438 } 439 update_option('oss_facet', $facets); 440 }else { 441 $oss_query = isset($_POST['oss_query']) ? $_POST['oss_query'] : NULL; 442 if (isset($oss_query)) { 443 $oss_query = trim($oss_query); 444 if (strlen($oss_query) == 0) { 445 $oss_query = opensearchserver_default_query(); 446 } 447 } 448 $oss_facet = isset($_POST['oss_facet']) ? $_POST['oss_facet'] : NULL; 449 $oss_spell = isset($_POST['oss_spell']) ? $_POST['oss_spell'] : NULL; 450 $oss_spell_algo = isset($_POST['oss_spell_algo']) ? $_POST['oss_spell_algo'] : NULL; 451 update_option('oss_query', $oss_query); 452 if($oss_facet != 'none') { 453 if(get_option('oss_facet')) { 454 $facet = get_option('oss_facet'); 455 }else { 456 $facet = array(); 457 } 458 if (!in_array($oss_facet, $facet)) { 459 array_push($facet,$oss_facet); 460 } 461 update_option('oss_facet', $facet); 462 } 463 $oss_multi_filter = isset($_POST['oss_multi_filter']) ? $_POST['oss_multi_filter'] : NULL; 464 update_option('oss_multi_filter', $oss_multi_filter); 465 $oss_facet_behavior = isset($_POST['oss_facet_behavior']) ? $_POST['oss_facet_behavior'] : NULL; 466 update_option('oss_facet_behavior', $oss_facet_behavior); 467 update_option('oss_spell', $oss_spell); 468 update_option('oss_spell_algo', $oss_spell_algo); 469 $oss_language = isset($_POST['oss_language']) ? $_POST['oss_language'] : NULL; 470 update_option('oss_language', $oss_language); 471 $oss_phonetic = isset($_POST['oss_phonetic']) ? $_POST['oss_phonetic'] : NULL; 472 update_option('oss_phonetic', $oss_phonetic); 473 opensearchserver_display_messages('OpenSearchServer Settings has been updated.'); 474 } 475 476 } 477 if($action == 'index_settings') { 478 $is_index_created = opensearchserver_create_index(); 479 opensearchserver_display_messages('Index '.get_option('oss_indexname').' Created successfully'); 480 } 481 if($action == 'custom_field_settings') { 482 $oss_custom_field = isset($_POST['oss_custom_field']) ? $_POST['oss_custom_field'] :NULL; 483 update_option('oss_custom_field', $oss_custom_field); 484 opensearchserver_display_messages('OpenSearchServer Settings has been updated.'); 485 } 486 if($action == 'opensearchserver_reindex') { 487 $oss_index_from = isset($_POST['oss_index_from']) ? $_POST['oss_index_from'] : NULL; 488 $oss_index_to = isset($_POST['oss_index_to']) ? $_POST['oss_index_to'] : NULL; 489 update_option('oss_index_from', $oss_index_from); 490 update_option('oss_index_to', $oss_index_to); 491 $index_success = opensearchserver_reindex_site(NULL,NULL, $oss_index_from, $oss_index_to); 492 opensearchserver_display_messages('Re indexing has been finished successfully.'); 514 if ($action == 'settings') { 515 opensearchserver_admin_set_instance_settings(); 516 } else if ($action == 'query_settings') { 517 opensearchserver_admin_set_query_settings(); 518 } else if ($action == 'index_settings') { 519 opensearchserver_admin_set_index_settings(); 520 }else if ($action == 'custom_field_settings') { 521 opensearchserver_admin_set_custom_fields_settings(); 522 } if ($action == 'opensearchserver_reindex') { 523 opensearchserver_admin_set_reindex(); 493 524 } 494 525 ?> … … 538 569 value="<?php print get_option('oss_key');?>" /><br /> 539 570 </p> 540 <input type="hidden" name="oss_submit" id="oss_submit" 541 value="settings" /> 571 <input type="hidden" name="oss_submit" value="settings" /> 542 572 <p> 543 573 <input type="submit" name="opensearchserver_submit" 544 value="Update Settings »" class="button-primary" />574 value="Update Instance Settings »" class="button-primary" /> 545 575 </p> 546 576 </div> 547 577 </form> 548 578 </div> 549 <div class="postbox closed" id="second">579 <div class="postbox" id="second"> 550 580 <div class="handlediv" title="Click to toggle"> 551 581 <br /> … … 570 600 </p> 571 601 <p> 572 <label for="oss_ query">Facet field</label>:<br /> <select602 <label for="oss_facet">Facet field</label>:<br /> <select 573 603 name="oss_facet"> 574 604 <?php … … 597 627 <tr> 598 628 <td><?php print $fields[$facet]; ?></td> 599 <td><input type="hidden" name="oss_delete" id="oss_submit"629 <td><input type="hidden" name="oss_delete" 600 630 value="<?php print $facet; ?>" /> <input type="submit" 601 631 name="opensearchserver_delete" value="Delete" … … 607 637 <?php }?> 608 638 <p> 609 <label for="oss_facet_behavior">Facet behavior 610 </label>:<br /> <selectname="oss_facet_behavior"><?php611 $facet_option = get_option('oss_facet_behavior');612 foreach ($facet_behaviour as $key => $field) {639 <label for="oss_facet_behavior">Facet behavior </label>:<br /> <select 640 name="oss_facet_behavior"><?php 641 $facet_option = get_option('oss_facet_behavior'); 642 foreach ($facet_behaviour as $key => $field) { 613 643 $selected = ''; 614 644 if($facet_behaviour[$facet_option] == $field) { … … 628 658 </p> 629 659 <p> 630 <label for="oss_ query">SpellCheck field</label>:<br /> <select660 <label for="oss_spell">SpellCheck field</label>:<br /> <select 631 661 name="oss_spell"><?php 632 662 $facet = get_option('oss_spell'); … … 682 712 </p> 683 713 <p> 684 <input type="hidden" name="oss_submit" id="oss_submit" 685 value="query_settings" /> <input type="submit" 686 name="opensearchserver_submit" value="Update Options »" 687 class="button-primary" /> 714 Display: <input type="checkbox" name="oss_display_user" 715 value="1" 716 <?php checked( 1 == get_option('oss_display_user')); ?> /> <label 717 for="oss_display_user">user</label> <input 718 type="checkbox" name="oss_display_category" value="1" 719 <?php checked( 1 == get_option('oss_display_category')); ?> /> <label 720 for="oss_display_category">category</label> <input 721 type="checkbox" name="oss_display_type" value="1" 722 <?php checked( 1 == get_option('oss_display_type')); ?> /> <label 723 for="oss_display_type">type</label> 724 </p> 725 <p> 726 <input type="hidden" name="oss_submit" value="query_settings" /> 727 <input type="submit" name="opensearchserver_submit" 728 value="Update Query Settings »" class="button-primary" /> 688 729 </p> 689 730 </form> 690 731 </div> 691 732 </div> 692 <div class="postbox closed" id="third">733 <div class="postbox" id="third"> 693 734 <div class="handlediv" title="Click to toggle"> 694 735 <br /> … … 701 742 action=""> 702 743 <p> 703 <label for="oss_create_index">Create an index</label>: <input 704 type="text" name="oss_indexname_create" id="oss_indexname" 705 placeholder="opensearchserver_wordpress" size="50" 706 value="<?php print get_option('oss_indexname');?>" 707 disabled="disabled" /> <input type="hidden" name="oss_submit" 708 id="oss_submit" value="index_settings" /><input type="submit" 709 name="opensearchserver_submit" value="Create Index" 710 class="button-secondary" /> 744 <label for="oss_index_types">Check which type will be indexed:</label><br /> 745 <?php 746 foreach (get_post_types() as $post_type) { 747 $checkTypeName = 'oss_index_types_'.$post_type; 748 ?> 749 <input type="checkbox" name="<?php print $checkTypeName;?>" 750 value="1" <?php checked( 1 == get_option($checkTypeName)); ?> /> <label 751 for="oss_index_types"><?php print $post_type;?> </label><br /> 752 <?php } ?> 753 </p> 754 <p> 755 <input type="hidden" name="oss_submit" value="index_settings" /> 756 <input type="submit" name="opensearchserver_submit" 757 value="Update Index Settings »" class="button-primary" /> <input 758 type="submit" name="opensearchserver_submit" 759 value="(Re-)Create the index" class="button-secondary" /> 760 711 761 </p> 712 762 </form> 713 763 </div> 714 764 </div> 715 <div class="postbox closed" id="fourth">765 <div class="postbox" id="fourth"> 716 766 <div class="handlediv" title="Click to toggle"> 717 767 <br /> … … 736 786 </p> 737 787 <p> 738 <input type="hidden" name="oss_submit" id="oss_submit"788 <input type="hidden" name="oss_submit" 739 789 value="custom_field_settings" /><input type="submit" 740 name="opensearchserver_submit" value="Update Settings »"741 class="button-primary" /><br />790 name="opensearchserver_submit" 791 value="Update Custom Fields Settings »" class="button-primary" /><br /> 742 792 </p> 743 793 </form> … … 745 795 746 796 </div> 747 <form id="reindex_settings" name="reindex_settings" method="post" 748 action=""> 749 <p> 750 <label for="oss_index_from">From index</label>:<br /> <input 751 type="text" name="oss_index_from" id="oss_index_from" size="15" 752 value="<?php print get_option('oss_index_from');?>" /> <br /> 753 </p> 754 <p> 755 <label for="oss_index_to">To index</label>:<br /> <input 756 type="text" name="oss_index_to" id="oss_index_to" size="15" 757 value="<?php print get_option('oss_index_to');?>" /> <br /> 758 </p> 759 <p> 760 <input type="hidden" name="oss_submit" id="oss_submit" 761 value="opensearchserver_reindex" /> <input type="submit" 762 name="opensearchserver_submit" value="Synchronize / Re-Index" 763 class="button-primary" /> 764 </p> 765 </form> 797 <div class="postbox" id="fifth"> 798 <div class="handlediv" title="Click to toggle"> 799 <br /> 800 </div> 801 <h3 class="hndle"> 802 <span>Indexation </span> 803 </h3> 804 <div class="inside"> 805 <form id="reindex_settings" name="reindex_settings" method="post" 806 action=""> 807 <p> 808 <label for="oss_index_from">From index</label>:<br /> <input 809 type="text" name="oss_index_from" id="oss_index_from" size="15" 810 value="<?php print get_option('oss_index_from');?>" /> <br /> 811 </p> 812 <p> 813 <label for="oss_index_to">To index</label>:<br /> <input 814 type="text" name="oss_index_to" id="oss_index_to" size="15" 815 value="<?php print get_option('oss_index_to');?>" /> <br /> 816 </p> 817 <p> 818 <input type="hidden" name="oss_submit" 819 value="opensearchserver_reindex" /> <input type="submit" 820 name="opensearchserver_submit" value="Synchronize / Re-Index" 821 class="button-primary" /> 822 </p> 823 </form> 824 </div> 825 </div> 766 826 </div> 767 827 </div> -
opensearchserver-search/trunk/readme.txt
r690554 r707358 4 4 Requires at least: 3.0.1 5 5 Tested up to: 3.5.1 6 Stable tag: 1.2. 16 Stable tag: 1.2.2 7 7 License: GPLv2 or later 8 8 -
opensearchserver-search/trunk/template/opensearchserver_search.php
r685110 r707358 20 20 </div> 21 21 <?php 22 $displayUser = get_option('oss_display_user') == 1; 23 $displayCategory = get_option('oss_display_category') == 1; 24 $displayType = get_option('oss_display_type') == 1; 22 25 $query_fq_parm = isset($_REQUEST['fq']) ? $_REQUEST['fq'] : NULL; 23 26 $query = get_search_query(); … … 159 162 <a href="<?php print $url;?>"><?php print $url;?> </a> 160 163 <?php } 161 if($type && $user ) { 162 163 print $type." By ".$user; 164 if($categories != NULL || $categories != '') { 165 print ' in '. $categories. '<br/>'; 166 }else { 167 print '<br/>'; 168 } 169 }?> 164 if ($displayType || $displayUser || $displayCategory) { 165 print '<br/>'; 166 } 167 if ($type && $displayType) { 168 print $type; 169 } 170 if ($user && $displayUser) { 171 print ' by '.$user; 172 } 173 if (categories != null && $categories != '' && $displayCategory) { 174 print ' in '.categories; 175 } 176 ?> 170 177 </div> 171 178 </div>
Note: See TracChangeset
for help on using the changeset viewer.