| 1 |
<?php |
| 2 |
$uscpaged = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; |
| 3 |
//global $wp_query; |
| 4 |
//var_dump($wp_query); |
| 5 |
|
| 6 |
$html = '<script type="text/javascript"> |
| 7 |
function usces_nextpage() { |
| 8 |
document.getElementById(\'usces_paged\').value = ' . ($uscpaged + 1) . '; |
| 9 |
document.searchindetail.submit(); |
| 10 |
} |
| 11 |
function usces_prepage() { |
| 12 |
document.getElementById(\'usces_paged\').value = ' . ($uscpaged - 1) . '; |
| 13 |
document.searchindetail.submit(); |
| 14 |
} |
| 15 |
function newsubmit() { |
| 16 |
document.getElementById(\'usces_paged\').value = 1; |
| 17 |
} |
| 18 |
</script>'; |
| 19 |
|
| 20 |
$html .= '<div id="searchbox">'; |
| 21 |
|
| 22 |
if (isset($_REQUEST['usces_search'])) { |
| 23 |
|
| 24 |
$catresult = usces_search_categories(); |
| 25 |
$search_query = array('category__and' => $catresult, 'posts_per_page' => 10, 'paged' => $uscpaged); |
| 26 |
$search_query = apply_filters('usces_filter_search_query', $search_query); |
| 27 |
|
| 28 |
$my_query = new WP_Query( $search_query ); |
| 29 |
|
| 30 |
$html .= '<div class="title">'.__('Search results', 'usces') . ' ' . number_format($my_query->found_posts) . __('cases', 'usces') . '</div>'; |
| 31 |
|
| 32 |
if ($my_query->have_posts()) { |
| 33 |
|
| 34 |
$html .= apply_filters('usces_filter_search_result_pre', NULL, $my_query); |
| 35 |
|
| 36 |
$html .= '<div class="navigation clearfix">'; |
| 37 |
if( $uscpaged > 1 ) { |
| 38 |
$html .= '<a style="float:left; cursor:pointer;" onclick="usces_prepage();">'.__('« Previous article', 'usces').'</a>'; |
| 39 |
} |
| 40 |
if( $uscpaged < $my_query->max_num_pages ) { |
| 41 |
$html .= '<a style="float:right; cursor:pointer;" onclick="usces_nextpage();">'.__('Next article »', 'usces').'</a>'; |
| 42 |
} |
| 43 |
$html .= '</div>'; |
| 44 |
|
| 45 |
$itemhtml = '<div class="searchitems">'; |
| 46 |
while ($my_query->have_posts()) { |
| 47 |
$my_query->the_post(); |
| 48 |
usces_the_item(); |
| 49 |
|
| 50 |
$itemhtml .= '<div class="itemlist clearfix"><div class="loopimg"> |
| 51 |
<a href="' . get_permalink($post->ID) . '">' . usces_the_itemImage(0, 100, 100, $post, 'return') . '</a> |
| 52 |
</div> |
| 53 |
<div class="loopexp"> |
| 54 |
<div class="itemtitle"><a href="' . get_permalink($post->ID) . '">' . esc_html($post->post_title) . '</a></div> |
| 55 |
<div class="field">' . $post->post_content . '</div> |
| 56 |
</div> |
| 57 |
</div>'; |
| 58 |
} |
| 59 |
$itemhtml .= '</div><!-- searchitems -->'; |
| 60 |
$html .= apply_filters('usces_filter_search_result', $itemhtml, $my_query); |
| 61 |
|
| 62 |
$html .= '<div class="navigation clearfix">'; |
| 63 |
if( $uscpaged > 1 ) { |
| 64 |
$html .= '<a style="float:left; cursor:pointer;" onclick="usces_prepage();">'.__('« Previous article', 'usces').'</a>'; |
| 65 |
} |
| 66 |
if( $uscpaged < $my_query->max_num_pages ) { |
| 67 |
$html .= '<a style="float:right; cursor:pointer;" onclick="usces_nextpage();">'.__('Next article »', 'usces').'</a>'; |
| 68 |
} |
| 69 |
$html .= '</div>'; |
| 70 |
|
| 71 |
}else{ |
| 72 |
|
| 73 |
$html .= '<div class="searchitems">'; |
| 74 |
$html .= '<p>' . __('The article was not found.', 'usces') . '</p>'; |
| 75 |
$html .= '</div><!-- searchitems -->'; |
| 76 |
} |
| 77 |
} |
| 78 |
$html .= '<form name="searchindetail" action="' . USCES_CART_URL . $this->delim . 'page=search_item" method="post"> |
| 79 |
<div class="field"> |
| 80 |
<label class="outlabel">'.__('Categories: AND Search', 'usces').'</label>' . usces_categories_checkbox('return') . ' |
| 81 |
</div>'; |
| 82 |
|
| 83 |
$usces_search_button = '<input name="usces_search_button" class="usces_search_button" type="submit" value="'.__('Search', 'usces').'" onclick="newsubmit()" />'; |
| 84 |
$html .= apply_filters('usces_filter_search_button', $usces_search_button); |
| 85 |
|
| 86 |
$html .= '<input name="paged" id="usces_paged" type="hidden" value="' . esc_attr( $uscpaged ) . '" /> |
| 87 |
<input name="usces_search" type="hidden" /> |
| 88 |
</form>'; |
| 89 |
$html .= '</div><!-- searchbox -->'; |
| 90 |
?> |
| 91 |
|