Ejemplo n.º 1
0
 public function moveTemporaryFile($tmpId, $title = '')
 {
     $tmp = BOL_FileTemporaryDao::getInstance()->findById($tmpId);
     $tmpPath = BOL_FileTemporaryService::getInstance()->getTemporaryFilePath($tmpId);
     if (!$tmp) {
         throw new LogicException();
     }
     if (!UTIL_File::validateImage($tmp->filename)) {
         throw new LogicException();
     }
     $image = new BOL_ThemeImage();
     $image->addDatetime = time();
     $image->title = $title;
     $dimensions = getimagesize($tmpPath);
     $image->dimensions = "{$dimensions[0]}x{$dimensions[1]}";
     $image->filesize = UTIL_File::getFileSize($tmpPath);
     $this->themeImageDao->save($image);
     $ext = UTIL_File::getExtension($tmp->filename);
     $imageName = 'theme_image_' . $image->getId() . '.' . $ext;
     $newTempName = $tmp->filename . '.' . $ext;
     rename($tmp->filename, $newTempName);
     OW::getStorage()->copyFile($tmpPath, $this->userfileImagesDir . $imageName);
     if (file_exists($newTempName)) {
         unlink($newTempName);
     }
     BOL_FileTemporaryDao::getInstance()->deleteById($tmpId);
     $image->setFilename($imageName);
     $this->themeImageDao->save($image);
     return $image;
 }
Ejemplo n.º 2
0
foreach ($queryList as $query) {
    try {
        $db->query($query);
    } catch (Exception $e) {
        $logger->addEntry(json_encode($e));
    }
}
$themeService = BOL_ThemeService::getInstance();
$images = $themeService->findAllCssImages();
foreach ($images as $image) {
    try {
        $path = $themeService->getUserfileImagesDir() . $image->getFilename();
        if ($storage->fileExists($path)) {
            if (get_class($storage) == 'UPDATE_AmazonCloudStorage') {
                $tempPath = tempnam($themeService->getUserfileImagesDir(), 'themeTmpImage');
                $info = $storage->copyFileToLocalFS($path, $tempPath);
                $dimensions = getimagesize($tempPath);
                $filesize = UTIL_File::getFileSize($tempPath);
                unlink($tempPath);
            } else {
                $dimensions = getimagesize($path);
                $filesize = UTIL_File::getFileSize($path);
            }
            $image->dimensions = "{$dimensions[0]}x{$dimensions[1]}";
            $image->filesize = $filesize;
            BOL_ThemeImageDao::getInstance()->save($image);
        }
    } catch (Exception $e) {
        $logger->addEntry(json_encode($e));
    }
}