-
Notifications
You must be signed in to change notification settings - Fork 3
/
item-post.php
247 lines (241 loc) · 13.2 KB
/
item-post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/*
* Osclass – software for creating and publishing online classified
* advertising platforms
*
* Copyright (C) 2014 OSCLASS
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// meta tag robots
osc_add_hook('header','bender_nofollow_construct');
osc_enqueue_script('jquery-validate');
bender_add_body_class('item item-post');
$action = 'item_add_post';
$edit = false;
if(Params::getParam('action') == 'item_edit') {
$action = 'item_edit_post';
$edit = true;
}
?>
<?php osc_current_web_theme_path('header.php') ; ?>
<?php
if (bender_default_location_show_as() == 'dropdown') {
ItemForm::location_javascript();
} else {
ItemForm::location_javascript_new();
}
?>
<div class="form-container form-horizontal">
<div class="resp-wrapper">
<div class="header">
<h1><?php _e('Publish a listing', 'bender'); ?></h1>
</div>
<ul id="error_list"></ul>
<form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data" id="item-post">
<fieldset>
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<input type="hidden" name="page" value="item" />
<?php if($edit){ ?>
<input type="hidden" name="id" value="<?php echo osc_item_id();?>" />
<input type="hidden" name="secret" value="<?php echo osc_item_secret();?>" />
<?php } ?>
<h2><?php _e('General Information', 'bender'); ?></h2>
<div class="control-group">
<label class="control-label" for="select_1"><?php _e('Category', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::category_select(null, null, __('Select a category', 'bender')); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="title[<?php echo osc_current_user_locale(); ?>]"><?php _e('Title', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="description[<?php echo osc_current_user_locale(); ?>]"><?php _e('Description', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::description_textarea('description',osc_current_user_locale(), osc_esc_html( bender_item_description() )); ?>
</div>
</div>
<?php if( osc_price_enabled_at_items() ) { ?>
<div class="control-group control-group-price">
<label class="control-label" for="price"><?php _e('Price', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::price_input_text(); ?>
<?php ItemForm::currency_select(); ?>
</div>
</div>
<?php } ?>
<?php if( osc_images_enabled_at_items() ) {
ItemForm::ajax_photos();
} ?>
<div class="box location">
<h2><?php _e('Listing Location', 'bender'); ?></h2>
<?php if(count(osc_get_countries()) > 1) { ?>
<div class="control-group">
<label class="control-label" for="country"><?php _e('Country', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::country_select(osc_get_countries(), osc_user()); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="regionId"><?php _e('Region', 'bender'); ?></label>
<div class="controls">
<?php
if (bender_default_location_show_as() == 'dropdown') {
if($edit) {
ItemForm::region_select(osc_get_regions(osc_item_country_code()), osc_item());
} else {
ItemForm::region_select(osc_get_regions(osc_user_field('fk_c_country_code')), osc_user());
}
} else {
if($edit) {
ItemForm::region_text(osc_item());
} else {
ItemForm::region_text(osc_user());
}
}
?>
</div>
</div>
<?php
} else {
$aCountries = osc_get_countries();
$aRegions = osc_get_regions($aCountries[0]['pk_c_code']);
?>
<input type="hidden" id="countryId" name="countryId" value="<?php echo osc_esc_html($aCountries[0]['pk_c_code']); ?>"/>
<div class="control-group">
<label class="control-label" for="region"><?php _e('Region', 'bender'); ?></label>
<div class="controls">
<?php
if (bender_default_location_show_as() == 'dropdown') {
if($edit) {
ItemForm::region_select($aRegions, osc_item());
} else {
ItemForm::region_select($aRegions, osc_user());
}
} else {
if($edit) {
ItemForm::region_text(osc_item());
} else {
ItemForm::region_text(osc_user());
}
}
?>
</div>
</div>
<?php } ?>
<div class="control-group">
<label class="control-label" for="city"><?php _e('City', 'bender'); ?></label>
<div class="controls">
<?php
if (bender_default_location_show_as() == 'dropdown') {
if($edit) {
ItemForm::city_select(null, osc_item());
} else { // add new item
ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user());
}
} else {
ItemForm::city_text(osc_user());
}
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="cityArea"><?php _e('City Area', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::city_area_text(osc_user()); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="address"><?php _e('Address', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::address_text(osc_user()); ?>
</div>
</div>
</div>
<!-- seller info -->
<?php if(!osc_is_web_user_logged_in() ) { ?>
<div class="box seller_info">
<h2><?php _e("Seller's information", 'bender'); ?></h2>
<div class="control-group">
<label class="control-label" for="contactName"><?php _e('Name', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::contact_name_text(); ?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="contactEmail"><?php _e('E-mail', 'bender'); ?></label>
<div class="controls">
<?php ItemForm::contact_email_text(); ?>
</div>
</div>
<div class="control-group">
<div class="controls checkbox">
<?php ItemForm::show_email_checkbox(); ?> <label for="showEmail"><?php _e('Show e-mail on the listing page', 'bender'); ?></label>
</div>
</div>
</div>
<?php
}
if($edit) {
ItemForm::plugin_edit_item();
} else {
ItemForm::plugin_post_item();
}
?>
<div class="control-group">
<?php if( osc_recaptcha_items_enabled() ) { ?>
<div class="controls">
<?php osc_show_recaptcha(); ?>
</div>
<?php }?>
<div class="controls">
<button type="submit" class="ui-button ui-button-middle ui-button-main"><?php if($edit) { _e("Update", 'bender'); } else { _e("Publish", 'bender'); } ?></button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
<script type="text/javascript">
$('#price').bind('hide-price', function(){
$('.control-group-price').hide();
});
$('#price').bind('show-price', function(){
$('.control-group-price').show();
});
<?php if(osc_locale_thousands_sep()!='' || osc_locale_dec_point() != '') { ?>
$().ready(function(){
$("#price").blur(function(event) {
var price = $("#price").prop("value");
<?php if(osc_locale_thousands_sep()!='') { ?>
while(price.indexOf('<?php echo osc_esc_js(osc_locale_thousands_sep()); ?>')!=-1) {
price = price.replace('<?php echo osc_esc_js(osc_locale_thousands_sep()); ?>', '');
}
<?php }; ?>
<?php if(osc_locale_dec_point()!='') { ?>
var tmp = price.split('<?php echo osc_esc_js(osc_locale_dec_point())?>');
if(tmp.length>2) {
price = tmp[0]+'<?php echo osc_esc_js(osc_locale_dec_point())?>'+tmp[1];
}
<?php }; ?>
$("#price").prop("value", price);
});
});
<?php }; ?>
</script>
<?php osc_current_web_theme_path('footer.php'); ?>