Changeset 1078386
- Timestamp:
- 01/29/2015 05:31:54 PM (11 years ago)
- Location:
- opensearchserver-search/trunk
- Files:
-
- 6 edited
-
index.php (modified) (1 diff)
-
lib/oss_abstract.class.php (modified) (3 diffs)
-
lib/oss_api.class.php (modified) (1 diff)
-
lib/oss_searchtemplate.class.php (modified) (1 diff)
-
opensearchserver_admin.php (modified) (6 diffs)
-
opensearchserver_search_functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
opensearchserver-search/trunk/index.php
r1078202 r1078386 169 169 delete_option('oss_facets_option_hierarchical'); 170 170 delete_option('oss_facets_option_hierarchical_taxonomy'); 171 delete_option('oss_query_behaviour'); 172 delete_option('oss_query_template'); 171 173 172 174 $taxonomies=get_taxonomies('','names'); -
opensearchserver-search/trunk/lib/oss_abstract.class.php
r927584 r1078386 131 131 * Will fail if more than 16 HTTP redirection 132 132 */ 133 protected function queryServer($url, $data = NULL, $connexionTimeout = OssApi::DEFAULT_CONNEXION_TIMEOUT, $timeout = OssApi::DEFAULT_QUERY_TIMEOUT, $method = 'GET' ) {133 protected function queryServer($url, $data = NULL, $connexionTimeout = OssApi::DEFAULT_CONNEXION_TIMEOUT, $timeout = OssApi::DEFAULT_QUERY_TIMEOUT, $method = 'GET',$api_version = 1) { 134 134 135 135 $this->lastQueryString = $url; … … 139 139 if($method === 'GET') { 140 140 curl_setopt($rcurl, CURLOPT_HTTP_VERSION, '1.0'); 141 if($api_version == 2) { 142 curl_setopt($rcurl, CURLOPT_HTTPHEADER, array("Content-type: application/json; charset=utf-8")); 143 } 141 144 } 142 145 curl_setopt($rcurl, CURLOPT_BINARYTRANSFER, TRUE); … … 207 210 } 208 211 209 protected function queryServerREST($path, $params = null, $data = null, $connexionTimeout = OssApi::DEFAULT_CONNEXION_TIMEOUT, $timeout = OssApi::DEFAULT_QUERY_TIMEOUT, $method = 'GET' ) {210 return $this->queryServer($this->getQueryURL($path, $params), $data, $connexionTimeout, $timeout, $method );212 protected function queryServerREST($path, $params = null, $data = null, $connexionTimeout = OssApi::DEFAULT_CONNEXION_TIMEOUT, $timeout = OssApi::DEFAULT_QUERY_TIMEOUT, $method = 'GET', $api_version = 1 ) { 213 return $this->queryServer($this->getQueryURL($path, $params), $data, $connexionTimeout, $timeout, $method, $api_version); 211 214 } 212 215 -
opensearchserver-search/trunk/lib/oss_api.class.php
r854646 r1078386 69 69 const REST_API_AUTOCOMPLETION = 'services/rest/index/{index_name}/autocompletion/{autocompletion_name}?field={field_name}&rows={rows}'; 70 70 const REST_API_AUTOCOMPLETION_BUILD = 'services/rest/index/{index_name}/autocompletion/{autocompletion_name}'; 71 const REST_API_SEARCH_TEMPLATE_LIST = 'services/rest/index/{index_name}/search/template'; 71 72 72 73 -
opensearchserver-search/trunk/lib/oss_searchtemplate.class.php
r854646 r1078386 195 195 return $return === FALSE ? FALSE : TRUE; 196 196 } 197 197 198 199 public function get_search_template_list() { 200 $path_parameters = array( 201 "{index_name}" => $this->index 202 ); 203 $path = strtr(OssApi::REST_API_SEARCH_TEMPLATE_LIST, $path_parameters); 204 $return = $this->queryServerREST($path,NULL,NULL, OssApi::DEFAULT_CONNEXION_TIMEOUT, OssApi::DEFAULT_QUERY_TIMEOUT,'GET',2); 205 return json_decode($return)->templates; 206 } 198 207 } 199 208 ?> -
opensearchserver-search/trunk/opensearchserver_admin.php
r1078202 r1078386 44 44 $autocompletion->createAutocompletion($autocompletion_name, 'autocomplete'); 45 45 return TRUE; 46 } 47 48 49 function get_list_of_search_templates() { 50 $search_template_instance = opensearchserver_getsearchtemplate_instance(); 51 return $search_template_instance->get_search_template_list(); 46 52 } 47 53 … … 718 724 update_option('oss_facet', $facets); 719 725 726 $oss_write_query = isset($_POST['oss_write_query']) ? $_POST['oss_write_query'] : 1; 727 update_option('oss_query_behaviour', $oss_write_query); 728 $oss_query_template = isset($_POST['oss_query_template']) ? $_POST['oss_query_template'] : NULL; 729 update_option('oss_query_template', $oss_query_template); 720 730 $oss_multi_filter = isset($_POST['oss_multi_filter']) ? $_POST['oss_multi_filter'] : NULL; 721 731 update_option('oss_multi_filter', $oss_multi_filter); … … 738 748 $oss_advanced_facets = isset($_POST['oss_advanced_facets']) ? $_POST['oss_advanced_facets'] : NULL; 739 749 update_option('oss_advanced_facets', $oss_advanced_facets); 740 $oss_facet_max_display = isset($_POST['oss_facet_max_display']) ? $_POST['oss_facet_max_display'] : NULL;750 $oss_facet_max_display = isset($_POST['oss_facet_max_display']) ? $_POST['oss_facet_max_display'] : NULL; 741 751 update_option('oss_facet_max_display', $oss_facet_max_display); 742 752 $oss_sort_timestamp = isset($_POST['oss_sort_timestamp']) ? $_POST['oss_sort_timestamp'] : NULL; … … 957 967 <form id="query_settings" name="query_settings" method="post" 958 968 action=""> 969 <strong>Query Behaviour</strong> 970 <p> 971 <input type="radio" id="oss_write_query" 972 value="1" name="oss_write_query" 973 <?php 974 $oss_write_query = isset($_POST['oss_write_query']) ? $_POST['oss_write_query'] : 1; 975 checked( 1 == $oss_write_query); ?> /> 976 <label for="oss_write_query_enable">Write Query</label> 977 <input type="radio" id="oss_existing_query_template" 978 value="2" name="oss_write_query" 979 <?php checked( 2 == get_option('oss_query_behaviour')); ?> /> 980 <label for="oss_existing_query_template_enabled">Use an existing query template</label> 981 </p> 982 959 983 <fieldset><legend>Query template</legend> 960 984 <div id="oss-query-write-template"> 961 985 <p>Enter the template query, or leave empty to use the default one</p> 962 986 <p> <label for="oss_query">OpenSearchServer query template</label>:<br /> … … 976 1000 <p>For allowing search into a new field simply add it to the query, for example <code>OR custom_field_favorite_fruits:($$)^5</code>. <code>^5</code> gives a weight of 5 to this field. 977 1001 </div> 1002 </div> 1003 <div id="oss-query-select-template"> 1004 <p> 1005 <strong>Select query template</strong> 1006 <select name="oss_query_template" id="oss_query_template"> 1007 <option value="none">Select </option> 1008 <?php 1009 $templates = get_list_of_search_templates(); 1010 foreach($templates as $template) { 1011 ?> 1012 <option value="<?php print $template->name;?>"><?php print $template->name.' (Type '.$template->type.')';?></option> 1013 <?php 1014 } 1015 ?> 1016 1017 </select> 1018 </p> 1019 </div> 978 1020 </fieldset> 979 1021 <fieldset><legend>Facets</legend> … … 1516 1558 jQuery('#oss_log_enable').click(function(e) { jQuery('#oss_logs_custom').toggle();}); 1517 1559 jQuery('#oss_filter_language_wpml').click(function(e) { jQuery('#oss_filter_language_field').toggle();}); 1560 jQuery('#oss_write_query').click(function(e) {jQuery('#oss-query-select-template').hide();jQuery('#oss-query-write-template').show();}); 1561 jQuery('#oss_existing_query_template').click(function(e) {jQuery('#oss-query-write-template').hide();jQuery('#oss-query-select-template').show();}); 1562 if(jQuery('#oss_existing_query_template').is(":checked")) {jQuery('#oss-query-write-template').hide();jQuery('#oss-query-select-template').show();} 1563 else {jQuery('#oss-query-select-template').hide();jQuery('#oss-query-write-template').show();} 1518 1564 </script> 1519 1565 <?php -
opensearchserver-search/trunk/opensearchserver_search_functions.php
r1078202 r1078386 172 172 opensearchserver_add_filter($search, $fieldToFilterOn, ICL_LANGUAGE_CODE); 173 173 } 174 175 $oss_query = $search->query($query)->template('search'); 174 if(get_option('oss_query_behaviour') == 2) { 175 $oss_query = $search->query($query)->template(get_option('oss_query_template')); 176 }else { 177 $oss_query = $search->query($query)->template('search'); 178 } 176 179 if(get_query_var('sort')) { 177 180 if(get_query_var('sort') == '+date') {
Note: See TracChangeset
for help on using the changeset viewer.