Changeset 603172
- Timestamp:
- 09/24/2012 04:38:31 PM (13 years ago)
- Location:
- opensearchserver-search/trunk
- Files:
-
- 9 edited
-
autocomplete.php (modified) (1 diff)
-
index.php (modified) (5 diffs)
-
lib/oss_api.class.php (modified) (2 diffs)
-
lib/oss_results.class.php (modified) (1 diff)
-
lib/oss_search.class.php (modified) (5 diffs)
-
lib/oss_searchtemplate.class.php (modified) (2 diffs)
-
opensearchserver_admin.php (modified) (18 diffs)
-
opensearchserver_search_functions.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
opensearchserver-search/trunk/autocomplete.php
r601998 r603172 14 14 $count = count($result_array)-1; 15 15 for($i=0;$i<$count;$i++) { 16 echo $result_array[$i];17 echo "\r\n";16 echo $result_array[$i]; 17 echo "\r\n"; 18 18 } 19 19 -
opensearchserver-search/trunk/index.php
r602396 r603172 3 3 Plugin Name: OpenSearchServer 4 4 Plugin URI: http://wordpress.org/extend/plugins/opensearchserver-search/ 5 Description: This Plugin will integrate OpenSearchServer 1.3as search engine for Wordpress.Go to <a href="plugins.php?page=opensearchserver/index.php">OpenSearchServer Settings</a> for OpenSearchServer Settings,6 Author: Naveen.A.N5 Description: This Plugin will integrate OpenSearchServer as search engine for Wordpress.Go to <a href="plugins.php?page=opensearchserver/index.php">OpenSearchServer Settings</a> for OpenSearchServer Settings, 6 Author: Emmanuel Keller - Naveen.A.N 7 7 Author URI: http://open-search-server.com 8 8 Tested up to: 3.4.2 9 Version:1.1. 09 Version:1.1.1 10 10 */ 11 11 require_once 'lib/oss_api.class.php'; … … 27 27 add_submenu_page('plugins.php', 'OpenSearchServer Settings', 'OpenSearchServer', 'edit_plugins', __FILE__, 'opensearchserver_admin_page'); 28 28 } 29 29 30 function opensearchserver_load_scripts_styles() { 30 31 wp_register_script( 'opensearchserver', plugins_url('opensearchserver-search') .'/js/opensearchserver.js' ); … … 34 35 wp_enqueue_script( 'jQuery' ); 35 36 } 37 36 38 function opensearchserver_search() { 37 39 38 if ( stripos($_SERVER['REQUEST_URI'], '/?s=') === FALSE && stripos($_SERVER['REQUEST_URI'], '/search/') === FALSE) {40 if (stripos($_SERVER['REQUEST_URI'], '/?s=') === FALSE && stripos($_SERVER['REQUEST_URI'], '/search/') === FALSE) { 39 41 return; 40 42 } … … 56 58 } 57 59 } 60 58 61 function opensearchserver_install() { 59 $oss_query = 'title:($$)^10 OR title:("$$")^10 OR allContent:($$) OR allContent:("$$")60 OR61 content:($$)^5 OR content:("$$")^5 OR categories:($$) OR categories:("$$")';62 update_option('oss_query', $oss_query);63 62 } 64 63 … … 71 70 delete_option('oss_facet'); 72 71 delete_option('oss_spell'); 72 delete_option('oss_spell_algo'); 73 delete_option('oss_phonetic'); 74 delete_option('oss_language'); 73 75 } 76 74 77 function opensearchserver_do_while_posting($post_id,$post) { 75 78 if ($post->post_type == 'post' || $post->post_type == 'page' -
opensearchserver-search/trunk/lib/oss_api.class.php
r602348 r603172 77 77 */ 78 78 protected static $supportedLanguages = array( 79 "" => "Undefined", 80 "zh" => "Chinese", 81 "da" => "Danish", 82 "nl" => "Dutch", 83 "en" => "English", 84 "fi" => "Finnish", 85 "fr" => "French", 86 "de" => "German", 87 "hu" => "Hungarian", 88 "it" => "Italian", 89 "no" => "Norwegian", 90 "pt" => "Portuguese", 91 "ro" => "Romanian", 92 "ru" => "Russian", 93 "es" => "Spanish", 94 "sv" => "Swedish", 95 "tr" => "Turkish" 79 '' => 'Undefined', 80 'ar' => 'Arabic', 81 'zh' => 'Chinese', 82 'da' => 'Danish', 83 'nl' => 'Dutch', 84 'en' => 'English', 85 'fi' => 'Finnish', 86 'fr' => 'French', 87 'de' => 'German', 88 'hu' => 'Hungarian', 89 'it' => 'Italian', 90 'no' => 'Norwegian', 91 'pt' => 'Portuguese', 92 'ro' => 'Romanian', 93 'ru' => 'Russian', 94 'es' => 'Spanish', 95 'sv' => 'Swedish', 96 'tr' => 'Turkish' 96 97 ); 97 98 … … 265 266 266 267 /** 268 * Return the language constant from a 2 characters language code 269 * @param string $twoCharsLang Two characters language 270 */ 271 public static function getLanguage($twoCharsLang) { 272 $lang = OssApi::$supportedLanguages[mb_strtolower($twoCharsLang)]; 273 if ($lang == NULL) { 274 return OssApi::$supportedLanguages['']; 275 } 276 return $lang; 277 } 278 279 /** 267 280 * Escape Lucene's special chars 268 281 * param string $string -
opensearchserver-search/trunk/lib/oss_results.class.php
r602348 r603172 109 109 } 110 110 111 public function getScore($position) { 112 $doc = $this->result->xpath('result/doc[@pos="' . $position . '"]'); 113 if (isset($doc[0]) && is_array($doc)) { 114 return $doc[0]['score']; 115 } 116 return null; 117 } 118 111 119 112 120 /** -
opensearchserver-search/trunk/lib/oss_search.class.php
r601998 r603172 49 49 protected $field; 50 50 protected $sort; 51 protected $operator; 51 52 protected $collapse; 52 53 protected $facet; … … 74 75 $this->sort = array(); 75 76 $this->facets = array(); 77 $this->operator = NULL; 76 78 $this->collapse = array('field' => NULL, 'max' => NULL, 'mode' => NULL); 77 79 $this->moreLikeThis = array('active' => NULL, 'docquery' => NULL, 'minwordlen' => NULL, … … 118 120 119 121 /** 122 * Set the default operation OR or AND 123 * @param unknown_type $start 124 * @return OssSearch 125 */ 126 public function operator($operator = NULL) { 127 $this->operator = $operator; 128 return $this; 129 } 130 131 /** 120 132 * @return OssSearch 121 133 */ … … 277 289 } 278 290 291 if ($this->operator !== NULL) { 292 $queryChunks[] = 'operator=' . $this->operator; 293 } 294 279 295 if ($this->delete) { 280 296 $queryChunks[] = 'delete'; … … 286 302 continue; 287 303 } 288 $queryChunks[] = 'sort=' . $sort;304 $queryChunks[] = 'sort=' . urlencode($sort); 289 305 } 290 306 -
opensearchserver-search/trunk/lib/oss_searchtemplate.class.php
r602348 r603172 43 43 } 44 44 45 /** 46 * Create a query template 47 * @param string $qtname Name of the template 48 * @param string $qtquery Query 49 * @param string $qtoperator Default operator 50 * @param int $qtrows Number of rows 51 * @param int $qtslop Phrase slop 52 * @param string $qtlang Default language 53 */ 45 54 public function createSearchTemplate($qtname, $qtquery = NULL, $qtoperator = NULL, $qtrows = NULL, $qtslop = NULL, $qtlang = NULL) { 46 55 $params = array("qt.name" => $qtname); … … 58 67 } 59 68 if ($qtlang) { 69 if (strlen($qtlang) == 2) { 70 $qtlang = mb_strtoupper(OssAPI::getLanguage($qtlang)); 71 } 60 72 $params['qt.lang'] = $qtlang; 61 73 } -
opensearchserver-search/trunk/opensearchserver_admin.php
r602348 r603172 97 97 $query_template = opensearchserver_getsearchtemplate_instance(); 98 98 $oss_query = stripcslashes(get_option('oss_query')); 99 $query_template->createSearchTemplate('search', $oss_query, 'AND', '10', '2', 'ENGLISH');99 $query_template->createSearchTemplate('search', $oss_query, 'AND', '10', '2', get_option('oss_language')); 100 100 $query_template->setSnippetField('search','title', 70, 'b'); 101 101 $query_template->setSnippetField('search','content', 300, 'b', NULL, 'SentenceFragmenter'); … … 134 134 $oss_key = get_option('oss_key'); 135 135 $custom_fields = get_option('oss_custom_field'); 136 $lang = get_option('oss_language'); 136 137 $table_name_posts =$wpdb->prefix ."posts"; 137 138 $table_name_users =$wpdb->prefix ."users"; … … 146 147 $sql_query = 'SELECT p.ID,post_type,post_title,post_content,guid,post_date_gmt,post_author,user_nicename,user_url,user_email '.$sql_suffix; 147 148 $sql_posts = $wpdb->get_results($sql_query); 148 $index = opensearchserver_add_documents_to_index($ sql_posts, $custom_fields);149 $index = opensearchserver_add_documents_to_index($lang, $sql_posts, $custom_fields); 149 150 opensearchserver_start_indexing($index); 150 151 }else { … … 165 166 166 167 $sql_posts = $wpdb->get_results($sql_query.' LIMIT '.$current_pos.','.$batch); 167 $index = opensearchserver_add_documents_to_index($ sql_posts,$custom_fields);168 $index = opensearchserver_add_documents_to_index($lang, $sql_posts, $custom_fields); 168 169 opensearchserver_start_indexing($index); 169 170 $wpdb->flush(); … … 244 245 } 245 246 246 function opensearchserver_add_documents_to_index($ sql_posts,$customFields) {247 function opensearchserver_add_documents_to_index($lang, $sql_posts, $customFields) { 247 248 $index = new OSSIndexDocument(); 248 249 $lang= substr(get_locale(), 0, 2); … … 355 356 'LevensteinDistance' => 'LevensteinDistance', 356 357 'NGramDistance' => 'NGramDistance'); 358 $languages = array( 359 '' => 'Undefined', 360 'ar' => 'Arabic', 361 'zh' => 'Chinese', 362 'da' => 'Danish', 363 'nl' => 'Dutch', 364 'en' => 'English', 365 'fi' => 'Finnish', 366 'fr' => 'French', 367 'de' => 'German', 368 'hu' => 'Hungarian', 369 'it' => 'Italian', 370 'no' => 'Norwegian', 371 'pt' => 'Portuguese', 372 'ro' => 'Romanian', 373 'ru' => 'Russian', 374 'es' => 'Spanish', 375 'sv' => 'Swedish', 376 'tr' => 'Turkish' 377 ); 378 357 379 358 380 $action = isset($_POST['oss_submit']) ? $_POST['oss_submit'] :NULL; … … 404 426 update_option('oss_spell', $oss_spell); 405 427 update_option('oss_spell_algo', $oss_spell_algo); 428 $oss_language = isset($_POST['oss_language']) ? $_POST['oss_language'] : NULL; 429 update_option('oss_language', $oss_language); 406 430 $oss_phonetic = isset($_POST['oss_phonetic']) ? $_POST['oss_phonetic'] : NULL; 407 431 update_option('oss_phonetic', $oss_phonetic); … … 437 461 </div> 438 462 <h3 class="hndle"> 439 <span><?php print ' Server Settings'; ?> </span>463 <span><?php print 'Instance settings'; ?> </span> 440 464 </h3> 441 465 <form id="oss_settings" name="oss_settings" method="post" action=""> 442 466 <div class="inside"> 443 467 <p> 444 <label for="opensearchserver_location">OpenSearchServer 445 Installation Location</label>:<br /> <input type="text"446 name="oss_serverurl" id="oss_serverurl"447 placeholder="http://localhost:8080" size="50"448 value="<?php print get_option('oss_serverurl');?>" /><br />449 </p> 450 <p> 451 <label for="opensearchserver_index_name">OpenSearchServer Index452 Name</label>:<br /> <input type="text" name="oss_indexname"468 <label for="opensearchserver_location">OpenSearchServer instance 469 location</label>:<br /> <input type="text" name="oss_serverurl" 470 id="oss_serverurl" placeholder="http://localhost:8080" 471 size="80" value="<?php print get_option('oss_serverurl');?>" /> 472 <br /> 473 </p> 474 <p> 475 <label for="opensearchserver_index_name">OpenSearchServer index 476 name</label>:<br /> <input type="text" name="oss_indexname" 453 477 id="oss_indexname" placeholder="opensearchserver_wordpress" 454 478 size="50" value="<?php print get_option('oss_indexname');?>" /> … … 456 480 </p> 457 481 <p> 458 <label for="opensearchserver_login">OpenSearchServer Login Name</label>:<br />482 <label for="opensearchserver_login">OpenSearchServer login name</label>:<br /> 459 483 <input type="text" name="oss_login" id="oss_login" 460 placeholder="admin" size=" 50"484 placeholder="admin" size="30" 461 485 value="<?php print get_option('oss_login');?>" /> <br /> 462 486 </p> … … 464 488 465 489 <p> 466 <label for="opensearchserver_key">OpenSearchServer A ccesskey</label>:<br />490 <label for="opensearchserver_key">OpenSearchServer API key</label>:<br /> 467 491 <input type="text" name="oss_key" id="oss_key" 468 492 placeholder="9bc6aceeb43965b02b1d28a5201924e2" size="50" … … 483 507 </div> 484 508 <h3 class="hndle"> 485 <span>Query Settings </span>509 <span>Query settings </span> 486 510 </h3> 487 511 <div class="inside"> 488 <p>Available for querying,facet and spell check are title, posts, 489 category, user,user_email, post_type.</p> 512 <p>Enter the template query, or leave empty to use the default one</p> 490 513 <form id="query_settings" name="query_settings" method="post" 491 514 action=""> 492 515 <p> 493 <label for="oss_query">OpenSearchServer Query</label>:<br />516 <label for="oss_query">OpenSearchServer query template</label>:<br /> 494 517 <textarea rows="10" cols="100" name="oss_query" wrap="off"> 495 <?php496 if (trim(get_option('oss_query'))) {497 print stripslashes(get_option('oss_query'));498 }499 ?>518 <?php 519 if (trim(get_option('oss_query'))) { 520 print stripslashes(get_option('oss_query')); 521 } 522 ?> 500 523 </textarea> 501 524 </p> 502 525 <p> 503 <label for="oss_query">Facet Field</label>:<br /> <select526 <label for="oss_query">Facet field</label>:<br /> <select 504 527 name="oss_facet"> 505 528 <?php … … 518 541 <thead> 519 542 <tr> 520 <th>Facet Field</th>543 <th>Facet field list</th> 521 544 <th>Action</th> 522 545 </tr> … … 540 563 <?php }?> 541 564 <p> 542 <label for="oss_query">SpellCheck Field</label>:<br /> <select565 <label for="oss_query">SpellCheck field</label>:<br /> <select 543 566 name="oss_spell"><?php 544 567 $facet = get_option('oss_spell'); … … 553 576 </option> 554 577 <?php }?> 555 </select> <br /> <label for="oss_query">SpellCheck algorithm</label>:<br /> 578 </select> 579 580 581 <p> 582 <label for="oss_spell_algo">SpellCheck algorithm</label>:<br /> 556 583 <select name="oss_spell_algo"><?php 557 584 $facet = get_option('oss_spell_algo'); … … 568 595 </select> 569 596 </p> 597 </p> 598 <p> 599 <label for="oss_language">Default language</label>:<br /> <select 600 name="oss_language"><?php 601 $opt = get_option('oss_language'); 602 foreach ($languages as $key => $field) { 603 $selected = ''; 604 if($opt == $key) { 605 $selected = 'selected="selected"'; 606 } 607 ?> 608 <option value="<?php print $key;?>" <?php print $selected;?>> 609 <?php print $field;?> 610 </option> 611 <?php }?> 612 </select> 613 </p> 570 614 <p> 571 615 <label for="oss_phonetic">Enable phonetic</label>: <input … … 587 631 </div> 588 632 <h3 class="hndle"> 589 <span>Index Settings </span>633 <span>Index settings </span> 590 634 </h3> 591 635 <div class="inside"> … … 610 654 </div> 611 655 <h3 class="hndle"> 612 <span>Custom Fields Settings </span>656 <span>Custom fields settings </span> 613 657 </h3> 614 658 <div class="inside"> … … 617 661 <p> 618 662 <label for="custom_fields_oss">Enter the fields from the Custom 619 Field Template more information at 620 http://wordpress.org/extend/plugins/custom-field-template/</label>: 663 Field Template. Get useful information <a target="_blank" 664 href="http://wordpress.org/extend/plugins/custom-field-template/">here</a> 665 </label>:<br /> 621 666 <textarea rows="10" cols="100" name="oss_custom_field" 622 667 wrap="off"> -
opensearchserver-search/trunk/opensearchserver_search_functions.php
r602348 r603172 1 1 <?php 2 2 function opensearchserver_getsearch_instance($rows, $start) { 3 return new OssSearch(get_option('oss_serverurl'), get_option('oss_indexname'), $rows, $start,get_option('oss_login'), get_option('oss_key'));3 return new OssSearch(get_option('oss_serverurl'), get_option('oss_indexname'), $rows, $start,get_option('oss_login'), get_option('oss_key')); 4 4 } 5 5 6 6 function opensearchserver_getresult_instance($result) { 7 return new OssResults($result);7 return new OssResults($result); 8 8 } 9 9 10 function opensearchserver_getpaging_instance($result) { 10 return new OssPaging($result, 'r', 'pa');11 return new OssPaging($result, 'r', 'pa'); 11 12 } 13 12 14 function opensearchserver_getspellcheck($result) { 13 $spell_field = get_option('oss_spell').'Exact';14 return opensearchserver_getresult_instance($result)->getSpellSuggest($spell_field);15 $spell_field = get_option('oss_spell').'Exact'; 16 return opensearchserver_getresult_instance($result)->getSpellSuggest($spell_field); 15 17 } 18 16 19 function opensearchserver_getpaging($result) { 17 if ($result != NULL) {18 $ossPaging = opensearchserver_getpaging_instance($result);19 $pagingArray = array();20 if (isset($ossPaging) && $ossPaging->getResultTotal() >= 1) {21 if ($ossPaging->getResultLow() > 0) {22 $style='oss_pager_first';23 $label = 'First';24 $url = $ossPaging->getPageBaseURI() . '1';25 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url);26 }27 if ($ossPaging->getResultPrev() < $ossPaging->getResultCurrentPage()) {28 $style='oss_pager_prev';29 $label = 'Previous';30 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultPrev() + 1);31 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url);32 }33 for ($i = $ossPaging->getResultLow(); $i < $ossPaging->getResultHigh(); $i++) {34 $style='oss_pager_number';35 if ($i == $ossPaging->getResultCurrentPage()) {36 $label = $i + 1;37 $url = NULL;38 }39 else {40 $label = $i + 1;41 $url = $ossPaging->getPageBaseURI() . $label;42 }43 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url);44 }45 if ($ossPaging->getResultNext() > $ossPaging->getResultCurrentPage()) {46 $style='oss_pager_next';47 $label = 'Next';48 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultNext() + 1);49 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url);50 }51 if($ossPaging->getResultCurrentPage()<$ossPaging->getResultTotal() && $ossPaging->getResultNext() > $ossPaging->getResultCurrentPage()) {52 $style='oss_pager_last';53 $label = 'Last';54 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultTotal());55 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url);56 }57 }58 return $pagingArray;59 }20 if ($result != NULL) { 21 $ossPaging = opensearchserver_getpaging_instance($result); 22 $pagingArray = array(); 23 if (isset($ossPaging) && $ossPaging->getResultTotal() >= 1) { 24 if ($ossPaging->getResultLow() > 0) { 25 $style='oss_pager_first'; 26 $label = 'First'; 27 $url = $ossPaging->getPageBaseURI() . '1'; 28 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url); 29 } 30 if ($ossPaging->getResultPrev() < $ossPaging->getResultCurrentPage()) { 31 $style='oss_pager_prev'; 32 $label = 'Previous'; 33 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultPrev() + 1); 34 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url); 35 } 36 for ($i = $ossPaging->getResultLow(); $i < $ossPaging->getResultHigh(); $i++) { 37 $style='oss_pager_number'; 38 if ($i == $ossPaging->getResultCurrentPage()) { 39 $label = $i + 1; 40 $url = NULL; 41 } 42 else { 43 $label = $i + 1; 44 $url = $ossPaging->getPageBaseURI() . $label; 45 } 46 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url); 47 } 48 if ($ossPaging->getResultNext() > $ossPaging->getResultCurrentPage()) { 49 $style='oss_pager_next'; 50 $label = 'Next'; 51 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultNext() + 1); 52 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url); 53 } 54 if($ossPaging->getResultCurrentPage()<$ossPaging->getResultTotal() && $ossPaging->getResultNext() > $ossPaging->getResultCurrentPage()) { 55 $style='oss_pager_last'; 56 $label = 'Last'; 57 $url = $ossPaging->getPageBaseURI() . ($ossPaging->getResultTotal()); 58 $pagingArray[] = array('style' => $style, 'label' => $label, 'url' => $url); 59 } 60 } 61 return $pagingArray; 62 } 60 63 } 64 61 65 function opensearchserver_getsearchresult($query, $spellcheck, $facet) { 62 if($query) {63 $start = isset($_REQUEST['pa']) ? $_REQUEST['pa'] : null;64 $start = isset($start) ? max(0, $start - 1) * 10 : 0;65 $query = opensearchserver_clean_query($query);66 $search = opensearchserver_getsearch_instance(10, $start);67 if(!$spellcheck) {68 opensearchserver_add_facets_search($search);69 if($facet) {70 $filter = isset($_REQUEST['fq']) ? $_REQUEST['fq'] : null;71 if($filter) {72 if($filter != 'All') {73 $search->filter($filter);74 }75 }76 }77 $result = $search->query($query)->template('search')->execute(5);78 }else {79 $result = $search->query($query)->template('spellcheck')->execute(5);80 }81 return $result;82 }66 if($query) { 67 $start = isset($_REQUEST['pa']) ? $_REQUEST['pa'] : null; 68 $start = isset($start) ? max(0, $start - 1) * 10 : 0; 69 $query = opensearchserver_clean_query($query); 70 $search = opensearchserver_getsearch_instance(10, $start); 71 if(!$spellcheck) { 72 opensearchserver_add_facets_search($search); 73 if($facet) { 74 $filter = isset($_REQUEST['fq']) ? $_REQUEST['fq'] : null; 75 if($filter) { 76 if($filter != 'All') { 77 $search->filter($filter); 78 } 79 } 80 } 81 $result = $search->query($query)->template('search')->execute(5); 82 }else { 83 $result = $search->query($query)->template('spellcheck')->execute(5); 84 } 85 return $result; 86 } 83 87 84 88 } 85 89 90 function opensearchserver_clean_query($query) { 91 $escapechars = array('\\', '^', '~', ':', '(', ')', '{', '}', '[', ']' , '&', '||', '!', '*', '?','039;','\'','#'); 92 foreach ($escapechars as $escchar) { 93 $query = str_replace($escchar, ' ', $query); 94 } 95 $query = trim($query); 96 return $query; 97 } 86 98 87 function opensearchserver_clean_query($query) { 88 $escapechars = array('\\', '^', '~', ':', '(', ')', '{', '}', '[', ']' , '&', '||', '!', '*', '?','039;','\'','#'); 89 foreach ($escapechars as $escchar) { 90 $query = str_replace($escchar, ' ', $query); 91 } 92 $query = trim($query); 93 return $query; 99 function opensearchserver_add_facets_search($search) { 100 $facets = get_option('oss_facet'); 101 foreach ($facets as $facet) { 102 $search->facet($facet,1); 103 } 104 return $search; 94 105 } 95 function opensearchserver_add_facets_search($search) { 96 $facets = get_option('oss_facet'); 97 foreach ($facets as $facet) { 98 $search->facet($facet,1); 99 } 100 return $search; 106 107 function opensearchserver_get_max($oss_results) { 108 return ($oss_results->getResultStart() + $oss_results->getResultRows() > $oss_results->getResultFound()) ? $oss_results->getResultFound() : $oss_results->getResultStart() + $oss_results->getResultRows(); 101 109 } 102 function opensearchserver_get_max($oss_results) { 103 return ($oss_results->getResultStart() + $oss_results->getResultRows() > $oss_results->getResultFound()) ? $oss_results->getResultFound() : $oss_results->getResultStart() + $oss_results->getResultRows(); 104 } 110 105 111 function opensearchserver_get_custom_fields() { 106 return explode(",",get_option('oss_custom_field'));112 return explode(",",get_option('oss_custom_field')); 107 113 } 108 114 ?> -
opensearchserver-search/trunk/readme.txt
r602740 r603172 28 28 29 29 * WordPress 3.0.1 or higher 30 * A running OpenSearchServer instance30 * A running instance of OpenSearchServer 1.3 or higher 31 31 32 32 = Installing the plugin = … … 64 64 65 65 == Changelog == 66 67 = 1.1.1 = 68 * 17 Language support 69 * Spelling corrections 66 70 67 71 = 1.1.0 =
Note: See TracChangeset
for help on using the changeset viewer.