43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Hura8\Components\Media\AdminController;
|
|
|
|
use Hura8\Components\Media\Controller\bMediaController;
|
|
use Hura8\Interfaces\iEntityAdminController;
|
|
use Hura8\Traits\AdminEntityBaseControllerTraits;
|
|
|
|
|
|
class AMediaController extends bMediaController implements iEntityAdminController
|
|
{
|
|
|
|
use AdminEntityBaseControllerTraits;
|
|
|
|
|
|
public static function createUploadSubFolder() {
|
|
return date("Y-m-d");
|
|
}
|
|
|
|
protected function deleteFileBeforeDeleteItem($item_id): bool
|
|
{
|
|
// delete thumb files
|
|
$item_info = $this->getInfo($item_id);
|
|
if(!$item_info['file_url']) {
|
|
return true;
|
|
}
|
|
|
|
list($sub_folder, $file_name) = explode("/", $item_info['file_url']); // format: Y-m-d/file_name
|
|
|
|
foreach (static::$resized_sizes as $size => $value) {
|
|
$file_local_path = PUBLIC_DIR . "/". static::$image_folder . "/" . $sub_folder . "/". $size. IMAGE_FILE_SEPARATOR . $file_name;
|
|
@unlink($file_local_path);
|
|
}
|
|
|
|
// remove original file
|
|
$file_local_path = PUBLIC_DIR . "/". static::$image_folder . "/" . $sub_folder . "/". $file_name;
|
|
@unlink($file_local_path);
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|