当前位置: 首页>>代码示例>>PHP>>正文


PHP Countries::getCountriesArray方法代码示例

本文整理汇总了PHP中Countries::getCountriesArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Countries::getCountriesArray方法的具体用法?PHP Countries::getCountriesArray怎么用?PHP Countries::getCountriesArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Countries的用法示例。


在下文中一共展示了Countries::getCountriesArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editAction

 function editAction()
 {
     if ($this->_user->username != $this->_identity->username) {
         $this->_forward('default', 'auth', 'missing');
         return;
     } else {
         $countries_table = new Countries();
         $this->view->countries = $countries_table->getCountriesArray('Choose a country...');
         $user = $this->_user->toArray();
         $params = array('user' => $user, 'request' => $this->_request, 'session' => $this->session);
         $pre_render = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_render", $params);
         // FILTER HOOK
         $user = $pre_render['user'];
         foreach ($pre_render as $key => $value) {
             if ($key != "user") {
                 $this->view->{$key} = $value;
             }
         }
         //$tags = unserialize($user->tags);
         if ($this->getRequest()->isPost()) {
             $errors = array();
             $request = new Bolts_Request($this->getRequest());
             $request->stripTags(array('email', 'newpassword', 'confirm', 'aboutme'));
             $user['username'] = $this->_identity->username;
             $user['email'] = $request->email;
             $user['full_name'] = $request->full_name;
             $user['password'] = $request->newpassword;
             $user['confirm'] = $request->confirm;
             $user['birthday'] = $birthday = strtotime($request->Birthday_Day . $request->Birthday_Month . $request->Birthday_Year);
             //$user['tags'] = $tag_array = Bolts_Common::makeTagArray($request->tags);
             $user['gender'] = $request->gender;
             $user['country_code'] = $request->country_code;
             $user['aboutme'] = $request->aboutme;
             // validate email
             if (!Bolts_Validate::checkEmail($user['email'])) {
                 $errors[] = $this->_T("Email is not valid");
             }
             // check to see if email is in use already by someone else
             if ($this->_users_table->isEmailInUse($user['email'], $user['username'])) {
                 $errors[] = $this->_T("Email already in use");
             }
             // if password isn't blank, validate it
             if ($user['password'] != "") {
                 if (!Bolts_Validate::checkLength($user['password'], 6, Bolts_Registry::get('password_length'))) {
                     $errors[] = $this->_T("Password must be between %d and %d characters", array(6, Bolts_Registry::get('password_length')));
                 }
                 // if password is set, make sure it matches confirm
                 if ($user['password'] != $user['confirm']) {
                     $errors[] = $this->_T("Passwords don't match");
                 }
             }
             if (!Bolts_Validate::checkLength($user['aboutme'], 0, Bolts_Registry::get('user_about_me_length'))) {
                 $errors[] = $this->_T("About me must be less than %d characters.", Bolts_Registry::get('user_about_me_length'));
             }
             // convert birthday_ts to mysql date
             $birthday = date("Y-m-d H:i:s", $user['birthday']);
             $params = array('request' => $this->getRequest(), 'user' => $user, 'errors' => $errors);
             // upload new avatar image if present
             if (array_key_exists('filedata', $_FILES)) {
                 if ($_FILES['filedata']['tmp_name'] != '') {
                     $users_table = new Users();
                     $destination_path = $users_table->getAvatarPath($user['username']);
                     $destination_filename = $users_table->getAvatarPath($user['username'], true);
                     if (!is_dir($destination_path)) {
                         mkdir($destination_path, 0777, true);
                         Bolts_Log::report("Creating user folder at " . $destination_path, null, Zend_Log::DEBUG);
                     }
                     if (file_exists($destination_filename)) {
                         unlink($destination_filename);
                         Bolts_Log::report("Deleted existing user avatar from " . $destination_path, null, Zend_Log::DEBUG);
                     } else {
                         Bolts_Log::report("User avatar did not exist in " . $destination_path, null, Zend_Log::DEBUG);
                     }
                     move_uploaded_file($_FILES['filedata']['tmp_name'], $destination_filename);
                     Users::clearUserCache($user['username']);
                     Bolts_Log::report("User avatar uploaded to " . $destination_path, null, Zend_Log::DEBUG);
                     $params['user']['hasnewfile'] = true;
                 } else {
                     $params['user']['hasnewfile'] = false;
                 }
             }
             $additional = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_save", $params);
             // FILTER HOOK
             $errors = $additional['errors'];
             $user = $additional['user'];
             if (strlen($user['full_name']) < 1) {
                 $user['full_name'] = $this->_T("Unidentified User");
             }
             if (count($errors) == 0) {
                 $data = array('email' => $user['email'], 'full_name' => $user['full_name'], 'birthday' => $birthday, 'aboutme' => nl2br($user['aboutme']), 'gender' => $user['gender'], 'country_code' => $user['country_code'], 'last_modified_on' => date(DB_DATETIME_FORMAT));
                 if ($user['password'] != "") {
                     $data['password'] = $user['password'];
                 }
                 $where = $this->_users_table->getAdapter()->quoteInto('username = ?', $this->_username);
                 $this->_users_table->update($data, $where);
                 $this->_Bolts_plugin->doAction('default_user_edit_post_save', array('username' => $this->_username));
                 // ACTION HOOK
                 $this->view->success = $this->_T("Profile Updated.");
             } else {
                 $this->view->errors = $errors;
//.........这里部分代码省略.........
开发者ID:jaybill,项目名称:Bolts,代码行数:101,代码来源:UserController.php

示例2: editAction

 function editAction()
 {
     $errors = array();
     $users_table = new Users();
     $users_roles_table = new UsersRoles();
     $request = new Bolts_Request($this->getRequest());
     $countries_table = new Countries();
     $this->view->countries = $countries_table->getCountriesArray('Choose a country...');
     $roles_table = new Roles();
     $roles = $roles_table->fetchAll(NULL, "shortname ASC");
     $arRoles = array();
     foreach ($roles as $role) {
         if (!strpos($role->shortname, "-base")) {
             $arRoles[$role->id] = $role->description;
         }
     }
     $this->view->roles = $arRoles;
     $is_new = true;
     $user = array();
     if ($request->has('username')) {
         $obUser = $users_table->fetchByUsername($request->username);
         if (!is_null($obUser)) {
             $is_new = false;
             $user_roles = $users_roles_table->fetchAll($users_roles_table->select()->where("username = ?", $obUser->username));
             if (count($user_roles) > 0) {
                 $tmp_selected = array();
                 foreach ($user_roles as $user_role) {
                     $tmp_selected[] = $user_role->role_id;
                 }
                 $this->view->selected_roles = $tmp_selected;
             }
             $user = $obUser->toArray();
         }
     }
     $this->view->is_new = $is_new;
     if ($is_new) {
         // defaults for form fields
         $user['username'] = "";
         $user['full_name'] = "";
         $user['aboutme'] = "";
     }
     $pre_render = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_render", array('user' => $user, 'request' => $this->_request));
     // FILTER HOOK
     $user = $pre_render['user'];
     foreach ($pre_render as $key => $value) {
         if ($key != "user") {
             $this->view->{$key} = $value;
         }
     }
     // $tags = unserialize($user['tags']);
     if ($this->getRequest()->isPost()) {
         $errors = array();
         $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm'));
         // $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm', 'aboutme'));
         $user['username'] = $request->username;
         $user['email'] = $request->email;
         $user['password'] = $request->newpassword;
         $user['confirm'] = $request->confirm;
         $user['full_name'] = $request->full_name;
         $user['birthday'] = $birthday = strtotime($request->Birthday_Day . $request->Birthday_Month . $request->Birthday_Year);
         $user['gender'] = $request->gender;
         $user['country_code'] = $request->country_code;
         $user['aboutme'] = $request->aboutme;
         // validate username
         $username_validator = new Zend_Validate();
         $username_validator->addValidator(new Zend_Validate_StringLength(1, Bolts_Registry::get('username_length')));
         $username_validator->addValidator(new Zend_Validate_Alnum());
         if (!$username_validator->isValid($user['username'])) {
             $show_username = "'" . $user['username'] . "'";
             if (trim($user['username']) == "") {
                 $show_username = "[" . $this->_T("empty") . "]";
             }
             $errors[] = $this->_T("%s isn't a valid username. (Between %d and %d characters, only letters and numbers)", array($show_username, 1, Bolts_Registry::get('username_length')));
         }
         if ($is_new) {
             $user_where = $users_table->getAdapter()->quoteInto('username = ?', $user['username']);
             if ($users_table->getCountByWhereClause($user_where) > 0) {
                 $errors[] = $this->_T("The username '%s' is already in use", $user['username']);
             }
         }
         // validate email
         if (!Bolts_Validate::checkEmail($user['email'])) {
             $errors[] = $this->_T("Email is not valid");
         }
         // check to see if email is in use already by someone else
         if ($users_table->isEmailInUse($user['email'], $user['username'])) {
             $errors[] = $this->_T("Email already in use");
         }
         // if password isn't blank, validate it
         if ($user['password'] != "") {
             if (!Bolts_Validate::checkLength($user['password'], 6, Bolts_Registry::get('password_length'))) {
                 $errors[] = $this->_T("Password must be between 6 and 32 characters");
             }
             // if password is set, make sure it matches confirm
             if ($user['password'] != $user['confirm']) {
                 $errors[] = $this->_T("Passwords don't match");
             }
         }
         // convert birthday_ts to mysql date
         $birthday = date("Y-m-d H:i:s", $user['birthday']);
//.........这里部分代码省略.........
开发者ID:jaybill,项目名称:Bolts,代码行数:101,代码来源:UseradminController.php

示例3: Date

        $captcha = recaptcha_get_html($config['reCaptchapubk']);
    } else {
        $captcha = "<img src=\"includes/captcha.php\" alt=\"Captcha code\" id=\"captchaCode\" onclick=\"this.src = this.src + '?' + (new Date()).getTime();\" style=\"cursor: pointer;\" />";
        $captcha .= " <img src=\"images/posts/reload.gif\" alt=\"Reload captcha code\" onclick=\"document.getElementById('captchaCode').src = document.getElementById('captchaCode').src + '?' + (new Date()).getTime();\" style=\"cursor: pointer;\" />";
    }
    $boxContent->assign("NAME_VALUE", stripslashes($signCheck['name']));
    $boxContent->assign("COUNTRY_VALUE", $signCheck['country']);
    $boxContent->assign("LOCATION_VALUE", stripslashes($signCheck['location']));
    $boxContent->assign("EMAIL_VALUE", stripslashes($signCheck['email']));
    $boxContent->assign("RATING_VALUE", $signCheck['rating']);
    $boxContent->assign("MESSAGE_VALUE", stripslashes($signCheck['message']));
}
include_once 'classes/manage/countries.class.php';
$countryName = new Countries();
$selected = '';
foreach ($countryName->getCountriesArray() as $id_cc => $country_name) {
    if (isset($signCheck['country']) && !empty($signCheck['country'])) {
        if ($signCheck['country'] == $id_cc) {
            $selected = "selected";
        } else {
            $selected = '';
        }
    }
    if (strlen($country_name) > 23) {
        $country_name = substr($country_name, 0, 23);
    }
    $boxContent->assign('ID_COUNTRY', $id_cc);
    $boxContent->assign('COUNTRY_NAME', $country_name);
    $boxContent->assign('SELECTED', $selected);
    $boxContent->parse('sign.signForm.countries');
}
开发者ID:adelnoureddine,项目名称:angora-guestbook,代码行数:31,代码来源:sign.php


注:本文中的Countries::getCountriesArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。