Exemple #1
0
 private static function saveBookletImage($bookletCode, $imageName, $base64Image)
 {
     $bookletImagesRoot = DBPreferencesType::getPreferenceS(Constants::BOOKLET_IMAGE_PATH);
     $bookletImageDirectory = FileUtils::buildPath($bookletImagesRoot, $bookletCode);
     FileUtils::createDir($bookletImageDirectory);
     $imageEditor = ImageEditor::newImageBase64($base64Image);
     $bookletImagePath = FileUtils::buildPath($bookletImagesRoot, $bookletCode, $imageName);
     $imageEditor->saveImage($bookletImagePath);
     return FileUtils::buildPath($bookletCode, $imageName);
 }
Exemple #2
0
 public static function newImageBase64($base64)
 {
     $tmpDir = FileUtils::getTmpDir();
     $imageExtension = Utils::getImageExtensionFromBase64($base64);
     $imageName = Utils::getRandomString() . '.' . $imageExtension;
     $path = FileUtils::buildPath($tmpDir, $imageName);
     $base64PrefixLess = Utils::extractBase64($base64);
     FileUtils::createDir($tmpDir);
     chmod($tmpDir, 0777);
     $file = file_put_contents($path, base64_decode($base64PrefixLess));
     chmod($path, 0777);
     if ($file == true) {
         $instance = new ImageEditor($path);
     }
     return $instance;
 }
Exemple #3
0
 public static function getImages($id)
 {
     $pref = new DBPreferencesType();
     $catalogDir = $pref->getPreference(Constants::CATALOG_PATH)[DB::TABLE_PREFERENCES__VALUE];
     $goodsType = new DBGoodsType();
     $good = $goodsType->get($id);
     $goodCode = $good[DB::TABLE_GOODS__KEY_ITEM];
     $images = [];
     if (!is_null($goodCode)) {
         $images = FileUtils::getFilesByPrefixByDescription(FileUtils::buildPath($catalogDir, $goodCode), Constants::SMALL_IMAGE, "jpg");
         //$filesMedium = FileUtils::getFilesByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH.DIRECTORY_SEPARATOR.$goodCode.DIRECTORY_SEPARATOR, Constants::MEDIUM_IMAGE, "jpg");
     }
     return $images;
 }
Exemple #4
-4
 public static function updatePrices($data)
 {
     $result = [];
     if (count($data) > 0) {
         $dbPreference = new DBPreferencesType();
         $priceDirectory = $dbPreference->getPreference(Constants::PRICE_DIRECTORY)[DB::TABLE_PREFERENCES__VALUE];
         for ($orderIndex = 0; $orderIndex < count(self::$operationsOrder); $orderIndex++) {
             $currentAction = self::$operationsOrder[$orderIndex];
             foreach ($data as $key => $value) {
                 if ($value['action'] == $currentAction) {
                     $operationRes = false;
                     switch ($currentAction) {
                         case self::PRICE_DEL:
                             $operationRes = unlink(FileUtils::buildPath($priceDirectory, $value['name']));
                             break;
                         case self::PRICE_RENAME:
                             $operationRes = rename(FileUtils::buildPath($priceDirectory, $value['name']), FileUtils::buildPath($priceDirectory, $value['new_name']));
                             break;
                         case self::PRICE_ADD:
                             $operationRes = FileUtils::createFileBase64($value['file'], FileUtils::buildPath($priceDirectory, $value['name']));
                             break;
                     }
                     $result[$key] = $operationRes;
                 }
             }
         }
     }
     return $result;
 }