本文整理汇总了PHP中ezpObject::refresh方法的典型用法代码示例。如果您正苦于以下问题:PHP ezpObject::refresh方法的具体用法?PHP ezpObject::refresh怎么用?PHP ezpObject::refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezpObject
的用法示例。
在下文中一共展示了ezpObject::refresh方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue14983
/**
* Regression test for issue #14983
*
* @link http://issues.ez.no/14983
**/
public function testIssue14983()
{
$className = 'eZImageType test class';
$classIdentifier = 'ezimagetype_test_class';
$attributeName = 'Image';
$attributeIdentifier = 'image';
$attributeType = 'ezimage';
$filePath = 'tests/tests/kernel/datatypes/ezimage/ezimagetype_regression_issue14983.png';
$class = new ezpClass($className, $classIdentifier, $className);
$classAttribute = $class->add($attributeName, $attributeIdentifier, $attributeType);
$class->store();
$object = new ezpObject($classIdentifier, 2);
$object->name = __FUNCTION__;
$dataMap = $object->object->dataMap();
$fileAttribute = $dataMap[$attributeIdentifier];
$dataType = new eZImageType();
$dataType->fromString($fileAttribute, $filePath);
$fileAttribute->store();
$object->publish();
$object->refresh();
$contentObjectAttributeID = $fileAttribute->attribute("id");
$files = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID);
$file = $files[0];
// Read stored path, move to trash, and read stored path again
$this->assertNotEquals($file, null);
$oldFile = $file;
$object->object->removeThis();
$object->refresh();
$files = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID);
$file = $files[0];
$this->assertNotEquals($oldFile, $file, 'The stored file should be renamed when trashed');
}
示例2: testIssue15155
/**
* Regression test for issue #15155
*
* @link http://issues.ez.no/15155
*/
public function testIssue15155()
{
// figure out the max versions for images
$contentINI = eZINI::instance('content.ini');
$versionlimit = $contentINI->variable('VersionManagement', 'DefaultVersionHistoryLimit');
$limitList = eZContentClass::classIDByIdentifier($contentINI->variable('VersionManagement', 'VersionHistoryClass'));
$classID = 5;
// image class, can remain hardcoded, I guess
foreach ($limitList as $key => $value) {
if ($classID == $key) {
$versionlimit = $value;
}
}
if ($versionlimit < 2) {
$versionlimit = 2;
}
$baseImagePath = dirname(__FILE__) . '/ezimagealiashandler_regression_issue15155.png';
$parts = pathinfo($baseImagePath);
$imagePattern = $parts['dirname'] . DIRECTORY_SEPARATOR . $parts['filename'] . '_%s_%d.' . $parts['extension'];
$toDelete = array();
// Create version 1
$imagePath = sprintf($imagePattern, md5(1), 1);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
$image = new ezpObject('image', 43);
$image->name = __FUNCTION__;
$image->image = $imagePath;
$image->publish();
$image->refresh();
$contentObjectID = $image->object->attribute('id');
$dataMap = eZContentObject::fetch($contentObjectID)->dataMap();
$originalAliases[1] = $image->image->imageAlias('original');
for ($i = 2; $i <= 20; $i++) {
// Create a new image file
$imagePath = sprintf($imagePattern, md5($i), $i);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
$newVersion = $image->createNewVersion();
$dataMap = $newVersion->dataMap();
$dataMap['image']->fromString($imagePath);
ezpObject::publishContentObject($image->object, $newVersion);
$image->refresh();
$originalAliases[$i] = $image->image->imageAlias('original');
if ($i > $versionlimit) {
$removeVersion = $i - $versionlimit;
$aliasPath = $originalAliases[$removeVersion]['url'];
$this->assertFalse(file_exists($aliasPath), "Alias {$aliasPath} for version {$removeVersion} should have been removed");
}
}
array_map('unlink', $toDelete);
$image->purge();
}
示例3: testIssue14983
/**
* Regression test for issue #14983
*
* @link http://issues.ez.no/14983
*/
public function testIssue14983()
{
$className = 'eZBinaryFileType test class';
$classIdentifier = 'ezbinaryfiletype_test_class';
$attributeName = 'File';
$attributeIdentifier = 'file';
$attributeType = 'ezbinaryfile';
$filePath = 'tests/tests/kernel/datatypes/ezbinaryfile/ezbinaryfiletype_regression_issue14983.txt';
$class = new ezpClass( $className, $classIdentifier, $className );
$classAttribute = $class->add( $attributeName, $attributeIdentifier, $attributeType );
$class->store();
$object = new ezpObject( $classIdentifier, 2 );
$object->name = __FUNCTION__;
{
$dataMap = $object->object->dataMap();
$fileAttribute = $dataMap[$attributeIdentifier];
{
$dataType = new eZBinaryFileType();
$dataType->fromString( $fileAttribute, $filePath );
}
$fileAttribute->store();
}
$object->publish();
$object->refresh();
$contentObjectAttributeID = $fileAttribute->attribute( "id" );
$files = eZBinaryFile::fetch( $contentObjectAttributeID );
foreach ( $files as $file )
{
// Read stored path, move to trash, and read stored path again
$this->assertNotEquals( $file, null );
$storedFileInfo = $file->storedFileInfo();
$storedFilePath = $storedFileInfo['filepath'];
$version = $file->attribute( 'version' );
$object->object->removeThis();
$object->refresh();
$file = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
$storedFileInfo = $file->storedFileInfo();
$storedFilePathAfterTrash = $storedFileInfo['filepath'];
$this->assertNotEquals( $storedFilePath, $storedFilePathAfterTrash, 'The stored file should be renamed when trashed' );
}
}
示例4: testIssue16078
/**
* Regression test for issue #16078
*
* @link http://issues.ez.no/16078
*/
public function testIssue16078()
{
$classID = 5;
// image class, can remain hardcoded, I guess
$baseImagePath = dirname(__FILE__) . '/ezimagefile_regression_issue16078.png';
$parts = pathinfo($baseImagePath);
$imagePattern = $parts['dirname'] . DIRECTORY_SEPARATOR . $parts['filename'] . '_%s_%d.' . $parts['extension'];
$toDelete = array();
// Create version 1
$imagePath = sprintf($imagePattern, md5(1), 1);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
$image = new ezpObject('image', 43);
$image->name = __FUNCTION__;
$image->image = $imagePath;
$image->publish();
$image->refresh();
$publishedDataMap = $image->object->dataMap();
$files = eZImageFile::fetchForContentObjectAttribute($publishedDataMap['image']->attribute('id'));
$publishedImagePath = $files[0];
// Create a new image file
$imagePath = sprintf($imagePattern, md5(2), 2);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
// Create version 2 in another language, and remove it
$languageCode = 'nor-NO';
$version = self::addTranslationDontPublish($image, $languageCode);
$version->removeThis();
// Check that the original file still exists
$this->assertTrue(file_exists($publishedImagePath), 'The image file from version 1 should still exist when version 2 is removed');
array_map('unlink', $toDelete);
$image->purge();
}
示例5: 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);
}
示例6: testIssue16400
/**
* Regression test for issue 16400
* @link http://issues.ez.no/16400
* @return unknown_type
*/
public function testIssue16400()
{
$className = 'Media test class';
$classIdentifier = 'media_test_class';
$filePath = 'tests/tests/kernel/datatypes/ezmedia/ezmediatype_regression_issue16400.flv';
eZFile::create($filePath);
$attributeName = 'Media';
$attributeIdentifier = 'media';
$attributeType = 'ezmedia';
//1. test method fetchByContentObjectID
$class = new ezpClass($className, $classIdentifier, $className);
$class->add($attributeName, $attributeIdentifier, $attributeType);
$attribute = $class->class->fetchAttributeByIdentifier($attributeIdentifier);
$attribute->setAttribute('can_translate', 0);
$class->store();
$object = new ezpObject($classIdentifier, 2);
$dataMap = $object->object->dataMap();
$fileAttribute = $dataMap[$attributeIdentifier];
$dataType = new eZMediaType();
$dataType->fromString($fileAttribute, $filePath);
$fileAttribute->store();
$object->publish();
$object->refresh();
//verify fetchByContentObjectID
$mediaObject = eZMedia::fetch($fileAttribute->attribute('id'), 1);
$medias = eZMedia::fetchByContentObjectID($object->object->attribute('id'));
$this->assertEquals($mediaObject->attribute('filename'), $medias[0]->attribute('filename'));
$medias = eZMedia::fetchByContentObjectID($object->object->attribute('id'), $fileAttribute->attribute('language_code'));
$this->assertEquals($mediaObject->attribute('filename'), $medias[0]->attribute('filename'));
//2. test issue
// create translation
$contentObject = $object->object;
$storedFileName = $mediaObject->attribute('filename');
$version = $contentObject->createNewVersionIn('nor-NO', $fileAttribute->attribute('language_code'));
$version->setAttribute('status', eZContentObjectVersion::STATUS_INTERNAL_DRAFT);
$version->store();
$version->removeThis();
$sys = eZSys::instance();
$dir = $sys->storageDirectory();
//verify the file is deleted
$storedFilePath = $dir . '/original/video/' . $storedFileName;
$file = eZClusterFileHandler::instance($storedFilePath);
$this->assertTrue($file->exists($storedFilePath));
if ($file->exists($storedFilePath)) {
unlink($storedFilePath);
}
}
示例7: testRestoreImageTrashed
/**
* Regression test for issue #17781
* @link http://issues.ez.no/17781
* @group issue17781
*/
public function testRestoreImageTrashed()
{
$this->imageObject->refresh();
$dataMap = $this->imageObject->dataMap();
self::assertArrayHasKey("image", $dataMap);
$untrashedBasename = $dataMap["image"]->content()->directoryPath();
unset($dataMap);
/*
* 1. Move the object to trash with eZContentObject::removeThis()
* 2. Refresh (clear in-memory cache...)
* 3. Artificially restore the object attributes
* 4. Refresh
*/
$this->imageObject->removeThis();
// Now image dir is different (see self::testIssue14983())
$this->imageObject->refresh();
$this->imageObject->restoreObjectAttributes();
$this->imageObject->refresh();
$dataMap = $this->imageObject->dataMap();
self::assertArrayHasKey("image", $dataMap);
self::assertSame($untrashedBasename, $dataMap["image"]->content()->directoryPath());
}
示例8: 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();
}
示例9: 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.");
}
示例10: createUser
/**
* Helper method that creates a new user.
* Currently only creates in users/guest_accounts.
* First and last name will be a splitup of username
*
* @param string $username
* @param string $password If not provided, uses the username as password
* @param string $email If not provided, uses '<username><at>test.ez.no'
*
* @return eZContentObject
*/
protected static function createUser($username, $password = false, $email = false)
{
$firstname = substr($username, 0, floor(strlen($username) / 2));
$lastname = substr($username, ceil(strlen($username) / 2));
if ($email === false) {
$email = "{$username}@test.ez.no";
}
if ($password === false) {
$password = $username;
}
$user = new ezpObject('user', eZContentObjectTreeNode::fetchByPath('users/guest_accounts'));
$user->first_name = $firstname;
$user->last_name = $lastname;
$user->user_account = $account = sprintf('%s|%s|%s|%d', $username, $email, eZUser::createHash($username, $password, eZUser::site(), eZUser::PASSWORD_HASH_MD5_USER), eZUser::PASSWORD_HASH_MD5_USER);
$user->publish();
$user->refresh();
return $user->object;
}