Merge branch 'dev' into test.customwristbands.cz
This commit is contained in:
@@ -53,6 +53,17 @@ interface AppHandler
|
||||
*/
|
||||
public static function edit(Content &$content, Request $request, $revisionID);
|
||||
|
||||
/**
|
||||
* Method called right after content page is marked as deleted
|
||||
*
|
||||
* This method is supposed to clean after "deleted" page.
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete(Content $content);
|
||||
|
||||
/**
|
||||
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Enumerations\ModuleNamesWithIds;
|
||||
use App\Enumerations\TemplatePathsHumanReadableRootOnly;
|
||||
use App\Enumerations\WidgetTypes;
|
||||
use App\Handlers\Contracts\AppHandler;
|
||||
use App\Models\Content;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,11 @@ abstract class Handler implements AppHandler
|
||||
];
|
||||
}
|
||||
|
||||
public static function delete(Content $content)
|
||||
{
|
||||
// temporarily nothing to do
|
||||
}
|
||||
|
||||
public static function getExtendedFormInputsEdit()
|
||||
{
|
||||
return self::getExtendedFormInputsCreate();
|
||||
@@ -72,13 +78,19 @@ abstract class Handler implements AppHandler
|
||||
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-users']);
|
||||
}, 20, ['icon' => 'fa fa-users']);
|
||||
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
||||
$modules = ModuleNamesWithIds::getWithTranslations();
|
||||
$modules = \App\Models\Module::all();
|
||||
|
||||
if (!empty($modules)) {
|
||||
$sub->dropdown(trans('admin/mainMenu.newContentPage'), function ($sub) use ($modules) {
|
||||
$i = 1;
|
||||
foreach ($modules as $module => $name) {
|
||||
$sub->route('content.new', trans($name), ['moduleId' => $module], $i++);
|
||||
foreach ($modules as $module) {
|
||||
|
||||
// display only list of all modules, which manages content
|
||||
if (!call_user_func([$module->handler, 'managesContent'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sub->route('content.new', trans($module->name), ['moduleId' => $module->id], $i++);
|
||||
}
|
||||
}, 10, ['icon' => 'fa fa-plus']);
|
||||
}
|
||||
|
||||
@@ -228,6 +228,9 @@ class EditContent extends Controller
|
||||
|
||||
list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => Content::STATUS_DELETED]);
|
||||
|
||||
// let module to delete some extra content created during page's life
|
||||
call_user_func([$page->module_handler, 'delete'], $page);
|
||||
|
||||
// was something changed?
|
||||
if ($changedColumns == 0) {
|
||||
return redirect()
|
||||
|
||||
@@ -83,15 +83,13 @@ class Gallery implements AppHandler
|
||||
|
||||
// create new directory for images
|
||||
$directory = Directory::create([
|
||||
'name' => $request->title,
|
||||
'name' => $content->id . '_' . $request->title,
|
||||
'description' => $request->description,
|
||||
'parent_id' => $parentDirectoryId
|
||||
]);
|
||||
|
||||
// save id into module_config array
|
||||
$settings = [
|
||||
'directoryId' => $directory->id
|
||||
];
|
||||
$settings = ['directoryId' => $directory->id];
|
||||
|
||||
// save settings
|
||||
$content->module_settings = json_encode($settings);
|
||||
@@ -209,4 +207,34 @@ class Gallery implements AppHandler
|
||||
|
||||
Storage::put(self::CONFIG_FILENAME, $directory->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called right after content page is marked as deleted
|
||||
*
|
||||
* This method is supposed to clean after "deleted" page.
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete(Content $content)
|
||||
{
|
||||
// try to convert module_settings into something more accessible
|
||||
if (is_string($content->module_settings)) {
|
||||
$content->module_settings = json_decode($content->module_settings);
|
||||
}
|
||||
|
||||
// get directory id
|
||||
$directoryId = $content->module_settings->directoryId;
|
||||
|
||||
$directory = Directory::find($directoryId);
|
||||
|
||||
// check if gallery exists
|
||||
if (!$directory) {
|
||||
return;
|
||||
}
|
||||
|
||||
// delete directory used as photogallery
|
||||
$directory->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user