本文整理汇总了PHP中ezpObject::addTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP ezpObject::addTranslation方法的具体用法?PHP ezpObject::addTranslation怎么用?PHP ezpObject::addTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezpObject
的用法示例。
在下文中一共展示了ezpObject::addTranslation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue18249
/**
* @group issue18249
*/
public function testIssue18249()
{
// setup a class C1 with objectrelationlist and pattern name
$classIdentifier = strtolower( __FUNCTION__ );
$class1 = new ezpClass(
__FUNCTION__, $classIdentifier, '<test_name><test_relation>'
);
$class1->add( 'Test name', 'test_name', 'ezstring' );
$class1->add( 'Test Relation', 'test_relation', 'ezobjectrelationlist' );
$class1->store();
$o1 = new ezpObject( 'article', 2, 14, 1, 'eng-GB' );
$o1->title = 'Test_ENG';
$o1->publish();
$o1->addTranslation( 'xxx-XX', array( 'title' => 'Test_XXX' ) );
$o2 = new ezpObject( $classIdentifier, 2, 14, 1, 'xxx-XX' );
$o2->test_name = 'name_';
$o2->test_relation = array( $o1->attribute( 'id' ) );
$o2->publish();
// test O2's name
$this->assertEquals( 'name_Test_XXX', $o2->name );
}
示例2: testLinksAcrossTranslations
/**
* Test scenario for issue #13492: Links are lost after removing version
*
* Test Outline
* ------------
* 1. Create a Folder in English containing a link (in the short_description attribute).
* 2. Translate Folder into Norwegian containing another link (not the same link as above.)
* 3. Remove Folder version 1. (Version 2 is created when translating).
*
* @result: short_description in version 2 will have an empty link.
* @expected: short_description should contain same link as in version 1.
* @link http://issues.ez.no/13492
*/
public function testLinksAcrossTranslations()
{
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'eng-GB');
$xmlDataEng = '<link href="/some-where-random">a link</link>';
$xmlDataNor = '<link href="/et-tilfeldig-sted">en link</link>';
// Step 1: Create folder
$folder = new ezpObject("folder", 2);
$folder->name = "Folder Eng";
$folder->short_description = $xmlDataEng;
$folder->publish();
$version1Xml = $folder->short_description->attribute('output')->attribute('output_text');
// Step 2: Translate folder
$trData = array("name" => "Folder Nor", "short_description" => $xmlDataNor);
$folder->addTranslation("nor-NO", $trData);
// addTranslation() publishes too.
// Step 3: Remove version 1
$version1 = eZContentObjectVersion::fetchVersion(1, $folder->id);
$version1->removeThis();
// Grab current versions data and make sure it's fresh.
$folder->refresh();
$version2Xml = $folder->short_description->attribute('output')->attribute('output_text');
$folder->remove();
ezpINIHelper::restoreINISettings();
self::assertEquals($version1Xml, $version2Xml);
}
示例3: testIssue19174
/**
* Regression test for issue {@see #19174 http://issues.ez.no/19174}
*/
public function testIssue19174()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// create related objects
$relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
$xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
$xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
// Create an article in eng-GB, and embed related object one in the intro
$article = new ezpObject('article', 2, 14, 1, 'eng-GB');
$article->title = __METHOD__ . ' eng-GB';
$article->intro = $xmlTextEn;
$articleId = $article->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
$relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
self::assertEquals(4, count($relatedObjects));
$expectedRelations = array_flip($relatedObjectsIds);
foreach ($relatedObjects as $relatedObject) {
if (isset($expectedRelations[$relatedObject->ID])) {
unset($expectedRelations[$relatedObject->ID]);
}
}
self::assertEquals(0, count($expectedRelations));
$article->remove();
$translation->removeThis();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例4: testIssue18249
public function testIssue18249()
{
// setup a class C1 with objectrelationlist and pattern name
$class1 = new ezpClass('TestClass1', 'testclass1', '<test_name><test_relation>');
$class1->add('Test name', 'test_name', 'ezstring');
$class1->add('Test Relation', 'test_relation', 'ezobjectrelationlist');
$class1->store();
// create an object O1 with eng and nor
$o1 = new ezpObject('article', false, 14, 1, 'nor-NO');
$o1->title = 'Test_NOR';
$o1->publish();
$o1->addTranslation('nor-NO', array('title' => 'Test_NOR'));
// create an object O2 based on C1 with Nor
$o2 = new ezpObject('testclass1', false, 14, 1, 'nor-NO');
$o2->test_name = 'name_';
$o2->test_relation = array($o1->attribute('id'));
$o2->publish();
// test O2's name
$this->assertEquals('name_Test_NOR', $o2->name);
}
示例5: testIssue17632
/**
* Regression test for issue {@see #17632 http://issues.ez.no/17632}
*
* In a multi language environment, a node fetched with a language other than the prioritized one(s) will return the
* URL alias in the prioritized language
*/
public function testIssue17632()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
$strNameEngGB = __FUNCTION__ . " eng-GB";
$strNameFreFR = __FUNCTION__ . " fre-FR";
// add a secondary language
$locale = eZLocale::instance( 'fre-FR' );
$translation = eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
// set the prioritize language list to contain english
// ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) );
eZContentLanguage::setPrioritizedLanguages( array( 'fre-FR' ) );
// Create an object with data in fre-FR and eng-GB
$folder = new ezpObject( 'folder', 2, 14, 1, 'eng-GB' );
$folder->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$folder->addTranslation( 'eng-GB', array( 'name' => $strNameEngGB ) );
$folder->addTranslation( 'fre-FR', array( 'name' => $strNameFreFR ) );
$nodeId = $folder->main_node_id;
// fetch the node with no default parameters. Should return the french URL Alias
$node = eZContentObjectTreeNode::fetch( $nodeId );
self::assertEquals( 'testIssue17632-fre-FR' , $node->attribute( 'url_alias' ) );
// fetch the node in english. Should return the english URL Alias
$node = eZContentObjectTreeNode::fetch( $nodeId, 'eng-GB' );
self::assertEquals( 'testIssue17632-eng-GB' , $node->attribute( 'url_alias' ) );
ezpINIHelper::restoreINISettings();
eZContentLanguage::setPrioritizedLanguages( $bkpLanguages );
}
示例6: testFetchPathByActionListWithFallback
/**
* Ensures that eZURLAliasML::fetchPathByActionList() always uses prioritized languages,
* even if a locale is enforced (3rd param) and always available flag is false.
*
* @see http://issues.ez.no/19055
* @group issue19055
* @covers eZURLAliasML::fetchPathByActionList
*/
public function testFetchPathByActionListWithFallback()
{
$frenchLocale = $this->frenchLanguage->attribute('locale');
ezpINIHelper::setINISettings(array(array('site.ini', 'RegionalSettings', 'ContentObjectLocale', $frenchLocale), array('site.ini', 'RegionalSettings', 'Locale', $frenchLocale), array('site.ini', 'RegionalSettings', 'SiteLanguageList', array($frenchLocale, 'eng-GB')), array('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled')));
eZContentOperationCollection::updateAlwaysAvailable(1, false);
/*
* - Create a content object in Norsk
* - Remove AlwaysAvailable flag
* - Add a translation in english
* - Try to fetch path for this content in French (fallback is eng-GB as configured above)
*/
$folder = new ezpObject('folder', 2, 14, 1, $this->norskLanguage->attribute('locale'));
$folder->name = 'norsk folder';
$folder->publish();
eZContentOperationCollection::updateAlwaysAvailable($folder->object->attribute('id'), false);
$folder->refresh();
$folder->addTranslation('eng-GB', array('name' => 'english translation'));
$folder->publish();
$generatedPath = eZURLAliasML::fetchPathByActionList('eznode', array($folder->mainNode->node_id), $frenchLocale);
self::assertNotNull($generatedPath);
self::assertEquals('english-translation', $generatedPath);
eZContentOperationCollection::updateAlwaysAvailable(1, true);
ezpINIHelper::restoreINISettings();
$folder->remove();
}
示例7: testIssue016395
/**
* Test mainNode()
*
* create object like this structure:
*
* rootnode(folder) - objectNode1(folder) - obj(article, language: default and nor-NO)
* \ objectNode2(folder) /
*/
public function testIssue016395()
{
//create two nodes with one object
$parentNode = new ezpObject('folder', 2);
$parentNode->publish();
$objectNode1 = new ezpObject('folder', $parentNode->mainNode->node_id);
$objectNode1->publish();
$objectNode2 = new ezpObject('folder', $parentNode->mainNode->node_id);
$objectNode2->publish();
$obj = new ezpObject('article', $objectNode1->mainNode->node_id);
$obj->title = 'English article';
$obj->body = 'This an English article';
$obj->publish();
$obj->addNode($objectNode2->mainNode->node_id);
//create a translation
$languageData = array();
$languageData['title'] = 'Norsk artikkel';
$languageData['body'] = 'Dette er en norsk artikkel.';
$obj->addTranslation('nor-NO', $languageData);
//assert the main language and translation language
$objectMainNode = $obj->object->mainNode();
$this->assertEquals('English article', $objectMainNode->getName());
$this->assertEquals('Norsk artikkel', $objectMainNode->getName('nor-NO'));
$tempLanguage = $objectMainNode->currentLanguage();
$objectMainNode->setCurrentLanguage('nor-NO');
$this->assertEquals('Norsk artikkel', $objectMainNode->attribute('name'));
$objectMainNode->setCurrentLanguage($tempLanguage);
}
示例8: testURLAliasSplitParentTranslation
/**
* Tests a problem which arose when a combined URL entry,
* representing several translations are split up, by one translation being
* changed to to an earlier history entry, of that same entry.
*
*/
function testURLAliasSplitParentTranslation()
{
$db = eZDB::instance();
// STEP 1: Add test folder
$folder = new ezpObject("folder", 2);
$folder->name = __FUNCTION__;
$folder->publish();
// STEP 2: Add child below folder
$child = new ezpObject("folder", $folder->mainNode->node_id);
$child->name = "Child";
$child->publish();
// Sub-sub children disabled for now, might be used in future, for
// further assertions.
// // STEP 2a: Add a sub-sub child
// $subChild1 = new ezpObject( 'article', $child->mainNode->node_id );
// $subChild1->title = "SubChild";
// $subChild1->publish();
//
// // STEP 2b: Add a sub-sub child
// $subChild2 = new ezpObject( 'article', $child->mainNode->node_id );
// $subChild2->title = "SubChildOther";
// $subChild2->publish();
//
// // STEP 2ba: Adding sub-sub child translation
// $norSubChild2Trans = array( "title" => "SubChildOtherNor" );
// $subChild2->addTranslation( "nor-NO", $norSubChild2Trans );
//
// // STEP 2c: Add a sub-sub child
// $subChild3 = new ezpObject( 'article', $child->mainNode->node_id );
// $subChild3->title = "SubChildThird";
// $subChild3->publish();
//
// // STEP 2ca: Addubg sub-sub child translation
// $norSubChild3Trans = array( "title" => "SubChildThird" );
// $subChild3->addTranslation( "nor-NO", $norSubChild3Trans );
// STEP 3: Add translation to child with the same name
$translationAttributes = array("name" => "Child");
$child->addTranslation("nor-NO", $translationAttributes);
// STEP 4: Update the translation
$child->refresh();
$newVersion = $child->createNewVersion(false, true, 'nor-NO');
$norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
$norDataMap['name']->setAttribute('data_text', 'NorChildChanged');
$norDataMap['name']->store();
ezpObject::publishContentObject($child->object, $newVersion);
// STEP 5:
$child->refresh();
$child->name = "Renamed child";
$child->publish();
// STEP 6:
$child->refresh();
$child->name = "Child changed";
$child->publish();
// STEP 7:
$child->refresh();
$newVersion = $child->createNewVersion(false, true, 'nor-NO');
$norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
$norDataMap['name']->setAttribute('data_text', 'NorChildChanged again');
$norDataMap['name']->store();
ezpObject::publishContentObject($child->object, $newVersion);
// STEP 8:
$child->refresh();
$newVersion = $child->createNewVersion(false, true, 'nor-NO');
$norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
$norDataMap['name']->setAttribute('data_text', 'Child changed');
$norDataMap['name']->store();
ezpObject::publishContentObject($child->object, $newVersion);
// STEP 9:
$child->refresh();
$newVersion = $child->createNewVersion(false, true, 'nor-NO');
$norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
$norDataMap['name']->setAttribute('data_text', 'NorChildChanged again');
$norDataMap['name']->store();
ezpObject::publishContentObject($child->object, $newVersion);
$query = self::buildSql(array($child->mainNode->node_id));
$result = $db->arrayQuery($query);
$initialTranslationChild = self::urlEntryForName("Child-changed", $result);
$translationChild = self::urlEntryForName('NorChildChanged-again', $result);
self::assertEquals((int) $initialTranslationChild['id'], (int) $translationChild['id'], "Current translations of the same node need to have the same id.");
}
示例9: testIssue23753
/**
* Regression test for issue {@see #23753 http://issues.ez.no/23753}
*
* In a multi language environment, an untranslated node fetched with default language will return the
* full URL alias in the language of the node.
*/
public function testIssue23753()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
$strNameEngGB = __FUNCTION__ . " eng-GB";
$strNameFreFR = __FUNCTION__ . " fre-FR";
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// set the prioritize language list to contain english
eZContentLanguage::setPrioritizedLanguages(array('fre-FR', 'eng-GB'));
// Create an object with data in fre-FR and eng-GB
$folder = new ezpObject('folder', 2, 14, 1, 'eng-GB');
$folder->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$folder->addTranslation('eng-GB', array('name' => $strNameEngGB));
$folder->addTranslation('fre-FR', array('name' => $strNameFreFR));
$article = new ezpObject('article', $folder->main_node_id, 14, 1, 'eng-GB');
$article->publish();
// Workaround as setting article->name directly doesn't produce the expected result
$article->addTranslation('eng-GB', array('title' => $strNameEngGB));
$nodeId = $article->main_node_id;
// fetch the node with no default parameters. Should return the french URL Alias when applicable
$node = eZContentObjectTreeNode::fetch($nodeId);
self::assertEquals('testIssue23753-fre-FR/testIssue23753-eng-GB', $node->attribute('url_alias'));
// fetch the node in english. Should return the full english URL Alias
$node = eZContentObjectTreeNode::fetch($nodeId, 'eng-GB');
self::assertEquals('testIssue23753-eng-GB/testIssue23753-eng-GB', $node->attribute('url_alias'));
// Test that PathPrefix is correctly removed from UrlAlias
ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'PathPrefix', 'testIssue23753-fre-FR');
$node = eZContentObjectTreeNode::fetch($nodeId);
self::assertEquals('testIssue23753-eng-GB', $node->attribute('url_alias'));
$folder->remove();
$translation->removeThis();
ezpINIHelper::restoreINISettings();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}