normalize filenames

This commit is contained in:
HolgerHatGarKeineNode
2023-02-27 16:50:25 +01:00
parent 9896618944
commit 2be0b8da2a
13 changed files with 145 additions and 126 deletions

View File

@@ -47,7 +47,7 @@ class BitcoinEventForm extends Component
if (!$this->bitcoinEvent) {
$this->bitcoinEvent = new BitcoinEvent(
[
'description' => '',
'description' => '',
'show_worldwide' => true,
]
);
@@ -76,6 +76,7 @@ class BitcoinEventForm extends Component
if ($this->image) {
$this->bitcoinEvent->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('logo');
}

View File

@@ -50,6 +50,9 @@ class OrangePillForm extends Component
} elseif ($this->orangePill->user_id !== auth()->id()) {
abort(403);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function save()

View File

@@ -62,10 +62,11 @@ class ContentCreatorForm extends Component
if ($this->image) {
$this->lecturer->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('avatar');
}
return redirect($this->fromUrl ?? url()->route('welcome'));
return redirect($this->fromUrl);
}
public function render()

View File

@@ -72,7 +72,7 @@ class LibraryItemForm extends Component
$this->libraryItem = new LibraryItem([
'approved' => true,
'read_time' => 1,
'value' => '',
'value' => '',
]);
if ($this->lecturer) {
$this->library = Library::query()
@@ -106,11 +106,13 @@ class LibraryItemForm extends Component
if ($this->image) {
$this->libraryItem->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('main');
}
if ($this->file) {
$this->libraryItem->addMedia($this->file)
->usingFileName(md5($this->file->getClientOriginalName()).'.'.$this->file->getClientOriginalExtension())
->toMediaCollection('single_file');
}

View File

@@ -21,6 +21,10 @@ class MeetupEventForm extends Component
public array $series = [];
public ?string $fromUrl = '';
protected $queryString = ['fromUrl' => ['except' => '']];
public function rules()
{
return [
@@ -52,6 +56,9 @@ class MeetupEventForm extends Component
->can('update', $this->meetupEvent)) {
abort(403);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function updatedMeetupEventStart($value)

View File

@@ -57,6 +57,9 @@ class MeetupForm extends Component
) {
abort(403);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function submit()
@@ -66,6 +69,7 @@ class MeetupForm extends Component
if ($this->image) {
$this->meetup->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('logo');
}

View File

@@ -23,22 +23,26 @@ class NewsArticleForm extends Component
public array $temporaryUrls = [];
public ?string $fromUrl = '';
protected $queryString = ['fromUrl' => ['except' => '']];
public function rules()
{
return [
'image' => [Rule::requiredIf(! $this->libraryItem->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
'image' => [Rule::requiredIf(!$this->libraryItem->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
'libraryItem.lecturer_id' => 'required',
'libraryItem.name' => 'required',
'libraryItem.type' => 'required',
'libraryItem.language_code' => 'required',
'libraryItem.value' => 'required',
'libraryItem.subtitle' => 'required',
'libraryItem.excerpt' => 'required',
'libraryItem.lecturer_id' => 'required',
'libraryItem.name' => 'required',
'libraryItem.type' => 'required',
'libraryItem.language_code' => 'required',
'libraryItem.value' => 'required',
'libraryItem.subtitle' => 'required',
'libraryItem.excerpt' => 'required',
'libraryItem.main_image_caption' => 'required',
'libraryItem.read_time' => 'required',
'libraryItem.approved' => 'boolean',
'libraryItem.news' => 'boolean',
'libraryItem.read_time' => 'required',
'libraryItem.approved' => 'boolean',
'libraryItem.news' => 'boolean',
];
}
@@ -46,16 +50,19 @@ class NewsArticleForm extends Component
{
if ($this->libraryItem === null) {
$this->libraryItem = new LibraryItem([
'type' => 'markdown_article',
'value' => '',
'read_time' => 1,
'news' => true,
'type' => 'markdown_article',
'value' => '',
'read_time' => 1,
'news' => true,
'language_code' => 'de',
'approved' => auth()
'approved' => auth()
->user()
->hasRole('news-editor'),
]);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function updatedImages($value)
@@ -76,17 +83,18 @@ class NewsArticleForm extends Component
if ($this->image) {
$this->libraryItem->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('main');
}
return to_route('article.overview', ['country' => null]);
return redirect($this->fromUrl);
}
public function delete()
{
$this->libraryItem->delete();
return to_route('article.overview', ['country' => null]);
return redirect($this->fromUrl);
}
public function render()

View File

@@ -74,6 +74,7 @@ class VenueForm extends Component
if ($this->images && count($this->images) > 0) {
foreach ($this->images as $item) {
$this->venue->addMedia($item)
->usingFileName(md5($item->getClientOriginalName()).'.'.$item->getClientOriginalExtension())
->toMediaCollection('images');
}
}