From 29b0eab3144ab6653a1cbddad9b43daecd9d4cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 15 Mar 2016 14:12:03 +0100 Subject: [PATCH 1/6] FEATURE: divide search engines into admin and visitor ones. After this separation, search engine may be registered once for visitor area (with one presenter) and once for admin area (with different presenter). --- .../Registrators/SearchEngineRegistrator.php | 33 ++++++++++++++----- app/Http/Controllers/Admin/Search.php | 3 +- app/Providers/AppServiceProvider.php | 4 +-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/Handlers/Registrators/SearchEngineRegistrator.php b/app/Handlers/Registrators/SearchEngineRegistrator.php index 734fbac3..29bc700d 100644 --- a/app/Handlers/Registrators/SearchEngineRegistrator.php +++ b/app/Handlers/Registrators/SearchEngineRegistrator.php @@ -5,14 +5,20 @@ use App\Enumerations\Exceptions\EnumerationExistsException; use App\Handlers\Contracts\SearchHandler; use App\Handlers\Contracts\SearchPresenterHandler; use App\Handlers\Registrators\Items\SearchEngine; +use Symfony\Component\Process\Exception\InvalidArgumentException; class SearchEngineRegistrator { + const ADMIN = 'admin'; + const VISITOR = 'visitor'; protected $searchEngines; function __construct($app) { - $this->searchEngines = []; + $this->searchEngines = [ + self::ADMIN => [], + self::VISITOR => [] + ]; } /** @@ -21,37 +27,46 @@ class SearchEngineRegistrator * @param SearchHandler $search * @param SearchPresenterHandler $presenter * + * @param $type + * * @throws EnumerationExistsException */ - public function register(SearchHandler $search, SearchPresenterHandler $presenter) + public function register(SearchHandler $search, SearchPresenterHandler $presenter, $type) { - $this->checkIfRegistered($search->getId()); + $this->checkIfRegistered($type, $search->getId()); // register new extension - $this->searchEngines[$search->getId()] = [$search, $presenter]; + $this->searchEngines[$type][$search->getId()] = [$search, $presenter]; } /** * Getter for all registered extensions * + * @param $type + * * @return array */ - public function get() + public function get($type) { - return $this->searchEngines; + if (!isset($this->searchEngines[$type])) { + throw new InvalidArgumentException('Invalid type ' . $type); + } + + return $this->searchEngines[$type]; } /** * Checks if this section is not already defined * + * @param $type * @param $id * * @throws EnumerationExistsException */ - private function checkIfRegistered($id) + private function checkIfRegistered($type, $id) { - if (isset($this->searchEngines[$id])) { - throw new EnumerationExistsException('Already existing search engine ' . $id); + if (isset($this->searchEngines[$type][$id])) { + throw new EnumerationExistsException('Already existing search engine ' . $id . ' in ' . $type); } } } diff --git a/app/Http/Controllers/Admin/Search.php b/app/Http/Controllers/Admin/Search.php index 6250e8a3..45c5eaf8 100644 --- a/app/Http/Controllers/Admin/Search.php +++ b/app/Http/Controllers/Admin/Search.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin; use App\Handlers\Contracts\SearchHandler; use App\Handlers\Contracts\SearchPresenterHandler; +use App\Handlers\Registrators\SearchEngineRegistrator; use App\Http\Controllers\Controller; use App\Http\Requests; use Illuminate\Support\Facades\App; @@ -48,7 +49,7 @@ class Search extends Controller protected function performSearch($term) { $engines = App::make('registerSearchEngine') - ->get(); + ->get(SearchEngineRegistrator::ADMIN); $resultsParts = []; foreach ($engines as $engine) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 31abfee2..f7c4357d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -109,7 +109,7 @@ class AppServiceProvider extends ServiceProvider { $registrator = $this->app->make('registerSearchEngine'); - $registrator->register(new Content(), new AdminContentPresenter()); - $registrator->register(new Files(), new AdminFiles()); + $registrator->register(new Content(), new AdminContentPresenter(), SearchEngineRegistrator::ADMIN); + $registrator->register(new Files(), new AdminFiles(), SearchEngineRegistrator::ADMIN); } } From 3f03af7e03d5c737fd466ac5cddf8f40b502aaa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Fri, 1 Apr 2016 20:47:43 +0200 Subject: [PATCH 2/6] FIX: copy-paste error - content editation used form for creating content --- app/Http/Controllers/Admin/EditContent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/EditContent.php b/app/Http/Controllers/Admin/EditContent.php index dd6c3e49..31c5f4ee 100644 --- a/app/Http/Controllers/Admin/EditContent.php +++ b/app/Http/Controllers/Admin/EditContent.php @@ -59,7 +59,7 @@ class EditContent extends Controller 'rootPages' => $page->rootPages(), 'templates' => $templates, 'formSectionNames' => call_user_func([$page->module_handler, 'getExtendedFormSections']), - 'formSections' => call_user_func([$page->module_handler, 'getExtendedFormInputsCreate']), + 'formSections' => call_user_func([$page->module_handler, 'getExtendedFormInputsEdit']), 'historySize' => count($history['changesets']) ]); } From 811f2162c9b76b3ba858b7e8abcc494e5541c79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Fri, 1 Apr 2016 20:47:55 +0200 Subject: [PATCH 3/6] FEATURE: force history to save even module_settings fields --- app/Http/Controllers/Admin/EditContent.php | 14 ++++++-- app/Models/Content.php | 42 ++++++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Admin/EditContent.php b/app/Http/Controllers/Admin/EditContent.php index 31c5f4ee..ed5f9dbc 100644 --- a/app/Http/Controllers/Admin/EditContent.php +++ b/app/Http/Controllers/Admin/EditContent.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin; use App\Enumerations\ContentStatuses; use App\Enumerations\ModulesHandlerToId; use App\Http\Requests\EditContentRequest; +use App\Http\Requests\Request; use App\Models\Content; use App\Models\ContentHistory; use App\Models\File; @@ -111,7 +112,8 @@ class EditContent extends Controller ]; // save new values with history - list($revision, $changedColumns) = $page->updateWithHistory($fields, $this->getFields($request, $fields)); + $data = self::getFields($request, $fields); + list($revision, $changedColumns) = $page->updateWithHistory($fields, $data); $changedColumns += call_user_func_array([$page->module_handler, 'edit'], [&$page, $request, $revision]); @@ -275,7 +277,15 @@ class EditContent extends Controller ])); } - private function getFields(EditContentRequest $request, $fields) + /** + * Convert object of all request data into array of only wanted fields + * + * @param Request $request + * @param $fields + * + * @return array + */ + public static function getFields(Request $request, $fields) { $requestData = []; diff --git a/app/Models/Content.php b/app/Models/Content.php index 70fa0972..ee83c568 100644 --- a/app/Models/Content.php +++ b/app/Models/Content.php @@ -14,10 +14,13 @@ class Content extends Model public $timestamps = true; protected $fillable = [ 'user_id', + 'parent_id', 'module_handler', 'published_from', 'published_to', 'title_photo', + 'template', + 'is_homepage', 'title', 'url', 'meta_keywords', @@ -152,15 +155,31 @@ class Content extends Model foreach ($fields as $fieldDB => $fieldRequest) { // ignore non-existing fields - if ((!isset($this->$fieldDB) && !is_null($this->$fieldDB)) || (!isset($request[$fieldRequest]) && !is_null($request[$fieldRequest]))) { + if (!isset($request[$fieldRequest]) && !is_null($request[$fieldRequest])) { continue; } - // remove any whitespaces around real content - if (!is_null($request[$fieldRequest])) - $request[$fieldRequest] = trim($request[$fieldRequest]); + // if module settings is still JSON, decode it to normal stdClass + if (is_string($this->module_settings)) { + $this->module_settings = json_decode($this->module_settings); + } - if (trim($this->$fieldDB) != $request[$fieldRequest]) { + // are we editing common settings, or module-specific settings? + if (!in_array($fieldDB, $this->fillable)) { + // this field is not part of "core" content - probably it will be module settings + $commonField = false; + $fieldValue = $this->module_settings->$fieldDB; + } else { + $commonField = true; + $fieldValue = $this->$fieldDB; + } + + // remove any whitespaces around real content + if (!is_null($request[$fieldRequest])) { + $request[$fieldRequest] = trim($request[$fieldRequest]); + } + + if (trim($fieldValue) != $request[$fieldRequest]) { // setup history object $history = [ @@ -168,7 +187,7 @@ class Content extends Model 'content_id' => $this->id, 'edit_batch' => $revisionId, 'column' => $fieldRequest, - 'old_value' => $this->$fieldDB, + 'old_value' => $fieldValue, 'new_value' => $request[$fieldRequest] ]; @@ -176,12 +195,21 @@ class Content extends Model ContentHistory::create($history); // save change into database - $this->$fieldDB = $request[$fieldRequest]; + if ($commonField) { + $this->$fieldDB = $request[$fieldRequest]; + } else { + $this->module_settings->$fieldDB = $request[$fieldRequest]; + } $changed++; } } + // make JSON from stdClass + if (!is_string($this->module_settings)) { + $this->module_settings = json_encode($this->module_settings); + } + $this->save(); return [$revisionId, $changed]; From acd85a1cad2f3ab85ba9855644072b803a223f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Fri, 1 Apr 2016 20:48:44 +0200 Subject: [PATCH 4/6] FEATURE: add editation to contact form --- modules/ContactForm/Handlers/ContactForm.php | 23 +++++++++++++++++-- .../Handlers/ContactFormHistory.php | 22 ++++++++++++++---- .../Resources/lang/en/admin/history.php | 10 ++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 modules/ContactForm/Resources/lang/en/admin/history.php diff --git a/modules/ContactForm/Handlers/ContactForm.php b/modules/ContactForm/Handlers/ContactForm.php index a6df90f4..d5273ad3 100644 --- a/modules/ContactForm/Handlers/ContactForm.php +++ b/modules/ContactForm/Handlers/ContactForm.php @@ -3,6 +3,7 @@ namespace Modules\ContactForm\Handlers; use App\Enumerations\ModulesHandlerToId; use App\Handlers\Handler; +use App\Http\Controllers\Admin\EditContent; use App\Http\Controllers\Controller; use App\Http\Requests\Request; use App\Models\Content; @@ -41,7 +42,6 @@ class ContactForm extends Handler */ public static function createNew(Content &$content, Request $request) { - $settings = [ 'phone' => $request->phone, 'email' => $request->email, @@ -69,7 +69,21 @@ class ContactForm extends Handler */ public static function edit(Content &$content, Request $request, $revisionID) { - // TODO: Implement edit() method. + $fields = [ + 'phone' => 'phone', + 'email' => 'email', + 'companyName' => 'companyName', + 'address' => 'address', + 'gpsLat' => 'gpsLat', + 'gpsLng' => 'gpsLng', + ]; + + // get data and try to save them + $data = EditContent::getFields($request, $fields); + list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID); + + // return amount of changed columns + return $changedColumns; } public static function getModuleId() @@ -112,6 +126,11 @@ class ContactForm extends Handler ]; } + public static function getExtendedFormInputsEdit() + { + return self::getExtendedFormInputsCreate(); + } + /** * Register admin menu (or multiple ones) * diff --git a/modules/ContactForm/Handlers/ContactFormHistory.php b/modules/ContactForm/Handlers/ContactFormHistory.php index e5a33a37..0bbe9b42 100644 --- a/modules/ContactForm/Handlers/ContactFormHistory.php +++ b/modules/ContactForm/Handlers/ContactFormHistory.php @@ -5,12 +5,24 @@ use App\Handlers\History; class ContactFormHistory extends History { - public static function parseChangedValue($changeset) + /** + * Translate column name for history view + * + * @param $column + * + * @return mixed + */ + public static function parseColumnName($column) { - switch ($changeset->column) { - default: - return parent::parseChangedValue($changeset); - break; + // try to translate as contact form field + $translationString = 'contactform::admin/history.column' . ucfirst($column); + $translation = trans($translationString); + + // when translation is not available, try to fallback into core fields + if ($translation == $translationString) { + return parent::parseColumnName($column); } + + return $translation; } } \ No newline at end of file diff --git a/modules/ContactForm/Resources/lang/en/admin/history.php b/modules/ContactForm/Resources/lang/en/admin/history.php new file mode 100644 index 00000000..59a94453 --- /dev/null +++ b/modules/ContactForm/Resources/lang/en/admin/history.php @@ -0,0 +1,10 @@ + 'Phone', + 'columnAddress' => 'Address', + 'columnEmail' => 'E-mail', + 'columnCompanyName' => 'Company name', + 'columnGpsLat' => 'GPS Latitude', + 'columnGpsLng' => 'Gps Longitude', +]; + From f9afcae389e842b75aa868b5c139f015f0dc8395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Fri, 1 Apr 2016 21:50:05 +0200 Subject: [PATCH 5/6] FEATURE #1526: add simple photogallery Photogallery currently works with directories, UI is terrible, but it works. --- modules/Gallery/Assets/.gitkeep | 0 modules/Gallery/Config/.gitkeep | 0 modules/Gallery/Config/config.php | 12 ++ modules/Gallery/Console/.gitkeep | 0 modules/Gallery/Database/Migrations/.gitkeep | 0 modules/Gallery/Database/Seeders/.gitkeep | 0 .../Seeders/GalleryDatabaseSeeder.php | 20 ++ modules/Gallery/Entities/.gitkeep | 0 modules/Gallery/Handlers/Gallery.php | 194 ++++++++++++++++++ modules/Gallery/Http/Controllers/.gitkeep | 0 modules/Gallery/Http/Middleware/.gitkeep | 0 modules/Gallery/Http/Requests/.gitkeep | 0 modules/Gallery/Http/routes.php | 1 + modules/Gallery/Providers/.gitkeep | 0 .../Providers/GalleryServiceProvider.php | 110 ++++++++++ modules/Gallery/Repositories/.gitkeep | 0 .../Resources/lang/en/admin/content.php | 5 + modules/Gallery/Resources/lang/en/module.php | 6 + .../views/admin/content/editUpload.blade.php | 3 + .../views/admin/content/newUpload.blade.php | 3 + modules/Gallery/Tests/.gitkeep | 0 modules/Gallery/composer.json | 15 ++ modules/Gallery/start.php | 15 ++ 23 files changed, 384 insertions(+) create mode 100644 modules/Gallery/Assets/.gitkeep create mode 100644 modules/Gallery/Config/.gitkeep create mode 100644 modules/Gallery/Config/config.php create mode 100644 modules/Gallery/Console/.gitkeep create mode 100644 modules/Gallery/Database/Migrations/.gitkeep create mode 100644 modules/Gallery/Database/Seeders/.gitkeep create mode 100644 modules/Gallery/Database/Seeders/GalleryDatabaseSeeder.php create mode 100644 modules/Gallery/Entities/.gitkeep create mode 100644 modules/Gallery/Handlers/Gallery.php create mode 100644 modules/Gallery/Http/Controllers/.gitkeep create mode 100644 modules/Gallery/Http/Middleware/.gitkeep create mode 100644 modules/Gallery/Http/Requests/.gitkeep create mode 100644 modules/Gallery/Http/routes.php create mode 100644 modules/Gallery/Providers/.gitkeep create mode 100644 modules/Gallery/Providers/GalleryServiceProvider.php create mode 100644 modules/Gallery/Repositories/.gitkeep create mode 100644 modules/Gallery/Resources/lang/en/admin/content.php create mode 100644 modules/Gallery/Resources/lang/en/module.php create mode 100644 modules/Gallery/Resources/views/admin/content/editUpload.blade.php create mode 100644 modules/Gallery/Resources/views/admin/content/newUpload.blade.php create mode 100644 modules/Gallery/Tests/.gitkeep create mode 100644 modules/Gallery/composer.json create mode 100644 modules/Gallery/start.php diff --git a/modules/Gallery/Assets/.gitkeep b/modules/Gallery/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Config/.gitkeep b/modules/Gallery/Config/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Config/config.php b/modules/Gallery/Config/config.php new file mode 100644 index 00000000..2a2b7237 --- /dev/null +++ b/modules/Gallery/Config/config.php @@ -0,0 +1,12 @@ + '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/Console/.gitkeep b/modules/Gallery/Console/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Database/Migrations/.gitkeep b/modules/Gallery/Database/Migrations/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Database/Seeders/.gitkeep b/modules/Gallery/Database/Seeders/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Database/Seeders/GalleryDatabaseSeeder.php b/modules/Gallery/Database/Seeders/GalleryDatabaseSeeder.php new file mode 100644 index 00000000..1d0d0a07 --- /dev/null +++ b/modules/Gallery/Database/Seeders/GalleryDatabaseSeeder.php @@ -0,0 +1,20 @@ +call("OthersTableSeeder"); + } + +} \ No newline at end of file diff --git a/modules/Gallery/Entities/.gitkeep b/modules/Gallery/Entities/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Handlers/Gallery.php b/modules/Gallery/Handlers/Gallery.php new file mode 100644 index 00000000..1636fee8 --- /dev/null +++ b/modules/Gallery/Handlers/Gallery.php @@ -0,0 +1,194 @@ +module_settings)) { + $content->module_settings = json_decode($content->module_settings); + } + + // get directory ID + $directoryId = $content->module_settings->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]); + } + + public static function getHistoryHandler() + { + return History::class; + } + + /** + * 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' => $request->title, + 'description' => $request->description, + 'parent_id' => $parentDirectoryId + ]); + + // save id into module_config array + $settings = [ + 'directoryId' => $directory->id + ]; + + // save settings + $content->module_settings = 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 = Handler::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 = Handler::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 = Handler::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) + { + // nothing to register + } + + /** + * 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); + } +} \ No newline at end of file diff --git a/modules/Gallery/Http/Controllers/.gitkeep b/modules/Gallery/Http/Controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Http/Middleware/.gitkeep b/modules/Gallery/Http/Middleware/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Http/Requests/.gitkeep b/modules/Gallery/Http/Requests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Http/routes.php b/modules/Gallery/Http/routes.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/modules/Gallery/Http/routes.php @@ -0,0 +1 @@ +registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // + } + + /** + * Register config. + * + * @return void + */ + protected function registerConfig() + { + $this->publishes([ + __DIR__ . '/../Config/config.php' => config_path('gallery.php'), + ]); + $this->mergeConfigFrom(__DIR__ . '/../Config/config.php', 'gallery'); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = base_path('resources/views/modules/gallery'); + + $sourcePath = __DIR__ . '/../Resources/views'; + + $this->publishes([ + $sourcePath => $viewPath + ]); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/gallery'; + }, \Config::get('view.paths')), [$sourcePath]), 'gallery'); + + /** + * @var $registrator TemplateRegistrator + */ + $registrator = $this->app->make('registerTemplateDir'); + try { + // setup some global variables + $registrator->setBaseDirectory('resources/views/modules/gallery/visitor'); + $registrator->setNamespace('gallery'); + $registrator->setModuleId(call_user_func([config('gallery.handler'), 'getModuleId'])); + + // register path with current template name + $registrator->register(config('app.theme'), 'gallery::admin.templatePath'); + } catch (InvalidArgumentException $e) { + // ignore this exception + } + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = base_path('resources/lang/modules/gallery'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'gallery'); + } else { + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'gallery'); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array (); + } +} diff --git a/modules/Gallery/Repositories/.gitkeep b/modules/Gallery/Repositories/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/Resources/lang/en/admin/content.php b/modules/Gallery/Resources/lang/en/admin/content.php new file mode 100644 index 00000000..5458870a --- /dev/null +++ b/modules/Gallery/Resources/lang/en/admin/content.php @@ -0,0 +1,5 @@ + 'Upload photos', + 'uploadAfterSavingGallery' => 'Uploading for this gallery is not available yet. You must create the gallery first and upload later.' +]; \ No newline at end of file diff --git a/modules/Gallery/Resources/lang/en/module.php b/modules/Gallery/Resources/lang/en/module.php new file mode 100644 index 00000000..6b0048ab --- /dev/null +++ b/modules/Gallery/Resources/lang/en/module.php @@ -0,0 +1,6 @@ + 'Gallery', + 'description' => 'Simple photogallery', + +]; \ No newline at end of file diff --git a/modules/Gallery/Resources/views/admin/content/editUpload.blade.php b/modules/Gallery/Resources/views/admin/content/editUpload.blade.php new file mode 100644 index 00000000..d20f55a4 --- /dev/null +++ b/modules/Gallery/Resources/views/admin/content/editUpload.blade.php @@ -0,0 +1,3 @@ + \ 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 new file mode 100644 index 00000000..8d84eda9 --- /dev/null +++ b/modules/Gallery/Resources/views/admin/content/newUpload.blade.php @@ -0,0 +1,3 @@ +
+ @lang('gallery::admin/content.uploadAfterSavingGallery') +
\ No newline at end of file diff --git a/modules/Gallery/Tests/.gitkeep b/modules/Gallery/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Gallery/composer.json b/modules/Gallery/composer.json new file mode 100644 index 00000000..24d1e0a0 --- /dev/null +++ b/modules/Gallery/composer.json @@ -0,0 +1,15 @@ +{ + "name": "pingpong-modules/gallery", + "description": "", + "authors": [ + { + "name": "Pingpong Labs", + "email": "pingpong.labs@gmail.com" + } + ], + "autoload": { + "psr-4": { + "Modules\\Gallery\\": "" + } + } +} \ No newline at end of file diff --git a/modules/Gallery/start.php b/modules/Gallery/start.php new file mode 100644 index 00000000..7be329cb --- /dev/null +++ b/modules/Gallery/start.php @@ -0,0 +1,15 @@ + Date: Fri, 1 Apr 2016 21:51:15 +0200 Subject: [PATCH 6/6] FEATURE: add default template for gallery --- .../views/visitor/cwbs/modules/Gallery/default.blade.php | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 resources/views/visitor/cwbs/modules/Gallery/default.blade.php diff --git a/resources/views/visitor/cwbs/modules/Gallery/default.blade.php b/resources/views/visitor/cwbs/modules/Gallery/default.blade.php new file mode 100644 index 00000000..9936413d --- /dev/null +++ b/resources/views/visitor/cwbs/modules/Gallery/default.blade.php @@ -0,0 +1,5 @@ +

{{$page->title}}

+ +@foreach($images as $image) + +@endforeach \ No newline at end of file