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


PHP Tinebase_Translation::getRegionCodeByCountryName方法代码示例

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


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

示例1: toTineModel

 /**
  * convert contact from xml to Addressbook_Model_Contact
  *
  * @param SimpleXMLElement $_data
  * @return Addressbook_Model_Contact
  */
 public function toTineModel(SimpleXMLElement $_data, $_entry = null)
 {
     if ($_entry instanceof Addressbook_Model_Contact) {
         $contact = $_entry;
     } else {
         $contact = new Addressbook_Model_Contact(null, true);
     }
     unset($contact->jpegphoto);
     $xmlData = $_data->children('uri:Contacts');
     $airSyncBase = $_data->children('uri:AirSyncBase');
     foreach ($this->_mapping as $fieldName => $value) {
         switch ($value) {
             case 'jpegphoto':
                 // do not change if not set
                 if (isset($xmlData->{$fieldName})) {
                     if (!empty($xmlData->{$fieldName})) {
                         $devicePhoto = base64_decode((string) $xmlData->{$fieldName});
                         try {
                             $currentPhoto = Tinebase_Controller::getInstance()->getImage('Addressbook', $contact->getId())->getBlob('image/jpeg', 36000);
                         } catch (Exception $e) {
                         }
                         if (isset($currentPhoto) && $currentPhoto == $devicePhoto) {
                             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                                 Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . " photo did not change on device -> preserving server photo");
                             }
                         } else {
                             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                                 Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . " using new contact photo from device (" . strlen($devicePhoto) . "KB)");
                             }
                             $contact->jpegphoto = $devicePhoto;
                         }
                     } else {
                         if ($_entry && !empty($_entry->jpegphoto)) {
                             $contact->jpegphoto = '';
                             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                                 Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Deleting contact photo on device request (contact id: ' . $contact->getId() . ')');
                             }
                         }
                     }
                 }
                 break;
             case 'bday':
                 if (isset($xmlData->{$fieldName})) {
                     $isoDate = (string) $xmlData->{$fieldName};
                     $contact->bday = new Tinebase_DateTime($isoDate);
                     if ($this->_device->devicetype == Syncope_Model_Device::TYPE_IPHONE && $this->_device->getMajorVersion() < 800 || preg_match("/^\\d{4}-\\d{2}-\\d{2}\$/", $isoDate)) {
                         // iOS < 4 & webow < 2.1 send birthdays to the entered date, but the time the birthday got entered on the device
                         // acutally iOS < 4 somtimes sends the bday at noon but the timezone is not clear
                         // -> we don't trust the time part and set the birthdays timezone to the timezone the user has set in tine
                         $userTimezone = Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
                         $contact->bday = new Tinebase_DateTime($contact->bday->setTime(0, 0, 0)->format(Tinebase_Record_Abstract::ISO8601LONG), $userTimezone);
                         $contact->bday->setTimezone('UTC');
                     }
                 } else {
                     $contact->bday = null;
                 }
                 break;
             case 'adr_one_countryname':
             case 'adr_two_countryname':
                 $contact->{$value} = Tinebase_Translation::getRegionCodeByCountryName((string) $xmlData->{$fieldName});
                 break;
             case 'adr_one_street':
                 if (strtolower($this->_device->devicetype) == 'palm') {
                     // palm pre sends the whole address in the <Contacts:BusinessStreet> tag
                     unset($contact->adr_one_street);
                 } else {
                     // default handling for all other devices
                     if (isset($xmlData->{$fieldName})) {
                         $contact->{$value} = (string) $xmlData->{$fieldName};
                     } else {
                         $contact->{$value} = null;
                     }
                 }
                 break;
             case 'email':
             case 'email_home':
                 // android send email address as
                 // Lars Kneschke <l.kneschke@metaways.de>
                 if (preg_match('/(.*)<(.+@[^@]+)>/', (string) $xmlData->{$fieldName}, $matches)) {
                     $contact->{$value} = trim($matches[2]);
                 } else {
                     $contact->{$value} = (string) $xmlData->{$fieldName};
                 }
                 break;
             default:
                 if (isset($xmlData->{$fieldName})) {
                     $contact->{$value} = (string) $xmlData->{$fieldName};
                 } else {
                     $contact->{$value} = null;
                 }
                 break;
         }
     }
     // get body
//.........这里部分代码省略.........
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:101,代码来源:Contacts.php

示例2: testGetRegionCodeByCountryName

 /**
  * test getRegionCodeByCountryName
  */
 public function testGetRegionCodeByCountryName()
 {
     Tinebase_Core::setupUserLocale('de_DE');
     $this->assertEquals('DE', Tinebase_Translation::getRegionCodeByCountryName('Deutschland'));
     $this->assertEquals('US', Tinebase_Translation::getRegionCodeByCountryName('Vereinigte Staaten'));
     $this->assertNull(Tinebase_Translation::getRegionCodeByCountryName('XX'));
     Tinebase_Core::setupUserLocale('en_US');
     $this->assertEquals('DE', Tinebase_Translation::getRegionCodeByCountryName('Germany'));
     $this->assertEquals('US', Tinebase_Translation::getRegionCodeByCountryName('United States'));
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:13,代码来源:TranslationTest.php

示例3: toTineModel

 /**
  * convert contact from xml to Addressbook_Model_Contact
  *
  * @param SimpleXMLElement $_data
  * @return Addressbook_Model_Contact
  */
 public function toTineModel(Syncroton_Model_IEntry $data, $entry = null)
 {
     if ($entry instanceof Addressbook_Model_Contact) {
         $contact = $entry;
     } else {
         $contact = new Addressbook_Model_Contact(null, true);
     }
     unset($contact->jpegphoto);
     foreach ($this->_mapping as $fieldName => $value) {
         if (!isset($data->{$fieldName})) {
             $contact->{$value} = null;
             continue;
         }
         switch ($value) {
             case 'jpegphoto':
                 if (!empty($data->{$fieldName})) {
                     $devicePhoto = $data->{$fieldName};
                     $contact->setSmallContactImage($devicePhoto);
                 } else {
                     if ($entry && !empty($entry->jpegphoto)) {
                         $contact->jpegphoto = '';
                         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                             Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Deleting contact photo on device request (contact id: ' . $contact->getId() . ')');
                         }
                     }
                 }
                 break;
             case 'bday':
                 $contact->{$value} = new Tinebase_DateTime($data->{$fieldName});
                 if ($this->_device->devicetype == Syncroton_Model_Device::TYPE_IPHONE && $this->_device->getMajorVersion() < 800) {
                     // iOS < 4 & webos < 2.1 send birthdays to the entered date, but the time the birthday got entered on the device
                     // actually iOS < 4 sometimes sends the bday at noon but the timezone is not clear
                     // -> we don't trust the time part and set the birthdays timezone to the timezone the user has set in tine
                     $userTimezone = Tinebase_Core::getUserTimezone();
                     $contact->{$value} = new Tinebase_DateTime($contact->bday->setTime(0, 0, 0)->format(Tinebase_Record_Abstract::ISO8601LONG), $userTimezone);
                     $contact->{$value}->setTimezone('UTC');
                 } elseif ($this->_device->devicetype == Syncroton_Model_Device::TYPE_BLACKBERRY && version_compare($this->_device->getMajorVersion(), '10', '>=')) {
                     // BB 10+ expects birthday to be at noon
                     $contact->{$value}->subHour(12);
                 }
                 break;
             case 'adr_one_countryname':
             case 'adr_two_countryname':
                 $contact->{$value} = Tinebase_Translation::getRegionCodeByCountryName($data->{$fieldName});
                 break;
             case 'adr_one_street':
                 if (strtolower($this->_device->devicetype) == 'palm') {
                     // palm pre sends the whole address in the <Contacts:BusinessStreet> tag
                     unset($contact->adr_one_street);
                 } else {
                     $contact->{$value} = $data->{$fieldName};
                 }
                 break;
             case 'email':
             case 'email_home':
                 // android sends email address as
                 // Lars Kneschke <l.kneschke@metaways.de>
                 if (preg_match('/(.*)<(.+@[^@]+)>/', $data->{$fieldName}, $matches)) {
                     $contact->{$value} = trim($matches[2]);
                 } else {
                     $contact->{$value} = $data->{$fieldName};
                 }
                 break;
             case 'note':
                 // @todo check $data->$fieldName->Type and convert to/from HTML if needed
                 if ($data->{$fieldName} instanceof Syncroton_Model_EmailBody) {
                     $contact->{$value} = $data->{$fieldName}->data;
                 } else {
                     $contact->{$value} = null;
                 }
                 break;
             case 'url':
                 // remove facebook urls
                 if (!preg_match('/^fb:\\/\\//', $data->{$fieldName})) {
                     $contact->{$value} = $data->{$fieldName};
                 }
                 break;
             default:
                 $contact->{$value} = $data->{$fieldName};
                 break;
         }
     }
     // force update of n_fileas and n_fn
     $contact->setFromArray(array('n_given' => $contact->n_given, 'n_family' => $contact->n_family, 'org_name' => $contact->org_name));
     // either "org_name" or "n_family" must be given!
     if (empty($contact->org_name) && empty($contact->n_family)) {
         $contact->n_family = 'imported';
     }
     // contact should be valid now
     $contact->isValid();
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " contactData " . print_r($contact->toArray(), true));
     }
     return $contact;
//.........这里部分代码省略.........
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:ActiveSync.php


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