PageRenderTime 79ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/oc-content/themes/modern/search.php

https://code.google.com/
PHP | 342 lines | 302 code | 14 blank | 26 comment | 66 complexity | d0c5a40bd2f6c14b83235b215a914d58 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /*
  3. * OSCLass รข&#x20AC;&#x201C; software for creating and publishing online classified
  4. * advertising platforms
  5. *
  6. * Copyright (C) 2010 OSCLASS
  7. *
  8. * This program is free software: you can redistribute it and/or
  9. * modify it under the terms of the GNU Affero General Public License
  10. * as published by the Free Software Foundation, either version 3 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php echo str_replace('_', '-', osc_current_user_locale()); ?>">
  24. <head>
  25. <?php osc_current_web_theme_path('head.php') ; ?>
  26. <?php if( osc_count_items() == 0 || Params::getParam('iPage') > 0 || stripos($_SERVER['REQUEST_URI'], 'search') ) { ?>
  27. <meta name="robots" content="noindex, nofollow" />
  28. <meta name="googlebot" content="noindex, nofollow" />
  29. <?php } else { ?>
  30. <meta name="robots" content="index, follow" />
  31. <meta name="googlebot" content="index, follow" />
  32. <?php } ?>
  33. <style>
  34. ul.sub {
  35. padding-left: 20px;
  36. }
  37. .chbx{
  38. width:15px; height:15px;
  39. display: inline;
  40. padding:8px 3px;
  41. background-repeat:no-repeat;
  42. cursor: pointer;
  43. }
  44. .chbx span{
  45. width:13px; height:13px;
  46. display: inline-block;
  47. border:solid 1px #bababa;
  48. border-radius:2px;
  49. -moz-border-radius:2px;
  50. -webkit-border-radius:2px;
  51. }
  52. .chbx.checked{
  53. background-image:url('<?php echo osc_current_web_theme_url('images/checkmark.png'); ?>');
  54. }
  55. .chbx.semi-checked{
  56. background-image:url('<?php echo osc_current_web_theme_url('images/checkmark-partial.png'); ?>');
  57. }
  58. </style>
  59. <script type="text/javascript">
  60. $(document).ready(function(){
  61. $('li.parent').each(function() {
  62. var totalInputSub = $(this).find('ul.sub>li>input').size();
  63. var totalInputSubChecked = $(this).find('ul.sub>li>input:checked').size();
  64. $(this).find('ul.sub>li>input').each(function(){
  65. $(this).hide();
  66. var id = $(this).attr('id');
  67. id = id+'_';
  68. if( $(this).is(':checked') ){
  69. var aux = $('<div class="chbx checked"><span></span></div>').attr('id', id);
  70. $(this).before(aux);
  71. } else {
  72. var aux = $('<div class="chbx"><span></span></div>').attr('id', id);
  73. $(this).before(aux);
  74. }
  75. });
  76. var input = $(this).find('input.parent');
  77. $(input).hide();
  78. var id = $(input).attr('id');
  79. id = id+'_';
  80. if(totalInputSub == totalInputSubChecked) {
  81. if(totalInputSub == 0) {
  82. if( $(this).find("input[name='sCategory[]']:checked").size() > 0) {
  83. var aux = $('<div class="chbx checked"><span></span></div>').attr('id', id);
  84. $(input).before(aux);
  85. } else {
  86. var aux = $('<div class="chbx"><span></span></div>').attr('id', id);
  87. $(input).before(aux);
  88. }
  89. } else {
  90. var aux = $('<div class="chbx checked"><span></span></div>').attr('id', id);
  91. $(input).before(aux);
  92. }
  93. }else if(totalInputSubChecked == 0) {
  94. // no input checked
  95. var aux = $('<div class="chbx"><span></span></div>').attr('id', id);
  96. $(input).before(aux);
  97. }else if(totalInputSubChecked < totalInputSub) {
  98. var aux = $('<div class="chbx semi-checked"><span></span></div>').attr('id', id);
  99. $(input).before(aux);
  100. }
  101. });
  102. $('li.parent').prepend('<span style="width:6px;display:inline-block;" class="toggle">+</span>');
  103. $('ul.sub').toggle();
  104. $('span.toggle').click(function(){
  105. $(this).parent().find('ul.sub').toggle();
  106. if($(this).text()=='+'){
  107. $(this).html('-');
  108. } else {
  109. $(this).html('+');
  110. }
  111. });
  112. $("li input[name='sCategory[]']").change( function(){
  113. var id = $(this).attr('id');
  114. $(this).click();
  115. $('#'+id+'_').click();
  116. });
  117. $('div.chbx').click( function() {
  118. var isChecked = $(this).hasClass('checked');
  119. var isSemiChecked = $(this).hasClass('semi-checked');
  120. if(isChecked) {
  121. $(this).removeClass('checked');
  122. $(this).next('input').attr('checked', false);
  123. } else if(isSemiChecked) {
  124. $(this).removeClass('semi-checked');
  125. $(this).next('input').attr('checked', false);
  126. } else {
  127. $(this).addClass('checked');
  128. $(this).next('input').attr('checked', true);
  129. }
  130. // there are subcategories ?
  131. if($(this).parent().find('ul.sub').size()>0) {
  132. if(isChecked){
  133. $(this).parent().find('ul.sub>li>div.chbx').removeClass('checked');
  134. $(this).parent().find('ul.sub>li>input').attr('checked', false);
  135. } else if(isSemiChecked){
  136. // if semi-checked -> check-all
  137. $(this).parent().find('ul.sub>li>div.chbx').removeClass('checked');
  138. $(this).parent().find('ul.sub>li>input').attr('checked', false);
  139. $(this).removeClass('semi-checked');
  140. } else {
  141. $(this).parent().find('ul.sub>li>div.chbx').addClass('checked');
  142. $(this).parent().find('ul.sub>li>input').attr('checked', true);
  143. }
  144. } else {
  145. // is subcategory checkbox or is category parent without subcategories
  146. var parentLi = $(this).closest('li.parent');
  147. // subcategory
  148. if($(parentLi).find('ul.sub').size() > 0) {
  149. var totalInputSub = $(parentLi).find('ul.sub>li>input').size();
  150. var totalInputSubChecked = $(parentLi).find('ul.sub>li>input:checked').size();
  151. var input = $(parentLi).find('input.parent');
  152. var divInput = $(parentLi).find('div.chbx').first();
  153. $(input).attr('checked', false);
  154. $(divInput).removeClass('checked');
  155. $(divInput).removeClass('semi-checked');
  156. if(totalInputSub == totalInputSubChecked) {
  157. $(divInput).addClass('checked');
  158. $(input).attr('checked', true);
  159. }else if(totalInputSubChecked == 0) {
  160. // no input checked;
  161. }else if(totalInputSubChecked < totalInputSub) {
  162. $(divInput).addClass('semi-checked');
  163. }
  164. } else {
  165. // parent category
  166. }
  167. }
  168. });
  169. });
  170. </script>
  171. </head>
  172. <body>
  173. <?php osc_current_web_theme_path('header.php') ; ?>
  174. <div class="content list">
  175. <div id="main">
  176. <div class="ad_list">
  177. <div id="list_head">
  178. <div class="inner">
  179. <h1>
  180. <strong><?php echo search_title(); ?></strong>
  181. </h1>
  182. <p class="see_by">
  183. <?php _e('Sort by', 'modern'); ?>:
  184. <?php $i = 0 ; ?>
  185. <?php $orders = osc_list_orders();
  186. foreach($orders as $label => $params) {
  187. $orderType = ($params['iOrderType'] == 'asc') ? '0' : '1'; ?>
  188. <?php if(osc_search_order() == $params['sOrder'] && osc_search_order_type() == $orderType) { ?>
  189. <a class="current" href="<?php echo osc_update_search_url($params) ; ?>"><?php echo $label; ?></a>
  190. <?php } else { ?>
  191. <a href="<?php echo osc_update_search_url($params) ; ?>"><?php echo $label; ?></a>
  192. <?php } ?>
  193. <?php if ($i != count($orders)-1) { ?>
  194. <span>|</span>
  195. <?php } ?>
  196. <?php $i++ ; ?>
  197. <?php } ?>
  198. </p>
  199. </div>
  200. </div>
  201. <?php if(osc_count_items() == 0) { ?>
  202. <p class="empty" ><?php printf(__('There are no results matching "%s"', 'modern'), osc_search_pattern()) ; ?></p>
  203. <?php } else { ?>
  204. <?php require(osc_search_show_as() == 'list' ? 'search_list.php' : 'search_gallery.php') ; ?>
  205. <?php } ?>
  206. <div class="paginate" >
  207. <?php echo osc_search_pagination(); ?>
  208. </div>
  209. <div class="clear"></div>
  210. <?php $footerLinks = osc_search_footer_links(); ?>
  211. <ul class="footer-links">
  212. <?php foreach($footerLinks as $f) { View::newInstance()->_exportVariableToView('footer_link', $f); ?>
  213. <?php if($f['total'] < 3) continue; ?>
  214. <li><a href="<?php echo osc_footer_link_url(); ?>"><?php echo osc_footer_link_title(); ?></a></li>
  215. <?php } ?>
  216. </ul>
  217. <div class="clear"></div>
  218. </div>
  219. </div>
  220. <div id="sidebar">
  221. <div class="filters">
  222. <form action="<?php echo osc_base_url(true); ?>" method="get" onsubmit="return doSearch()">
  223. <input type="hidden" name="page" value="search" />
  224. <input type="hidden" name="sOrder" value="<?php echo osc_search_order(); ?>" />
  225. <input type="hidden" name="iOrderType" value="<?php $allowedTypesForSorting = Search::getAllowedTypesForSorting() ; echo $allowedTypesForSorting[osc_search_order_type()]; ?>" />
  226. <?php foreach(osc_search_user() as $userId) { ?>
  227. <input type="hidden" name="sUser[]" value="<?php echo $userId; ?>" />
  228. <?php } ?>
  229. <fieldset class="box location">
  230. <h3><strong><?php _e('Your search', 'modern'); ?></strong></h3>
  231. <div class="row one_input">
  232. <input type="text" name="sPattern" id="query" value="<?php echo osc_esc_html( osc_search_pattern() ); ?>" />
  233. <div id="search-example"></div>
  234. </div>
  235. <h3><strong><?php _e('Location', 'modern') ; ?></strong></h3>
  236. <div class="row one_input">
  237. <h6><?php _e('City', 'modern'); ?></h6>
  238. <input type="text" id="sCity" name="sCity" value="<?php echo osc_esc_html( osc_search_city() ); ?>" />
  239. </div>
  240. </fieldset>
  241. <fieldset class="box show_only">
  242. <?php if( osc_images_enabled_at_items() ) { ?>
  243. <h3><strong><?php _e('Show only', 'modern') ; ?></strong></h3>
  244. <div class="row checkboxes">
  245. <ul>
  246. <li>
  247. <input type="checkbox" name="bPic" id="withPicture" value="1" <?php echo (osc_search_has_pic() ? 'checked="checked"' : ''); ?> />
  248. <label for="withPicture"><?php _e('Show only listings with pictures', 'modern') ; ?></label>
  249. </li>
  250. </ul>
  251. </div>
  252. <?php } ?>
  253. <?php if( osc_price_enabled_at_items() ) { ?>
  254. <div class="row two_input">
  255. <h6><?php _e('Price', 'modern') ; ?></h6>
  256. <div><?php _e('Min', 'modern') ; ?>.</div>
  257. <input type="text" id="priceMin" name="sPriceMin" value="<?php echo osc_search_price_min() ; ?>" size="6" maxlength="6" />
  258. <div><?php _e('Max', 'modern') ; ?>.</div>
  259. <input type="text" id="priceMax" name="sPriceMax" value="<?php echo osc_search_price_max() ; ?>" size="6" maxlength="6" />
  260. </div>
  261. <?php } ?>
  262. <?php osc_get_non_empty_categories(); ?>
  263. <?php if ( osc_count_categories() ) { ?>
  264. <div class="row checkboxes">
  265. <h6><?php _e('Category', 'modern') ; ?></h6>
  266. <ul>
  267. <?php // RESET CATEGORIES IF WE USED THEN IN THE HEADER ?>
  268. <?php osc_goto_first_category() ; ?>
  269. <?php while(osc_has_categories()) { ?>
  270. <li class="parent">
  271. <input class="parent" type="checkbox" id="cat<?php echo osc_category_id(); ?>" name="sCategory[]" value="<?php echo osc_category_id(); ?>" <?php $parentSelected=false; if (in_array(osc_category_id(), osc_search_category()) || in_array(osc_category_slug()."/", osc_search_category()) || in_array(osc_category_slug(), osc_search_category()) || count(osc_search_category())==0 ){ echo 'checked="checked"'; $parentSelected=true;} ?> /> <label for="cat<?php echo osc_category_id(); ?>"><strong><?php echo osc_category_name(); ?></strong></label>
  272. <?php if(osc_count_subcategories() > 0) { ?>
  273. <ul class="sub">
  274. <?php while(osc_has_subcategories()) { ?>
  275. <li>
  276. <input type="checkbox" id="cat<?php echo osc_category_id(); ?>" name="sCategory[]" value="<?php echo osc_category_id(); ?>" <?php if( $parentSelected || in_array(osc_category_id(), osc_search_category()) || in_array(osc_category_slug()."/", osc_search_category()) || in_array(osc_category_slug(), osc_search_category()) || count(osc_search_category())==0 ){echo 'checked="checked"';} ?> />
  277. <label for="cat<?php echo osc_category_id(); ?>"><strong><?php echo osc_category_name(); ?></strong></label>
  278. </li>
  279. <?php } ?>
  280. </ul>
  281. <?php } ?>
  282. </li>
  283. <?php } ?>
  284. </ul>
  285. </div>
  286. <?php } ?>
  287. </fieldset>
  288. <?php
  289. if(osc_search_category_id()) {
  290. osc_run_hook('search_form', osc_search_category_id()) ;
  291. } else {
  292. osc_run_hook('search_form') ;
  293. }
  294. ?>
  295. <button type="submit"><?php _e('Apply', 'modern') ; ?></button>
  296. </form>
  297. <?php osc_alert_form() ; ?>
  298. </div>
  299. </div>
  300. <script type="text/javascript">
  301. $(function() {
  302. function log( message ) {
  303. $( "<div/>" ).text( message ).prependTo( "#log" );
  304. $( "#log" ).attr( "scrollTop", 0 );
  305. }
  306. $( "#sCity" ).autocomplete({
  307. source: "<?php echo osc_base_url(true); ?>?page=ajax&action=location",
  308. minLength: 2,
  309. select: function( event, ui ) {
  310. log( ui.item ?
  311. "<?php _e('Selected', 'modern'); ?>: " + ui.item.value + " aka " + ui.item.id :
  312. "<?php _e('Nothing selected, input was', 'modern'); ?> " + this.value );
  313. }
  314. });
  315. });
  316. function checkEmptyCategories() {
  317. var n = $("input[id*=cat]:checked").length;
  318. if(n>0) {
  319. return true;
  320. } else {
  321. return false;
  322. }
  323. }
  324. </script>
  325. </div>
  326. <?php osc_current_web_theme_path('footer.php') ; ?>
  327. </body>
  328. </html>