/** * 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'); }
/** * 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(); }
/** * Regression test for issue #14983 * Linked to #17781 * * @link http://issues.ez.no/14983 * @link http://issues.ez.no/17781 * @group issue14983 * @group issue17781 */ public function testIssue14983() { $files = eZImageFile::fetchForContentObjectAttribute($this->fileAttribute->attribute("id"), true); self::assertInternalType("array", $files); $file = $files[0]; unset($files); // Read stored path, move to trash, and read stored path again self::assertInstanceOf('eZImageFile', $file); $oldFile = $file; $this->imageObject->object->removeThis(); $this->imageObject->refresh(); $files = eZImageFile::fetchForContentObjectAttribute($this->fileAttribute->attribute("id"), true); self::assertInternalType("array", $files); $file = $files[0]; unset($files); self::assertInstanceOf('eZImageFile', $file); self::assertTrue(strpos($file->attribute("filepath"), '/trashed') !== false, "The stored file should be renamed when trashed"); }
/** * (called for each obj attribute) */ public function checkObjectAttribute(array $contentObjectAttribute) { // we adopt the ez api instead of acting on raw data $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute); $handler = $contentObjectAttribute->attribute('content'); $warnings = array(); // do not check attributes which do not even contain images if ($handler->attribute('is_valid')) { // get path to original file $original = $handler->attribute('original'); $filePath = $original['full_path']; // check if it is on fs (remember, images are clusterized) $file = eZClusterFileHandler::instance($filePath); if (!$file->exists()) { $warnings[] = array("Image file not found: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute)); } else { // if it is, check its size as well if ($this->maxSize > 0) { $maxSize = $this->maxSize * 1024 * 1024; if ($file->size() > $maxSize) { $warnings[] = "Image bigger than {$maxSize} bytes : " . $file->size() . $this->postfixErrorMsg($contentObjectAttribute); } } } // check if it is in custom table in db $image = eZImageFile::fetchByFilepath($contentObjectAttribute->attribute('id'), $filePath, false); if (!$image) { $warnings[] = "Image not found in ezimagefile table: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute); } } else { if (!$this->nullable) { $warnings[] = "Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute); } // q: are these old images possibly tied to older versions of the content ? /*$db = eZDB::instance(); $count = $db->arrayQuery('select count(*) as leftovers from ezimagefile where contentobject_attribute_id='.$contentObjectAttribute->attribute('id')); if($count[0]['leftovers']) { $warnings[] = "Leftovers in ezimageattribute table" . $this->postfixErrorMsg( $contentObjectAttribute ); }*/ } return $warnings; }
function trashStoredObjectAttribute($contentObjectAttribute, $version = null) { $contentObjectAttributeID = $contentObjectAttribute->attribute("id"); $imageHandler = $contentObjectAttribute->attribute('content'); $imageFiles = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID); foreach ($imageFiles as $imageFile) { if ($imageFile == null) { continue; } $existingFilepath = $imageFile; // Check if there are any other records in ezimagefile that point to that filename. $imageObjectsWithSameFileName = eZImageFile::fetchByFilepath(false, $existingFilepath); $file = eZClusterFileHandler::instance($existingFilepath); if ($file->exists() and count($imageObjectsWithSameFileName) <= 1) { $orig_dir = dirname($existingFilepath) . '/trashed'; $fileName = basename($existingFilepath); // create dest filename in the same manner as eZHTTPFile::store() // grab file's suffix $fileSuffix = eZFile::suffix($fileName); // prepend dot if ($fileSuffix) { $fileSuffix = '.' . $fileSuffix; } // grab filename without suffix $fileBaseName = basename($fileName, $fileSuffix); // create dest filename $newFileBaseName = md5($fileBaseName . microtime() . mt_rand()); $newFileName = $newFileBaseName . $fileSuffix; $newFilepath = $orig_dir . '/' . $newFileName; // rename the file, and update the database data $imageHandler->updateAliasPath($orig_dir, $newFileBaseName); if ($imageHandler->isStorageRequired()) { $imageHandler->store($contentObjectAttribute); $contentObjectAttribute->store(); } } } }
/** * Iterates over images referenced in data_text, and adds eZImageFile references * @param eZContentObjectAttribute $objectAttribute */ function postStore($objectAttribute) { $objectAttributeId = $objectAttribute->attribute("id"); if (($doc = simplexml_load_string($objectAttribute->attribute("data_text"))) === false) { return; } // Creates ezimagefile entries foreach ($doc->xpath("//*/@url") as $url) { $url = (string) $url; if ($url === "") { continue; } eZImageFile::appendFilepath($objectAttributeId, $url, true); } }
/** * @param int $contentObjectId * @param string $file * @return eZImageFile|null */ protected static function fetchImageFile($contentObjectAttributeId, $file) { return eZImageFile::fetchObject(eZImageFile::definition(), null, array('contentobject_attribute_id' => $contentObjectAttributeId, 'filepath' => $file)); }
* @version 2014.11.1 */ require_once 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "Re-creates missing references to image files in ezimagefile. See issue EZP-21324\n", 'use-session' => true, 'use-modules' => false, 'use-extensions' => true)); $script->startup(); $options = $script->getOptions("[dry-run]", "", array('n' => 'Dry run')); $optDryRun = (bool) $options['dry-run']; $script->initialize(); $imageAttributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), array('id', 'contentobject_id', 'version', 'data_text'), array('data_type_string' => 'ezimage'), null, null, false); $cli->output("Re-creating missing ezcontentobject_attribute / ezimagefile references"); if ($optDryRun) { $cli->warning("dry-run mode"); } foreach ($imageAttributes as $imageAttribute) { if (($doc = simplexml_load_string($imageAttribute["data_text"])) === false) { continue; } // Creates ezimagefile entries foreach ($doc->xpath("//*/@url") as $url) { $url = (string) $url; echo "Processing {$imageAttribute['contentobject_id']}#{$imageAttribute['version']} ({$url})\n"; if ($url === "") { continue; } if (eZImageFile::appendFilepath($imageAttribute['id'], $url)) { $cli->output("Restored link from {$url} to {$imageAttribute['id']}"); } } } $script->shutdown();
$progressBar = new ezcConsoleProgressbar( $output, $nbImageFiles, $progressBarOptions ); // Loop the image files and check if it is still used by a content object attribute. If not, delete it. foreach( $aImageFiles as $image ) { $filePath = $image->attribute( 'filepath' ); $dirpath = dirname( $filePath ); $contentObjectAttributeID = $image->attribute( 'contentobject_attribute_id' ); $dbResult = eZImageFile::fetchImageAttributesByFilepath( $filePath, $contentObjectAttributeID ); if( count( $dbResult ) == 0 ) { $file = eZClusterFileHandler::instance( $filePath ); if ( $file->exists() ) // Delete the file physically { $file->delete(); eZImageFile::removeFilepath( $contentObjectAttributeID, $filePath ); eZDir::cleanupEmptyDirectories( $dirpath ); } // Delete the obsolete reference in the database $image->remove(); } $progressBar->advance(); } $progressBar->finish(); $output->outputLine(); } else {
static function removeForContentObjectAttribute( $contentObjectAttributeID ) { eZPersistentObject::removeObject( eZImageFile::definition(), array( 'contentobject_attribute_id' => $contentObjectAttributeID ) ); }
function initialize($mimeData, $originalFilename, $imageAltText = false) { $imageManager = eZImageManager::factory(); $this->setOriginalAttributeDataValues($this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code']); $aliasList = array('original' => $mimeData); $aliasList['original']['alternative_text'] = $imageAltText; $aliasList['original']['original_filename'] = $originalFilename; $fileHandler = eZClusterFileHandler::instance(); $filePath = $mimeData['url']; $fileHandler->fileStore($filePath, 'image', false, $mimeData['name']); if ($imageManager->createImageAlias('original', $aliasList, array('basename' => $mimeData['basename']))) { $mimeData = $aliasList['original']; $mimeData['name'] = $mimeData['mime_type']; $aliasList['original']['original_filename'] = $originalFilename; } if ($aliasList['original']['url']) { $aliasFile = eZClusterFileHandler::instance($aliasList['original']['url']); if ($aliasFile->exists()) { $aliasList['original']['filesize'] = $aliasFile->size(); } } // refetch the original image $fileHandler->fileFetch($filePath); $imageManager->analyzeImage($mimeData); $doc = new DOMDocument('1.0', 'utf-8'); $imageNode = $doc->createElement("ezimage"); $doc->appendChild($imageNode); $width = false; $height = false; $info = getimagesize($mimeData['url']); if ($info) { $width = $info[0]; $height = $info[1]; } $originalNode = $doc->createElement("original"); $imageNode->appendChild($originalNode); $attributeData = $this->originalAttributeData(); $this->createOriginalAttributeXMLData($originalNode, $attributeData); $imageNode->setAttribute('serial_number', $this->imageSerialNumber()); $imageNode->setAttribute('is_valid', true); $imageNode->setAttribute('filename', $mimeData['filename']); $imageNode->setAttribute('suffix', $mimeData['suffix']); $imageNode->setAttribute('basename', $mimeData['basename']); $imageNode->setAttribute('dirpath', $mimeData['dirpath']); $imageNode->setAttribute('url', $mimeData['url']); $imageNode->setAttribute('original_filename', $originalFilename); $imageNode->setAttribute('mime_type', $mimeData['name']); $imageNode->setAttribute('width', $width); $imageNode->setAttribute('height', $height); $imageNode->setAttribute('alternative_text', $imageAltText); $imageNode->setAttribute('alias_key', $imageManager->createImageAliasKey($imageManager->alias('original'))); $imageNode->setAttribute('timestamp', time()); $this->createImageInformationNode($imageNode, $mimeData); $this->setDOMTree($doc); $this->setAliasList($aliasList); eZImageFile::appendFilepath($this->ContentObjectAttributeData['id'], $mimeData['url']); $fileHandler->fileDeleteLocal($filePath); return true; }
public function restoreTrashedObjectAttribute($contentObjectAttribute) { $imageHandler = $contentObjectAttribute->attribute("content"); $originalAlias = $imageHandler->imageAlias("original"); $originalPath = str_replace("/trashed", "", $originalAlias["dirpath"]); $originalName = $imageHandler->imageName($contentObjectAttribute, $contentObjectAttribute->objectVersion()); $imageHandler->updateAliasPath($originalPath, $originalName); if ($imageHandler->isStorageRequired()) { $imageHandler->store($contentObjectAttribute); $contentObjectAttribute->store(); } // Now clean all other aliases, not cleanly registered within the attribute content // First get all remaining aliases full path to then safely remove them $aliasNames = array_keys($imageHandler->aliasList()); $aliasesPath = array(); foreach ($aliasNames as $aliasName) { if ($aliasName === "original") { continue; } $aliasesPath[] = "{$originalAlias["dirpath"]}/{$originalAlias["basename"]}_{$aliasName}.{$originalAlias["suffix"]}"; } if (empty($aliasesPath)) { return; } $conds = array("contentobject_attribute_id" => $contentObjectAttribute->attribute("id"), "filepath" => array($aliasesPath)); $remainingAliases = eZPersistentObject::fetchObjectList(eZImageFile::definition(), null, $conds); unset($conds, $remainingAliasesPath); if (!empty($remainingAliases)) { foreach ($remainingAliases as $remainingAlias) { $filename = basename($remainingAlias->attribute("filepath")); $newFilePath = $originalPath . "/" . $originalName . substr($filename, strrpos($filename, '_')); eZClusterFileHandler::instance($remainingAlias->attribute("filepath"))->move($newFilePath); // $newFilePath might have already been processed in eZImageFile // If so, $remainingAlias is a duplicate. We can then remove it safely $imageFile = eZImageFile::fetchByFilepath(false, $newFilePath, false); if (empty($imageFile)) { $remainingAlias->setAttribute("filepath", $newFilePath); $remainingAlias->store(); } else { $remainingAlias->remove(); } } } }
} } } $mimeData = eZMimeType::findByFileContents($fileName); $imageManager->analyzeImage($mimeData); $imageNode->setAttribute('serial_number', false); $imageNode->setAttribute('is_valid', $isValid); $imageNode->setAttribute('filename', $fileName); $imageNode->setAttribute('suffix', $suffix); $imageNode->setAttribute('basename', $baseName); $imageNode->setAttribute('dirpath', $dirPath); $imageNode->setAttribute('url', $filePath); $imageNode->setAttribute('original_filename', $originalFileName); $imageNode->setAttribute('mime_type', $mimeType); $imageNode->setAttribute('width', $width); $imageNode->setAttribute('height', $height); $imageNode->setAttribute('alternative_text', $altText); $imageNode->setAttribute('alias_key', $imageManager->createImageAliasKey($imageManager->alias('original'))); $imageNode->setAttribute('timestamp', time()); $imageAliasHandler->createImageInformationNode($imageNode, $mimeData); $imageAliasHandler->storeDOMTree($doc, true, false); eZImageFile::appendFilepath($attributeID, $filePath); unset($doc); } $script->iterate($cli, !$success); } $db->commit(); // drop tables of old image system $db->query('DROP TABLE ezimage'); $db->query('DROP TABLE ezimagevariation'); $script->shutdown(0);
/** * Attempt to remove content object 'image' attribute image variations by content object attribute * * @param object $contentClassImageAttribute object of objects of class eZContentObjectAttribute * @param array $class Array of object class identifiers to remove aliases for only these classes. Optional. Defaults to false * @param array $attributes Array of object image attribute identifiers to remove aliases from. Optional. Defaults to false * @param array $aliases Array of object image attribute image aliases to remove. Optional. Defaults to false * * @return bool true if successful, false otherwise * @static */ static function removeByAttribute($contentObjectAttribute = false, $classes = false, $attributes = false, $aliases = false) { if (!is_object($contentObjectAttribute)) { return false; } // Test that content object class attribute identifier matches provided classes if ($classes != false && is_array($classes) && !in_array($contentObjectAttribute->attribute('object')->attribute('class_identifier'), $classes)) { return false; } // Test that content object class attribute identifier matches provided classes if ($attributes != false && is_array($attributes) && !in_array($contentObjectAttribute->attribute('contentclass_attribute_identifier'), $attributes)) { return false; } // Default datatypes to create image alias variations $imageDataTypeStrings = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'ImageDataTypeStringList'); // Check that content object attribute data type string matches allowed datatype settings if (!in_array($contentObjectAttribute->attribute('data_type_string'), $imageDataTypeStrings) || !$contentObjectAttribute->attribute('has_content')) { return false; } $filePaths = array(); $results = array(); $executionOptions = self::executionOptions(); $messageCount = 0; $imageHandler = $contentObjectAttribute->attribute('content'); $aliasList = $imageHandler->aliasList(false); // Do not process the orginal image alias unset($aliasList['original']); if (count($aliasList) == 0) { return false; } // Optional debug output if ($executionOptions['troubleshoot'] && $executionOptions['verboseLevel'] >= 2) { if ($executionOptions['verboseLevel'] >= 3) { self::displayMessage('All attribute image aliases stored in content data text field:', false); self::displayMessage($contentObjectAttribute->attribute('data_text'), "\n"); } if ($executionOptions['verboseLevel'] >= 4) { self::displayMessage('All attribute image aliases stored in content alias list:', false); print_r($aliasList); self::displayMessage('', "\n\n"); } elseif ($executionOptions['verboseLevel'] >= 3) { self::displayMessage('All attribute image aliases stored in content alias list:', false); print_r(array_keys($aliasList)); self::displayMessage('', "\n"); } } $contentObjectID = $contentObjectAttribute->attribute('contentobject_id'); $contentObjectAttributeID = $contentObjectAttribute->attribute('id'); $contentObjectAttributeVersion = $contentObjectAttribute->attribute('version'); if ($contentObjectAttributeVersion === null) { $files = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID, true); $dirs = array(); $count = 0; // Iterate over files foreach ($files as $filepath) { // Test $filepath from $files is in contains one of the $aliases items if ($aliases != false && is_array($aliases)) { foreach ($aliases as $alias) { if (!stristr('_' . $alias, $filepath)) { continue 1; } } } $file = eZClusterFileHandler::instance($filepath); if ($file->exists()) { $filePaths[] = $filepath; if (!$executionOptions['dry']) { $file->fileDelete($filepath); $dirs[] = eZDir::dirpath($filepath); } $count++; } } if (!$executionOptions['dry']) { $dirs = array_unique($dirs); foreach ($dirs as $dirpath) { eZDir::cleanupEmptyDirectories($dirpath); } eZImageFile::removeForContentObjectAttribute($contentObjectAttributeID); $message = "Removed datatype " . $contentObjectAttribute->attribute('data_type_string') . "type image alias variation " . $filePaths[$messageCount] . "\n"; } else { $message = "Dry run: Remove datatype " . $contentObjectAttribute->attribute('data_type_string') . "type image alias variation " . $filePaths[$messageCount] . "\n"; } while ($messageCount < $count) { self::scriptIterate($message); $messageCount++; $result = true; } } else { // We loop over each image alias, and look up the file in ezcontentobject_attribute // Only images referenced by one version will be removed foreach ($aliasList as $aliasName => $aliasListAliasItem) { // Test $aliasListAliasItem from $aliasList is in $aliases array if ($aliases != false && is_array($aliases) && !in_array($aliasListAliasItem['name'], $aliases)) { continue; } if ($aliasListAliasItem['is_valid'] && $aliasListAliasItem['name'] != 'original') { $filepath = $aliasListAliasItem['url']; // Calculate appropriate message to Alert user with if (!$executionOptions['dry']) { // Remove the alias variation image file from the attribute dom tree $doc = $imageHandler->ContentObjectAttributeData['DataTypeCustom']['dom_tree']; foreach ($doc->getElementsByTagName('alias') as $aliasNode) { if ($aliasListAliasItem['name'] == $aliasNode->getAttribute('name')) { // Optional debug output if ($executionOptions['troubleshoot']) { self::displayMessage('Removing image alias image variation ' . "'" . $aliasNode->getAttribute('name') . "'" . ' from attribute dom document'); } $aliasNode->parentNode->removeChild($aliasNode); } } $imageHandler->ContentObjectAttributeData['DataTypeCustom']['dom_tree'] = $doc; unset($imageHandler->ContentObjectAttributeData['DataTypeCustom']['alias_list']); $imageHandler->storeDOMTree($doc, true, $contentObjectAttribute); } // Calculate appropriate message to Alert user with if ($executionOptions['dry']) { $message = "Dry run: Calculating removal of datatype " . $contentObjectAttribute->attribute('data_type_string') . "type image alias variation file " . $filepath; } else { $message = "Removed standard datatype " . $contentObjectAttribute->attribute('data_type_string') . "type image alias variation file " . $filepath; } if (!$executionOptions['dry']) { $dirpath = $aliasListAliasItem['dirpath']; $file = eZClusterFileHandler::instance($filepath); if ($file->exists()) { $file->purge(); eZImageFile::removeFilepath($contentObjectAttributeID, $filepath); eZDir::cleanupEmptyDirectories($dirpath); self::scriptIterate($message); $results[] = true; } else { eZDebug::writeError("Image file {$filepath} for alias {$aliasName} does not exist, could not remove from disk", __METHOD__); self::displayMessage("Image file {$filepath} for alias {$aliasName} does not exist, could not remove from disk: " . __METHOD__); } eZContentCacheManager::clearContentCacheIfNeeded($contentObjectID); } else { self::scriptIterate($message); $results[] = true; } } } } // Calculate return results based on execution options and results comparison if (in_array(true, $results) && count($aliasList) == count($results) && !$executionOptions['dry']) { return true; } return false; }
public function restoreTrashedObjectAttribute($contentObjectAttribute) { $imageHandler = $contentObjectAttribute->attribute("content"); $originalAlias = $imageHandler->imageAlias("original"); $imageHandler->updateAliasPath(str_replace("/trashed", "", $originalAlias["dirpath"]), $imageHandler->imageName($contentObjectAttribute, $contentObjectAttribute->objectVersion())); if ($imageHandler->isStorageRequired()) { $imageHandler->store($contentObjectAttribute); $contentObjectAttribute->store(); } // Now clean all other aliases, not cleanly registered within the attribute content // First get all remaining aliases full path to then safely remove them $aliasNames = array_keys($imageHandler->aliasList()); $aliasesPath = array(); foreach ($aliasNames as $aliasName) { if ($aliasName === "original") { continue; } $aliasesPath[] = "{$originalAlias["dirpath"]}/{$originalAlias["basename"]}_{$aliasName}.{$originalAlias["suffix"]}"; } if (empty($aliasesPath)) { return; } $conds = array("contentobject_attribute_id" => $contentObjectAttribute->attribute("id"), "filepath" => array($aliasesPath)); $remainingAliases = eZPersistentObject::fetchObjectList(eZImageFile::definition(), null, $conds); unset($conds, $remainingAliasesPath); if (!empty($remainingAliases)) { foreach ($remainingAliases as $remainingAlias) { eZClusterFileHandler::instance($remainingAlias->attribute("filepath"))->delete(); $remainingAlias->remove(); } } }
$path = $options['from_path']; } else { $cli->error("Specifica il percorso da sostituire"); $script->shutdown(); eZExecution::cleanExit(); } $path = rtrim($path, '/') . '/'; $varDir = rtrim($varDir, '/') . '/'; $output = new ezcConsoleOutput(); $question = ezcConsoleQuestionDialog::YesNoQuestion($output, "Correggo i percorsi per VarDir: da \"{$path}\" a \"{$varDir}\" ?", "y"); if (ezcConsoleDialogViewer::displayDialog($question) == "n") { $script->shutdown(); eZExecution::cleanExit(); } else { $cli->output("Process ezimagefile table"); $list = eZImageFile::fetchObjectList(eZImageFile::definition()); foreach ($list as $item) { $newPath = str_replace($path, $varDir, $item->attribute('filepath')); if ($newPath != $item->attribute('filepath')) { $cli->output("Fix attribute " . $item->attribute('contentobject_attribute_id') . " " . $item->attribute('filepath')); eZImageFile::moveFilepath($item->attribute('contentobject_attribute_id'), $item->attribute('filepath'), $newPath); } $attributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, array('id' => $item->attribute('contentobject_attribute_id'))); foreach ($attributes as $attribute) { $newDataText = str_replace($path, $varDir, $attribute->attribute('data_text')); $attribute->setAttribute('data_text', $newDataText); $attribute->store(); } } $script->shutdown(); }