Example #1
0
function form_name($input_name, $label = "", $input_value = FALSE, array $options)
{
    global $defender, $locale;
    $title = isset($label) && !empty($label) ? $label : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $html = '';
    // NOTE (remember to parse readback value as of '|' seperator)
    if (isset($input_value) && !empty($input_value)) {
        if (!is_array($input_value)) {
            $input_value = construct_array($input_value, "", "|");
        }
    } else {
        $input_value['0'] = "";
        $input_value['1'] = "";
        $input_value['2'] = "";
    }
    $options += array('input_id' => !empty($options['input_id']) ? $options['input_id'] : $input_name, 'required' => !empty($options['required']) && $options['required'] == 1 ? '1' : '0', 'placeholder' => !empty($options['placeholder']) ? $options['placeholder'] : '', 'deactivate' => !empty($options['deactivate']) && $options['deactivate'] == 1 ? '1' : '0', 'width' => !empty($options['width']) ? $options['width'] : '100%', 'class' => !empty($options['class']) ? $options['class'] : '', 'inline' => !empty($options['inline']) ? $options['inline'] : '', 'error_text' => !empty($options['error_text']) ? $options['error_text'] : $locale['firstname_error'], 'error_text_2' => !empty($options['error_text']) ? $options['error_text_2'] : $locale['lastname_error'], 'tip' => !empty($options['tip']) ? $options['tip'] : '', 'safemode' => !empty($options['safemode']) && $options['safemode'] == 1 ? '1' : '0');
    $error_class = $defender->inputHasError($input_name . '-firstname') || $defender->inputHasError($input_name . '-lastname') ? "has-error " : "";
    $html .= "<div id='" . $options['input_id'] . "-field' class='form-group clearfix " . $error_class . $options['class'] . "' >\n";
    $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3 p-l-0" : '') . "' for='" . $options['input_id'] . "'>{$label} " . ($options['required'] ? "<span class='required'>*</span>" : '') . "\n\t" . ($options['tip'] ? "<i class='pointer fa fa-question-circle' title='" . $options['tip'] . "'></i>" : '') . "\n\t</label>\n" : '';
    $html .= $options['inline'] ? "<div class='col-xs-12 " . ($title ? "col-sm-9 col-md-9 col-lg-9" : "col-sm-12 col-md-12 col-lg-12  p-l-0") . "'>\n" : "";
    $html .= "<div class='row p-l-15'>\n";
    $html .= "<div class='col-xs-12 col-sm-4 col-md-4 col-lg-4 m-b-10 p-l-0'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control textbox' id='" . $options['input_id'] . "-firstname' value='" . $input_value['0'] . "' placeholder='" . $locale['first_name'] . " " . ($options['required'] ? '*' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[0]) || $defender->inputHasError($input_name[0]) ? "<div id='" . $options['input_id'] . "-firstname-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-4 col-md-4 col-lg-4 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control textbox' id='" . $options['input_id'] . "-lastname' value='" . $input_value['1'] . "' placeholder='" . $locale['last_name'] . " " . ($options['required'] ? '*' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[1]) || $defender->inputHasError($input_name[1]) ? "<div id='" . $options['input_id'] . "-lastname-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_2'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "</div>\n";
    // close inner row
    $html .= $options['inline'] ? "</div>\n" : "";
    $html .= "</div>\n";
    $defender->add_field_session(array('input_name' => $input_name, 'type' => 'name', 'title' => $title, 'id' => $options['input_id'], 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'], 'error_text_2' => $options['error_text_2']));
    return $html;
}
Example #2
0
function form_document($input_name, $label = '', $input_value = FALSE, array $options = array())
{
    global $locale, $defender, $settings;
    if (!defined('DATEPICKER')) {
        define('DATEPICKER', TRUE);
        add_to_head("<link href='" . DYNAMICS . "assets/datepicker/css/datepicker3.css' rel='stylesheet' />");
        add_to_head("<script src='" . DYNAMICS . "assets/datepicker/js/bootstrap-datepicker.js'></script>");
    }
    $title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $label = isset($label) && !empty($label) ? $label : "";
    $input_name = isset($input_name) && !empty($input_name) ? stripinput($input_name) : "";
    $input_id = isset($options['input_id']) && !empty($options['input_id']) ? stripinput($options['input_id']) : "";
    // NOTE (remember to parse readback value as of '|' seperator)
    if (isset($input_value) && !empty($input_value)) {
        if (!is_array($input_value)) {
            $input_value = construct_array($input_value, "", "|");
            if ($input_value[4] != "1900-01-01") {
                $input_value[4] = date('d-m-Y', strtotime($input_value[4]));
            } else {
                $input_value[4] = "";
            }
            if ($input_value[5] != "1900-01-01") {
                $input_value[5] = date('d-m-Y', strtotime($input_value[5]));
            } else {
                $input_value[5] = "";
            }
        }
    } else {
        $input_value['0'] = "";
        $input_value['1'] = "";
        $input_value['2'] = "";
        $input_value['3'] = "";
        $input_value['4'] = "";
        $input_value['5'] = "";
    }
    $options += array('required' => !empty($options['required']) && $options['required'] == 1 ? '1' : '0', 'placeholder' => !empty($options['placeholder']) ? $options['placeholder'] : '', 'deactivate' => !empty($options['deactivate']) && $options['deactivate'] == 1 ? '1' : '0', 'width' => !empty($options['width']) ? $options['width'] : '100%', 'class' => !empty($options['class']) ? $options['class'] : '', 'inline' => !empty($options['inline']) ? $options['inline'] : '', 'tip' => !empty($options['tip']) ? $options['tip'] : '', 'error_text' => !empty($options['error_text']) ? $options['error_text'] : $locale['doc_type_error'], 'error_text_2' => !empty($options['error_text_2']) ? $options['error_text_2'] : $locale['doc_series_error'], 'error_text_3' => !empty($options['error_text_3']) ? $options['error_text_3'] : $locale['doc_number_error'], 'error_text_4' => !empty($options['error_text_4']) ? $options['error_text_4'] : $locale['doc_authority_error'], 'error_text_5' => !empty($options['error_text_5']) ? $options['error_text_5'] : $locale['doc_issue_error'], 'error_text_6' => !empty($options['error_text_6']) ? $options['error_text_6'] : '', 'safemode' => !empty($options['safemode']) && $options['safemode'] == 1 ? '1' : '0', 'date_format' => !empty($options['date_format']) ? $options['date_format'] : 'dd-mm-yyyy', 'week_start' => !empty($options['week_start']) && isnum($options['week_start']) ? $options['week_start'] : isset($settings['week_start']) && isnum($settings['week_start']) ? $settings['week_start'] : 0);
    $error_key = array(0 => $options['error_text'], 1 => $options['error_text_2'], 2 => $options['error_text_3'], 3 => $options['error_text_4'], 4 => $options['error_text_5'], 5 => $options['error_text_6']);
    $error_class = "";
    for ($i = 0; $i <= 5; $i++) {
        if ($defender->inputHasError($input_name[$i])) {
            $error_class = "has-error ";
            addNotice("danger", "<strong>{$title}</strong> - " . $error_key[$i]);
        }
    }
    $html = "<div id='{$input_id}-field' class='form-group clearfix m-b-10 " . $error_class . $options['class'] . "' >\n";
    $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3 p-l-0" : '') . "' for='{$input_id}'>{$label}" . ($options['required'] ? "<span class='required'> *</span>" : '') . "\n\t" . ($options['tip'] ? "<i class='pointer fa fa-question-circle' title='" . $options['tip'] . "'></i>" : '') . "\n\t</label>\n" : '';
    $html .= $options['inline'] ? "<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9'>\n" : '';
    $html .= "<div class='row'>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-doc_type' value='" . $input_value['0'] . "' placeholder='" . $locale['doc_type'] . ($options['required'] ? ' *' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[0]) || $defender->inputHasError($input_name[0]) ? "<div id='" . $input_id . "-doc_type-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-4 col-sm-4 col-md-4 col-lg-3 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-doc_series' value='" . $input_value['1'] . "' placeholder='" . $locale['doc_series'] . ($options['required'] ? ' *' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[1]) || $defender->inputHasError($input_name[1]) ? "<div id='" . $input_id . "-doc_series-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-8 col-sm-8 col-md-8 col-lg-6 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-doc_number' value='" . $input_value['2'] . "' placeholder='" . $locale['doc_number'] . ($options['required'] ? ' *' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[2]) || $defender->inputHasError($input_name[2]) ? "<div id='" . $input_id . "-doc_number-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-doc_authority' value='" . $input_value['3'] . "' placeholder='" . $locale['doc_authority'] . ($options['required'] ? ' *' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[3]) || $defender->inputHasError($input_name[3]) ? "<div id='" . $input_id . "-doc_authority-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-5'>\n";
    $html .= "<div class='input-group date' " . ($options['width'] ? "style='width:" . $options['width'] . ";'" : '') . ">\n";
    $html .= "<input type='text' name='" . $input_name . "[]' id='" . $input_id . "-doc_date_issue' value='" . $input_value[4] . "' class='form-control textbox' placeholder='" . $locale['doc_date_issue'] . ($options['required'] ? ' *' : '') . "' />\n";
    $html .= "<span class='input-group-addon '><i class='entypo calendar'></i></span>\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[4]) || $defender->inputHasError($input_name[4]) ? "<div id='" . $input_id . "-doc_issue-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n</div>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-5'>\n";
    $html .= "<div class='input-group date' " . ($options['width'] ? "style='width:" . $options['width'] . ";'" : '') . ">\n";
    $html .= "<input type='text' name='" . $input_name . "[]' id='" . $input_id . "-doc_date_expire' value='" . $input_value[5] . "' class='form-control textbox' placeholder='" . $locale['doc_date_expire'] . "' />\n";
    $html .= "<span class='input-group-addon '><i class='entypo calendar'></i></span>\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[5]) || $defender->inputHasError($input_name[5]) ? "<div id='" . $input_id . "-doc_expire-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n</div>\n";
    $html .= "</div>\n";
    // close inner row
    $html .= $options['inline'] ? "</div>\n" : "";
    $html .= "</div>\n";
    $defender->add_field_session(array('input_name' => $input_name, 'type' => 'document', 'label' => $title, 'id' => $input_id, 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text']));
    if ($options['deactivate'] !== 1) {
        add_to_jquery("\n        \$('#{$input_id}-field .input-group.date').datepicker({\n        format: '" . $options['date_format'] . "',\n        todayBtn: 'linked',\n        autoclose: true,\n\t\tweekStart: " . $options['week_start'] . ",\n        todayHighlight: true\n        });\n        ");
    }
    return $html;
}
Example #3
0
$states['United-Kingdom'] = construct_array("Aberdeen,Aberdeenshire,Anglesey,Angus,Antrim,Ards,Argyll and Bute,Armagh,Ballymena,Ballymoney,Bambridge,Barnsley,Bath and North East Somerset,Bedford,Belfast,Birmingham,Blackburn with Darwen,Blackpool,Blaenau Gwent,Bolton,Bourmemouth,Bracknell Forest,Bradford,Bridgend,Brighton and Hove,Bristol,Buckinghamshire,Bury,Caerphilly,Calderdale,Cambridgeshire,Cardiff,Carmarthenshire,Carrickfergus,Castlereah,Central Bedfordshire,Ceredigion,Cheshire East,Cheshire West and Chester,Clackmannanshire,Coleraine,Conwy,Cookstown,COmwall,Conventry,Craigavon,Cumbria,Darlington,Denbighshire,Derby,Derbyshire,Derry,Devon,Doncaster,Dorset,Down,Dudley,Dumfries and Galloway,Dundee,Dungannon,Durham,East Ayrshire,East Dunbartonshire,East Lothian,East Renfrewshire,East Riding of Yorkshire,East Sussex,Edinburgh,Eilean Siar,Essex,Falkirk,Fermanagh,Fife,Flintshire,Gateshead,Glasgow,Gloucestershire,Greater London,Gwynedd,Halton,Hampshire,Hartlepool,Herefordshire,Hertfordshire,Highland,Inverclyde,Isle of Wight,Isles of Scilly,Kent,Kingston upon Hull,Kirklees,Knowsley,Lancashire,Larne,Leeds,Leicester,Leicestershire,Limavady,Lincolnshire,Lisburn,Liverpool,Luton,Magherafelt,Manchester,Medway,Merthyr Tydfil,Middlesbrough,Midlothian,Milton Keynes,Monmouthshire,Moray,Moyle,Neath Port Talbot,Newcastle upon Tyne,Newport,Newry and Mourne,Newtownabbey,Norfolk,Northamptonshire,North Ayrshire,North Down,North East Licolnshire,North Lanarkshire,North Lincolnshire,North Somerset,North Tyneside,Northumberland,North Yorkshire,Nottingham,Nottinghamshire,Oldham,Omagh,Orkney Islands,Oxfordshire,Pembrokeshire,Perthshire and Kinross,Peterborough,Plymouth,Poole,Portsmouth,Powys,Reading,Redcar and Cleveland,Renfrewshire,Rhondda Cynon Taff,Rochdale,Rotherham,Rutland,Saint Helens,Salford,Sandwell,Scottish Borders,Sefton,Sheffield,Shetland Islands,Shropshire,Slough,Solihull,Somerset,Southampton,South Ayrshire,Southend-on-Sea,South Gloucestershire,South Lanarkshire,South Tyneside,Staffordshire,Stirling,Stockport,Stockton-on-Tees,Stoke-on-Trent,Strabane,Suffolk,Sunderland,Surrey,Swansea,Swindon,Tameside,Telford and Wrekin,Thurrock,Torbay,Torfaen,Trafford,Vale of Glamorgan,Wakefield,Walsall,Warrington,Warwickshire,West Berkshire,West Dunbartonshire,West Lothian,West Sussex,Wigan,Wiltshire,Windsor and Maidenhead,Wirral,Wokingham,Wolverchampton,Worcestershire,Wrexham,York");
$states['USA'] = construct_array("Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming");
//$states['United-States-Minor-Outlying-Islands'] = construct_array("Baker Island,Howland Island,Jarvis Island,Johnston Atoll,Kingman Reef,Midway Islands,Navassa Island,Palmyra Atoll,Wake Island");
$states['Uruguay'] = construct_array("Artigas,Canelones,Cerro Largo,Colonia,Durazno,Flores,Florida,Lavalleja,Maldonado,Montevideo,Paysandú,Río Negro,Rivera,Rocha,Salto,San José,Soriano,Tacuarembó,Treinta");
$states['Uzbekistan'] = construct_array("Akmal Ikromov,Amudaryo,Andijon,Andijon - Kuyganyor Angor,Angren,Arnasoy,Asaka,Asaka - Asaka,Bahoriston,Baliqchi,Bandixon,Baxmal,Baxt,Bekobod,Bekobod - Zafar,Bektemir,Beruniy,Beruniy - Beruniy,Beshariq,Bog'dod,Bog'ot,Bo'ka,Bo'stonliq,Boyovut,Boysun,Bo'zatov,Bo'zsuv,Buloqboshi,Bulung'ur,Buvayda,Buxoro,Buxoro - Galaosiyo,Chilonzor,Chimboy,Chinoz,Chirchiq,Chiroqchi,Chortoq,Chortoq - Chortoq,Chust,Dang'ara,Dashtobod,Dehqonobod,Denov,Do'stlik,Ellikqala,Farg'ona,Farg'ona - Vodil,Forish,Furqat,G'allaorol,G'ijduvon,Guliston,Guliston - Dehqonobod,Gurlan,G'uzor,Hamza,Haqqulobod,Hazorasp,Ishtixon,Izboskan,Jalolquduq,Jarqo'rg'on,Jizzax,Jizzax - Uchtepa,Jomboy,Jondor,Kasbi,Kattaqo'rg'on,Kattaqo'rg'on - Payshanba,Kegeyli,Kitob,Kogon,Kogon,Konimex,Koson,Kosonsoy,Marg'ilon,Marhamat,Mehnatobod,Mingbuloq,Mirobod,Mirzacho'l,Mirzaobod,Mirzo Ulug'bek,Mo'ynoq,Muborak,Muzrabot,Namangan,Namangan - Toshbuloq,Narpay,Navbahor,Navoiy,Nishon,Norin,Nukus,Nukus - Oqmang'it,Nurobod,Nurota,Ohangaron,Olmaliq,Olot,Oltiariq,Oltinko'l,Oltinsoy,Oqaryo,Oqoltin,Oqqo'rg'on,Oqtosh,O'rtachirchiq,Oxunboboev,O'zbekiston,Parkent,Pastdarg,Paxtachi,Paxtakor,Paxtaobod,Payariq,Peshku,Piskent,Pitnak,Pop,Qamashi,Qanliko'l,Qarshi,Qarshi - Beshkent,Qibray,Qiziltepa,Qiziriq,Qo'ng'irot,Qo'qon,Qorako'l,Qorao'zak,Qorasuv,Qo'rg'ontepa,Qorovulbozor,Qo'shko'pir,Qo'shrabot,Qumqo'rg'on,Quva,Quvasoy,Quyichirchiq,Rishton,Romitan,Samarqand,Samarqand - Gulobod,Sariosiyo,Sayxunobod,Sergeli,Shahrisabz,Shahrixon,Sharof Rashidov,Shayxontohur,Sherobod,Shirin,Shofirkon,Sho'rchi,Shovot,Shumanay,Sirdaryo,Sobir Rahimov,So'x,Taxiatosh,Taxtako'pir,Termiz,Tomdi,To'raqo'rg'on,To'rtko'l,Toshkent,Toshloq,Toyloq,Uchko'prik,Uchqo'rg'on,Uchquduq,Ulug'nor,Urganch,Urganch - Qorovul,Urgut,Usmon Yusupov,Uychi,Uzun,Vobkent,Xatirchi,Xiva,Xo'jaobod,Xo'jayli,Xonobod,Xonqa,Xovos,Yagiqo'rg'on,Yakkabog',Yakkasaroy,Yangiariq,Yangibozor,Yangiobod,Yangiobod - Balandchaqir,Yangiyer,Yangiyo'lYangiyo'l - Gulbahor,Yozyovon,Yunusobod,Yuqorichirchiq,Zafarobod,Zangiota,Zarafshon,Zarbdor,Zomin");
$states['Vanuatu'] = construct_array("Aneityum,Aniwa,Bangan-Vanua,Canal-Fanafo,Central Malekula,Central Pentecost 1,Central Pentecost 2,Central Torba,East Malo,East Santo,Emau,Erakor,Eratap,Eton,Futuna,Ifira,Luganville,Lungei-Tagaro,Makimae,Malorua,Mele,Middle Bush Tanna,Nguna,North Ambae,North Ambrym,North East Malekula,North Efate,North Erromango,North Pentecost,North Santo,North Tanna,North Tongoa,North West Malekula,North West Santo,Northern Torba,Paama,Pango,Port Vila,South Ambae,South East Ambrym,South East Malekula,South East Santo,South Erromango,South Maewo,South Malekula,South Pentecost,South Santo,South Tanna,South West Malekula,South West Tanna,Southern Torba,Tongariki,Varisu,Vermali - Ringdove,Vermaul,West Ambae,West Ambrym,West Malo,West Santo,West Tanna,Whitesands Tanna,Yarsu,Aneityum,Aniwa,Big Bay,Buninga,Central Malakula,Central Pentecost,Central Tongoa,East Aoba,East Efate,East Epi,East Erromango,East Malakula,East Santo,East Tanna,Emae,Emao,Erakor,Fanafo-Canal,Futuna,Gaua- Merig,Ifira,Luganville,Makira,Mataso,Mele,Mere Lava,Mota,Mota Lava,Nguma-Pele,North Ambrym,North Aoba,North East Malakula,North Efate,North Epi,North Maewo,North Malo,North Paama,North Pentecost,North Tanna,North Tongoa,North West Malakula,North West Santo,Pango,Port Vila,South Aoba,South East Ambrym,South East Malakula,South East Santo,South Efate,South Epi,South Maewo,South Malo,South Paama,South Pentecost,South Santo,South Tanna,South Tongoa,South West Malakula,Tongariki,Torres,Uraparapara,Vanua Lava,West Ambrym,West Aoba,West Epi,West Erromango,West Santo,West Tanna");
$states['Vatican City'] = construct_array("Vatican City");
$states['Venezuela'] = construct_array("Acevedo,Achaguas,Acosta,Acosta,Agua Blanca,Aguasay,Alberto Adriani,Alberto Arvelo Torrealba,Almirante Padilla,Alto Orinoco,Anaco,Andrés Bello - La Azulita,Andrés Bello - San José de Barlovento,Andrés Bello - Cordero,Andrés Bello - Santa Isabel,Andrés Eloy Blanco - El Cantón,Andrés Eloy Blanco - Sanare,Andrés Eloy Blanco - Casanay,Andrés Mata,Antolín del Campo,Antonio Díaz,Antonio José de Sucre,Antonio Pinto Salinas,Antonio Rómulo Costa,Anzoátegui,Aragua,Araure,Aricagua,Arismendi - Arismendi,Arismendi - La Asunción,Arismendi - Río Caribe,Arístides Bastidas - San Pablo,Arzobispo Chacón,Atabapo,Atures,Autana,Ayacucho,Baralt,Barinas,Baruta,Bejuma,Benítez,Bermúdez,Biruaca,Boconó,Bolívar - San Mateo,Bolívar - Barinitas,Bolívar - San Luís,Bolívar - Caripito,Bolívar - Mariguitar Bolívar - San Antonio del Táchira,Bolívar - Sabana Grande,Bolívar - Aroa,Brión,Bruzual,Buchivacoa,Buroz,Cabimas,Cacique Manaure,Cajigal,Camaguán,Camatagua,Campo Elías,Candelaria,Caracciolo Parra Olmedo,Carache,\nCardenal Quintero,Cárdenas,Caripe,Carirubana,Carlos Arvelo,Caroní,Carrizal,Casacoima,Catatumbo,Cedeño - Caicara del Orinoco,Cedeño - Caicara,Chacao,Chaguaramas,Cocorote,Colina,Colón,Córdoba,Crespo,Cristóbal Rojas,Cruz Paredes,Cruz Salmerón Acosta,Dabajuro,Democracia,Dependencias Federales,Díaz,Diego Bautista Urbaneja,Diego Ibarra,El Callao,El Hatillo,El Socorro,Escuque,Esteller,Ezequiel Zamora - Santa Bárbara,Ezequiel Zamora - Punta de Mata,Falcón - Tinaquillo,Falcón - Pueblo Nuevo,Federación,Fernández Feo,Fernando de Peñalver,Francisco del Carmen Carvajal,Francisco de Miranda - Pariaguán,Francisco de Miranda - Calabozo,Francisco de Miranda - San José de Bolívar,Francisco Javier Pulgar,Francisco Linares Alcántara,García,García de Hevia,Girardot - Maracay,Girardot - El Baúl,Gómez,Gran Sabana,Guacara,Guaicaipuro,Guanare,Guanarito,Guanta,Guaraque,Guasimos,Heres,Independencia - Soledad,Independencia - Santa Teresa del Tuy,Independencia - Capacho Nuevo,Independencia - Independencia,Iribarren,Jacura,Jauregui,\nJesús Enrique Lossada,Jesús María Semprún,Jiménez,José Angel Lamas,José Antonio Páez,José Felipe Márquez Cañizales,José Félix Ribas - La Victoria,José Félix Ribas - Tucupido,José Gregorio Monagas,José María Vargas,José Rafael Revenga,José Tadeo Monagas,Juan Antonio Sotillo,Juan Germán Roscio,Juan José Mora,Juan Manuel Cajigal,Juan Vicente Campo Elías,Julián Mellado,Julio César Salas,Junín,Justo Briceño,La Cañada de Urdaneta,La Ceiba,Lagunillas,Lander,Las Mercedes,La Trinidad,Leonardo Infante,Libertad - San Mateo,Libertad - Capacho Viejo,Libertador - Palo Negro,Libertador - Tocuyito,Libertador - Caracas,Libertador - Mérida,Libertador - Temblador,Libertador - Tunapuy,Libertador - Abejales,Lima Blanco - Macapo,Lobatera,Los Guayos,Los Salias,Los Taques,Machiques de Perijá,Manapiare,Maneiro,Manuel Ezequiel Bruzual,Manuel Monge,Mara,Maracaibo,Marcano,Mariño - Porlamar,Mariño - Irapa,Mario Briceño Iragorry,Maroa,Maturín,Mauroa,Mejía,Michelena,Miranda - Miranda,Miranda - Santa Ana de Coro,Miranda - Timotes,\nMiranda -  Dividive,Miranda - Los Puertos de Altagracia,Monseñor Iturriza,Monseñor José Vicente de Unda,Montalbán,Monte Carmelo,Montes,Morán,Motatán,Muñoz,Naguanagua,Nirgua,Obispo Ramos de Lora,Obispos,Ocumare de la Costa de Oro,Ortíz,Ospino,Padre Noguera,Padre Pedro Chien,Páez - Guasdualito,Páez - Río Chico,Páez - Acarigua,Páez - Sinamaica, Palavecino,Palmasola,Pampán,Pampanito,Panamericano,Pao de San Juan Bautista,Papelón,Paz Castillo,Pedernales,Pedraza,Pedro Camejo,Pedro Gual,Pedro María Freites,Pedro María Ureña,Pedro Zaraza,Peña,Península de Macanao,Petit,Piar - Upata,Piar - Aragua,Píritu - Píritu,Plaza,Pueblo Llano,Puerto Cabello,Punceres,Rafael Rangel,Rafael Urdaneta,Rangel,Raúl Leoni,Ribero,Ricaurte,Río Negro,Rivas Dávila,Rojas,Rómulo Gallegos - Elorza,Rómulo Gallegos - Las Vegas,Rosario de Perijá,Roscio,Samuel Darío Maldonado,San Carlos,San Casimiro,San Cristóbal,San Diego,San Felipe,San Fernando,San Francisco - Mirimire,San Francisco,San Genaro de Boconoito,San Gerónimo de Guayabal,San Joaquín,\nSan José de Guanipa - San José de Guanipa,San José de Guaribe - San José de Guaribe,San Juan de Capistrano - Boca de Uchire,San Judas Tadeo,San Rafael de Carvajal,San Rafael de Onoto,San Sebastián,Santa Ana,Santa Bárbara,Santa María de Ipire,Santa Rita,Santa Rosalía,Santiago Mariño,Santos Marquina,Santos Michelena,Seboruco,Sifontes,Silva,Simón Bolívar - Barcelona,Simón Bolívar - San Francisco de Yare,Simón Bolívar - Tía Juana,Simón Planas,Simón Rodríguez - El Tigre,Simón Rodríguez - San Simón,Sir Artur McGregor,Sosa,Sotillo,Sucre - Cagua,Sucre - Maripa,Sucre - La Cruz de Taratara,Sucre - Lagunillas,Sucre - Petare,Sucre - Biscucuy,Sucre - Cumaná,Sucre - Queniquea,Sucre - Sabana de Mendoza,Sucre - Guama,Sucre - Bobures,Tinaco,Tocopero,Torbes,Torres,Tovar - Colonia Tovar,Tovar, Trujillo,Tubores,Tucupita,Tulio Febres Cordero,Turén,Unión,Urachiche,Uracoa,Urdaneta - Barbacoas,Urdaneta - Siquisique,Urdaneta - Cúa,Urdaneta - La Quebrada,Uribante,Urumaco,Valdez,Valencia,Valera,Valmore Rodríguez,Vargas,Veroes,Villalba,\nZamora - Villa de Cura,Zamora - Puerto Cumarebo,Zamora - Guatire,Zea");
$states['Vietnam'] = construct_array("A Luoi,An Bien,An Duong,Anh Son,An Khe,An Trung - An Lao,An Lao,An Minh,An Nhon,An Phu,An Thi,Ayun Pa,Ba Be,Bac Ai,Bac Binh,Bac Giang,Bac Ha,Ba Che,Bach Long,Bach Thong,Bac Kan,Bac Lieu,Bac Me,Bac Ninh,Bac Quang,Bac Son,Bac Tra My,Bac Yen,Ba Dinh,Bao Lac,Bao Lam,Loc Thang,Bao Loc,Bao Thang,Bao Yen,Ba Ria,Ba Thuoc,Ba To,Ba Tri,Bat Xat,Ba Vi,Ben Cat,Ben Cau,Ben Luc,Ben Tre,Bien Hoa,Bim Son,inh Chanh,Binh Dai,Binh Gia,inh Giang,Binh Lieu,Binh Long,Binh Luc,Binh Minh,Binh Son,Binh Tan,Binh Thanh,Binh Thuy,Binh Xuyen,Bo Trach,Bu Dang,Bu Dop,Buon Don,Buon Ma Thuot,Cai Be,Cai Lay,Cai Nuoc,Cai Rang,Ca Mau,Cam Giang,Cam Khe,Cam Le,Cam Lo,Cam My,Cam Pha,Cam Ranh,Cam Thuy,Cam Xuyen,Can Duoc,Can Gio,Can Giuoc,Cang Long,Can Loc,Cao Bang,Cao Lanh,Cao Lanh,Cao Loc,Cao Phong,Cat Hai,Cat Tien,Cau Giay,Cau Ke,Cau Ngang,Chau Doc,Chau Duc,Chau Phu,Chau Thanh - An Chau,Chau Thanh - Chau Thanh,Chau Thanh - Cai Tau Ha, Chau Thanh - Nga Sau,Chau Thanh - Minh Luong,Chau Thanh - Tam Vu,Chau Thanh - Tan Hiep,Chau Thanh - Chau Thanh,\nChau Thanh A - Mot Ngan,Chiem Hoa - Vinh Loc,Chi Lang - Dong Mo,Chi Linh - Sao Do,Cho Don,Cho Gao,Cho Lach,Cho Moi,Chon Thanh,Chuong My,Chu Pah,Chu Prong,Chu Se,Co Do,Con Co,Con Cuong,Con Dao,Co To,Cua Lo,Cu Chi,Cu Jut,Cu Lao Dung,Cu M'Gar,Da Huoai,Dai Loc,Dai Tu,Dak Doa,Dak Glei,Dak Ha,Dak Mil,Dak Nong,Dak Po,Dak Rlap,Dakrong,Dak Song,Dak To,Da Lat,Dam Doi,Dam Ha,Dam Rong,Dan Phuong,Da Rac,Dat Do,Da Teh,Dau Tieng,Di An,Dien Ban,Dien Bien - Muong Thanh,Dien Bien Dong,Dien Bien Phu,Dien Chau,Dien Khanh,Di Linh,Dinh Hoa,Dinh Lap,Dinh Quan,Doan Hung,Do Luong,Don Duong,Dong Anh,Dong Da,Dong Giang,Dong Ha,Dong Hai - Ganh Hao,Dong Hoi - Dong Hoi,Dong Hung,Dong Hy,Dong Phu,Dong Son,Dong Trieu,Dong Van,Dong Xoai,Dong Xuan,Do Son,Duc Co,Duc Hoa,Duc Hue,Duc Linh,Duc Pho,Duc Tho,Duc Trong,Duong Minh Chau,Duyen Hai,Duy Tien,Duy Xuyen,Ea H'Leo,Ea Kar,Ea Sup,Gia Binh,Gia Lam,Gia Loc,Giao Thuy,Gia Rai,Gia Vien,Gio Linh,Giong Rieng,Giong Trom,Go Cong - Go Cong,Go Cong Dong - Tan Hoa,Go Cong Tay - Vinh Binh,Go Dau,Go Quao,\nGo Vap,Ha Dong,Ha Giang,Ha Hoa,Hai An,Hai Ba Trung,Hai Chau,Hai Duong,Hai Ha,Hai Hau,Hai Lang,Ha Lang,Ha Long,Ham Tan,Ham Thuan Bac,Ham Thuan Nam,Ham Yen,Ha Quang,Ha Tien,Ha Tinh,Ha Trung,Hau Loc,Hiep Duc,Hiep Hoa,Hoa An,Goa Binh,Hoai An,Hoai Duc,Hoai Nhon,Hoa Lu,Hoang Hoa,Hoang Mai,Hoang Sa,Hoang Su Phi,Hoanh Bo,Hoan Kiem,Hoa Thanh,Hoa Vang,Hoc Mon,Hoi An,Hon Dat,Hong Bang,Hong Dan,Hong Linh,Hong Ngu,Hue,Hung,Hung Nguyen,Hung Yen,Huong Hoa,Huong Khe,Huong Son,Huong Thuy,Huong Tra,Huu Lung,Ia Grai,Ia Pa,Kbang,Ke Sach,Khanh Son,Khanh Vinh,Khoai Chau,Kien An,Kien Hai,Kien Luong,Kien Thuy,Kien Xuong,Kim Bang,Kim Boi,Kim Dong,Kim Son,Kim Thanh,Kinh Mon,Kong Chro,Kon Plong,Kon Ray,Kon Tum,Krong Ana,Krong Bong,Krong Buk,Krong Nang,Krong No,Krong Pa,Krong Pak,Ky Anh,Ky Son - Ky Son,Ky Son - Muong Xen,Lac Duong,Lac Son,Lac Thuy,Lai Chau,Lai Vung,Lak,Lam Ha,Lam Thao,Lang Chanh,Lang Giang,Lang Son,Lao Cai,Lap Thach,Lap Vo,Le Chan,Le Thuy,Lien Chieu,Loc Binh,Loc Ninh,Long Bien,Long Dien,Long Ho,Long Khanh,\nLong My - Long My,Long My - Soc Trang,Long Phu,Long Thanh,Long Xuyen,Luc Nam,Luc Ngan,Luc Yen,Luong Son,Luong Tai,Ly Nhan,Ly Son,Mai Chau,Mai Son,Mang Thit,Mang Yang,M'Drak,Me Linh,Meo Vac,Minh Hoa,Minh Long,Mo Cay,Moc Chau,Moc Hoa,Mo Duc,Mong Cai,Mu Cang Trai,Muong Cha,Muong Khuong,Muong La,Muong Lat,Muong Lay,Muong Nhe,Muong Te,My Duc,My Hao,My Loc,My Tho,My Tu,My Xuyen,Na Hang,Nam Can,Nam Dan,Nam Dinh,Nam Dong,Nam Giang,Nam Sach,Nam Tra My,Nam Truc,Na Ri,Nga Nam,Ngan Son,Nga Son,Nghia Dan,Nghia Hanh,Nghia Hung,Nghia Lo,Nghi Loc,Nghi Xuan,Ngoc Hien,Ngoc Hoi,Ngoc Lac,Ngo Quyen,Ngu Hanh Son,Nguyen Binh,Nha Be,Nha Trang,Nhon Trach,Nho Quan,Nhu Thanh,Nhu Xuan,Ninh Binh,Ninh Giang,Ninh Hai,Ninh Hoa,Ninh Kieu,Ninh Phuoc,Ninh Son,Nong Cong,Nui Thanh,O Mon,Pac Nam,Phan Rang-Thap Cham,Phan Thiet,Phong Dien - My Khanh,Phong Dien - Phong Dien,Phong Tho,Pho Yen,Phu Binh,Phu Cat,Phuc Hoa,Phuc Tho,Phu Cu,Phuc Yen,Phu Giao,Phu Hoa,Phu Loc,Phu Luong,Phu Ly,Phu My,Phung Hiep,Phu Nhuan,Phu Ninh - Phong Chau,\nPhu Ninh - Tam Da,Phuoc Long - Phuoc Long,Phuoc Long - Thac Mo,Phuoc Son,Phu Quoc,Phu Quy,Phu Tan - Cho Vam,Phu Tan - Cai Doi Vam,Phu Tho,Phu Vang,Phu Xuyen,Phu Yen,Pleiku,Quan 1,Quan 2,Quan 3,Quan 4,Quan 5,Quan 6,Quan 7,Quan 8,Quan 9,Quan 10,Quan 11,Quan 12,Quan Ba,Quang Binh,Quang Dien,Quang Ngai,Quang Ninh,Quang Trach,Quang Tri,Quang Xuong,Quang Yen,Quan Hoa,Quan Son,Que Phong,Que Son,Que Vo,Quoc Oai,Quy Chau,Quy Hop,Quynh Luu,Quynh Nhai,Quy Nhon,Quynh Phu,Rach Gia,Sa Dec,Sam Son,Sa Pa,Sa Thay,Si Ma Cai,Sin Ho,Soc Son,Son Dong,Son Duong,Song Cau,Song Cong,Song Hinh,Song Ma - Song Ma,Son Ha - Di Lang,Son Hoa,Son La,Son Tay - Son Dung,Son Tay - Son Tay,Son Tinh,Son Tra,Sop Cop,Tam Binh,Tam Dao,Tam Diep,Tam Duong - Tam Duong,Tam Duong - Hop Hoa,Tam Ki,Tam Nong - Tram Chim,Tam Nong - Hung Hoa,Tan An,Tan Bien,Tan Binh,Tan Chau - Tan Chau,Tan Hiep,Tanh Linh,Tan Hong - Sa Rai,Tan Hung - Tan Hung,Tan Ky,Tan Lac,Tan Phu - Tan Phu,Tan Phu - Ho Chi Minh City,Tan Phuoc,Tan Thanh - Phu My,Tan Thanh - Tan Thanh,Tan Tru,Tan Uyen,Tan Yen,Tay Giang,Tay Ho,Tay Ninh,Tay Son,Tay Tra,Thach An,Thach Ha,Thach Thanh,Thach That,Thai Binh,Thai Nguyen,Thai Thuy,Thang Binh,Thanh Ba,Thanh Binh,Thanh Chuong,Thanh Ha,Thanh Hoa,Thanh Khe,Thanh Liem,Thanh Mien,Thanh Oai,Thanh Phu,Thanh Son,Thanh Thuy,Thanh Tri - Van Dien,Thanh Tri - Phu Loc,Thanh Xuan,Than Uyen,Thap Muoi,Thieu Hoa,Thoai Son,Thoi Binh,Thong Nhat,Thong Nong,Thot Not,Tho Xuan,Thuan An,Thuan Chau,Thuan Thanh,Thu Dau Mot,Thu Duc,Thuong Tin,Thuong Xua,Thu Thua,Thuy Nguyen,Tien Du,Tien Hai,Tien Lang,Tien Lu,Tien Phuoc,Tien Yen,Tieu Can,Tinh Bien,Tinh Gia,Tra Bong,Tra Cu,Tra Linh,Tram Tau,Trang Bang,Trang Bom,Trang Dinh,Tran Van Thoi,Tran Yen,Tra On,Tra Vinh,Trieu Phong,Trieu Son,Tri Ton,Truc Ninh,Trung Khanh,Truong Sa,Tua Chua,Tuan Giao,Tu Ky,Tu Liem,Tu Nghia,Tuong Duong,Tu Son,Tuy An,Tuyen Hoa,Tuyen Quang,Tuy Hoa,Tuy Hoa,Tuy Phong,Tuy Phuoc,U Minh,Ung Hoa,Uong Bi,Van Ban,Van Canh,Van Chan,Van Don,Van Giang,Van Lam,Van Lang,Van Ninh,Van Quan,Van Yen,Viet Tri,Viet Yen,Vinh,Vinh Bao,\nVinh Chau,Vinh Cuu,Vinh Hung,Vinh Linh,Vinh Loc,Vinh Loi,Vinh Long,Vinh Thanh - Vinh Hao,Vinh Thanh - Thanh An,Vinh Thuan,Vinh Tuong,Vinh Yen,Vi Thanh,Vi Thuy,Vi Xuyen,Vo Nhai,Vu Ban,Vung Liem,Vung Tau,Vu Quang,Vu Thu,Xin Man,Xuan Loc,Xuan Truon,Xuyen Moc,Yen Bai,Yen Chau,Yen Dinh,Yen Dung,Yen Hung,Yen Khanh,Yen Lac,Yen Lap,Yen Minh,Yen Mo,Yen My,Yen Phong,Yen Son,Yen Than,Yen The,Yen Thuy,Y Yen");
$states['Virgin-Islands'] = construct_array("Anna's Hope Village,Central,Charlotte Amalie,Christiansted,Coral Bay,Cruz Bay,East End,Frederiksted,Northcentral,Northside,Northwest,Sion Farm,Southcentral,Southside,Southwest,Tutu,Water Island,West End,Virgin-Islands-(British)");
$states['Wallis-and-Futuna'] = construct_array("Alo,Hahake,Hihifo,Mua,Singave");
//$states['Western-Sahara'] = construct_array("Western-Sahara");
//Short Yemen version $states['Yemen'] = construct_array("Sanaa,Taizz,Al Hudaydah,Aden,Ibb,Dhamar,al-Mukalla,Zinjibar,Sayyan,Ash Shihr,Sahar,Zabid,Hajjah,Badschil,Dhi as-Sufal,Rida,Socotra,Bait al-Faqih,al-Marawi'a,Al Bayda',Lahij,Marib,Mocha");
$states['Yemen'] = construct_array("Abs,Ad Dahi,Ad Dhale'e,Ad Dis,Ad Durayhimi,Adh Dhlia'ah,Aflah Al Yaman,Aflah Ash Shawm,Ahwar,Ain,Al Abdiyah,Al Abr,Al A'rsh,Al Ashah,Al Azariq,Al Bayda,Al Bayda City,Al Buraiqeh,Al Dhaher,Al Dhihar,Al Garrahi,Al Ghaydah,Al Ghayl,Al Had,Al Hada,Al Hajjaylah,Al Hali,Al Hashwah,Al Hawak,Al Hawtah,Al Haymah Ad Dakhiliyah,Al Haymah Al Kharijiyah,Al Hazm,Al Humaydat,Al Husha,Al Husn,Al Hussein,Al Jabin,Al Jafariyah,Al Jamimah,Al Jubah,Al Khabt,Al Khalq,Al Khawkhah,Alluheyah,Al Ma'afer,Al Madan,Al Madaribah Wa Al Arah,Al Maflahy,Al Maghrabah,Al Mahabishah,Al Mahfad,Al Mahwait,Al Mahwait City,Al Makhadir,Al Malagim,Al Manar,Al Mansura,Al Mansuriyah,Al Maqatirah,Al Marawi'ah,Al Mashannah,Al Masilah,Al Maslub,Al Matammah,Al Maton,Al Mawasit,Al Miftah,Al Mighlaf,Al Milah,Al Mina,Al Misrakh,Al Mualla,Al Mudhaffar,Al Mukalla,Al Mukalla City,Al Mukha,Al Munirah,Al Musaymir,Al Qabbaytah,Al Qaf,Al Qaflah,Al Qafr,Al Qahirah,Al Qanawis,Al Qatn,Al Quraishyah,Al Talh,Al Udayn,Al Wade'a,Al Wahd,Al Wazi'iyah,Amd,Amran,An Nadirah,Anss,Arhab,Arma,Ar Radmah,Ar Rawdah,Ar Raydah Wa Qusayar,Ar Rujum,Ar Ryashyyah,Ash Shaghadirah,Ash Shahil,Ash Shaikh Outhman,Ash Sha'ir,Ash Shamayatayn,Ash Sharyah,Ash Shihr,Ash Shu'ayb,Aslem,As Sabain,As Sabrah,As Saddah,Assafi'yah,As Safra,As Said,As Salafiyah,As Salif,As Sawadiyah,As Sawd,As Sawm,As Sawma'ah,As Sayyani,As Silw,As Sudah,As Sukhnah,Ataq,Ath'thaorah,At Taffah,At Tahrir,At Ta'iziyah,Attawahi,At Tawilah,At Tuhayat,Attyal,Az Zahir,Az'zal,Az Zaydiyah,Az Zuhrah,Ba'dan,Bajil,Bakil Al Mir,Bani Al Awam,Bani Al Harith,Bani Dhabyan,Bani Hushaysh,Bani Matar,Bani Qa'is,Bani Sa'd,Bani Suraim,Baqim,Bart Al Anan,Bayhan,Bayt Al Faqiah,Bidbadah,Bilad Ar Rus,Bilad At Ta'am,Brom Mayfa,Bura,Craiter,Damt,Dar Sad,Daw'an,Dawran Aness,Dhamar City,Dhar,Dhi As Sufal,Dhi Bin,Dhi Na'im,Dhubab,Dimnat Khadir,Far Al Udayn,Ghamr,Ghayl Ba Wazir,Ghayl Bin Yamin,Habban,Habil Jabr,Habur Zulaymah,Hagr As Sai'ar,Hajjah,Hajjah City,Hajr,Halimayn,Hamdan,Harad,Harf Sufyan,Harib,Harib Al Qaramish,\nHaHatib,Hawf,Haydan,Hayfan,Hayran,Hays,Hazm Al Udayn,Hidaybu,Hubaysh,Hufash,Huraidhah,Huswain,Huth,Ibb,Iyal Surayh,Jabal Ash Sharq,Jabal Habashy,Jabal Iyal Yazid,Jabal Murad,Jabal Ra's,Jahaf,Jahran,Jardan,Jayshan,Jiblah,Jihanah,Juban,Kamaran,Khabb wa ash Sha'af,Khamir,Khanfir,Kharab Al Marashi,Kharif,Khayran Al Muharraq,Khur Maksar,Khwlan,Kitaf wa Al Boqe'e,Ku'aydinah,Kuhlan Affar,Kuhlan Ash Sharaf,Kushar,Kusmah,Lawdar,Ma'ain,Mabyan,Maghirib Ans,Mahliyah,Majz,Majzar,Manakhah,Man'ar,Maqbanah,Marib,Marib City,Mashra'a Wa Hadnan,Maswar,Maswarah,Mawiyah,Mawza,Mayfa'a,Mayfa'at Anss,Mazhar,Medghal,Merkhah Al Ulya,Merkhah As Sufla,Midi,Milhan,Monabbih,Mudhaykhirah,Mudiyah,Mukayras,Mustaba,Najrah,Na'man,Nati',Nihm,Nisab,Old City,Qa'atabah,Qafl Shamer,Qarah,Qatabir,Qishn,Qulensya Wa Abd Al Kuri,Rada',Radfan,Radman Al Awad,Raghwan,Rahabah,Rajuzah,Rakhyah,Rasad,Raydah,Razih,Rudum,Rumah,Sa'adah,Sabah,Sabir Al Mawadim,Sa'fan,Sah,Sahar,Salh,Sama,Sanhan,Saqayn,Sarar,Sayhut,Sayun,Shada'a,Shahan,Shaharah,Shara'b Ar Rawnah,\nShab As Salam,Sharas,Shibam,Shibam Kawkaban,Shu'aub,Sibah,Sirwah,Suwayr,Tarim,Thamud,Thula,Tuban,Tur Al Bahah,Usaylan,Utmah,Wadhrah,Wadi Al Ayn,Wald Rabi',Washhah,Wusab Al Ali,Wusab As Safil,Yabuth,Yafa'a,Yahr,Yarim,Zabid,Zamakh wa Manwakh,Zingibar");
$states['Zambia'] = construct_array("Chadiza,Chama,Chavuma,Chibombo,Chiengi,Chililabombwe,Chilubi,Chingola,Chinsali,Chipata,Choma,Chongwe,Gwembe,Isoka,Itezhi Tezhi,Kabompo,Kabwe,Kafue,Kalabo,Kalomo,Kalulushi,Kaoma,Kapiri Mposhi,Kaputa,Kasama,Kasempa,Katete,Kawambwa,Kazungula,Kitwe,Livingstone,Luangwa,Luanshya,Lufwanyama,Lukulu,Lundazi,Lusaka,Luwingu,Mambwe,Mansa,Masaiti,Mazabuka,Mbala,Milenge,Mkushi,Mongu,Monze,Mpika,Mpongwe,Mporokoso,Mpulungu,Mufulira,Mufumbwe,Mumbwa,Mungwi,Mwense,Mwinilunga,Nakonde,Namwala,Nchelenge,Ndola,Nyimba,Petauke,Samfya,Senanga,Serenje,Sesheke,Shangombo,Siavonga,Sinazongwe,Solwezi,Zambezi");
$states['Zimbabwe'] = construct_array("Beitbridge,Bikita,Bindura,Binga,Bubi,Buhera,Bulawayo,Bulilima,Centenary,Chegutu,Chikomba,Chimanimani,Chipinge,Chiredzi,Chirumhanzu,Chitungwiza,Chivi,Epworth,Gokwe North,Gokwe South,Goromonzi,Guruve,Gutu,Gwanda,Gweru,Harare Rural,Harare Urban,Hurungwe,Hwange,Insiza,Kadoma,Kariba,Kwekwe,Lupane,Makonde,Makoni,Mangwe (South),Marondera,Masvingo,Matobo,Mazowe,Mberengwa,Mount Darwin,Mudzi,Murehwa,Mutare,Mutasa,Mutoko,Mwenezi,Nkayi,Nyanga,Rushinga,Seke,Shamva,Shurugwi,Tsholotsho,Umguza,UMP,Umzingwane,Wedza,Zaka,Zvimba,Zvishavane");
ksort($states);
/* Data Population Count
// print_p($countries);
$new_states = array();
$my_status = array_merge($new_states, $states);
//print_p($my_status);
$i = 0;
foreach($my_status AS $arr=>$v) {
    $y = count($v);
    //print_p($y);
    $i= $i+$y;
}
print_p($i);
*/
// Total Countries Covered: 250 Countries ( With the Geo Class )
Example #4
0
function form_select($title, $input_name, $input_id, $option_array, $input_value = FALSE, $array = FALSE)
{
    if (!defined("SELECT2")) {
        define("SELECT2", TRUE);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js'></script>");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />");
    }
    $input_value = $input_value ? $input_value : '0';
    $title2 = isset($title) && !empty($title) ? stripinput($title) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    if (!is_array($array)) {
        $placeholder = '';
        $deactivate = "";
        $multiple = 0;
        $multiple_attr = "";
        $width = '';
        $keyflip = 0;
        $chainable = "";
        $allowclear = '';
        $jsonmode = 0;
        $required = 0;
        $safemode = 0;
        $tags = 0;
        $maximum_selection = 30;
        $class = '';
        $inline = '';
        $error_text = '';
    } else {
        $chainable = array_key_exists('chainable', $array) ? $array['chainable'] : "";
        $multiple = array_key_exists('multiple', $array) && $array['multiple'] == 1 ? 1 : 0;
        $multiple_attr = $multiple == 1 ? "multiple" : "";
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : '';
        $deactivate = array_key_exists("deactivate", $array) && $array['deactivate'] == "1" ? 1 : 0;
        $width = array_key_exists("width", $array) && $array['width'] ? $array['width'] : '';
        $keyflip = array_key_exists('keyflip', $array) ? $array['keyflip'] : 0;
        $allowclear = array_key_exists('allowclear', $array) && $array['allowclear'] ? 'allowClear:true' : "";
        $jsonmode = array_key_exists('jsonmode', $array) && $array['jsonmode'] == "1" ? 1 : 0;
        $required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
        $tags = array_key_exists("tags", $array) && $array['tags'] == 1 ? 1 : 0;
        if ($multiple) {
            $maximum_selection = array_key_exists('maxselect', $array) && isnum($array['maxselect']) ? $array['maxselect'] : 30;
        }
        $error_text = array_key_exists("error_text", $array) ? $array['error_text'] : "";
        $class = array_key_exists("class", $array) ? $array['class'] : '';
        $inline = array_key_exists("inline", $array) ? 1 : 0;
    }
    if ($multiple == 1) {
        if ($input_value) {
            $input_value = construct_array($input_value);
        } else {
            $input_value = array();
        }
    }
    $html = "";
    $html .= "<div id='{$input_id}-field' class='form-group m-b-0 " . $class . "'>\n";
    $html .= $title ? "<label class='control-label " . ($inline ? "col-xs-12 col-sm-3 col-md-3 col-lg-3" : 'col-xs-12 col-sm-12 col-md-12 col-lg-12 p-l-0') . "' for='{$input_id}'>{$title} " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</label>\n" : '';
    $html .= $inline ? "<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9'>\n" : "";
    if ($jsonmode == 1) {
        // json mode.
        $html .= "<div id='{$input_id}-spinner' style='display:none;'>\n<img src='" . IMAGES . "loader.gif'>\n</div>\n";
        $html .= "<input " . ($required ? "class='req'" : '') . " type='hidden' name='{$input_name}' id='{$input_id}' " . ($width ? "style='width: {$width}'" : "style='min-width: 250px'") . ">\n";
    } else {
        // normal mode
        $html .= "<select name='{$input_name}' id='{$input_id}' " . ($width ? "style='width: {$width}'" : "style='min-width: 250px'") . " " . ($deactivate == "1" && isnum($deactivate) ? "disabled" : "") . " {$multiple_attr} >";
        //
        $html .= $allowclear ? "<option value=''></option>" : "";
        if (is_array($option_array)) {
            foreach ($option_array as $arr => $v) {
                // outputs: key, value, class - in order
                if (isnum($keyflip) && $keyflip == "1") {
                    // flip mode = store array values
                    $chain = $chainable == "1" ? "class='{$v}'" : "";
                    $select = '';
                    if ($input_value !== NULL) {
                        $select = $input_value == $v ? "selected" : "";
                    }
                    $html .= "<option value='{$v}' {$chain} {$select}>{$v}</option>";
                } else {
                    // normal mode = store array keys
                    $chain = $chainable == "1" ? "class='{$arr}'" : "";
                    $select = '';
                    if ($input_value || $input_value == '0') {
                        $input_value = stripinput($input_value);
                        // make selected based on $input_value.
                        $select = isset($input_value) && $input_value == $arr ? "selected" : "";
                    }
                    $html .= "<option value='{$arr}' " . $chain . " " . $select . ">{$v}</option>";
                }
                unset($arr);
            }
            // end foreach
        }
        $html .= "</select>";
    }
    $html .= "<div id='{$input_id}-help' class='display-inline-block'></div>";
    $html .= $inline ? "</div>\n" : "";
    $html .= "</div>\n";
    if ($required) {
        $html .= "<input class='req' id='dummy-{$input_id}' type='hidden'>\n";
        // for jscheck
    }
    // Generate Defender Tag
    $input_name = $multiple ? str_replace("[]", "", $input_name) : $input_name;
    $html .= "<input type='hidden' name='def[{$input_name}]' value='[type=dropdown],[title={$title2}],[id={$input_id}],[required={$required}],[safemode={$safemode}]" . ($error_text ? ",[error_text={$error_text}]" : '') . "' readonly />";
    // Initialize Select2
    // Select 2 Multiple requires hidden DOM.
    if ($jsonmode == 0) {
        // not json mode (normal)
        $max_js = '';
        if ($multiple) {
            $max_js = "maximumSelectionSize : {$maximum_selection},";
        }
        if ($required) {
            add_to_jquery("\n                    var init_value = \$('#" . $input_id . "').select2('val');\n                    if (init_value) {\n                    \$('dummy-" . $input_id . "').val(init_value);\n                    } else {\n                    \$('dummy-" . $input_id . "').val('');\n                    }\n                    \$('#" . $input_id . "').select2({\n                        placeholder: '" . $placeholder . "',\n                        " . $max_js . "\n                        " . $allowclear . "\n                    }).bind('change', function(e) {\n                    \$('#dummy-" . $input_id . "').val(\$(this).val());\n                    });\n                    ");
        } else {
            add_to_jquery("\n                    \$('#" . $input_id . "').select2({\n                        placeholder: '" . $placeholder . "',\n                        " . $max_js . "\n                        " . $allowclear . "\n                    });\n                    ");
        }
    } else {
        // json mode
        add_to_jquery("\n                var this_data = [{id:0, text: '{$placeholder}'}];\n                \$('#" . $input_id . "').select2({\n                placeholder: '" . $placeholder . "',\n                data: this_data\n                });\n            ");
    }
    // For Multiple Callback.
    if (is_array($input_value) && $multiple == 1) {
        // stores as value;
        $vals = '';
        foreach ($input_value as $arr => $val) {
            $vals .= $arr == count($input_value) - 1 ? "'{$val}'" : "'{$val}',";
        }
        add_to_jquery("\n            \$('#" . $input_id . "').select2('val', [{$vals}]);\n            ");
        // For Tags */
        /* foreach ($input_value as $id => $text) {
               $select_array[] = $keyflip ? array('id' => "$text", 'text' => "$text") : array('id' => "$id", 'text' => "$text");
           }
           if (!isset($select_array)) {
               $select_array = array();
           }
           $encoded = json_encode($select_array);
           add_to_jquery("$('#".$input_id."').select2('data', $encoded);"); */
    }
    // alert('Selected value is '+$('#".$input_id."').select2('val'));
    return $html;
}
Example #5
0
function form_name($title = false, $input_name, $input_id, $input_value = false, $array = false)
{
    if (isset($title) && $title !== "") {
        $title = stripinput($title);
    } else {
        $title = "";
    }
    if (isset($input_name) && $input_name !== "") {
        $input_name = stripinput($input_name);
    } else {
        $input_name = "";
    }
    if (isset($input_id) && $input_id !== "") {
        $input_id = stripinput($input_id);
    } else {
        $input_id = "";
    }
    $html = '';
    if (!is_array($array)) {
        $array = array();
        $state_validation = "";
        $before = "";
        $after = "";
        $required = "";
        $placeholder = "";
        $deactivate = "";
        $width = "";
        $class = "input-sm";
        $well = '';
        $inline = '';
        $error_text = '';
    } else {
        $before = array_key_exists('before', $array) ? $array['before'] : "";
        $after = array_key_exists('after', $array) ? $array['after'] : "";
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : "";
        $deactivate = array_key_exists('deactivate', $array) ? $array['deactivate'] : "";
        $class = array_key_exists('class', $array) ? $array['class'] : "input-sm";
        $required = array_key_exists('required', $array) ? $array['required'] : "";
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? '1' : '0';
        $width = array_key_exists('width', $array) ? "style='width: " . $array['width'] . "'" : "";
        $well = array_key_exists('well', $array) ? "style='margin-top:-10px;'" : "";
        $type = array_key_exists('password', $array) && $array['password'] == "1" ? "password" : "text";
        $error_text = array_key_exists("error_text", $array) ? $array['error_text'] : "";
        $inline = array_key_exists("rowstart", $array) ? 1 : 0;
    }
    // readback value
    if (isset($input_value) && !empty($input_value)) {
        if (!is_array($input_value)) {
            $input_value = construct_array($input_value, '', '|');
        }
    } else {
        $input_value['0'] = "";
        $input_value['1'] = "";
        $input_value['2'] = "";
    }
    $html .= !$inline ? "<div id='{$input_id}-field' class='three fields'/>\n" : '';
    $html .= "<div id='{$input_id}-0-field' class='field'>\n";
    $html .= $title ? "<label for='{$input_id}-0'/><h3>First Name " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</h3></label>\n" : '';
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' id='" . $input_id . "-0' name='" . $input_name . "[]' class='{$class}' value='" . $input_value['0'] . "' placeholder='First Name' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= $required ? "<div class='ui corner label'/><i class='icon asterisk'/></i></div>\n" : '';
    $html .= "<div id='{$input_id}-0-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div id='{$input_id}-1-field' class='field'>\n";
    $html .= $title ? "<label for='{$input_id}-1'/><h3>Middle Name</h3></label>\n" : '';
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' id='" . $input_id . "-1' name='" . $input_name . "[]' class='{$class}' value='" . $input_value['1'] . "' placeholder='Middle Name' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= "<div id='{$input_id}-1-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div id='{$input_id}-2-field'  class='field'>\n";
    $html .= $title ? "<label for='{$input_id}-2'/><h3>Last Name " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</h3></label>\n" : '';
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' id='" . $input_id . "-2' name='" . $input_name . "[]' class='form-control {$class}' value='" . $input_value['2'] . "' placeholder='Last Name' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= $required ? "<div class='ui corner label'/><i class='icon asterisk'/></i></div>\n" : '';
    $html .= "<div id='{$input_id}-2-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title=First Name],[id=" . $input_id . "-0],[required={$required}],[safemode={$safemode}]" . ($error_text ? ",[error_text={$error_text}]" : '') . "' readonly>";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title=Middle Name],[id=" . $input_id . "-1],[required=0],[safemode={$safemode}]" . ($error_text ? ",[error_text={$error_text}]" : '') . "' readonly>";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title=Last Name],[id=" . $input_id . "-2],[required={$required}],[safemode={$safemode}]" . ($error_text ? ",[error_text={$error_text}]" : '') . "' readonly>";
    return $html;
}
Example #6
0
/**
 * Select2 hierarchy
 * Returns a full hierarchy nested dropdown.
 * @param        $input_name
 * @param string $label
 * @param bool   $input_value
 * @param array  $options
 * @param        $db - your db
 * @param        $name_col - the option text to show
 * @param        $id_col - unique id
 * @param        $cat_col - parent id
 *                         ## The rest of the Params are used by the function itself -- no need to handle ##
 * @param bool   $self_id - not required
 * @param bool   $id - not required
 * @param bool   $level - not required
 * @param bool   $index - not required
 * @param bool   $data - not required
 * @return string
 */
function form_select_tree($input_name, $label = "", $input_value = FALSE, array $options = array(), $db, $name_col, $id_col, $cat_col, $self_id = FALSE, $id = FALSE, $level = FALSE, $index = FALSE, $data = FALSE)
{
    global $defender, $locale;
    if (!defined("SELECT2")) {
        define("SELECT2", TRUE);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js' /></script>\n");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />\n");
    }
    $title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $default_options = array('required' => FALSE, 'regex' => '', 'input_id' => $input_name, 'placeholder' => $locale['choose'], 'deactivate' => FALSE, 'safemode' => FALSE, 'allowclear' => FALSE, 'multiple' => FALSE, 'width' => '250px', 'keyflip' => FALSE, 'tags' => FALSE, 'jsonmode' => FALSE, 'chainable' => FALSE, 'maxselect' => FALSE, 'error_text' => $locale['error_input_default'], 'class' => '', 'inline' => FALSE, 'tip' => '', 'delimiter' => ',', 'callback_check' => '', 'file' => '', 'parent_value' => $locale['root'], 'add_parent_opts' => FALSE, 'disable_opts' => '', 'hide_disabled' => FALSE, 'no_root' => FALSE, 'show_current' => FALSE, 'query' => '');
    $options += $default_options;
    $options['input_id'] = trim($options['input_id'], "[]");
    if ($options['multiple']) {
        if ($input_value) {
            $input_value = construct_array($input_value, 0, $options['delimiter']);
        } else {
            $input_value = array();
        }
    }
    if (!$options['width']) {
        $options['width'] = $default_options['width'];
    }
    $allowclear = $options['placeholder'] && $options['multiple'] || $options['allowclear'] ? "allowClear:true" : '';
    $disable_opts = '';
    if ($options['disable_opts']) {
        $disable_opts = is_array($options['disable_opts']) ? $options['disable_opts'] : explode(',', $options['disable_opts']);
    }
    /* Child patern */
    $opt_pattern = str_repeat("&#8212;", $level);
    if (!$level) {
        $level = 0;
        if (!isset($index[$id])) {
            $index[$id] = array('0' => $locale['no_opts']);
        }
        $error_class = "";
        if ($defender->inputHasError($input_name)) {
            $error_class = "has-error ";
            if (!empty($options['error_text'])) {
                $new_error_text = $defender->getErrorText($input_name);
                if (!empty($new_error_text)) {
                    $options['error_text'] = $new_error_text;
                }
                addNotice("danger", "<strong>{$title}</strong> - " . $options['error_text']);
            }
        }
        $html = "<div id='" . $options['input_id'] . "-field' class='form-group " . $error_class . $options['class'] . "' " . ($options['inline'] && $options['width'] && !$label ? "style='width: " . $options['width'] . "'" : '') . ">\n";
        $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 p-l-0" : 'col-xs-12 p-l-0') . "' for='" . $options['input_id'] . "'>{$label} " . ($options['required'] == TRUE ? "<span class='required'>*</span>" : '') . " " . ($options['tip'] ? "<i class='pointer fa fa-question-circle' label=\"" . $options['tip'] . "\"></i>" : '') . "</label>\n" : '';
        $html .= $options['inline'] ? "<div class='col-xs-12 " . ($label ? "col-sm-9 col-md-9 col-lg-9" : "col-sm-12") . "'>\n" : "";
    }
    if ($level == 0) {
        $html =& $html;
        add_to_jquery("\n\t\t\$('#" . $options['input_id'] . "').select2({\n\t\tplaceholder: '" . $options['placeholder'] . "',\n\t\t{$allowclear}\n\t\t});\n\t\t");
        if (is_array($input_value) && $options['multiple']) {
            // stores as value;
            $vals = '';
            foreach ($input_value as $arr => $val) {
                $vals .= $arr == count($input_value) - 1 ? "'{$val}'" : "'{$val}',";
            }
            add_to_jquery("\$('#" . $options['input_id'] . "').select2('val', [{$vals}]);");
        }
        $html .= "<select name='{$input_name}' id='" . $options['input_id'] . "' style='width: " . ($options['width'] ? $options['width'] : $default_options['width']) . "' " . ($options['deactivate'] ? " disabled" : "") . ($options['multiple'] ? " multiple" : "") . ">";
        $html .= $options['allowclear'] ? "<option value=''></option>" : '';
        if ($options['no_root'] == FALSE) {
            // api options to remove root from selector. used in items creation.
            $this_select = '';
            if ($input_value !== NULL) {
                if ($input_value !== '') {
                    $this_select = 'selected';
                }
            }
            $html .= $options['add_parent_opts'] == TRUE ? "<option value='0' " . $this_select . ">{$opt_pattern} " . $locale['parent'] . "</option>\n" : "<option value='0' " . $this_select . " >{$opt_pattern} " . $options['parent_value'] . "</option>\n";
        }
        $index = dbquery_tree($db, $id_col, $cat_col, $options['query']);
        $data = dbquery_tree_data($db, $id_col, $cat_col, $options['query']);
    }
    if (!$id) {
        $id = 0;
    }
    if (isset($index[$id])) {
        foreach ($index[$id] as $key => $value) {
            //$hide = $disable_branch && $value == $self_id ? 1 : 0;
            $html =& $html;
            $name = $data[$value][$name_col];
            $name = PHPFusion\QuantumFields::parse_label($name);
            $select = $input_value !== "" && $input_value == $value ? 'selected' : '';
            $disabled = $disable_opts && in_array($value, $disable_opts) ? TRUE : FALSE;
            $hide = $disabled && $options['hide_disabled'] ? TRUE : FALSE;
            // do a disable for filter_opts item.
            $html .= !$hide ? "<option value='{$value}' " . $select . " " . ($disable_opts && in_array($value, $disable_opts) ? 'disabled' : '') . " >{$opt_pattern} {$name} " . ($options['show_current'] && $self_id == $value ? '(Current Item)' : '') . "</option>\n" : '';
            if (isset($index[$value]) && !$hide) {
                $html .= form_select_tree($input_name, $label, $input_value, $options, $db, $name_col, $id_col, $cat_col, $self_id, $value, $level + TRUE, $index, $data);
            }
        }
    }
    if (!$level) {
        $html =& $html;
        $html .= "</select>";
        $html .= $options['required'] == 1 && $defender->inputHasError($input_name) || $defender->inputHasError($input_name) ? "<div id='" . $options['input_id'] . "-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
        $html .= $options['inline'] ? "</div>\n" : '';
        $html .= "</div>\n";
        if ($options['required']) {
            $html .= "<input class='req' id='dummy-" . $options['input_id'] . "' type='hidden'>\n";
            // for jscheck
        }
        $input_name = $options['multiple'] ? str_replace("[]", "", $input_name) : $input_name;
        $defender->add_field_session(array('input_name' => $input_name, 'title' => trim($title, '[]'), 'id' => $options['input_id'], 'type' => 'dropdown', 'regex' => $options['regex'], 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'], 'callback_check' => $options['callback_check'], 'delimiter' => $options['delimiter']));
    }
    return $html;
}
Example #7
0
function form_address($title = false, $input_name, $input_id, $input_value = false, $array = false)
{
    if (isset($title) && $title !== "") {
        $title = stripinput($title);
    } else {
        $title = "";
    }
    if (isset($input_name) && $input_name !== "") {
        $input_name = stripinput($input_name);
    } else {
        $input_name = "";
    }
    if (isset($input_id) && $input_id !== "") {
        $input_id = stripinput($input_id);
    } else {
        $input_id = "";
    }
    $input_id = str_replace(" ", "", $input_id);
    $input_id = str_replace("/", "", $input_id);
    if (!defined("SELECT2")) {
        define("SELECT2", true);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js'></script>");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />");
    }
    require INCLUDES . "geomap/geomap.inc.php";
    // NOTE (remember to parse readback value as such):
    // $input_value = "Lot 87, Taman Khidmat,|Lorong Pokok Seraya 3A,|North-Korea|Sabah|Kota Kinabalu|89350";
    if (isset($input_value) && !empty($input_value)) {
        if (!is_array($input_value)) {
            $input_value = construct_array($input_value, "", "|");
        }
    } else {
        $input_value['0'] = "";
        $input_value['1'] = "";
        $input_value['2'] = "";
        $input_value['3'] = "";
        $input_value['4'] = "";
        $input_value['5'] = "";
    }
    if (!is_array($array)) {
        $array = array();
        $before = "";
        $after = "";
        $required = "";
        $deactivate = "";
        $width = "";
        $class = "";
        $well = "";
        $required = 0;
        $safemode = 0;
        $stacking = 0;
        $helper_text = "";
    } else {
        $deactivate = array_key_exists('deactivate', $array) ? $array['deactivate'] : "";
        $class = array_key_exists('class', $array) ? $array['class'] : "";
        $width = array_key_exists('width', $array) ? $array['width'] : "";
        $well = array_key_exists('well', $array) ? "style='margin-top:-10px;'" : "";
        $required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
        $stacking = array_key_exists("stacking", $array) ? 1 : "";
        $helper_text = array_key_exists("helper", $array) ? $array['helper'] : "";
    }
    $html = "";
    $html .= "<div class='field'/>\n";
    $html .= $title ? "<label for='{$input_id}'/><h3>{$title} " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</h3></label>\n" : '';
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control input-sm' id='" . $input_id . "-street' value='" . $input_value['0'] . "' placeholder='Street Address 1' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . " />\n";
    $html .= $required ? "<div class='ui corner label'/><i class='icon asterisk'/></i></div>\n" : '';
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div class='field'>\n";
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control input-sm' id='" . $input_id . "-street2' value='" . $input_value['1'] . "' placeholder='Street Address 2' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div id='{$input_id}-field' class='three fields'/>\n";
    $html .= "<div class='field'>\n";
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<select name='" . $input_name . "[]' id='{$input_id}-country' style='width:100%;'/>\n";
    $html .= "<option value=''></option>";
    foreach ($countries as $arv => $countryname) {
        // outputs: key, value, class - in order
        $country_key = str_replace(" ", "-", $countryname);
        if ($input_value['2'] == $country_key) {
            $select = "selected";
        } else {
            $select = "";
        }
        $html .= "<option value='{$country_key}' {$select}>{$countryname}</option>";
    }
    $html .= "</select>\n";
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div class='field'>\n";
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<div id='state-spinner' style='display:none;'>\n<img src='" . IMAGES . "loader.gif'>\n</div>\n";
    $html .= "<input type='hidden' name='" . $input_name . "[]' id='{$input_id}-state' value='" . $input_value['3'] . "' style='width:100%;' />\n";
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div class='field'>\n";
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' id='" . $input_id . "-city' value='" . $input_value['4'] . "' placeholder='City' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<div id='{$input_id}-field' class='three fields'/>\n";
    $html .= "<div class='field'>\n";
    $html .= "<div class='ui left labeled input'/>\n";
    $html .= "<input type='text' name='" . $input_name . "[]'  id='" . $input_id . "-postcode' value='" . $input_value['5'] . "' placeholder='Postcode' " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . ">";
    $html .= "<div id='{$input_id}-help'></div>";
    $html .= "</div>\n";
    $html .= "</div>\n";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title={$title} Street Address 1],[id=" . $input_id . "-street],[required={$required}],[safemode={$safemode}]' readonly />\n";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title={$title} Street Address 2],[id=" . $input_id . "-street2],[required={$required}],[safemode={$safemode}]' readonly>";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=dropdown],[title={$title} Country],[id=" . $input_id . "-country],[required={$required}],[safemode={$safemode}]' readonly />\n";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=dropdown],[title={$title} State],[id=" . $input_id . "-state],[required={$required}],[safemode={$safemode}]' readonly />\n";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title={$title} City],[id=" . $input_id . "-city],[required={$required}],[safemode={$safemode}]' readonly>";
    $html .= "<input type='hidden' name='def[{$input_name}][]' value='[type=textbox],[title={$title} Postcode],[id=" . $input_id . "-postcode],[required={$required}],[safemode={$safemode}]' readonly>";
    $html .= "</div>\n";
    add_to_jquery("\n         \$('#{$input_id}-country').select2({placeholder: 'Country'});\n         \$('#" . $input_id . "-country').bind('change', function(){\n\n            var ce_id = \$(this).val();\n            \$.ajax({\n                url: '" . INCLUDES . "geomap/form_geomap.json.php',\n                type: 'GET',\n                data: { id : ce_id },\n                dataType: 'json',\n                beforeSend: function(e) {\n//                \$('#state-spinner').show();\n                },\n                success: function(data) {\n//                    \$('#state-spinner').hide();\n                    \$('#" . $input_id . "-state').select2({\n                    placeholder: 'Select State',\n                    allowClear: true,\n                    data : data\n                    });\n                },\n                error : function() {\n                        \$.pnotify({title: 'Error! Something went wrong.',\n                        text: 'We cannot read the database, please recheck source codes.',\n                        icon: 'pngicon-l-badge-multiply',\n                        width: 'auto'\n                        });\n                }\n            })\n            }).trigger('change');\n         ");
    /*
    add_to_jquery("
                    //function icon(item) {
                      //  if(!item.id) {return item.text;}
                      //  var icon = 'pngicon-flag-'+ item.id.toLowerCase();
                      //  return '<i style=\"float:left; margin-top:5px;\" class=\"' + icon + '\"/></i>' + item.text;
                    //}
                    $('#".$input_id."-country').select2({
                    placeholder: 'Select Country',
                    allowClear:true,
                    formatResult: icon,
                    formatSelection: icon,
                    escapeMarkup: function(m) { return m; }
                    });
    
                    $('#".$input_id."-state').select2({
                    placeholder: 'Select State',
                    allowClear:true,
                    data: [{id:'0', 'text' :'Select Country to View State'}]
                    });
    ");
    
    
    
    /*
    $html .= add_to_jquery("$('#".$input_id."-country').chained('#".$input_id."-country');");
    */
    return $html;
}
Example #8
0
function form_geo($input_name, $label = '', $input_value = FALSE, array $options = array())
{
    global $locale, $defender;
    $title = isset($title) && !empty($title) ? $title : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $countries = array();
    require INCLUDES . "geomap/geomap.inc.php";
    // NOTE (remember to parse readback value as of '|' seperator)
    if (isset($input_value) && !empty($input_value)) {
        if (!is_array($input_value)) {
            $input_value = construct_array($input_value, "", "|");
        }
    } else {
        $input_value['0'] = "";
        $input_value['1'] = "";
        $input_value['2'] = "";
        $input_value['3'] = "";
        $input_value['4'] = "";
        $input_value['5'] = "";
    }
    $options += array('input_id' => !empty($options['input_id']) ? $options['input_id'] : $input_name, 'required' => !empty($options['required']) && $options['required'] == 1 ? '1' : '0', 'placeholder' => !empty($options['placeholder']) ? $options['placeholder'] : '', 'deactivate' => !empty($options['deactivate']) && $options['deactivate'] == 1 ? '1' : '0', 'width' => !empty($options['width']) ? $options['width'] : '100%', 'class' => !empty($options['class']) ? $options['class'] : '', 'inline' => !empty($options['inline']) ? $options['inline'] : '', 'tip' => !empty($options['tip']) ? $options['tip'] : '', 'error_text' => !empty($options['error_text']) ? $options['error_text'] : $locale['street_error'], 'error_text_2' => !empty($options['error_text_2']) ? $options['error_text_2'] : $locale['street_error'], 'error_text_3' => !empty($options['error_text_3']) ? $options['error_text_3'] : $locale['country_error'], 'error_text_4' => !empty($options['error_text_4']) ? $options['error_text_4'] : $locale['state_error'], 'error_text_5' => !empty($options['error_text_5']) ? $options['error_text_5'] : $locale['city_error'], 'error_text_6' => !empty($options['error_text_6']) ? $options['error_text_6'] : $locale['postcode_error'], 'safemode' => !empty($options['safemode']) && $options['safemode'] == 1 ? '1' : '0', 'flag' => !empty($options['flag']) ? $options['flag'] : '');
    $input_id = $options['input_id'];
    $validation_key = array(0 => 'street-1', 1 => 'street-2', 2 => 'country', 3 => 'region', 4 => 'city', 5 => 'postcode');
    $error_key = array(0 => $options['error_text'], 1 => $options['error_text_2'], 2 => $options['error_text_3'], 3 => $options['error_text_4'], 4 => $options['error_text_5'], 5 => $options['error_text_6']);
    $error_class = "";
    for ($i = 0; $i <= 5; $i++) {
        if ($defender->inputHasError($input_name . '-' . $validation_key[$i])) {
            $error_class = "has-error ";
            addNotice("danger", "<strong>{$title}</strong> - " . $error_key[$i]);
        }
    }
    $html = "<div id='{$input_id}-field' class='form-group clearfix m-b-10 " . $error_class . $options['class'] . "' >\n";
    $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3 p-l-0" : '') . "' for='{$input_id}'>{$label} " . ($options['required'] ? "<span class='required'>*</span>" : '') . "\n\t" . ($options['tip'] ? "<i class='pointer fa fa-question-circle' title='" . $options['tip'] . "'></i>" : '') . "\n\t</label>\n" : '';
    $html .= $options['inline'] ? "<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9'>\n" : '';
    $html .= "<div class='row'>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-street' value='" . $input_value['0'] . "' placeholder='" . $locale['street1'] . " " . ($options['required'] ? '*' : '') . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name . '-' . $validation_key[0]) || $defender->inputHasError($input_name . '-' . $validation_key[0]) ? "<div id='" . $options['input_id'] . "-street-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' class='form-control' id='" . $input_id . "-street2' value='" . $input_value['1'] . "' placeholder='" . $locale['street2'] . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name . '-' . $validation_key[1]) || $defender->inputHasError($input_name . '-' . $validation_key[1]) ? "<div id='" . $options['input_id'] . "-street-2-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_2'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-5 col-md-5 col-lg-5 m-b-10'>\n";
    $html .= "<select name='" . $input_name . "[]' id='{$input_id}-country' style='width:100%;'/>\n";
    $html .= "<option value=''></option>";
    foreach ($countries as $arv => $countryname) {
        // outputs: key, value, class - in order
        $country_key = str_replace(" ", "-", $countryname);
        $select = $input_value[2] == $country_key ? "selected" : '';
        $html .= "<option value='{$country_key}' " . $select . ">" . $countryname . "</option>";
    }
    $html .= "</select>\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name . '-' . $validation_key[2]) || $defender->inputHasError($input_name . '-' . $validation_key[2]) ? "<div id='" . $options['input_id'] . "-country-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_3'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-7 col-md-7 col-lg-7 m-b-10'>\n";
    $html .= "<div id='state-spinner' style='display:none;'>\n<img src='" . IMAGES . "loader.gif'>\n</div>\n";
    $html .= "<input type='hidden' name='" . $input_name . "[]' id='{$input_id}-state' value='" . $input_value['3'] . "' style='width:100%;' />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name . '-' . $validation_key[3]) || $defender->inputHasError($input_name . '-' . $validation_key[3]) ? "<div id='" . $options['input_id'] . "-state-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_4'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-5 col-md-5 col-lg-5 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]' id='" . $input_id . "-city' class='form-control textbox' value='" . $input_value['4'] . "' placeholder='" . $locale['city'] . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name[4]) || $defender->inputHasError($input_name[4]) ? "<div id='" . $options['input_id'] . "-city-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_5'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "<div class='col-xs-12 col-sm-4 col-md-4 col-lg-4 m-b-10'>\n";
    $html .= "<input type='text' name='" . $input_name . "[]'  id='" . $input_id . "-postcode' class='form-control textbox' value='" . $input_value['5'] . "' placeholder='" . $locale['postcode'] . "' " . ($options['deactivate'] == "1" ? "readonly" : '') . " />\n";
    $html .= $options['required'] == 1 && $defender->inputHasError($input_name . '-' . $validation_key[5]) || $defender->inputHasError($input_name . '-' . $validation_key[5]) ? "<div id='" . $options['input_id'] . "-postcode-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text_6'] . "</div>" : "";
    $html .= "</div>\n";
    $html .= "</div>\n";
    // close inner row
    $html .= $options['inline'] ? "</div>\n" : "";
    $html .= "</div>\n";
    $defender->add_field_session(array('input_name' => $input_name, 'type' => 'address', 'title' => $title, 'id' => $input_id, 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'], 'error_text_2' => $options['error_text_2'], 'error_text_3' => $options['error_text_3'], 'error_text_4' => $options['error_text_4'], 'error_text_5' => $options['error_text_5'], 'error_text_6' => $options['error_text_6']));
    if (!defined("SELECT2")) {
        define("SELECT2", TRUE);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js'></script>");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />");
    }
    $flag_function = '';
    $flag_plugin = '';
    if ($options['flag']) {
        $flag_function = "\n\t\tfunction show_flag(item) {\n\t\tif(!item.id) {return item.text;}\n\t\tvar icon = '" . IMAGES . "small_flag/flag_'+ item.id.replace(/-/gi,'_').toLowerCase() +'.png';\n\t\treturn '<img style=\"float:left; margin-right:5px; margin-top:3px;\" src=\"' + icon + '\"/></i>' + item.text;\n\t\t}";
        $flag_plugin = "\n         formatResult: show_flag,\n\t\t formatSelection: show_flag,\n\t\t escapeMarkup: function(m) { return m; },\n\t\t";
    }
    add_to_jquery("\n\t" . $flag_function . "\n    \$('#{$input_id}-country').select2({\n\t{$flag_plugin}\n\tplaceholder: 'Country " . ($options['required'] == 1 ? '*' : '') . "'\n    });\n    \$('#" . $input_id . "-country').bind('change', function(){\n    \tvar ce_id = \$(this).val();\n        \$.ajax({\n        url: '" . INCLUDES . "geomap/form_geomap.json.php',\n        type: 'GET',\n        data: { id : ce_id },\n        dataType: 'json',\n        beforeSend: function(e) {\n        //\$('#state-spinner').show();\n        \$('#" . $input_id . "-state').hide();\n        },\n        success: function(data) {\n        //\$('#state-spinner').hide();\n        \$('#" . $input_id . "-state').select2({\n        placeholder: 'Select State " . ($options['required'] == 1 ? '*' : '') . "',\n        allowClear: true,\n        data : data\n        });\n        },\n        error : function() {\n\t\t\$.pnotify({title: 'Error! Something went wrong.',\n\t\ttext: 'We cannot read the database, please recheck source codes.',\n\t\ticon: 'pngicon-l-badge-multiply',\n\t\twidth: 'auto'\n\t\t});\n        }\n        })\n\t}).trigger('change');\n\t");
    return $html;
}
Example #9
0
 public function defenseOpts($input_name)
 {
     $array = array();
     $array = construct_array($input_name);
     foreach ($array as $ks => $vs) {
         $clean_up = str_replace("[", "", $vs);
         $clean_up = str_replace("]", "", $clean_up);
         $cdata[$input_name][] = construct_array($clean_up, "", "=");
     }
     foreach ($cdata[$input_name] as $arr => $v) {
         $data[$v['0']] = array_key_exists('1', $v) ? $v['1'] : '';
     }
     if ($data) {
         $opts['type'] = array_key_exists("type", $data) ? $data['type'] : "";
         $opts['name'] = array_key_exists("title", $data) ? rtrim($data['title'], ':') : "";
         $opts['id'] = array_key_exists("id", $data) ? $data['id'] : "";
         $opts['required'] = array_key_exists("required", $data) ? $data['required'] : 0;
         $opts['safemode'] = array_key_exists("safemode", $data) ? $data['safemode'] : 0;
         $opts['error_text'] = array_key_exists('error_text', $data) && $data['error_text'] ? $data['error_text'] : "" . $opts['name'] . " needs your attention";
         if (array_key_exists('path', $data) && $data['path']) {
             $opts['path'] = $data['path'];
         }
         if (array_key_exists('maxsize', $data) && $data['maxsize']) {
             $opts['maxsize'] = $data['maxsize'];
         }
         return $opts;
     }
     return FALSE;
 }