public static function country_text($item = null) { if ($item == null) { $item = osc_item(); } if (Session::newInstance()->_getForm('country') != "") { $item['s_country'] = Session::newInstance()->_getForm('country'); } $only_one = false; if (!isset($item['s_country'])) { $countries = osc_get_countries(); if (count($countries) == 1) { $item['s_country'] = $countries[0]['s_name']; $item['fk_c_country_code'] = $countries[0]['pk_c_code']; $only_one = true; } } parent::generic_input_text('countryName', isset($item['s_country']) ? $item['s_country'] : null, null, $only_one); parent::generic_input_hidden('countryId', isset($item['fk_c_country_code']) && $item['fk_c_country_code'] != null ? $item['fk_c_country_code'] : ''); return true; }
</label> <div class="controls"> <?php UserForm::phone_land_text(osc_user()); ?> </div> </div> <div class="form-group"> <label class="control-label" for="country"> <?php _e('Stream', OSCLASSWIZARDS_THEME_FOLDER); ?> </label> <div class="controls"> <?php UserForm::country_select(osc_get_countries(), osc_user()); ?> </div> </div> <div class="form-group"> <label class="control-label" for="region"> <?php _e('University', OSCLASSWIZARDS_THEME_FOLDER); ?> </label> <div class="controls"> <?php UserForm::region_select(osc_get_regions(), osc_user()); ?> </div> </div>
function get_country_id($item) { $country_id = ""; $aCountries = osc_get_countries(); if (count($aCountries) == 1) { $country_id = $aCountries[0]['pk_c_code']; } if (array_key_exists('fk_c_country_code', $item)) { $country_id = $item['fk_c_country_code']; } if (Session::newInstance()->_getForm('countryId') != '') { $country_id = Session::newInstance()->_getForm('countryId'); } return $country_id; }
_e('Region', 'bender'); ?> </label> <div class="controls"> <?php if (bender_default_location_show_as() == 'dropdown') { ItemForm::region_select(osc_get_regions(osc_user_field('fk_c_country_code')), osc_user()); } 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') { ItemForm::region_select($aRegions, osc_user());
public static function country_text() { // get params GET (only manageItems) if (Params::getParam('country') != '') { $item['s_country'] = Params::getParam('country'); $item['fk_c_country_code'] = Params::getParam('countryId'); } $only_one = false; if (!isset($item['s_country'])) { $countries = osc_get_countries(); if (count($countries) == 1) { $item['s_country'] = $countries[0]['s_name']; $item['fk_c_country_code'] = $countries[0]['pk_c_code']; $only_one = true; } } parent::generic_input_text('countryName', isset($item['s_country']) ? $item['s_country'] : null, null, $only_one); parent::generic_input_hidden('countryId', isset($item['fk_c_country_code']) && $item['fk_c_country_code'] != null ? $item['fk_c_country_code'] : ''); return true; }
</button> <div id="facebook-login"> <?php fbc_button(); ?> </div> </div> </div> </form> </div> </div> <?php PopUserForm::location_javascript(); UserForm::js_validation(); if (count(osc_get_countries()) == 1) { ?> <script type="text/javascript"> $(document).ready(function() { $('select[id="countryId"]').addClass("{required: true, messages: { required: '<?php _e("Country is required", "pop"); ?> '}}") ; $('select[id="regionId"]').addClass("{required: true, messages: { required: '<?php _e("Region is required", "pop"); ?> '}}") ; $('select[id="cityId"]').addClass("{required: true, messages: { required: '<?php _e("City is required", "pop"); ?>
function pop_user_update_lat_long($userId) { $user = User::newInstance()->findByPrimaryKey($userId); $lat = 41.298336; $long = 2.084683; $location_string = pop_get_listing_location_string($user); if ($location_string == '') { $aCountries = osc_get_countries(); $country = $aCountries[0]; $url = "http://maps.googleapis.com/maps/api/geocode/json?address=" . $country['s_name'] . "&sensor=true_or_false"; } else { $url = "http://maps.googleapis.com/maps/api/geocode/json?address=" . urlencode($location_string) . "&sensor=true_or_false"; } $content = file_get_contents($url); if (json_encode($content)) { $json = json_decode($content, true); if (isset($json['results'][0]['geometry']['location']['lat'])) { $lat = $json['results'][0]['geometry']['location']['lat']; $long = $json['results'][0]['geometry']['location']['lng']; } } User::newInstance()->update(array('d_coord_lat' => $lat, 'd_coord_long' => $long), array('pk_i_id' => $userId)); }
function item_country_box($country_txt, $country_select_txt) { $aCountries = osc_get_countries(); $item = osc_item() != null ? osc_item() : array(); switch (count($aCountries)) { case 0: // no country, show input ?> <div class="clearfix"> <label><?php echo $country_txt; ?> </label> <div class="input"> <input class="country_name" id="country_name" type="text" name="country" value="<?php echo get_country_name($item); ?> " /> </div> </div> <?php break; case 1: // one country ?> <input class="country_id" id="country_id" type="hidden" name="countryId" value="<?php echo get_country_id($item) == "" ? $aCountries[0]['pk_c_code'] : get_country_id($item); ?> " /> <?php break; default: // more than one country ?> <div class="clearfix"> <label><?php echo $country_txt; ?> </label> <div class="input"> <select class="country_id" id="country_id" name="countryId"> <option value=""><?php echo $country_select_txt; ?> </option> <?php foreach ($aCountries as $country) { ?> <option value="<?php echo $country['pk_c_code']; ?> "><?php echo $country['s_name']; ?> </option> <?php } ?> </select> </div> </div> <?php break; } }
public static function country_select($countries = null, $item = null) { if ($countries == null) { $countries = osc_get_countries(); } if ($item == null) { $item = osc_item(); } if (count($countries) > 1) { parent::generic_select('countryId', $countries, 'pk_c_code', 's_name', __('Select a country...'), isset($item['fk_c_country_code']) ? $item['fk_c_country_code'] : null); return true; } else { if (count($countries) == 1) { parent::generic_input_hidden('countryId', isset($item['fk_c_country_code']) ? $item['fk_c_country_code'] : $countries[0]['pk_c_code']); echo '</span>' . $countries[0]['s_name'] . '</span>'; return false; } else { parent::generic_input_text('country', isset($item['s_country']) ? $item['s_country'] : null); return true; } } }