allowed mimetypes from database
This commit is contained in:
parent
2f930457d1
commit
415016a4c2
|
@ -431,8 +431,8 @@ class IndexController extends Controller
|
|||
$user = Auth::user();
|
||||
$dataset->user()->associate($user)->save();
|
||||
|
||||
// $error = 'Always throw this error';
|
||||
// throw new \Exception($error);
|
||||
$error = 'Always throw this error';
|
||||
throw new \Exception($error);
|
||||
|
||||
// all good//commit everything
|
||||
DB::commit();
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Exceptions\GeneralException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use App\Models\MimeType;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MimetypeController extends Controller
|
||||
{
|
||||
// public function download($id)
|
||||
// {
|
||||
// //$report = $this->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');
|
||||
|
@ -23,15 +17,15 @@ class MimetypeController extends Controller
|
|||
|
||||
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');
|
||||
// $mimetypes = Config::get('enums.mime_types');
|
||||
// $checkeds = Config::get('enums.mimetypes_allowed');
|
||||
$direction = 'asc'; // or desc
|
||||
$mimetypes = MimeType::orderBy('name', $direction)->get();
|
||||
|
||||
return view('settings.filetype.index', [
|
||||
'options' => $mimetypes,
|
||||
'checkeds' => $checkeds
|
||||
]);
|
||||
'mimetypes' => $mimetypes,
|
||||
// 'checkeds' => $checkeds
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
|
@ -40,11 +34,37 @@ class MimetypeController extends Controller
|
|||
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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* deactivate mimetype
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function down($id): RedirectResponse
|
||||
{
|
||||
$mimetype = MimeType::findOrFail($id);
|
||||
$mimetype->update(['enabled' => 0]);
|
||||
session()->flash('flash_message', 'mimetype has been deactivated!');
|
||||
return redirect()->route('settings.mimetype.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* activate mimetype.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function up($id): RedirectResponse
|
||||
{
|
||||
$mimetype = MimeType::findOrFail($id);
|
||||
$mimetype->update(['enabled' => 1]);
|
||||
session()->flash('flash_message', 'mimetype has been activated!');
|
||||
return redirect()->route('settings.mimetype.index');
|
||||
}
|
||||
}
|
||||
|
|
16
app/Models/MimeType.php
Normal file
16
app/Models/MimeType.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MimeType extends Model
|
||||
{
|
||||
|
||||
protected $table = 'mime_types';
|
||||
|
||||
// for using $input = $request->all();
|
||||
//$project = Project::create($input);
|
||||
protected $fillable = [
|
||||
'name', 'file_extension', 'enabled',
|
||||
];
|
||||
}
|
|
@ -3,7 +3,8 @@
|
|||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
//use Illuminate\Support\Facades\Config;
|
||||
use App\Models\MimeType;
|
||||
|
||||
class RdrFiletypes implements Rule
|
||||
{
|
||||
|
@ -16,7 +17,10 @@ class RdrFiletypes implements Rule
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->mimetypes = Config::get('enums.mimetypes_allowed', ['application/pdf']);
|
||||
//$this->mimetypes = Config::get('enums.mimetypes_allowed', ['application/pdf']);
|
||||
$this->mimetypes = MimeType::where('enabled', 1)
|
||||
->pluck('name')
|
||||
->toArray();
|
||||
// $this->maxFileSize = Config::get('enums.max_filesize');
|
||||
}
|
||||
|
||||
|
@ -30,9 +34,9 @@ class RdrFiletypes implements Rule
|
|||
public function passes($attribute, $value)
|
||||
{
|
||||
//return Rule::in($this->filetypes);
|
||||
$test = $value->getMimeType();//"application/pdf"
|
||||
$mimeType = $value->getMimeType();//"application/pdf"
|
||||
return $value->getPath() != '' &&
|
||||
in_array($value->getMimeType(), $this->mimetypes);
|
||||
in_array($mimeType, $this->mimetypes);
|
||||
// in_array($value->guessExtension(), $this->filetypes); //file extension
|
||||
|
||||
|
||||
|
@ -49,23 +53,4 @@ class RdrFiletypes implements Rule
|
|||
{
|
||||
return 'attribute :attribute has not a valid mime type.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of an attribute.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
private function getSize($attribute, $value)
|
||||
{
|
||||
if (is_numeric($value) && $hasNumeric) {
|
||||
return array_get($this->data, $attribute);
|
||||
} elseif (is_array($value)) {
|
||||
return count($value);
|
||||
} elseif ($value instanceof File) {
|
||||
return $value->getSize() / 1024;
|
||||
}
|
||||
return mb_strlen($value);
|
||||
}
|
||||
}
|
||||
|
|
29
composer.lock
generated
29
composer.lock
generated
|
@ -281,25 +281,30 @@
|
|||
},
|
||||
{
|
||||
"name": "dragonmantank/cron-expression",
|
||||
"version": "v2.2.0",
|
||||
"version": "v2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dragonmantank/cron-expression.git",
|
||||
"reference": "92a2c3768d50e21a1f26a53cb795ce72806266c5"
|
||||
"reference": "72b6fbf76adb3cf5bc0db68559b33d41219aba27"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/92a2c3768d50e21a1f26a53cb795ce72806266c5",
|
||||
"reference": "92a2c3768d50e21a1f26a53cb795ce72806266c5",
|
||||
"url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/72b6fbf76adb3cf5bc0db68559b33d41219aba27",
|
||||
"reference": "72b6fbf76adb3cf5bc0db68559b33d41219aba27",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0.0"
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~6.4"
|
||||
"phpunit/phpunit": "^6.4|^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cron\\": "src/Cron/"
|
||||
|
@ -326,7 +331,7 @@
|
|||
"cron",
|
||||
"schedule"
|
||||
],
|
||||
"time": "2018-06-06T03:12:17+00:00"
|
||||
"time": "2019-03-31T00:38:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
|
@ -961,16 +966,16 @@
|
|||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "1.0.50",
|
||||
"version": "1.0.51",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "dab4e7624efa543a943be978008f439c333f2249"
|
||||
"reference": "755ba7bf3fb9031e6581d091db84d78275874396"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/dab4e7624efa543a943be978008f439c333f2249",
|
||||
"reference": "dab4e7624efa543a943be978008f439c333f2249",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/755ba7bf3fb9031e6581d091db84d78275874396",
|
||||
"reference": "755ba7bf3fb9031e6581d091db84d78275874396",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1041,7 +1046,7 @@
|
|||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2019-02-01T08:50:36+00:00"
|
||||
"time": "2019-03-30T13:22:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mcamara/laravel-localization",
|
||||
|
|
105
config/enums.php
105
config/enums.php
|
@ -25,108 +25,5 @@ return [
|
|||
"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',
|
||||
]
|
||||
'max_filesize' => 5120
|
||||
];
|
||||
|
|
|
@ -368,26 +368,26 @@
|
|||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:if test="@ElevationMin != '' and @ElevationMax != ''">
|
||||
<xsl:value-of select="concat(' *ELEVATION MIN: ', @ElevationMin, ' *ELEVATION MAX: ', @ElevationMax)" />
|
||||
<xsl:value-of select="concat(' * ELEVATION MIN: ', @ElevationMin, ' * ELEVATION MAX: ', @ElevationMax)" />
|
||||
</xsl:if>
|
||||
<xsl:if test="@ElevationAbsolut != ''">
|
||||
<xsl:value-of select="concat(' *ELEVATION ABSOLUT: ', @ElevationAbsolut)" />
|
||||
<xsl:value-of select="concat(' * ELEVATION ABSOLUT: ', @ElevationAbsolut)" />
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:if test="@DepthMin != '' and @DepthMax != ''">
|
||||
<xsl:value-of select="concat(' *DEPTH MIN: ', @DepthMin, ' *DEPTH MAX: ', @DepthMax)" />
|
||||
<xsl:value-of select="concat(' * DEPTH MIN: ', @DepthMin, ' * DEPTH MAX: ', @DepthMax)" />
|
||||
</xsl:if>
|
||||
<xsl:if test="@DepthAbsolut != ''">
|
||||
<xsl:value-of select="concat(' *DEPTH ABSOLUT: ', @DepthAbsolut)" />
|
||||
<xsl:value-of select="concat(' * DEPTH ABSOLUT: ', @DepthAbsolut)" />
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:if test="@TimeMin != '' and @TimeMax != ''">
|
||||
<xsl:value-of select="concat(' *TIME MIN: ', @TimeMin, ' *TIME MAX: ', @TimeMax)" />
|
||||
<xsl:value-of select="concat(' * TIME MIN: ', @TimeMin, ' * TIME MAX: ', @TimeMax)" />
|
||||
</xsl:if>
|
||||
<xsl:if test="@TimeAbsolut != ''">
|
||||
<xsl:value-of select="concat(' *TIME ABSOLUT: ', @TimeAbsolut)" />
|
||||
<xsl:value-of select="concat(' * TIME ABSOLUT: ', @TimeAbsolut)" />
|
||||
</xsl:if>
|
||||
|
||||
</dc:coverage>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@extends('settings.layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<h3 class="header-title">
|
||||
|
@ -11,43 +10,41 @@
|
|||
<div class="pure-g box-content">
|
||||
|
||||
<div class="pure-u-1 pure-u-md-2-3">
|
||||
{{-- <a class="pure-button button-small is-primary" href="{{ route('access.user.create') }}">
|
||||
{{-- <a class="pure-button button-small is-primary" href="{{ route('settings.person.add') }}">
|
||||
<i class="fa fa-plus-circle"></i>
|
||||
<span>Create New File Extension</span>
|
||||
</a> --}}
|
||||
<span>ADD NEW MimeType</span>
|
||||
</a>
|
||||
<br><br> --}}
|
||||
|
||||
@if ($message = Session::get('success'))
|
||||
<div class="alert summary-success">
|
||||
<p>{{ $message }}</p>
|
||||
</div>
|
||||
@endif
|
||||
<table class="pure-table pure-table-horizontal">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>File Extension</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
{!! Form::open(array('route' => 'settings.mimetype.update','method' => 'PATCH', 'class'=>'pure-form')) !!}
|
||||
<tbody>
|
||||
@foreach($mimetypes as $mimetype)
|
||||
<tr>
|
||||
|
||||
<div class="pure-control-group checkboxlist">
|
||||
@foreach ($options as $key => $value)
|
||||
<label for={{"mimetype". $key }} class="pure-checkbox">
|
||||
{{-- <input name="mimetypes[]" value={{ $value }} {{ (in_array($value, $checkeds)) ? 'checked=checked' : '' }} type="checkbox" class="form-check-input"> --}}
|
||||
|
||||
{!! Form::checkbox( 'mimetypes['. $key .']',
|
||||
$value,
|
||||
in_array($value, $checkeds),
|
||||
['class' => 'md-check', 'id' => $key]
|
||||
) !!}
|
||||
{{ $value }}
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{-- <div class="pure-controls">
|
||||
<button type="submit" class="pure-button button-small">
|
||||
<i class="fa fa-save"></i>
|
||||
<span>Update allowed mimetypes</span>
|
||||
</button>
|
||||
</div> --}}
|
||||
|
||||
{!! Form::close() !!}
|
||||
<td>{{ $mimetype->name }}</td>
|
||||
<td>{{ $mimetype->file_extension }}</td>
|
||||
<td>
|
||||
@if($mimetype->enabled == 1) Active @else Inactive @endif
|
||||
</td>
|
||||
<td>
|
||||
@if($mimetype->enabled == 1)
|
||||
<a href="{{ route('settings.mimetype.down', $mimetype->id) }}" class="pure-button button-small is-warning">Deactivate</a> @else
|
||||
<a href="{{ route('settings.mimetype.up', $mimetype->id) }}" class="pure-button button-small is-success">Activate</a> @endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -187,6 +187,12 @@ Route::group(['middleware' => ['permission:settings']], function () {
|
|||
// Route::get('settings/collection/delete/{id}', [
|
||||
// 'as' => 'settings.collection.delete', 'uses' => 'Settings\CollectionController@delete',
|
||||
// ]);
|
||||
Route::get('settings/mimetype/down/{id}', [
|
||||
'as' => 'settings.mimetype.down', 'uses' => 'Settings\MimetypeController@down',
|
||||
]);
|
||||
Route::get('settings/mimetype/up/{id}', [
|
||||
'as' => 'settings.mimetype.up', 'uses' => 'Settings\MimetypeController@up',
|
||||
]);
|
||||
|
||||
//=================================================setting collection=============================================
|
||||
Route::get('/settings/collection', [
|
||||
|
|
Loading…
Reference in New Issue
Block a user