/** * Gets available search orders * * @return array */ function osc_list_orders() { if (osc_price_enabled_at_items()) { return array(__('Newly listed') => array('sOrder' => 'dt_pub_date', 'iOrderType' => 'desc'), __('Lower price first') => array('sOrder' => 'i_price', 'iOrderType' => 'asc'), __('Higher price first') => array('sOrder' => 'i_price', 'iOrderType' => 'desc')); } else { return array(__('Newly listed') => array('sOrder' => 'dt_pub_date', 'iOrderType' => 'desc')); } }
echo osc_item_contact_name(); ?> </a><?php } else { echo osc_item_contact_name(); } ?> </p> <p class="description"><?php echo osc_highlight(strip_tags(osc_item_description()), 110); ?> </p> <div class="row"> <div class="col-md-5 col-sm-5 col-xs-5 price"> <?php if (osc_price_enabled_at_items()) { ?> <span><?php echo osc_format_price(osc_item_price()); ?> </span><?php } ?> </div> <div class="col-md-7 col-sm-7 col-xs-7 location"> <i class="glyphicon glyphicon-map-marker"></i><?php if (osc_item_region()) { ?> <?php echo osc_item_region(); } else {
public static function location_javascript($path = "front") { ?> <script type="text/javascript"> $(document).ready(function(){ $("#countryId").live("change",function(){ var pk_c_code = $(this).val(); <?php if ($path == "admin") { ?> var url = '<?php echo osc_admin_base_url(true) . "?page=ajax&action=regions&countryId="; ?> ' + pk_c_code; <?php } else { ?> var url = '<?php echo osc_base_url(true) . "?page=ajax&action=regions&countryId="; ?> ' + pk_c_code; <?php } ?> var result = ''; if(pk_c_code != '') { $("#regionId").attr('disabled',false); $("#cityId").attr('disabled',true); $.ajax({ type: "POST", url: url, dataType: 'json', success: function(data){ var length = data.length; if(length > 0) { result += '<option value=""><?php _e("Select a region..."); ?> </option>'; for(key in data) { result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>'; } $("#region").before('<select name="regionId" id="regionId" ></select>'); $("#region").remove(); $("#city").before('<select name="cityId" id="cityId" ></select>'); $("#city").remove(); $("#regionId").val(""); } else { $("#regionId").before('<input type="text" name="region" id="region" />'); $("#regionId").remove(); $("#cityId").before('<input type="text" name="city" id="city" />'); $("#cityId").remove(); } $("#regionId").html(result); $("#cityId").html('<option selected value=""><?php _e("Select a city..."); ?> </option>'); } }); } else { // add empty select $("#region").before('<select name="regionId" id="regionId" ><option value=""><?php _e("Select a region..."); ?> </option></select>'); $("#region").remove(); $("#city").before('<select name="cityId" id="cityId" ><option value=""><?php _e("Select a city..."); ?> </option></select>'); $("#city").remove(); if( $("#regionId").length > 0 ){ $("#regionId").html('<option value=""><?php _e("Select a region..."); ?> </option>'); } else { $("#region").before('<select name="regionId" id="regionId" ><option value=""><?php _e("Select a region..."); ?> </option></select>'); $("#region").remove(); } if( $("#cityId").length > 0 ){ $("#cityId").html('<option value=""><?php _e("Select a city..."); ?> </option>'); } else { $("#city").before('<select name="cityId" id="cityId" ><option value=""><?php _e("Select a city..."); ?> </option></select>'); $("#city").remove(); } $("#regionId").attr('disabled',true); $("#cityId").attr('disabled',true); } }); $("#regionId").live("change",function(){ var pk_c_code = $(this).val(); <?php if ($path == "admin") { ?> var url = '<?php echo osc_admin_base_url(true) . "?page=ajax&action=cities®ionId="; ?> ' + pk_c_code; <?php } else { ?> var url = '<?php echo osc_base_url(true) . "?page=ajax&action=cities®ionId="; ?> ' + pk_c_code; <?php } ?> var result = ''; if(pk_c_code != '') { $("#cityId").attr('disabled',false); $.ajax({ type: "POST", url: url, dataType: 'json', success: function(data){ var length = data.length; if(length > 0) { result += '<option selected value=""><?php _e("Select a city..."); ?> </option>'; for(key in data) { result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>'; } $("#city").before('<select name="cityId" id="cityId" ></select>'); $("#city").remove(); } else { result += '<option value=""><?php _e('No results'); ?> </option>'; $("#cityId").before('<input type="text" name="city" id="city" />'); $("#cityId").remove(); } $("#cityId").html(result); } }); } else { $("#cityId").attr('disabled',true); } }); if( $("#regionId").attr('value') == "") { $("#cityId").attr('disabled',true); } if($("#countryId").length != 0) { if( $("#countryId").attr('type').match(/select-one/) ) { if( $("#countryId").attr('value') == "") { $("#regionId").attr('disabled',true); } } } /** * Validate form */ // Validate description without HTML. $.validator.addMethod( "minstriptags", function(value, element) { altered_input = strip_tags(value); if (altered_input.length < 3) { return false; } else { return true; } }, "<?php _e("Description: needs to be longer"); ?> ." ); // Code for form validation $("form[name=item]").validate({ rules: { catId: { required: true, digits: true }, <?php if (osc_price_enabled_at_items()) { ?> price: { maxlength: 15 }, currency: "required", <?php } ?> <?php if (osc_images_enabled_at_items()) { ?> "photos[]": { accept: "<?php echo osc_allowed_extension(); ?> " }, <?php } ?> <?php if ($path == 'front') { ?> contactName: { minlength: 3, maxlength: 35 }, contactEmail: { required: true, email: true }, <?php } ?> regionId: { required: true, digits: true }, cityId: { required: true, digits: true }, cityArea: { minlength: 3, maxlength: 50 }, address: { minlength: 3, maxlength: 100 } }, messages: { catId: "<?php _e('Choose one category'); ?> .", <?php if (osc_price_enabled_at_items()) { ?> price: { maxlength: "<?php _e("Price: no more than 50 characters"); ?> ." }, currency: "<?php _e("Currency: make your selection"); ?> .", <?php } ?> <?php if (osc_images_enabled_at_items()) { ?> "photos[]": { accept: "<?php printf(__("Photo: must be %s"), osc_allowed_extension()); ?> ." }, <?php } ?> <?php if ($path == 'front') { ?> contactName: { minlength: "<?php _e("Name: enter at least 3 characters"); ?> .", maxlength: "<?php _e("Name: no more than 35 characters"); ?> ." }, contactEmail: { required: "<?php _e("Email: this field is required"); ?> .", email: "<?php _e("Invalid email address"); ?> ." }, <?php } ?> regionId: "<?php _e("Select a region"); ?> .", cityId: "<?php _e("Select a city"); ?> .", cityArea: { minlength: "<?php _e("City area: enter at least 3 characters"); ?> .", maxlength: "<?php _e("City area: no more than 50 characters"); ?> ." }, address: { minlength: "<?php _e("Address: enter at least 3 characters"); ?> .", maxlength: "<?php _e("Address: no more than 100 characters"); ?> ." } }, errorLabelContainer: "#error_list", wrapper: "li", invalidHandler: function(form, validator) { $('html,body').animate({ scrollTop: $('h1').offset().top }, { duration: 250, easing: 'swing'}); } }); }); /** * Strip HTML tags to count number of visible characters. */ function strip_tags(html) { if (arguments.length < 3) { html=html.replace(/<\/?(?!\!)[^>]*>/gi, ''); } else { var allowed = arguments[1]; var specified = eval("["+arguments[2]+"]"); if (allowed){ var regex='</?(?!(' + specified.join('|') + '))\b[^>]*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } else{ var regex='</?(' + specified.join('|') + ')\b[^>]*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } } return html; } function delete_image(id, item_id,name, secret) { //alert(id + " - "+ item_id + " - "+name+" - "+secret); var result = confirm('<?php echo osc_esc_js(__("This action can't be undone. Are you sure you want to continue?")); ?> '); if(result) { $.ajax({ type: "POST", url: '<?php echo osc_base_url(true); ?> ?page=ajax&action=delete_image&id='+id+'&item='+item_id+'&code='+name+'&secret='+secret, dataType: 'json', success: function(data){ var class_type = "error"; if(data.success) { $("div[name="+name+"]").remove(); class_type = "ok"; } var flash = $("#flash_js"); var message = $('<div>').addClass('pubMessages').addClass(class_type).attr('id', 'FlashMessage').html(data.msg); flash.html(message); $("#FlashMessage").slideDown('slow').delay(3000).slideUp('slow'); } }); } } </script> <?php }
<div class="item-date"> <i class="fa fa-calendar"></i> <?php if (osc_item_pub_date() !== '') { printf(__('%1$s', 'pop'), osc_format_date(osc_item_pub_date())); } ?> </div> <?php voting_item_detail(); ?> </div> <?php if (osc_price_enabled_at_items() && osc_item_price()) { ?> <div class="item-price"> <?php echo osc_item_formated_price(); ?> </div> <?php } ?> <div> <?php watchlist(); ?> </div>
<?php printf(__('%s characters '), '<input type="text" class="input-small" name="max_chars_per_description" value="' . osc_max_characters_per_description() . '" />'); ?> </div> </div> </div> <div class="form-row"> <div class="form-label"> <?php _e('Optional fields'); ?> </div> <div class="form-controls"> <div class="form-label-checkbox"> <label> <input type="checkbox" <?php echo osc_price_enabled_at_items() ? 'checked="checked"' : ''; ?> name="enableField#f_price@items" value="1" /> <?php _e('Price'); ?> </label> <div class="separate-top-medium"> <label> <input type="checkbox" <?php echo osc_images_enabled_at_items() ? 'checked="checked"' : ''; ?> name="enableField#images@items" value="1" /> <?php _e('Attach images'); ?>
public static function location_javascript($path = "front") { ?> <script type="text/javascript"> $(document).ready(function(){ $("#countryId").change(function(){ var pk_c_code = $(this).val(); <?php if ($path == "admin") { ?> var url = '<?php echo osc_admin_base_url(true) . "?page=ajax&action=regions&countryId="; ?> ' + pk_c_code; <?php } else { ?> var url = '<?php echo osc_base_url(true) . "?page=ajax&action=regions&countryId="; ?> ' + pk_c_code; <?php } ?> var result = ''; if(pk_c_code != '') { $("#regionId").attr('disabled',false); $("#cityId").attr('disabled',true); $.ajax({ type: "POST", url: url, dataType: 'json', success: function(data){ var length = data.length; if(length > 0) { result += '<option value=""><?php _e("Select a region..."); ?> </option>'; for(key in data) { result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>'; } $("#region").before('<select name="regionId" id="regionId" ></select>'); $("#region").remove(); } else { result += '<option value=""><?php _e('No results'); ?> </option>'; $("#regionId").before('<input type="text" name="region" id="region" />'); $("#regionId").remove(); } $("#regionId").html(result); } }); } else { $("#regionId").attr('disabled',true); $("#cityId").attr('disabled',true); } }); $("#regionId").change(function(){ var pk_c_code = $(this).val(); <?php if ($path == "admin") { ?> var url = '<?php echo osc_admin_base_url(true) . "?page=ajax&action=cities®ionId="; ?> ' + pk_c_code; <?php } else { ?> var url = '<?php echo osc_base_url(true) . "?page=ajax&action=cities®ionId="; ?> ' + pk_c_code; <?php } ?> var result = ''; if(pk_c_code != '') { $("#cityId").attr('disabled',false); $.ajax({ type: "POST", url: url, dataType: 'json', success: function(data){ var length = data.length; if(length > 0) { result += '<option value=""><?php _e("Select a city..."); ?> </option>'; for(key in data) { result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>'; } $("#city").before('<select name="cityId" id="cityId" ></select>'); $("#city").remove(); } else { result += '<option value=""><?php _e('No results'); ?> </option>'; $("#cityId").before('<input type="text" name="city" id="city" />'); $("#cityId").remove(); } $("#cityId").html(result); } }); } else { $("#cityId").attr('disabled',true); } }); if( $("#regionId").attr('value') == "") { $("#cityId").attr('disabled',true); } if( $("#countryId").attr('type').match(/select-one/) ) { if( $("#countryId").attr('value') == "") { $("#regionId").attr('disabled',true); } } /** * Validate form */ // Validate description without HTML. $.validator.addMethod( "minstriptags", function(value, element) { altered_input = strip_tags(value); if (altered_input.length < 10) { return false; } else { return true; } }, "<?php _e("Description: needs to be longer"); ?> ." ); // Validate fields in each locale. $("form[name=item] button").click(function() { lang_count = $(".title input").length; // Title $(".title input").each(function(){ lang_name = $(this).parent().prev('h2').text().replace(/^(.+) \((.+)\)$/, '$1'); lang_locale = $(this).attr('name').replace(/^title\[(.+)\]$/,'$1'); str = ((lang_count > 1) ? lang_name + ' ' : ''); $(this).rules("add", { required: true, minlength: 9, maxlength: 80, messages: { required: str + "<?php _e("Title: this field is required"); ?> .", minlength: str + "<?php _e("Title: enter at least 9 characters"); ?> .", maxlength: str + "<?php _e("Title: no more than 80 characters"); ?> ." } }); }); // Description $(".description textarea").each(function(){ lang_name = $(this).parent().prev('h2').text().replace(/^(.+) \((.+)\)$/, '$1'); lang_locale = $(this).attr('name').replace(/^title\[(.+)\]$/,'$1'); str = ((lang_count > 1) ? lang_name + ' ' : ''); $(this).rules("add", { required: true, minlength: 10, maxlength: 5000, 'minstriptags': true, messages: { required: str + "<?php _e("Description: this field is required"); ?> .", minlength: str + "<?php _e("Description: needs to be longer"); ?> .", maxlength: str + "<?php _e("Description: no more than 5000 characters"); ?> ." } }); }); }); // Code for form validation $("form[name=item]").validate({ rules: { catId: { required: true, digits: true }, <?php if (osc_price_enabled_at_items()) { ?> price: { number: true, maxlength: 15 }, currency: "required", <?php } ?> <?php if (osc_images_enabled_at_items()) { ?> "photos[]": { accept: "<?php echo osc_allowed_extension(); ?> " }, <?php } ?> <?php if ($path == 'front') { ?> contactName: { minlength: 3, maxlength: 35 }, contactEmail: { required: true, email: true }, <?php } ?> regionId: { required: true, digits: true }, cityId: { required: true, digits: true }, cityArea: { minlength: 3, maxlength: 35 }, address: { minlength: 5, maxlength: 50 } }, messages: { catId: "<?php _e('Choose one category'); ?> .", <?php if (osc_price_enabled_at_items()) { ?> price: { number: "<?php _e('Price: enter a valid number'); ?> .", maxlength: "<?php _e("Price: no more than 15 characters"); ?> ." }, currency: "<?php _e("Currency: make your selection"); ?> .", <?php } ?> <?php if (osc_images_enabled_at_items()) { ?> "photos[]": { accept: "<?php printf(__("Photo: must be %s"), osc_allowed_extension()); ?> ." }, <?php } ?> <?php if ($path == 'front') { ?> contactName: { minlength: "<?php _e("Name: enter at least 3 characters"); ?> .", maxlength: "<?php _e("Name: no more than 35 characters"); ?> ." }, contactEmail: { required: "<?php _e("Email: this field is required"); ?> .", email: "<?php _e("Invalid email address"); ?> ." }, <?php } ?> regionId: "<?php _e("Select a region"); ?> .", cityId: "<?php _e("Select a city"); ?> .", cityArea: { minlength: "<?php _e("City area: enter at least 3 characters"); ?> .", maxlength: "<?php _e("City area: no more than 35 characters"); ?> ." }, address: { minlength: "<?php _e("Address: enter at least 5 characters"); ?> .", maxlength: "<?php _e("Address: no more than 50 characters"); ?> ." } }, errorLabelContainer: "#error_list", wrapper: "li", invalidHandler: function(form, validator) { $('html,body').animate({ scrollTop: $('h1').offset().top }, { duration: 250, easing: 'swing'}); } }); }); /** * Strip HTML tags to count number of visible characters. */ function strip_tags(html) { if (arguments.length < 3) { html=html.replace(/<\/?(?!\!)[^>]*>/gi, ''); } else { var allowed = arguments[1]; var specified = eval("["+arguments[2]+"]"); if (allowed){ var regex='</?(?!(' + specified.join('|') + '))\b[^>]*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } else{ var regex='</?(' + specified.join('|') + ')\b[^>]*>'; html=html.replace(new RegExp(regex, 'gi'), ''); } } return html; } </script> <?php }
} ?> <td class="text"> <h3><a href="<?php echo osc_item_url(); ?> "><?php echo osc_item_title(); ?> </a></h3> <h5><?php echo osc_item_contact_name(); ?> </h5> <p><strong><?php if (osc_price_enabled_at_items() && osc_item_category_price_enabled()) { echo osc_item_formated_price(); ?> - <?php } echo osc_item_city(); ?> (<?php echo osc_item_region(); ?> ) - <?php echo osc_format_date(osc_item_pub_date()); ?> </strong></p> <p><?php echo osc_highlight(strip_tags(osc_item_description()));
function pop_search_filters() { ?> <form id="filterForm" name="filterForm" action="<?php echo osc_base_url(true); ?> " method="get" class="nocsrf"> <input type="hidden" name="page" value="search" /> <input type="hidden" name="sOrder" value="<?php echo osc_search_order(); ?> " /> <input type="hidden" name="iOrderType" value="<?php $allowedTypesForSorting = Search::getAllowedTypesForSorting(); echo $allowedTypesForSorting[osc_search_order_type()]; ?> " /> <?php foreach (osc_search_user() as $userId) { ?> <input type="hidden" name="sUser[]" value="<?php echo $userId; ?> " /> <?php } ?> <fieldset class="form-group first"> <h6> <?php _e('Search text', 'pop'); ?> </h6> <input class="input-text" type="text" name="sPattern" id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?> " /> </fieldset> <fieldset class="form-group"> <h6> <?php _e('Region', 'pop'); ?> </h6> <div> <?php $sCountries = osc_get_countries(); $countryId = $sCountries[0]['pk_c_code']; $sRegions = osc_get_regions($countryId); ?> <?php //pop_region_autocomplete($sRegions); ?> <input type="hidden" id="countryId" name="countryId" value="<?php echo $countryId; ?> " /> <input class="input-text" type="text" id="region" name="sRegion" value="<?php echo osc_esc_html(osc_search_region()); ?> " /> <input type="hidden" id="regionId" name="regionId" /> </div> </fieldset> <fieldset class="form-group"> <h6> <?php _e('City', 'pop'); ?> </h6> <div> <input class="input-text" type="text" id="city" name="sCity" value="<?php echo osc_esc_html(osc_search_city()); ?> " /> <input type="hidden" id="cityId" name="cityId" /> </div> </fieldset> <?php if (osc_images_enabled_at_items()) { ?> <fieldset class="form-group"> <div class="checkbox"> <input type="checkbox" name="bPic" id="withPicture" value="1" <?php echo osc_search_has_pic() ? 'checked' : ''; ?> /> <label for="withPicture"> <?php _e('Listings with pictures', 'pop'); ?> </label> </div> </fieldset> <?php } ?> <?php if (osc_price_enabled_at_items()) { ?> <fieldset class="form-group"> <div class="price-slice"> <h6> <?php _e('Price', 'pop'); ?> </h6> <ul class="row"> <li class="col-md-6"> <span> <?php _e('Min', 'pop'); ?> :</span> <input class="input-text" type="text" id="priceMin" name="sPriceMin" value="<?php echo osc_esc_html(osc_search_price_min()); ?> " size="6" maxlength="6" /> </li> <li class="col-md-6"> <span> <?php _e('Max', 'pop'); ?> :</span> <input class="input-text" type="text" id="priceMax" name="sPriceMax" value="<?php echo osc_esc_html(osc_search_price_max()); ?> " size="6" maxlength="6" /> </li> </ul> </div> </fieldset> <?php } ?> <div class="form-group plugin-hooks"> <?php if (osc_search_category_id()) { osc_run_hook('search_form', osc_search_category_id()); } else { osc_run_hook('search_form'); } ?> </div> <?php $aCategories = osc_search_category(); foreach ($aCategories as $cat_id) { ?> <input type="hidden" name="sCategory[]" value="<?php echo osc_esc_html($cat_id); ?> " /> <?php } ?> <div class="actions"> <button type="submit" class="btn btn-primary"> <?php _e('Apply', 'pop'); ?> </button> <a class="clear" onclick="formReset($('#filterForm'))"> <i class="fa fa-times"></i><?php echo _e('Clear filters', 'pop'); ?> </a> </div> </form> <?php }