Beispiel #1
0
     global $user_fields_empty_name;
     $user_fields_empty_name = T_('Select...');
     $Form->select('criteria_type[]', '', 'callback_options_user_new_fields', T_('Specific criteria'), $criteria_input);
     break;
 case 'get_regions_option_list':
     // Get option list with regions by selected country
     $country_ID = param('ctry_id', 'integer', 0);
     $region_ID = param('rgn_id', 'integer', 0);
     $page = param('page', 'string', '');
     $mode = param('mode', 'string', '');
     $params = array();
     if ($page == 'edit') {
         $params['none_option_text'] = T_('Unknown');
     }
     load_funcs('regional/model/_regional.funcs.php');
     echo get_regions_option_list($country_ID, 0, $params);
     if ($mode == 'load_subregions' || $mode == 'load_all') {
         // Load also the subregions
         echo '-##-' . get_subregions_option_list($region_ID, 0, $params);
     }
     if ($mode == 'load_all') {
         // Load also the cities
         echo '-##-' . get_cities_option_list($country_ID, $region_ID, 0, 0, $params);
     }
     break;
 case 'get_subregions_option_list':
     // Get option list with sub-regions by selected region
     $country_ID = param('ctry_id', 'integer', 0);
     $region_ID = param('rgn_id', 'integer', 0);
     $page = param('page', 'string', '');
     $mode = param('mode', 'string', '');
Beispiel #2
0
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_cities(&$Form)
{
    load_class('regional/model/_country.class.php', 'Country');
    $CountryCache =& get_CountryCache(T_('All'));
    $Form->select_country('c', get_param('c'), $CountryCache, T_('Country'), array('allow_none' => true));
    $Form->select_input_options('r', get_regions_option_list(get_param('c'), get_param('r')), T_('Region'));
    $Form->select_input_options('sr', get_subregions_option_list(get_param('r'), get_param('sr')), T_('Sub-region'));
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
}
 * @var Sub-region
 */
global $edited_Subregion;
// Determine if we are creating or updating...
global $action;
$creating = is_create_action($action);
$Form = new Form(NULL, 'subregion_checkchanges', 'post', 'compact');
$Form->global_icon(T_('Delete this sub-region!'), 'delete', regenerate_url('action', 'action=delete&' . url_crumb('subregion')));
$Form->global_icon(T_('Cancel editing!'), 'close', regenerate_url('action'));
$Form->begin_form('fform', ($creating ? T_('New sub-region') : T_('Sub-region')) . get_manual_link('subregions-editing'));
$Form->add_crumb('subregion');
$Form->hiddens_by_key(get_memorized('action' . ($creating ? ',subrg_ID' : '')));
// (this allows to come back to the right list order & page)
$CountryCache =& get_CountryCache();
$Form->select_country('subrg_ctry_ID', $edited_Subregion->ctry_ID, $CountryCache, T_('Country'), array('allow_none' => true, 'required' => true));
$Form->select_input_options('subrg_rgn_ID', get_regions_option_list($edited_Subregion->ctry_ID, $edited_Subregion->rgn_ID, array('none_option_text' => T_('Unknown'))), T_('Region'), '', array('required' => true));
$Form->text_input('subrg_code', $edited_Subregion->code, 6, T_('Code'), '', array('maxlength' => 6, 'required' => true));
$Form->text_input('subrg_name', $edited_Subregion->name, 40, T_('Name'), '', array('maxlength' => 40, 'required' => true));
if ($creating) {
    $Form->end_form(array(array('submit', 'actionArray[create]', T_('Record'), 'SaveButton'), array('submit', 'actionArray[create_new]', T_('Record, then Create New'), 'SaveButton'), array('submit', 'actionArray[create_copy]', T_('Record, then Create Similar'), 'SaveButton')));
} else {
    $Form->end_form(array(array('submit', 'actionArray[update]', T_('Save Changes!'), 'SaveButton')));
}
?>
<script type="text/javascript">
jQuery( '#subrg_ctry_ID' ).change( function ()
{	// Load option list with regions for seleted country
	jQuery.ajax( {
	type: 'POST',
	url: '<?php 
echo get_samedomain_htsrv_url();
Beispiel #4
0
/**
 * Display location select elements (Country, Region, Subregion, City)
 *
 * @param object Form
 * @param object Edited Item
 */
function echo_item_location_form(&$Form, &$edited_Item)
{
    load_class('regional/model/_country.class.php', 'Country');
    load_funcs('regional/model/_regional.funcs.php');
    $edited_Item_Blog = $edited_Item->get_Blog();
    if (!$edited_Item_Blog->country_visible()) {
        // If country is NOT visible it means all other location fields also are not visible, so exit here
        return;
    }
    global $rsc_url;
    $Form->begin_fieldset(T_('Location'));
    $table_class = '';
    if ($edited_Item->is_special()) {
        // A post with special type should always has the location fields as not required
        // This css class hides all red stars of required fields
        $table_class = ' not_required';
    }
    $Form->switch_layout('table');
    $Form->formstart = '<table id="item_locations" cellspacing="0" class="fform' . $table_class . '">' . "\n";
    $Form->labelstart = '<td class="right"><strong>';
    $Form->labelend = '</strong></td>';
    echo $Form->formstart;
    $button_refresh_regional = '<button id="%s" type="submit" name="actionArray[edit_switchtab]" class="action_icon refresh_button">' . get_icon('refresh') . '</button>';
    $button_refresh_regional .= '<img src="' . $rsc_url . 'img/ajax-loader.gif" alt="' . T_('Loading...') . '" title="' . T_('Loading...') . '" style="display:none;margin-left:5px" align="top" />';
    // Country
    $CountryCache =& get_CountryCache();
    $country_is_required = $edited_Item->Blog->get_setting('location_country') == 'required';
    $Form->select_country('item_ctry_ID', $edited_Item->ctry_ID, $CountryCache, T_('Country'), array('required' => $country_is_required, 'allow_none' => true));
    if ($edited_Item->Blog->region_visible()) {
        // Region
        $region_is_required = $edited_Item->Blog->get_setting('location_region') == 'required';
        $Form->select_input_options('item_rgn_ID', get_regions_option_list($edited_Item->ctry_ID, $edited_Item->rgn_ID, array('none_option_text' => T_('Unknown'))), T_('Region'), sprintf($button_refresh_regional, 'button_refresh_region'), array('required' => $region_is_required));
    }
    if ($edited_Item->Blog->subregion_visible()) {
        // Subregion
        $subregion_is_required = $edited_Item->Blog->get_setting('location_subregion') == 'required';
        $Form->select_input_options('item_subrg_ID', get_subregions_option_list($edited_Item->rgn_ID, $edited_Item->subrg_ID, array('none_option_text' => T_('Unknown'))), T_('Sub-region'), sprintf($button_refresh_regional, 'button_refresh_subregion'), array('required' => $subregion_is_required));
    }
    if ($edited_Item->Blog->city_visible()) {
        // City
        $city_is_required = $edited_Item->Blog->get_setting('location_city') == 'required';
        $Form->select_input_options('item_city_ID', get_cities_option_list($edited_Item->ctry_ID, $edited_Item->rgn_ID, $edited_Item->subrg_ID, $edited_Item->city_ID, array('none_option_text' => T_('Unknown'))), T_('City'), sprintf($button_refresh_regional, 'button_refresh_city'), array('required' => $city_is_required));
    }
    echo $Form->formend;
    $Form->switch_layout(NULL);
    $Form->end_fieldset();
}
Beispiel #5
0
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function callback_filter_userlist(&$Form)
{
    global $Settings, $current_User;
    $Form->hidden('filter', 'new');
    $Form->text('keywords', get_param('keywords'), 20, T_('Name'), '', 50);
    echo '<span class="nowrap">';
    $Form->checkbox('gender_men', get_param('gender_men'), T_('Men'));
    $Form->checkbox('gender_women', get_param('gender_women'), T_('Women'));
    echo '</span>';
    if (!is_admin_page()) {
        echo '<br />';
    }
    if (is_admin_page()) {
        // show this filters only on admin interface
        if ($current_User->check_perm('users', 'edit')) {
            // Show "Reported users" filter only for users with edit user permission
            $Form->checkbox('reported', get_param('reported'), T_('Reported users'));
            $Form->checkbox('custom_sender_email', get_param('custom_sender_email'), T_('Users with custom sender address'));
            $Form->checkbox('custom_sender_name', get_param('custom_sender_name'), T_('Users with custom sender name'));
        }
        $Form->select_input_array('account_status', get_param('account_status'), get_user_statuses(T_('All')), T_('Account status'));
        $GroupCache = new DataObjectCache('Group', true, 'T_groups', 'grp_', 'grp_ID', 'grp_name');
        $group_options_array = array('-1' => T_('All (Ungrouped)'), '0' => T_('All (Grouped)')) + $GroupCache->get_option_array();
        $Form->select_input_array('group', get_param('group'), $group_options_array, T_('User group'), '', array('force_keys_as_values' => true));
        echo '<br />';
    }
    if (user_country_visible()) {
        // Filter by country
        load_class('regional/model/_country.class.php', 'Country');
        load_funcs('regional/model/_regional.funcs.php');
        $CountryCache =& get_CountryCache(T_('All'));
        $Form->select_country('country', get_param('country'), $CountryCache, T_('Country'), array('allow_none' => true));
    }
    if (user_region_visible()) {
        // Filter by region
        echo '<span id="region_filter"' . (!regions_exist(get_param('country'), true) ? ' style="display:none"' : '') . '>';
        $Form->select_input_options('region', get_regions_option_list(get_param('country'), get_param('region')), T_('Region'));
        echo '</span>';
    }
    if (user_subregion_visible()) {
        // Filter by subregion
        echo '<span id="subregion_filter"' . (!subregions_exist(get_param('region'), true) ? ' style="display:none"' : '') . '>';
        $Form->select_input_options('subregion', get_subregions_option_list(get_param('region'), get_param('subregion')), T_('Sub-region'));
        echo '</span>';
    }
    if (user_city_visible()) {
        // Filter by city
        echo '<span id="city_filter"' . (!cities_exist(get_param('country'), get_param('region'), get_param('subregion'), true) ? ' style="display:none"' : '') . '>';
        $Form->select_input_options('city', get_cities_option_list(get_param('country'), get_param('region'), get_param('subregion'), get_param('city')), T_('City'));
        echo '</span>';
    }
    echo '<br />';
    $Form->interval('age_min', get_param('age_min'), 'age_max', get_param('age_max'), 3, T_('Age group'));
    echo '<br />';
    $criteria_types = param('criteria_type', 'array/integer');
    $criteria_values = param('criteria_value', 'array/string');
    if (count($criteria_types) == 0) {
        // Init one criteria fieldset for first time
        $criteria_types[] = '';
        $criteria_values[] = '';
    }
    foreach ($criteria_types as $c => $type) {
        $value = trim(strip_tags($criteria_values[$c]));
        if ($value == '' && count($criteria_types) > 1 && $c > 0) {
            // Don't display empty field again after filter request
            continue;
        }
        if ($c > 0) {
            // Separator between criterias
            echo '<br />';
        }
        $Form->output = false;
        $criteria_input = $Form->text('criteria_value[]', $value, 17, '', '', 50);
        $criteria_input .= get_icon('add', 'imgtag', array('rel' => 'add_criteria'));
        $Form->output = true;
        global $user_fields_empty_name;
        $user_fields_empty_name = T_('Select...');
        $Form->select('criteria_type[]', $type, 'callback_options_user_new_fields', T_('Specific criteria'), $criteria_input);
    }
    if (user_region_visible()) {
        // JS functions for AJAX loading of regions, subregions & cities
        ?>
<script type="text/javascript">
jQuery( '#country' ).change( function()
{
	var this_obj = jQuery( this );
	jQuery.ajax( {
	type: 'POST',
	url: '<?php 
        echo get_samedomain_htsrv_url();
        ?>
anon_async.php',
	data: 'action=get_regions_option_list&ctry_id=' + jQuery( this ).val(),
	success: function( result )
		{
			jQuery( '#region' ).html( ajax_debug_clear( result ) );
			if( jQuery( '#region option' ).length > 1 )
			{
				jQuery( '#region_filter' ).show();
			}
			else
			{
				jQuery( '#region_filter' ).hide();
			}
			load_subregions( 0 ); // Reset sub-regions
		}
	} );
} );

jQuery( '#region' ).change( function ()
{	// Change option list with sub-regions
	load_subregions( jQuery( this ).val() );
} );

jQuery( '#subregion' ).change( function ()
{	// Change option list with cities
	load_cities( jQuery( '#country' ).val(), jQuery( '#region' ).val(), jQuery( this ).val() );
} );

function load_subregions( region_ID )
{	// Load option list with sub-regions for seleted region
	jQuery.ajax( {
	type: 'POST',
	url: '<?php 
        echo get_samedomain_htsrv_url();
        ?>
anon_async.php',
	data: 'action=get_subregions_option_list&rgn_id=' + region_ID,
	success: function( result )
		{
			jQuery( '#subregion' ).html( ajax_debug_clear( result ) );
			if( jQuery( '#subregion option' ).length > 1 )
			{
				jQuery( '#subregion_filter' ).show();
			}
			else
			{
				jQuery( '#subregion_filter' ).hide();
			}
			load_cities( jQuery( '#country' ).val(), region_ID, 0 );
		}
	} );
}

function load_cities( country_ID, region_ID, subregion_ID )
{	// Load option list with cities for seleted region or sub-region
	jQuery.ajax( {
	type: 'POST',
	url: '<?php 
        echo get_samedomain_htsrv_url();
        ?>
anon_async.php',
	data: 'action=get_cities_option_list&ctry_id=' + country_ID + '&rgn_id=' + region_ID + '&subrg_id=' + subregion_ID,
	success: function( result )
		{
			jQuery( '#city' ).html( ajax_debug_clear( result ) );
			if( jQuery( '#city option' ).length > 1 )
			{
				jQuery( '#city_filter' ).show();
			}
			else
			{
				jQuery( '#city_filter' ).hide();
			}
		}
	} );
}
</script>
<?php 
    }
}
Beispiel #6
0
 * @var City
 */
global $edited_City;
// Determine if we are creating or updating...
global $action;
$creating = is_create_action($action);
$Form = new Form(NULL, 'city_checkchanges', 'post', 'compact');
$Form->global_icon(T_('Delete this city!'), 'delete', regenerate_url('action', 'action=delete&amp;' . url_crumb('city')));
$Form->global_icon(T_('Cancel editing!'), 'close', regenerate_url('action'));
$Form->begin_form('fform', ($creating ? T_('New city') : T_('City')) . get_manual_link('cities-editing'));
$Form->add_crumb('city');
$Form->hiddens_by_key(get_memorized('action' . ($creating ? ',city_ID' : '')));
// (this allows to come back to the right list order & page)
$CountryCache =& get_CountryCache();
$Form->select_country('city_ctry_ID', $edited_City->ctry_ID, $CountryCache, T_('Country'), array('allow_none' => true, 'required' => true));
$Form->select_input_options('city_rgn_ID', get_regions_option_list($edited_City->ctry_ID, $edited_City->rgn_ID, array('none_option_text' => T_('Unknown'))), T_('Region'));
$Form->select_input_options('city_subrg_ID', get_subregions_option_list($edited_City->rgn_ID, $edited_City->subrg_ID, array('none_option_text' => T_('Unknown'))), T_('Sub-region'));
$Form->text_input('city_postcode', $edited_City->postcode, 12, T_('Post code'), '', array('maxlength' => 12, 'required' => true));
$Form->text_input('city_name', $edited_City->name, 40, T_('Name'), '', array('maxlength' => 40, 'required' => true));
if ($creating) {
    $Form->end_form(array(array('submit', 'actionArray[create]', T_('Record'), 'SaveButton'), array('submit', 'actionArray[create_new]', T_('Record, then Create New'), 'SaveButton'), array('submit', 'actionArray[create_copy]', T_('Record, then Create Similar'), 'SaveButton')));
} else {
    $Form->end_form(array(array('submit', 'actionArray[update]', T_('Save Changes!'), 'SaveButton')));
}
?>
<script type="text/javascript">
jQuery( '#city_ctry_ID' ).change( function ()
{	// Load option list with regions for seleted country
	jQuery.ajax( {
	type: 'POST',
	url: '<?php 
 }
 $nickname_editing = $Settings->get('nickname_editing');
 if (in_array($nickname_editing, $edited_user_perms) && $edited_User->ID == $current_User->ID || $nickname_editing != 'hidden' && $has_full_access) {
     $Form->text_input('edited_user_nickname', $edited_User->nickname, 20, T_('Nickname'), '', array('maxlength' => 50, 'required' => $nickname_editing == 'edited-user-required'));
 }
 $Form->radio('edited_user_gender', $edited_User->get('gender'), array(array('M', T_('A man')), array('F', T_('A woman'))), T_('I am'), false, '', $Settings->get('registration_require_gender') == 'required');
 $button_refresh_regional = '<button id="%s" type="submit" name="actionArray[refresh_regional]" class="action_icon refresh_button">' . get_icon('refresh') . '</button>';
 $button_refresh_regional .= '<img src="' . $rsc_url . 'img/ajax-loader.gif" alt="' . T_('Loading...') . '" title="' . T_('Loading...') . '" style="display:none;margin:2px 0 0 5px" align="top" />';
 if (user_country_visible()) {
     // Display a select input for Country
     $CountryCache =& get_CountryCache();
     $Form->select_country('edited_user_ctry_ID', $edited_User->ctry_ID, $CountryCache, T_('Country'), array('required' => $Settings->get('location_country') == 'required', 'allow_none' => $has_full_access || empty($edited_User->ctry_ID) || !empty($edited_User->ctry_ID) && $Settings->get('location_country') != 'required'));
 }
 if (user_region_visible()) {
     // Display a select input for Region
     $regions_option_list = get_regions_option_list($edited_User->ctry_ID, $edited_User->rgn_ID, array('none_option_text' => T_('Unknown')));
     $Form->select_input_options('edited_user_rgn_ID', $regions_option_list, T_('Region'), sprintf($button_refresh_regional, 'button_refresh_region'), array('required' => $Settings->get('location_region') == 'required'));
 }
 if (user_subregion_visible()) {
     // Display a select input for Subregion
     $subregions_option_list = get_subregions_option_list($edited_User->rgn_ID, $edited_User->subrg_ID, array('none_option_text' => T_('Unknown')));
     $Form->select_input_options('edited_user_subrg_ID', $subregions_option_list, T_('Sub-region'), sprintf($button_refresh_regional, 'button_refresh_subregion'), array('required' => $Settings->get('location_subregion') == 'required'));
 }
 if (user_city_visible()) {
     // Display a select input for City
     $cities_option_list = get_cities_option_list($edited_User->ctry_ID, $edited_User->rgn_ID, $edited_User->subrg_ID, $edited_User->city_ID, array('none_option_text' => T_('Unknown')));
     $Form->select_input_options('edited_user_city_ID', $cities_option_list, T_('City'), sprintf($button_refresh_regional, 'button_refresh_city'), array('required' => $Settings->get('location_city') == 'required'));
 }
 $Form->interval('edited_user_age_min', $edited_User->age_min, 'edited_user_age_max', $edited_User->age_max, 3, T_('My age group'));
 // Organization select fields:
 $OrganizationCache =& get_OrganizationCache();