From 3955d7290fd782ad83cfdabee58b5d9eb3df0eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 22 Aug 2017 20:19:06 +0200 Subject: [PATCH] FEATURE: remove gallery and move it into own repository --- modules/Gallery/Config/config.php | 12 - modules/Gallery/Handlers/Gallery.php | 254 ------------------ .../Providers/GalleryServiceProvider.php | 16 -- .../Resources/lang/cs/admin/adminMenu.php | 6 - .../Resources/lang/cs/admin/content.php | 11 - modules/Gallery/Resources/lang/cs/module.php | 5 - .../Resources/lang/en/admin/adminMenu.php | 6 - .../Resources/lang/en/admin/content.php | 11 - modules/Gallery/Resources/lang/en/module.php | 6 - .../Resources/lang/sk/admin/adminMenu.php | 6 - .../Resources/lang/sk/admin/content.php | 11 - modules/Gallery/Resources/lang/sk/module.php | 5 - .../views/admin/content/editUpload.blade.php | 12 - .../views/admin/content/newUpload.blade.php | 3 - modules/Gallery/start.php | 2 - 15 files changed, 366 deletions(-) delete mode 100644 modules/Gallery/Config/config.php delete mode 100644 modules/Gallery/Handlers/Gallery.php delete mode 100644 modules/Gallery/Providers/GalleryServiceProvider.php delete mode 100644 modules/Gallery/Resources/lang/cs/admin/adminMenu.php delete mode 100644 modules/Gallery/Resources/lang/cs/admin/content.php delete mode 100644 modules/Gallery/Resources/lang/cs/module.php delete mode 100644 modules/Gallery/Resources/lang/en/admin/adminMenu.php delete mode 100644 modules/Gallery/Resources/lang/en/admin/content.php delete mode 100644 modules/Gallery/Resources/lang/en/module.php delete mode 100644 modules/Gallery/Resources/lang/sk/admin/adminMenu.php delete mode 100644 modules/Gallery/Resources/lang/sk/admin/content.php delete mode 100644 modules/Gallery/Resources/lang/sk/module.php delete mode 100644 modules/Gallery/Resources/views/admin/content/editUpload.blade.php delete mode 100644 modules/Gallery/Resources/views/admin/content/newUpload.blade.php delete mode 100644 modules/Gallery/start.php diff --git a/modules/Gallery/Config/config.php b/modules/Gallery/Config/config.php deleted file mode 100644 index 2a2b7237..00000000 --- a/modules/Gallery/Config/config.php +++ /dev/null @@ -1,12 +0,0 @@ - '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, -]; \ No newline at end of file diff --git a/modules/Gallery/Handlers/Gallery.php b/modules/Gallery/Handlers/Gallery.php deleted file mode 100644 index 48e203e9..00000000 --- a/modules/Gallery/Handlers/Gallery.php +++ /dev/null @@ -1,254 +0,0 @@ -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 . 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; - } -} \ No newline at end of file diff --git a/modules/Gallery/Providers/GalleryServiceProvider.php b/modules/Gallery/Providers/GalleryServiceProvider.php deleted file mode 100644 index 0e675e82..00000000 --- a/modules/Gallery/Providers/GalleryServiceProvider.php +++ /dev/null @@ -1,16 +0,0 @@ -alias = 'gallery'; - } - - protected function setModulePath() - { - $this->path = __DIR__; - } -} diff --git a/modules/Gallery/Resources/lang/cs/admin/adminMenu.php b/modules/Gallery/Resources/lang/cs/admin/adminMenu.php deleted file mode 100644 index 91299728..00000000 --- a/modules/Gallery/Resources/lang/cs/admin/adminMenu.php +++ /dev/null @@ -1,6 +0,0 @@ - "Nová galerie", -"overview" => "Všechny galerie", -"templatePath" => "Šablony galerie", -]; diff --git a/modules/Gallery/Resources/lang/cs/admin/content.php b/modules/Gallery/Resources/lang/cs/admin/content.php deleted file mode 100644 index ac72921f..00000000 --- a/modules/Gallery/Resources/lang/cs/admin/content.php +++ /dev/null @@ -1,11 +0,0 @@ - "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.", -]; diff --git a/modules/Gallery/Resources/lang/cs/module.php b/modules/Gallery/Resources/lang/cs/module.php deleted file mode 100644 index 337dd6d5..00000000 --- a/modules/Gallery/Resources/lang/cs/module.php +++ /dev/null @@ -1,5 +0,0 @@ - "Jednoduchá galerie zobrazující fotografie/grafiku v jednoduchém lightboxu. Tento modul nenabízí žádné speciální zobrazení pro fotografie.", -"name" => "Galerie", -]; diff --git a/modules/Gallery/Resources/lang/en/admin/adminMenu.php b/modules/Gallery/Resources/lang/en/admin/adminMenu.php deleted file mode 100644 index 099f852a..00000000 --- a/modules/Gallery/Resources/lang/en/admin/adminMenu.php +++ /dev/null @@ -1,6 +0,0 @@ - 'Gallery templates', - 'new' => 'New gallery', - 'overview' => 'All galleries' -]; \ No newline at end of file diff --git a/modules/Gallery/Resources/lang/en/admin/content.php b/modules/Gallery/Resources/lang/en/admin/content.php deleted file mode 100644 index c7741f22..00000000 --- a/modules/Gallery/Resources/lang/en/admin/content.php +++ /dev/null @@ -1,11 +0,0 @@ - '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', -]; \ No newline at end of file diff --git a/modules/Gallery/Resources/lang/en/module.php b/modules/Gallery/Resources/lang/en/module.php deleted file mode 100644 index 6b0048ab..00000000 --- a/modules/Gallery/Resources/lang/en/module.php +++ /dev/null @@ -1,6 +0,0 @@ - 'Gallery', - 'description' => 'Simple photogallery', - -]; \ No newline at end of file diff --git a/modules/Gallery/Resources/lang/sk/admin/adminMenu.php b/modules/Gallery/Resources/lang/sk/admin/adminMenu.php deleted file mode 100644 index bd541608..00000000 --- a/modules/Gallery/Resources/lang/sk/admin/adminMenu.php +++ /dev/null @@ -1,6 +0,0 @@ - "Nová galéria", -"overview" => "Všetky galérie", -"templatePath" => "Šablóny galérie", -]; diff --git a/modules/Gallery/Resources/lang/sk/admin/content.php b/modules/Gallery/Resources/lang/sk/admin/content.php deleted file mode 100644 index 41ffac65..00000000 --- a/modules/Gallery/Resources/lang/sk/admin/content.php +++ /dev/null @@ -1,11 +0,0 @@ - "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.", -]; diff --git a/modules/Gallery/Resources/lang/sk/module.php b/modules/Gallery/Resources/lang/sk/module.php deleted file mode 100644 index 01532983..00000000 --- a/modules/Gallery/Resources/lang/sk/module.php +++ /dev/null @@ -1,5 +0,0 @@ - "Jednoduchá galéria zobrazujúca fotografie/grafiku v jednoduchom lightboxe. Tento modul neponúka žiadne špeciálne zobrazovanie fotografií.", - "name" => "Galéria", -]; diff --git a/modules/Gallery/Resources/views/admin/content/editUpload.blade.php b/modules/Gallery/Resources/views/admin/content/editUpload.blade.php deleted file mode 100644 index 75f03669..00000000 --- a/modules/Gallery/Resources/views/admin/content/editUpload.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - - -
\ No newline at end of file diff --git a/modules/Gallery/Resources/views/admin/content/newUpload.blade.php b/modules/Gallery/Resources/views/admin/content/newUpload.blade.php deleted file mode 100644 index 8d84eda9..00000000 --- a/modules/Gallery/Resources/views/admin/content/newUpload.blade.php +++ /dev/null @@ -1,3 +0,0 @@ -
- @lang('gallery::admin/content.uploadAfterSavingGallery') -
\ No newline at end of file diff --git a/modules/Gallery/start.php b/modules/Gallery/start.php deleted file mode 100644 index a4abe2da..00000000 --- a/modules/Gallery/start.php +++ /dev/null @@ -1,2 +0,0 @@ -