本文整理汇总了PHP中Tinebase_Translation::getCountryNameByRegionCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Translation::getCountryNameByRegionCode方法的具体用法?PHP Tinebase_Translation::getCountryNameByRegionCode怎么用?PHP Tinebase_Translation::getCountryNameByRegionCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Translation
的用法示例。
在下文中一共展示了Tinebase_Translation::getCountryNameByRegionCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetCountryNameByRegionCode
/**
* test getCountryNameByRegionCode
*/
public function testGetCountryNameByRegionCode()
{
Tinebase_Core::setupUserLocale('de_DE');
$this->assertEquals('Deutschland', Tinebase_Translation::getCountryNameByRegionCode('DE'));
$this->assertEquals('Vereinigte Staaten', Tinebase_Translation::getCountryNameByRegionCode('US'));
$this->assertNull(Tinebase_Translation::getCountryNameByRegionCode('XX'));
Tinebase_Core::setupUserLocale('en_US');
$this->assertEquals('Germany', Tinebase_Translation::getCountryNameByRegionCode('DE'));
$this->assertEquals('United States', Tinebase_Translation::getCountryNameByRegionCode('US'));
}
示例2: testAppendXmlPalm
/**
* validate xml generation for all devices except IPhone
*/
public function testAppendXmlPalm()
{
$imp = new DOMImplementation();
$dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN", "http://www.microsoft.com/");
$testDom = $imp->createDocument('uri:AirSync', 'Sync', $dtd);
$testDom->formatOutput = true;
$testDom->encoding = 'utf-8';
$testDom->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:Contacts', 'uri:Contacts');
$testNode = $testDom->documentElement->appendChild($testDom->createElementNS('uri:AirSync', 'TestAppendXml'));
$controller = new ActiveSync_Controller_Contacts($this->objects['deviceWebOS'], new Tinebase_DateTime());
$controller->appendXML($testNode, null, $this->objects['contact']->getId(), array());
$controller->appendXML($testNode, null, $this->objects['contact']->getId(), array());
$this->assertEquals(Tinebase_Translation::getCountryNameByRegionCode('DE'), @$testDom->getElementsByTagNameNS('uri:Contacts', 'BusinessCountry')->item(0)->nodeValue, $testDom->saveXML());
$this->assertEquals('1975-01-02T03:00:00.000Z', @$testDom->getElementsByTagNameNS('uri:Contacts', 'Birthday')->item(0)->nodeValue, $testDom->saveXML());
}
示例3: appendXML
/**
* append contact data to xml element
*
* @param DOMElement $_domParrent the parrent xml node
* @param string $_folderId the local folder id
* @param string $_serverId the local entry id
* @param boolean $_withBody retrieve body of entry
*/
public function appendXML(DOMElement $_domParrent, $_collectionData, $_serverId)
{
$_domParrent->ownerDocument->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:Contacts', 'uri:Contacts');
$data = $_serverId instanceof Tinebase_Record_Abstract ? $_serverId : $this->_contentController->get($_serverId);
foreach ($this->_mapping as $key => $value) {
if (!empty($data->{$value}) || $data->{$value} == '0') {
$nodeContent = null;
switch ($value) {
case 'bday':
if ($data->{$value} instanceof DateTime) {
$nodeContent = $data->bday->format("Y-m-d\\TH:i:s") . '.000Z';
}
break;
case 'jpegphoto':
try {
$image = Tinebase_Controller::getInstance()->getImage('Addressbook', $data->getId());
$jpegData = $image->getBlob('image/jpeg', 36000);
$nodeContent = base64_encode($jpegData);
} catch (Exception $e) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Image for contact {$data->getId()} not found or invalid");
}
break;
case 'adr_one_countryname':
case 'adr_two_countryname':
$nodeContent = Tinebase_Translation::getCountryNameByRegionCode($data->{$value});
break;
default:
$nodeContent = $data->{$value};
break;
}
// skip empty elements
if ($nodeContent === null || $nodeContent == '') {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Value for {$key} is empty. Skip element.");
continue;
}
// strip off any non printable control characters
if (!ctype_print($nodeContent)) {
$nodeContent = $this->removeControlChars($nodeContent);
}
$node = $_domParrent->ownerDocument->createElementNS('uri:Contacts', $key);
$node->appendChild($_domParrent->ownerDocument->createTextNode($nodeContent));
$_domParrent->appendChild($node);
}
}
if (!empty($data->note)) {
if (version_compare($this->_device->acsversion, '12.0', '>=') === true) {
$body = $_domParrent->appendChild(new DOMElement('Body', null, 'uri:AirSyncBase'));
$body->appendChild(new DOMElement('Type', 1, 'uri:AirSyncBase'));
// create a new DOMElement ...
$dataTag = new DOMElement('Data', null, 'uri:AirSyncBase');
// ... append it to parent node aka append it to the document ...
$body->appendChild($dataTag);
// ... and now add the content (DomText takes care of special chars)
$dataTag->appendChild(new DOMText($data->note));
} else {
// create a new DOMElement ...
$node = new DOMElement('Body', null, 'uri:Contacts');
// ... append it to parent node aka append it to the document ...
$_domParrent->appendChild($node);
// ... and now add the content (DomText takes care of special chars)
$node->appendChild(new DOMText($data->note));
}
}
if (isset($data->tags) && count($data->tags) > 0) {
$categories = $_domParrent->appendChild(new DOMElement('Categories', null, 'uri:Contacts'));
foreach ($data->tags as $tag) {
$categories->appendChild(new DOMElement('Category', $tag, 'uri:Contacts'));
}
}
}
示例4: toSyncrotonModel
/**
* (non-PHPdoc)
* @see ActiveSync_Frontend_Abstract::toSyncrotonModel()
*/
public function toSyncrotonModel($entry, array $options = array())
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " contact data " . print_r($entry->toArray(), TRUE));
}
$syncrotonContact = new Syncroton_Model_Contact();
foreach ($this->_mapping as $syncrotonProperty => $tine20Property) {
// skip empty values
if (empty($entry->{$tine20Property}) && $entry->{$tine20Property} != '0' || count($entry->{$tine20Property}) === 0) {
continue;
}
switch ($tine20Property) {
case 'adr_one_countryname':
case 'adr_two_countryname':
$syncrotonContact->{$syncrotonProperty} = Tinebase_Translation::getCountryNameByRegionCode($entry->{$tine20Property});
break;
case 'bday':
$syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property};
if ($this->_device->devicetype == Syncroton_Model_Device::TYPE_BLACKBERRY && version_compare($this->_device->getMajorVersion(), '10', '>=')) {
// BB 10+ expects birthday to be at noon
$syncrotonContact->{$syncrotonProperty}->addHour(12);
}
break;
case 'note':
$syncrotonContact->{$syncrotonProperty} = new Syncroton_Model_EmailBody(array('type' => Syncroton_Model_EmailBody::TYPE_PLAINTEXT, 'data' => $entry->{$tine20Property}));
break;
case 'jpegphoto':
try {
$syncrotonContact->{$syncrotonProperty} = $entry->getSmallContactImage();
} catch (Exception $e) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Image for contact {$entry->getId()} not found or invalid");
}
break;
// @todo validate tags are working
// @todo validate tags are working
case 'tags':
$syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property}->name;
break;
default:
$syncrotonContact->{$syncrotonProperty} = $entry->{$tine20Property};
break;
}
}
return $syncrotonContact;
}