/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { if (WPSOLR_Global::getOption()->get_search_is_replace_default_wp_search() && WPSOLR_Global::getOption()->get_search_is_use_current_theme_search_template() && WPSOLR_Query_Parameters::is_wp_search()) { echo $args['before_widget']; $results = WPSOLR_Global::getSolrClient()->display_results(WPSOLR_Global::getQuery()); echo '<div id="res_facets">' . WPSOLR_UI_Facets::Build(WPSOLR_Data_Facets::get_data(WPSOLR_Global::getQuery()->get_filter_query_fields_group_by_name(), WPSOLR_Global::getOption()->get_facets_to_display(), $results[1]), OptionLocalization::get_options()) . '</div>'; echo $args['after_widget']; } }
function return_solr_results() { $final_result = WPSOLR_Global::getSolrClient()->display_results(WPSOLR_Global::getQuery()); // Add result rows as html $res1[] = $final_result[3]; // Add pagination html $total = $final_result[2]; $number_of_res = WPSOLR_Global::getOption()->get_search_max_nb_results_by_page(); $paginat_var = ''; if ($total > $number_of_res) { $pages = ceil($total / $number_of_res); $paginat_var .= '<ul id="pagination-flickr"class="wdm_ul">'; for ($k = 1; $k <= $pages; $k++) { $paginat_var .= "<li ><a class='paginate' href='javascript:void(0)' id='{$k}'>{$k}</a></li>"; } $paginat_var .= '</ul>'; } $res1[] = $paginat_var; // Add results infos html ('showing x to y results out of n') $res1[] = $final_result[4]; // Add facets data $res1[] = WPSOLR_UI_Facets::Build(WPSOLR_Data_Facets::get_data(WPSOLR_Global::getQuery()->get_filter_query_fields_group_by_name(), WPSOLR_Global::getOption()->get_facets_to_display(), $final_result[1]), OptionLocalization::get_options()); // Output Json response to Ajax call echo json_encode($res1); die; }