static function removeByID($id, $version) { if ($version == null) { eZPersistentObject::removeObject(eZBinaryFile::definition(), array('contentobject_attribute_id' => $id)); } else { eZPersistentObject::removeObject(eZBinaryFile::definition(), array('contentobject_attribute_id' => $id, 'version' => $version)); } }
* @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * @version 2014.07.0 * @package kernel */ require 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "\nAdds the file extension suffix to the files stored by the binary file datatype\n" . "where it is currently missing.\n", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true)); $script->startup(); $options = $script->getOptions('', '', array()); $script->initialize(); $limit = 20; $offset = 0; $db = eZDB::instance(); $script->setIterationData('.', '~'); while ($binaryFiles = eZPersistentObject::fetchObjectList(eZBinaryFile::definition(), null, null, null, array('offset' => $offset, 'limit' => $limit))) { foreach ($binaryFiles as $binaryFile) { $fileName = $binaryFile->attribute('filename'); if (strpos($fileName, '.') !== false) { $text = "skipping {$fileName}, it contains a suffix"; $script->iterate($cli, true, $text); continue; } $suffix = eZFile::suffix($binaryFile->attribute('original_filename')); if ($suffix) { $newFileName = $fileName . '.' . $suffix; $db->begin(); $oldFilePath = $binaryFile->attribute('filepath'); $binaryFile->setAttribute('filename', $newFileName); $binaryFile->store(); $newFilePath = $binaryFile->attribute('filepath');