FEATURE: remove gallery and move it into own repository
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => 'Gallery',
|
|
||||||
'translatedName' => 'gallery::module.name',
|
|
||||||
'translatedDescription' => 'gallery::module.description',
|
|
||||||
'alias' => 'gallery',
|
|
||||||
'handler' => '\\Modules\\Gallery\\Handlers\\Gallery',
|
|
||||||
'providers' => [\Modules\Gallery\Providers\GalleryServiceProvider::class],
|
|
||||||
'files' => ['start.php'],
|
|
||||||
'order' => 0,
|
|
||||||
];
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Modules\Gallery\Handlers;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Modules\AppHandler;
|
|
||||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
|
||||||
use App\CMS\Handlers\AdminHandler;
|
|
||||||
use App\CMS\Handlers\History;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use App\Models\FileManager\Directory;
|
|
||||||
use App\Models\FileManager\File;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class Gallery implements AppHandler
|
|
||||||
{
|
|
||||||
const CONFIG_FILENAME = 'photogallery-config';
|
|
||||||
const DIRECTORY_NAME = 'photogallery-data';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render given module into visitor area.
|
|
||||||
*
|
|
||||||
* @param Content $content DB model from table contents
|
|
||||||
* @param array $parameters parameters used for modifications/custom settings of given model
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function render(Content $content, $parameters)
|
|
||||||
{
|
|
||||||
// get directory ID
|
|
||||||
$directoryId = $content->moduleSettings->directoryId;
|
|
||||||
|
|
||||||
// get all images in given directory
|
|
||||||
$images = File::where('directory_id', $directoryId)
|
|
||||||
->where('mime_type', 'LIKE', 'image%')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
// render content
|
|
||||||
return Controller::visitorsView($content->template, [
|
|
||||||
'images' => $images,
|
|
||||||
'page' => $content,
|
|
||||||
'extra' => $parameters
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getHistoryHandler()
|
|
||||||
{
|
|
||||||
return History::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Content $content
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function loadExtraData(Content $content)
|
|
||||||
{
|
|
||||||
if (is_string($content->moduleSettings)) {
|
|
||||||
$content->moduleSettings = json_decode($content->moduleSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
$extra = [
|
|
||||||
'slider' => isset($content->moduleSettings->slider) ? $content->moduleSettings->slider : false
|
|
||||||
];
|
|
||||||
|
|
||||||
return $extra;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save module-specific values into database
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @internal param Widget $widget
|
|
||||||
*/
|
|
||||||
public static function createNew(Content &$content, Request $request)
|
|
||||||
{
|
|
||||||
$parentDirectoryId = Storage::get(self::CONFIG_FILENAME);
|
|
||||||
|
|
||||||
// create new directory for images
|
|
||||||
$directory = Directory::create([
|
|
||||||
'name' => $content->id . '_' . $request->title,
|
|
||||||
'description' => $request->description,
|
|
||||||
'parent_id' => $parentDirectoryId
|
|
||||||
]);
|
|
||||||
|
|
||||||
// save id into module_config array
|
|
||||||
$settings = ['directoryId' => $directory->id];
|
|
||||||
|
|
||||||
// save settings
|
|
||||||
$content->moduleSettings = json_encode($settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used for editing existing content page.
|
|
||||||
*
|
|
||||||
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @param $revisionID string ID of revision used
|
|
||||||
*
|
|
||||||
* @return int number of edited fields
|
|
||||||
*/
|
|
||||||
public static function edit(Content &$content, Request $request, $revisionID)
|
|
||||||
{
|
|
||||||
// nothing to edit
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function managesContent()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getModuleId()
|
|
||||||
{
|
|
||||||
$handler = config('gallery.handler');
|
|
||||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
|
||||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
|
||||||
|
|
||||||
return $moduleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for section names in creating/editing content resource
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function getExtendedFormSections()
|
|
||||||
{
|
|
||||||
$sections = AdminHandler::getExtendedFormSections();
|
|
||||||
|
|
||||||
$sections['upload'] = trans('gallery::admin/content.upload');
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for views used in extended part of form for creating new content
|
|
||||||
*
|
|
||||||
* This method should return pairs <section, view-name>. View is returned only as name in plain text
|
|
||||||
*
|
|
||||||
* @return array of views/templates/html codes divided into section
|
|
||||||
*/
|
|
||||||
public static function getExtendedFormInputsCreate()
|
|
||||||
{
|
|
||||||
$parts = AdminHandler::getExtendedFormInputsCreate();
|
|
||||||
$parts['upload'] = 'gallery::admin.content.newUpload';
|
|
||||||
|
|
||||||
return $parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for extended part of form for editing existing content
|
|
||||||
*
|
|
||||||
* Basically, this method may be
|
|
||||||
*
|
|
||||||
* @return array of views/templates/html codes divided into section
|
|
||||||
*/
|
|
||||||
public static function getExtendedFormInputsEdit()
|
|
||||||
{
|
|
||||||
$parts = AdminHandler::getExtendedFormInputsCreate();
|
|
||||||
$parts['upload'] = 'gallery::admin.content.editUpload';
|
|
||||||
|
|
||||||
return $parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register admin menu (or multiple ones)
|
|
||||||
*
|
|
||||||
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
|
|
||||||
* starting any middleware..
|
|
||||||
*
|
|
||||||
* @param User $user model of logged user
|
|
||||||
*/
|
|
||||||
public static function registerAdminMenu(User $user)
|
|
||||||
{
|
|
||||||
$menu = \Menu::instance('mainMenu');
|
|
||||||
$submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages'));
|
|
||||||
$submenu->dropdown(trans('gallery::module.name'), function ($submenu) use ($user) {
|
|
||||||
$submenu->route('content.new', trans('gallery::admin/adminMenu.new'), ['module' => 'gallery'], 10, ['icon' => 'fa fa-plus']);
|
|
||||||
$submenu->route('content.overview', trans('gallery::admin/adminMenu.overview'), ['module' => 'gallery'], 20, ['icon' => 'fa fa-list']);
|
|
||||||
}, 25, ['icon' => 'fa fa-camera']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install module
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function install()
|
|
||||||
{
|
|
||||||
$directory = Directory::where('name', self::DIRECTORY_NAME)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!count($directory)) {
|
|
||||||
$directory = Directory::create([
|
|
||||||
'name' => self::DIRECTORY_NAME,
|
|
||||||
'hidden' => true
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 moduleSettings into something more accessible
|
|
||||||
if (is_string($content->moduleSettings)) {
|
|
||||||
$content->moduleSettings = json_decode($content->moduleSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get directory id
|
|
||||||
$directoryId = $content->moduleSettings->directoryId;
|
|
||||||
|
|
||||||
$directory = Directory::find($directoryId);
|
|
||||||
|
|
||||||
// check if gallery exists
|
|
||||||
if (!$directory) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete directory used as photogallery
|
|
||||||
$directory->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does this module support categories?
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function supportCategories()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php namespace Modules\Gallery\Providers;
|
|
||||||
|
|
||||||
use App\CMS\Modules\ServiceProviders\ServiceProvider;
|
|
||||||
|
|
||||||
class GalleryServiceProvider extends ServiceProvider
|
|
||||||
{
|
|
||||||
protected function setModuleAlias()
|
|
||||||
{
|
|
||||||
$this->alias = 'gallery';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setModulePath()
|
|
||||||
{
|
|
||||||
$this->path = __DIR__;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"new" => "Nová galerie",
|
|
||||||
"overview" => "Všechny galerie",
|
|
||||||
"templatePath" => "Šablony galerie",
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"invalidGallery" => "Tato stránka není platnou fotogalerií.",
|
|
||||||
"makeSlider" => "Vytvořit slider z této fotogalerie",
|
|
||||||
"orbitSliderMissing" => "Nelze vytvořit slider. Widget pro zobrazení slideru není nainstalován.",
|
|
||||||
"sliderCreated" => "Slider úspěšně vytvořen.",
|
|
||||||
"sliderEdit" => "Nastavení slideru",
|
|
||||||
"sliderFailed" => "Slider nemohl být vytvořen. Zpráva: :message",
|
|
||||||
"upload" => "Nahrát fotografie",
|
|
||||||
"uploadAfterSavingGallery" => "Nahrávání do této galerie zatím není dostupné. Uložte galerii a nahrávejte fotografie až v rámci editace.",
|
|
||||||
];
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"description" => "Jednoduchá galerie zobrazující fotografie/grafiku v jednoduchém lightboxu. Tento modul nenabízí žádné speciální zobrazení pro fotografie.",
|
|
||||||
"name" => "Galerie",
|
|
||||||
];
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'templatePath' => 'Gallery templates',
|
|
||||||
'new' => 'New gallery',
|
|
||||||
'overview' => 'All galleries'
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'upload' => 'Upload photos',
|
|
||||||
'uploadAfterSavingGallery' => 'Uploading for this gallery is not available yet. You must create the gallery first and upload later.',
|
|
||||||
'makeSlider' => 'Make slider from this photogallery',
|
|
||||||
'orbitSliderMissing' => 'Cannot create slider. Widget for slider is not installed.',
|
|
||||||
'invalidGallery' => 'This content page is not a valid gallery page.',
|
|
||||||
'sliderFailed' => 'Slider could not be created. Reason: :message',
|
|
||||||
'sliderCreated' => 'Slider successfully created.',
|
|
||||||
'sliderEdit' => 'Slider settings',
|
|
||||||
];
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'name' => 'Gallery',
|
|
||||||
'description' => 'Simple photogallery',
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"new" => "Nová galéria",
|
|
||||||
"overview" => "Všetky galérie",
|
|
||||||
"templatePath" => "Šablóny galérie",
|
|
||||||
];
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"invalidGallery" => "Táto stránka nie je platná fotogaléria.",
|
|
||||||
"makeSlider" => "Vytvoriť slider z tejto fotogalérie",
|
|
||||||
"orbitSliderMissing" => "Nie je možné vytvoriť slider. Widget pre zobrazenie slideru nie je nainštalovaný.",
|
|
||||||
"sliderCreated" => "Slider úspešne vytvorený.",
|
|
||||||
"sliderEdit" => "Nastavenie slideru",
|
|
||||||
"sliderFailed" => "Slider nemohol byť vytvorený. Správa: :message",
|
|
||||||
"upload" => "Nahrať fotografie",
|
|
||||||
"uploadAfterSavingGallery" => "Nahrávanie do tejto galérie nie je dostupné. Najprv uložte galériu a fotografie nahrávajte až v rámci editácie.",
|
|
||||||
];
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
"description" => "Jednoduchá galéria zobrazujúca fotografie/grafiku v jednoduchom lightboxe. Tento modul neponúka žiadne špeciálne zobrazovanie fotografií.",
|
|
||||||
"name" => "Galéria",
|
|
||||||
];
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<div class="row column">
|
|
||||||
<a href="{{route('upload.overview', ['id' => $page->moduleSettings->directoryId])}}" class="button large expanded success">@lang('gallery::admin/content.upload')</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row column text-center">
|
|
||||||
@if (!$extraData['slider'])
|
|
||||||
<a href="{{route('gallery.makeSlider', ['id' => $page->id])}}" class="button primary">@lang('gallery::admin/content.makeSlider')</a>
|
|
||||||
@else
|
|
||||||
<a href="{{route('widgets.edit', ['id' => $extraData['slider']])}}" class="button secondary">@lang('gallery::admin/content.sliderEdit')</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<div class="row column">
|
|
||||||
<em>@lang('gallery::admin/content.uploadAfterSavingGallery')</em>
|
|
||||||
</div>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user