From 51b03acbcd73dda735a0a358725eecfd4310a67a Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 5 Oct 2016 16:31:37 +0100 Subject: [PATCH] Added copyright/powered by notices to the footers of all pages. Added a config option to turn it off on the public-facing gallery pages --- app/Helpers/ConfigHelper.php | 1 + .../Controllers/Admin/AlbumController.php | 2 ++ .../Controllers/Admin/DefaultController.php | 3 +++ .../Controllers/Admin/PhotoController.php | 2 ++ .../Controllers/Admin/StorageController.php | 2 ++ app/Http/Controllers/Admin/UserController.php | 7 ++++++ app/Http/Middleware/GlobalConfiguration.php | 16 +++++++++++++ resources/lang/en/global.php | 4 ++++ .../themes/base/admin/settings.blade.php | 14 +++++++++++ resources/views/themes/base/layout.blade.php | 6 +++++ .../base/partials/copyright_admin.blade.php | 24 +++++++++++++++++++ .../base/partials/copyright_gallery.blade.php | 20 ++++++++++++++++ 12 files changed, 101 insertions(+) create mode 100644 resources/views/themes/base/partials/copyright_admin.blade.php create mode 100644 resources/views/themes/base/partials/copyright_gallery.blade.php diff --git a/app/Helpers/ConfigHelper.php b/app/Helpers/ConfigHelper.php index 43ec37a..18b8fc2 100644 --- a/app/Helpers/ConfigHelper.php +++ b/app/Helpers/ConfigHelper.php @@ -90,6 +90,7 @@ class ConfigHelper 'recaptcha_enabled_registration' => false, 'recaptcha_secret_key' => '', 'recaptcha_site_key' => '', + 'remove_copyright' => false, 'require_email_verification' => true, 'restrict_original_download' => true, 'sender_address' => sprintf('hostmaster@%s', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost')), diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index 92e05e0..1131ac6 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -16,12 +16,14 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\View; class AlbumController extends Controller { public function __construct() { $this->middleware('auth'); + View::share('is_admin', true); } public function analyse($id) diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 65eb404..0f0fc6c 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -17,12 +17,14 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\View; class DefaultController extends Controller { public function __construct() { $this->middleware('auth'); + View::share('is_admin', true); } public function index() @@ -56,6 +58,7 @@ class DefaultController extends Controller 'allow_self_registration', 'hotlink_protection', 'recaptcha_enabled_registration', + 'remove_copyright', 'require_email_verification', 'restrict_original_download', 'smtp_encryption', diff --git a/app/Http/Controllers/Admin/PhotoController.php b/app/Http/Controllers/Admin/PhotoController.php index 49b271e..018af20 100644 --- a/app/Http/Controllers/Admin/PhotoController.php +++ b/app/Http/Controllers/Admin/PhotoController.php @@ -18,6 +18,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\View; use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator; use Symfony\Component\HttpFoundation\File\File; @@ -26,6 +27,7 @@ class PhotoController extends Controller public function __construct() { $this->middleware(['auth', 'max_post_size_exceeded']); + View::share('is_admin', true); } public function analyse($photoId) diff --git a/app/Http/Controllers/Admin/StorageController.php b/app/Http/Controllers/Admin/StorageController.php index 1252f2b..978ea16 100644 --- a/app/Http/Controllers/Admin/StorageController.php +++ b/app/Http/Controllers/Admin/StorageController.php @@ -10,12 +10,14 @@ use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\View; class StorageController extends Controller { public function __construct() { $this->middleware('auth'); + View::share('is_admin', true); } /** diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 8c1f693..5166cc5 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -11,9 +11,16 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\View; class UserController extends Controller { + public function __construct() + { + $this->middleware('auth'); + View::share('is_admin', true); + } + public function delete(Request $request, $id) { $this->authorize('admin-access'); diff --git a/app/Http/Middleware/GlobalConfiguration.php b/app/Http/Middleware/GlobalConfiguration.php index c09545f..c547956 100644 --- a/app/Http/Middleware/GlobalConfiguration.php +++ b/app/Http/Middleware/GlobalConfiguration.php @@ -42,6 +42,7 @@ class GlobalConfiguration // When running migrations, CLI tasks or the installer, don't need to add things to the view if (php_sapi_name() != 'cli') { + $this->addLicenseInfoToView(); $this->addThemeInfoToView(); $this->addAlbumsToView(); } @@ -58,6 +59,21 @@ class GlobalConfiguration View::share('albums', $albums); } + private function addLicenseInfoToView() + { + $licenseName = null; + $licenseNo = null; + + if (function_exists('sg_get_const')) + { + $licenseName = sg_get_const('license_name'); + $licenseNo = sg_get_const('license_number'); + } + + View::share('license_name', strlen($licenseName) == 0 ? '**UNLICENSED**' : $licenseName); + View::share('license_no', strlen($licenseNo) == 0 ? '0' : $licenseNo); + } + private function addThemeInfoToView() { $themeInfo = Theme::info(); diff --git a/resources/lang/en/global.php b/resources/lang/en/global.php index 2f6f06f..67791ce 100644 --- a/resources/lang/en/global.php +++ b/resources/lang/en/global.php @@ -4,7 +4,11 @@ return [ 'filesystem' => 'Local filesystem' ], 'app_name' => 'Blue Twilight', + 'copyright' => '© :years :link_startAndy Heathershaw:link_end', + 'licensed_to' => 'Licensed to :name (:number)', + 'version_number' => 'Version :version', 'post_max_exceeded' => 'Your upload exceeded the maximum size the web server is configured to allow. Please check the value of the "post_max_size" parameter in php.ini.', + 'powered_by' => 'Powered by :link_startBlue Twilight:link_end - the self-hosted photo gallery software.', 'units' => [ 'megabytes' => 'MB' ] diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index d017d86..7b08fa8 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -56,6 +56,20 @@ + +
+
+ "Powered by" footer link +

To help spread the word about Blue Twilight, I'd really appreciate it if you left the "Powered by" notice in your gallery's footer.

+

This is not compulsory, however, and you may remove it by checking the box below.

+ +
+ +
+
{{-- E-mail --}} diff --git a/resources/views/themes/base/layout.blade.php b/resources/views/themes/base/layout.blade.php index fa59bd2..47fa6b5 100644 --- a/resources/views/themes/base/layout.blade.php +++ b/resources/views/themes/base/layout.blade.php @@ -62,6 +62,12 @@ @endif @yield('content') + + @if (isset($is_admin) && $is_admin) + @include(\App\Facade\Theme::viewName('partials.copyright_admin')) + @elseif (!\App\Facade\UserConfig::get('remove_copyright')) + @include(\App\Facade\Theme::viewName('partials.copyright_gallery')) + @endif {{-- Cannot use $theme_url here: if a theme uses the base layout, it would also have to provide all these dependencies! --}} diff --git a/resources/views/themes/base/partials/copyright_admin.blade.php b/resources/views/themes/base/partials/copyright_admin.blade.php new file mode 100644 index 0000000..ba41eec --- /dev/null +++ b/resources/views/themes/base/partials/copyright_admin.blade.php @@ -0,0 +1,24 @@ +
+
+
+
+

+ + @lang('global.powered_by', [ + 'link_start' => '', + 'link_end' => '', + ]) +
+ @lang('global.copyright', [ + 'link_start' => '', + 'link_end' => '', + 'years' => (date('Y') == 2016 ? '2016' : '2016-' . date('Y')) + ]) +

+

+ @lang('global.licensed_to', ['name' => $license_name, 'number' => $license_no])
+ @lang('global.version_number', ['version' => config('app.version')]) +

+
+
+
\ No newline at end of file diff --git a/resources/views/themes/base/partials/copyright_gallery.blade.php b/resources/views/themes/base/partials/copyright_gallery.blade.php new file mode 100644 index 0000000..3d84e00 --- /dev/null +++ b/resources/views/themes/base/partials/copyright_gallery.blade.php @@ -0,0 +1,20 @@ +
+
+
+
+

+ + @lang('global.powered_by', [ + 'link_start' => '', + 'link_end' => '', + ]) +
+ @lang('global.copyright', [ + 'link_start' => '', + 'link_end' => '', + 'years' => (date('Y') == 2016 ? '2016' : '2016-' . date('Y')) + ]) +

+
+
+
\ No newline at end of file