コード例 #1
0
ファイル: BookletService.php プロジェクト: gingerP/shop
 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);
 }
コード例 #2
0
ファイル: ImageEditor.php プロジェクト: gingerP/shop
 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;
 }
コード例 #3
0
ファイル: GoodsService.php プロジェクト: gingerP/shop
 public static function updateGood($id, $values)
 {
     if (is_array($values)) {
         $goodsType = new DBGoodsType();
         if (array_key_exists(DB::TABLE_GOODS__ID, $values)) {
             unset($values[DB::TABLE_GOODS__ID]);
         }
         $pref = new DBPreferencesType();
         $imagePath = $pref->getPreference(Constants::CATALOG_PATH);
         $imagePath = $imagePath[DB::TABLE_PREFERENCES__VALUE];
         $imagesCatalog = $values[DB::TABLE_GOODS__KEY_ITEM];
         $isDirCreated = FileUtils::createDir($imagePath . $imagesCatalog);
         return $goodsType->update($id, $values);
     }
     return -1;
 }