diff --git a/app/Http/Controllers/Publish/IndexController.php b/app/Http/Controllers/Publish/IndexController.php index 89d70ab..303c3ca 100644 --- a/app/Http/Controllers/Publish/IndexController.php +++ b/app/Http/Controllers/Publish/IndexController.php @@ -473,10 +473,10 @@ class IndexController extends Controller 'abstract_main.language' => 'required', ]; if (null != $request->file('files')) { - $files = count($request->file('files')) - 1; + $files = count($request->file('files')) -1; foreach (range(0, $files) as $index) { // $rules['files.' . $index] = 'image|max:2048'; - $rules['files.' . $index . '.file'] = ['required', 'file', new RdrFiletypes(), new RdrFilesize()]; + $rules['files.' . $index . '.file'] = ['required', 'file', new RdrFiletypes(), new RdrFilesize($index)]; } } $validator = Validator::make($request->all(), $rules); diff --git a/app/Http/Controllers/Settings/DatasetController.php b/app/Http/Controllers/Settings/DatasetController.php index fbc7638..5f44c8e 100644 --- a/app/Http/Controllers/Settings/DatasetController.php +++ b/app/Http/Controllers/Settings/DatasetController.php @@ -1,18 +1,18 @@ middleware('auth'); } - public function index(Request $request) : View + public function index(Request $request): View { $searchType = $request->input('searchtype'); $builder = Dataset::query(); //$registers = array(); $filter = $request->input('filter'); - + if (null !== ($request->input('state'))) { $state = $request->input('state'); } else { - $state = "published"; + $state = "published"; } - $data = $request->all(); + $data = $request->all(); if ($searchType == "simple") { if (strlen($filter) > 0) { - //$builder->where('field1', '=', $criteria1); - $builder->whereHas('titles', function ($query) use ($filter) { + $closure = function ($query) use ($filter) { $query->where('value', 'LIKE', '%' . $filter . '%'); - }); + }; + $builder->whereHas('titles', $closure); // ::with(['titles' => function ($query) use($filter) { // $query->where('value', 'LIKE', '%' . $filter . '%'); // }]) } } $builder->where('server_state', $state); - - + //$perPage = $request->get('perPage', 20); $documents = $builder - ->paginate(8); + ->paginate(8); return view('settings.document.document', compact('documents', 'state', 'filter')); } @@ -107,20 +106,20 @@ class DatasetController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function edit($id) : View + public function edit($id): View { $document = Dataset::findOrFail($id); $document->load('licenses', 'titles', 'abstracts', 'files'); $projects = Project::pluck('label', 'id'); - + $datum = date('Y-m-d'); $nowYear = substr($datum, 0, 4); $years = array(); for ($jahr = 1990; $jahr <= $nowYear; $jahr++) { $years[$jahr] = $jahr; } - + $languages = DB::table('languages') ->where('active', true) ->pluck('part1', 'part1'); @@ -151,7 +150,7 @@ class DatasetController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function update(DocumentRequest $request, $id) : RedirectResponse + public function update(DocumentRequest $request, $id): RedirectResponse { $dataset = Dataset::findOrFail($id); //$input = $request->all(); @@ -191,7 +190,7 @@ class DatasetController extends Controller } } - if (! $dataset->isDirty(dataset::UPDATED_AT)) { + if (!$dataset->isDirty(dataset::UPDATED_AT)) { $time = new \Illuminate\Support\Carbon(); $dataset->setUpdatedAt($time); } @@ -204,14 +203,13 @@ class DatasetController extends Controller throw new GeneralException(trans('exceptions.backend.dataset.update_error')); } - /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) : RedirectResponse + public function destroy($id): RedirectResponse { // $document = Document::findOrFail($id); // $document->delete(); diff --git a/app/Http/Controllers/Settings/FiletypeController.php b/app/Http/Controllers/Settings/FiletypeController.php deleted file mode 100644 index 1e416e5..0000000 --- a/app/Http/Controllers/Settings/FiletypeController.php +++ /dev/null @@ -1,28 +0,0 @@ -report->find($id); - // $file = File::findOrFail($id); - // $file_path = public_path('storage/' . $file->path_name); - // return response()->download($file_path, $file->label, ['Content-Type:' . $file->mime_type]); - // } - public function __construct() - { - $this->middleware('auth'); - } - - public function index(): View - { - $direction = 'asc'; // or desc - $fileextensions = Config::get('enums.filetypes_allowed'); - return view('settings.filetype.index', compact('fileextensions')); - } -} diff --git a/app/Http/Controllers/Settings/MimetypeController.php b/app/Http/Controllers/Settings/MimetypeController.php new file mode 100644 index 0000000..e6e0ae2 --- /dev/null +++ b/app/Http/Controllers/Settings/MimetypeController.php @@ -0,0 +1,50 @@ +report->find($id); + // $file = File::findOrFail($id); + // $file_path = public_path('storage/' . $file->path_name); + // return response()->download($file_path, $file->label, ['Content-Type:' . $file->mime_type]); + // } + public function __construct() + { + $this->middleware('auth'); + } + + public function index(): View + { + //$direction = 'asc'; // or desc + $mimetypes = Config::get('enums.mime_types'); + //$checkeds = $document->licenses->pluck('id')->toArray(); + $checkeds = Config::get('enums.mimetypes_allowed'); + + return view('settings.filetype.index', [ + 'options' => $mimetypes, + 'checkeds' => $checkeds + ]); + } + + public function update(Request $request) + { + $mimetypes = $request->input('mimetypes'); + Config::set('enums.mimetypes_allowed', $mimetypes); + return redirect()->back()->with('success', 'Mimetypes are updated'); + + + + // session()->flash('flash_message', 'allowed mimtypes have been updated!'); + // return redirect()->route('settings.document'); + + // throw new GeneralException(trans('exceptions.backend.dataset.update_error')); + } +} diff --git a/app/Http/Controllers/Settings/WorkflowController.php b/app/Http/Controllers/Settings/WorkflowController.php index c95cc49..ac92e8a 100644 --- a/app/Http/Controllers/Settings/WorkflowController.php +++ b/app/Http/Controllers/Settings/WorkflowController.php @@ -68,7 +68,7 @@ class WorkflowController extends Controller session()->flash('flash_message', 'You have puplished 1 dataset!'); } $dataset->save(); - return redirect()->back(); + return redirect()->back(); //return redirect()->route('settings.review.index'); } catch (Exception $e) { //return $this->_redirectTo('index', array('failure' => $e->getMessage()), 'documents', 'admin'); diff --git a/app/Observers/DatasetObserver.php b/app/Observers/DatasetObserver.php index c929517..247534f 100644 --- a/app/Observers/DatasetObserver.php +++ b/app/Observers/DatasetObserver.php @@ -93,7 +93,7 @@ class DatasetObserver $service = new SolariumAdapter("solr", config('solarium')); $service->addDatasetsToIndex($dataset); } catch (Opus_Search_Exception $e) { - Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $documentId . ' failed: ' . $e->getMessage()); + Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $datasetId . ' failed: ' . $e->getMessage()); } catch (InvalidArgumentException $e) { Log::warning(__METHOD__ . ': ' . $e->getMessage()); } diff --git a/app/Rules/RdrFiletypes.php b/app/Rules/RdrFiletypes.php index ad9cafe..44a39db 100644 --- a/app/Rules/RdrFiletypes.php +++ b/app/Rules/RdrFiletypes.php @@ -16,7 +16,7 @@ class RdrFiletypes implements Rule */ public function __construct() { - $this->filetypes = Config::get('enums.filetypes_allowed', ['pdf']); + $this->mimetypes = Config::get('enums.mimetypes_allowed', ['application/pdf']); // $this->maxFileSize = Config::get('enums.max_filesize'); } @@ -30,8 +30,13 @@ class RdrFiletypes implements Rule public function passes($attribute, $value) { //return Rule::in($this->filetypes); + $test = $value->getMimeType();//"application/pdf" return $value->getPath() != '' && - in_array($value->guessExtension(), $this->filetypes); // && + in_array($value->getMimeType(), $this->mimetypes); + // in_array($value->guessExtension(), $this->filetypes); //file extension + + + // && // $this->getSize($attribute, $value) <= $this->maxFileSize; } diff --git a/composer.json b/composer.json index 3595c90..0aeaf44 100755 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "fzaninotto/faker": "^1.8", "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "^3.3" + "squizlabs/php_codesniffer": "^3.4" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index 4391ed9..994ef3a 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cfd99ddd9c6460b54b15771a05d2e1d7", + "content-hash": "35e771d8a4e73ec0c3768490092f9391", "packages": [ { "name": "davejamesmiller/laravel-breadcrumbs", diff --git a/config/enums.php b/config/enums.php index ad76b9d..98f098b 100644 --- a/config/enums.php +++ b/config/enums.php @@ -18,8 +18,115 @@ return [ 'temporary' => 'temporary', 'created' => 'created', ], - 'filetypes_allowed' => [ - "pdf", "txt", "html", "htm", "png", "jpeg", + 'mimetypes_allowed' => [ + "pdf" => "application/pdf", + "txt|asc|c|cc|h|srt" => "text/plain", + "htm|html" => "text/html", + "png" => "image/png", + "jpg|jpeg|jpe" => "image/jpeg", ], 'max_filesize' => 5120, + 'mime_types' => [ + // Image formats. + 'jpg|jpeg|jpe' => 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'bmp' => 'image/bmp', + 'tiff|tif' => 'image/tiff', + 'ico' => 'image/x-icon', + // Video formats. + 'asf|asx' => 'video/x-ms-asf', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wm' => 'video/x-ms-wm', + 'avi' => 'video/avi', + 'divx' => 'video/divx', + 'flv' => 'video/x-flv', + 'mov|qt' => 'video/quicktime', + 'mpeg|mpg|mpe' => 'video/mpeg', + 'mp4|m4v' => 'video/mp4', + 'ogv' => 'video/ogg', + 'webm' => 'video/webm', + 'mkv' => 'video/x-matroska', + '3gp|3gpp' => 'video/3gpp', // Can also be audio + '3g2|3gp2' => 'video/3gpp2', // Can also be audio + // Text formats. + 'txt|asc|c|cc|h|srt' => 'text/plain', + 'csv' => 'text/csv', + 'tsv' => 'text/tab-separated-values', + 'ics' => 'text/calendar', + 'rtx' => 'text/richtext', + 'css' => 'text/css', + 'htm|html' => 'text/html', + 'vtt' => 'text/vtt', + 'dfxp' => 'application/ttaf+xml', + // Audio formats. + 'mp3|m4a|m4b' => 'audio/mpeg', + 'aac' => 'audio/aac', + 'ra|ram' => 'audio/x-realaudio', + 'wav' => 'audio/wav', + 'ogg|oga' => 'audio/ogg', + 'flac' => 'audio/flac', + 'mid|midi' => 'audio/midi', + 'wma' => 'audio/x-ms-wma', + 'wax' => 'audio/x-ms-wax', + 'mka' => 'audio/x-matroska', + // Misc application formats. + 'rtf' => 'application/rtf', + 'js' => 'application/javascript', + 'pdf' => 'application/pdf', + 'swf' => 'application/x-shockwave-flash', + 'class' => 'application/java', + 'tar' => 'application/x-tar', + 'zip' => 'application/zip', + 'gz|gzip' => 'application/x-gzip', + 'rar' => 'application/rar', + '7z' => 'application/x-7z-compressed', + 'exe' => 'application/x-msdownload', + 'psd' => 'application/octet-stream', + 'xcf' => 'application/octet-stream', + // MS Office formats. + 'doc' => 'application/msword', + 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', + 'wri' => 'application/vnd.ms-write', + 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', + 'mdb' => 'application/vnd.ms-access', + 'mpp' => 'application/vnd.ms-project', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', + 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', + 'oxps' => 'application/oxps', + 'xps' => 'application/vnd.ms-xpsdocument', + // OpenOffice formats. + 'odt' => 'application/vnd.oasis.opendocument.text', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odf' => 'application/vnd.oasis.opendocument.formula', + // WordPerfect formats. + 'wp|wpd' => 'application/wordperfect', + // iWork formats. + 'key' => 'application/vnd.apple.keynote', + 'numbers' => 'application/vnd.apple.numbers', + 'pages' => 'application/vnd.apple.pages', + ] ]; diff --git a/resources/views/settings/filetype/index.blade.php b/resources/views/settings/filetype/index.blade.php index 756e5b8..e733629 100644 --- a/resources/views/settings/filetype/index.blade.php +++ b/resources/views/settings/filetype/index.blade.php @@ -4,18 +4,17 @@
File Extensions | -Action | -
---|---|
{{ $fileextension }} | -- {{-- Edit - - Delete --}} - | -