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


PHP ca_locales::get方法代码示例

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


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

示例1: Get

 public function Get()
 {
     global $g_ui_locale_id;
     $ps_query = $this->request->getParameter('q', pString);
     $ps_type = $this->request->getParameter('type', pString);
     $vo_conf = Configuration::load();
     $vs_user = trim($vo_conf->get("geonames_user"));
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         $vs_base = "http://api.geonames.org/search";
         $t_locale = new ca_locales($g_ui_locale_id);
         $vs_lang = $t_locale->get("language");
         $va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user);
         foreach ($va_params as $vs_key => $vs_value) {
             $vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
         }
         try {
             $vo_xml = new SimpleXMLElement(@file_get_contents("{$vs_base}?{$vs_query_string}"));
             //var_dump($vo_result);
             foreach ($vo_xml->children() as $vo_child) {
                 if ($vo_child->getName() != "totalResultsCount") {
                     $va_items[$vo_child->geonameId . ""] = array('displayname' => $vo_child->name, 'country' => $vo_child->countryName ? $vo_child->countryName : null, 'continent' => $vo_child->continentCode ? $vo_child->continentCode : null, 'fcl' => $vo_child->fclName ? $vo_child->fclName : null, 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'idno' => $vo_child->geonameId);
                 }
             }
         } catch (Exception $e) {
             $va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'country' => '', 'continent' => '', 'fcl' => '', 'lat' => '', 'lng' => '', 'idno' => '');
         }
     }
     $this->view->setVar('geonames_list', $va_items);
     return $this->render('ajax_geonames_list_html.php');
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:31,代码来源:GeoNamesController.php

示例2: Get

 public function Get($pa_additional_query_params = null, $pa_options = null)
 {
     global $g_ui_locale_id;
     $vn_max = $this->request->getParameter('maxRows', pInteger) ? $this->request->getParameter('maxRows', pInteger) : 20;
     $ps_query = $this->request->getParameter('term', pString);
     $ps_gn_elements = urldecode($this->request->getParameter('gnElements', pString));
     $ps_gn_delimiter = urldecode($this->request->getParameter('gnDelimiter', pString));
     $pa_elements = explode(',', $ps_gn_elements);
     $vo_conf = Configuration::load();
     $vs_user = trim($vo_conf->get("geonames_user"));
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         $vs_base = $vo_conf->get('geonames_api_base_url') . '/search';
         $t_locale = new ca_locales($g_ui_locale_id);
         $vs_lang = $t_locale->get("language");
         $va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user, 'maxRows' => $vn_max);
         $vs_query_string = '';
         foreach ($va_params as $vs_key => $vs_value) {
             $vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
         }
         try {
             $vs_xml = caQueryExternalWebservice("{$vs_base}?{$vs_query_string}");
             $vo_xml = new SimpleXMLElement($vs_xml);
             $va_attr = $vo_xml->status ? $vo_xml->status->attributes() : null;
             if ($va_attr && isset($va_attr['value']) && (int) $va_attr['value'] > 0) {
                 $va_items[0] = array('displayname' => _t('Connection to GeoNames with username "%1" was rejected with the message "%2". Check your configuration and make sure your GeoNames.org account is enabled for web services.', $vs_user, $va_attr['message']), 'lat' => '', 'lng' => '');
                 $va_items[0]['label'] = $va_items[0]['displayname'];
             } else {
                 foreach ($vo_xml->children() as $vo_child) {
                     if ($vo_child->getName() == "geoname") {
                         $va_elements = array();
                         foreach ($pa_elements as $ps_element) {
                             $vs_val = $vo_child->{trim($ps_element)};
                             if (strlen(trim($vs_val)) > 0) {
                                 $va_elements[] = trim($vs_val);
                             }
                         }
                         $va_items[(string) $vo_child->geonameId] = array('displayname' => $vo_child->name, 'label' => join($ps_gn_delimiter, $va_elements) . ($vo_child->lat ? " [" . $vo_child->lat . "," : '') . ($vo_child->lng ? $vo_child->lng . "]" : ''), 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'id' => (string) $vo_child->geonameId);
                     }
                 }
             }
         } catch (Exception $e) {
             $va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'lat' => '', 'lng' => '', 'id' => 0);
             $va_items[0]['label'] = $va_items[0]['displayname'];
         }
     }
     $this->view->setVar('geonames_list', $va_items);
     return $this->render('ajax_geonames_list_html.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:49,代码来源:GeoNamesController.php


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