Esempio n. 1
0
 function updateAliasPath($dirpath, $name)
 {
     if (!file_exists($dirpath)) {
         eZDir::mkdir($dirpath, false, true);
     }
     $aliasList = $this->aliasList();
     $this->resetImageSerialNumber();
     foreach ($aliasList as $aliasName => $alias) {
         if ($alias['dirpath'] != $dirpath) {
             $oldDirpath = $alias['url'];
             $oldURL = $alias['url'];
             $basename = $name;
             if ($aliasName != 'original') {
                 $basename .= '_' . $aliasName;
             }
             eZMimeType::changeFileData($alias, $dirpath, $basename);
             $alias['full_path'] = $alias['url'];
             if ($this->isImageOwner()) {
                 if ($oldURL == '') {
                     continue;
                 }
                 $fileHandler = eZClusterFileHandler::instance();
                 $fileHandler->fileMove($oldURL, $alias['url']);
                 eZDir::cleanupEmptyDirectories($oldDirpath);
                 eZImageFile::moveFilepath($this->ContentObjectAttributeData['id'], $oldURL, $alias['url']);
             } else {
                 $fileHandler = eZClusterFileHandler::instance();
                 $fileHandler->fileLinkCopy($oldURL, $alias['url'], false);
                 eZImageFile::appendFilepath($this->ContentObjectAttributeData['id'], $alias['url']);
             }
             $this->setAliasVariation($aliasName, $alias);
         }
     }
     $this->recreateDOMTree();
     $this->setStorageRequired();
 }
    $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();
}