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


PHP Region::findByCountry方法代码示例

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


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

示例1: doModel

    function doModel()
    {
        switch ($this->action) {
            case 'comments':
                //calling the comments settings view
                $this->doView('settings/comments.php');
                break;
            case 'comments_post':
                // updating comment
                $iUpdated = 0;
                $enabledComments = Params::getParam('enabled_comments');
                $enabledComments = $enabledComments != '' ? true : false;
                $moderateComments = Params::getParam('moderate_comments');
                $moderateComments = $moderateComments != '' ? true : false;
                $numModerateComments = Params::getParam('num_moderate_comments');
                $commentsPerPage = Params::getParam('comments_per_page');
                $notifyNewComment = Params::getParam('notify_new_comment');
                $notifyNewComment = $notifyNewComment != '' ? true : false;
                $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
                $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
                $regUserPostComments = Params::getParam('reg_user_post_comments');
                $regUserPostComments = $regUserPostComments != '' ? true : false;
                $msg = '';
                if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
                    $msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
                }
                if (!osc_validate_int(Params::getParam("comments_per_page"))) {
                    $msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
                }
                if ($msg != '') {
                    osc_add_flash_error_message($msg, 'admin');
                    $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
                if ($moderateComments) {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
                } else {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
                if ($iUpdated > 0) {
                    osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
                }
                $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                break;
            case 'locations':
                // calling the locations settings view
                $location_action = Params::getParam('type');
                $mCountries = new Country();
                switch ($location_action) {
                    case 'add_country':
                        // add country
                        $countryCode = strtoupper(Params::getParam('c_country'));
                        $countryName = Params::getParam('country');
                        $exists = $mCountries->findByCode($countryCode);
                        if (isset($exists['s_name'])) {
                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                        } else {
                            $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
                            $countries = json_decode($countries_json);
                            $mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
                            CountryStats::newInstance()->setNumItems($countryCode, 0);
                            if (isset($countries->error)) {
                                // Country is not in our GEO database
                                // We have no region for user-typed countries
                            } else {
                                // Country is in our GEO database, add regions and cities
                                $manager_region = new Region();
                                $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
                                $regions = json_decode($regions_json);
                                if (!isset($regions->error)) {
                                    if (count($regions) > 0) {
                                        foreach ($regions as $r) {
                                            $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                                            $id = $manager_region->dao->insertedId();
                                            RegionStats::newInstance()->setNumItems($id, 0);
                                        }
                                    }
                                    unset($regions);
                                    unset($regions_json);
                                    $manager_city = new City();
                                    if (count($countries) > 0) {
                                        foreach ($countries as $c) {
                                            $regions = $manager_region->findByCountry($c->id);
                                            if (!isset($regions->error)) {
                                                if (count($regions) > 0) {
                                                    foreach ($regions as $region) {
                                                        $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
                                                        $cities = json_decode($cities_json);
                                                        if (!isset($cities->error)) {
                                                            if (count($cities) > 0) {
                                                                foreach ($cities as $ci) {
                                                                    $manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
                                                                    $id = $manager_city->dao->insertedId();
                                                                    CityStats::newInstance()->setNumItems($id, 0);
                                                                }
                                                            }
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:settings.php

示例2: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'comments':
             //calling the comments settings view
             $this->doView('settings/comments.php');
             break;
         case 'comments_post':
             // updating comment
             $iUpdated = 0;
             $enabledComments = Params::getParam('enabled_comments');
             $enabledComments = $enabledComments != '' ? true : false;
             $moderateComments = Params::getParam('moderate_comments');
             $moderateComments = $moderateComments != '' ? true : false;
             $numModerateComments = Params::getParam('num_moderate_comments');
             $commentsPerPage = Params::getParam('comments_per_page');
             $notifyNewComment = Params::getParam('notify_new_comment');
             $notifyNewComment = $notifyNewComment != '' ? true : false;
             $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
             $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
             $regUserPostComments = Params::getParam('reg_user_post_comments');
             $regUserPostComments = $regUserPostComments != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
             if ($moderateComments) {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
             } else {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
             }
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
             if ($iUpdated > 0) {
                 osc_add_flash_ok_message(_m('Comments\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             break;
         case 'locations':
             // calling the locations settings view
             $location_action = Params::getParam('type');
             $mCountries = new Country();
             switch ($location_action) {
                 case 'add_country':
                     // add country
                     $countryCode = strtoupper(Params::getParam('c_country'));
                     $request = Params::getParam('country');
                     foreach ($request as $k => $v) {
                         $countryName = $v;
                         break;
                     }
                     $exists = $mCountries->findByCode($countryCode);
                     if (isset($exists['s_name'])) {
                         osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                     } else {
                         $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
                         $countries = json_decode($countries_json);
                         foreach ($request as $k => $v) {
                             $data = array('pk_c_code' => $countryCode, 'fk_c_locale_code' => $k, 's_name' => $v);
                             $mCountries->insert($data);
                         }
                         if (isset($countries->error)) {
                             // Country is not in our GEO database
                             // We have no region for user-typed countries
                         } else {
                             // Country is in our GEO database, add regions and cities
                             $manager_region = new Region();
                             $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
                             $regions = json_decode($regions_json);
                             if (!isset($regions->error)) {
                                 if (count($regions) > 0) {
                                     foreach ($regions as $r) {
                                         $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                                     }
                                 }
                                 unset($regions);
                                 unset($regions_json);
                                 $manager_city = new City();
                                 if (count($countries) > 0) {
                                     foreach ($countries as $c) {
                                         $regions = $manager_region->findByCountry($c->id);
                                         if (!isset($regions->error)) {
                                             if (count($regions) > 0) {
                                                 foreach ($regions as $region) {
                                                     $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
                                                     $cities = json_decode($cities_json);
                                                     if (!isset($cities->error)) {
                                                         if (count($cities) > 0) {
                                                             foreach ($cities as $ci) {
                                                                 $manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
                                                             }
                                                         }
                                                     }
                                                     unset($cities);
                                                     unset($cities_json);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
//.........这里部分代码省略.........
开发者ID:acharei,项目名称:OSClass,代码行数:101,代码来源:settings.php


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