From 3ff2fca215058d4c778cafaf6c8c3bf6955e5033 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Fri, 9 Jan 2015 20:57:19 +0100 Subject: [PATCH] Add credits page --- module/assets/css/credits.css | 80 ++++++++++++++ module/config/autoload.php | 1 + module/config/config.php | 30 ++++- module/languages/en/modules.php | 2 + module/templates/be_leaflet_credits.html5 | 104 ++++++++++++++++++ .../Contao/Leaflet/Backend/Credits.php | 93 ++++++++++++++++ .../Leaflet/Subscriber/BootSubscriber.php | 2 +- 7 files changed, 309 insertions(+), 3 deletions(-) create mode 100644 module/assets/css/credits.css create mode 100644 module/templates/be_leaflet_credits.html5 create mode 100644 src/Netzmacht/Contao/Leaflet/Backend/Credits.php diff --git a/module/assets/css/credits.css b/module/assets/css/credits.css new file mode 100644 index 0000000..0e71c71 --- /dev/null +++ b/module/assets/css/credits.css @@ -0,0 +1,80 @@ + +.netzmacht-leaflet-credits .tl_box { + padding: 15px; +} + + +.netzmacht-leaflet-credits a { + color: #669A00; +} + +.netzmacht-leaflet-credits .header { + background: #82cb00; + background-image: -webkit-linear-gradient(top, #b0de5c, #82cb00); + padding: 20px 15px 5px; +} + +.netzmacht-leaflet-credits h1 { + color: #fff; + font-size: 1.4em; + text-shadow: 0 -1px 1px rgba(0,0,0,0.35); +} + +.netzmacht-leaflet-credits .row:after { + content: "."; + display: block; + clear: both; + font-size: 0; + height: 0; + visibility: hidden; +} + +.netzmacht-leaflet-credits .row > .left { + width: 55%; + float: left; + padding-right: 5%; +} + +.netzmacht-leaflet-credits .row > .right { + width: 40%; + float: left; +} + +.netzmacht-leaflet-credits .row > .col { + width: 30%; + float: left; +} + +.netzmacht-leaflet-credits .row > .col + .col { + margin-left: 4%; +} + +.netzmacht-leaflet-credits th { + background: #ddd; + border-top: 1px solid #ccc; + border-bottom: 1px solid #ccc; + padding: 5px 3px 3px; +} + +.netzmacht-leaflet-credits td { + padding: 2px 3px; + border-bottom: 1px solid #e9e9e9; +} + +.netzmacht-leaflet-credits th.subtitle { + background: #f6f6f6; + border-bottom: 1px solid #ddd; +} + +.netzmacht-leaflet-credits .btn { + background: #619A00; + color: #fff; + padding: 5px 8px; + border-radius: 3px; + display: inline-block; +} + +.netzmacht-leaflet-credits .btn:hover { + background: #82cb00; + color: #333; +} diff --git a/module/config/autoload.php b/module/config/autoload.php index 3cb9e96..7ac1b16 100644 --- a/module/config/autoload.php +++ b/module/config/autoload.php @@ -4,5 +4,6 @@ TemplateLoader::addFiles( array( 'ce_leaflet_map' => 'system/modules/leaflet/templates', 'be_leaflet_geocode' => 'system/modules/leaflet/templates', + 'be_leaflet_credits' => 'system/modules/leaflet/templates', ) ); diff --git a/module/config/config.php b/module/config/config.php index 8324b09..dc54c0d 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -31,6 +31,12 @@ array_insert( ), 'icon' => 'system/modules/leaflet/assets/img/layers.png', 'stylesheet' => 'system/modules/leaflet/assets/css/backend.css', + ), + 'leaflet_credits' => array + ( + 'callback' => 'Netzmacht\Contao\Leaflet\Backend\Credits', + 'icon' => 'system/modules/leaflet/assets/img/info.png', + 'stylesheet' => 'system/modules/leaflet/assets/css/credits.css', ) ) ) @@ -39,7 +45,7 @@ array_insert( /* * Content elements. */ -$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMapElement'; +$GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\Frontend\MapElement'; /* @@ -250,28 +256,48 @@ require_once TL_ROOT . '/system/modules/leaflet/config/leaflet_providers.php'; * You don't have to define it as array if you simply add a file. Do not add |static and or media type flag to it. * It's getting added by default if not being in debug mode. */ -$GLOBALS['LEAFLET_ASSETS'] = array +$GLOBALS['LEAFLET_LIBRARIES'] = array ( 'leaflet' => array ( + 'name' => 'Leaflet', + 'version' => '0.7.3', + 'license' => 'BSD-2-Clause', + 'homepage' => 'http://leafletjs.com', 'css' => 'assets/leaflet/libs/leaflet/leaflet.css', 'javascript' => 'assets/leaflet/libs/leaflet/leaflet.js' ), 'leaflet-providers' => array ( + 'name' => 'Leaflet-providers', + 'version' => '1.0.12', + 'license' => 'BSD-2-Clause', + 'homepage' => 'http://leaflet-extras.github.io/leaflet-providers', 'javascript' => 'assets/leaflet/libs/leaflet-providers/leaflet-providers.js' ), 'leaflet-ajax' => array ( + 'name' => 'Leaflet-ajax', + 'version' => '1.1.0', + 'license' => 'MIT', + 'homepage' => 'https://github.com/calvinmetcalf/leaflet-ajax', 'javascript' => 'assets/leaflet/libs/leaflet-ajax/leaflet.ajax.min.js' ), 'leaflet-loading' => array ( + 'name' => 'Leaflet.loading', + 'version' => '0.1.13 ', + 'license' => 'MIT', + 'homepage' => 'https://github.com/ebrelsford/Leaflet.loading', 'css' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.css', 'javascript' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.js' ), 'spin.js' => array ( + 'name' => 'spin.js', + 'version' => '2.0.2', + 'license' => 'MIT', + 'homepage' => 'http://fgnass.github.io/spin.js', 'javascript' => 'assets/leaflet/libs/spin-js/spin.min.js' ) ); diff --git a/module/languages/en/modules.php b/module/languages/en/modules.php index 34f09ec..aa4da2b 100644 --- a/module/languages/en/modules.php +++ b/module/languages/en/modules.php @@ -6,6 +6,8 @@ $GLOBALS['TL_LANG']['MOD']['leaflet_map'][0] = 'Leaflet Maps'; $GLOBALS['TL_LANG']['MOD']['leaflet_map'][1] = 'Manage Leaflet maps'; $GLOBALS['TL_LANG']['MOD']['leaflet_layer'][0] = 'Map Layers'; $GLOBALS['TL_LANG']['MOD']['leaflet_layer'][1] = 'Manage map layers'; +$GLOBALS['TL_LANG']['MOD']['leaflet_credits'][0] = 'Support it'; +$GLOBALS['TL_LANG']['MOD']['leaflet_credits'][1] = 'Contao leaflet integration credits'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_map'] = 'Maps'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_layer'] = 'Layers'; diff --git a/module/templates/be_leaflet_credits.html5 b/module/templates/be_leaflet_credits.html5 new file mode 100644 index 0000000..d296f7b --- /dev/null +++ b/module/templates/be_leaflet_credits.html5 @@ -0,0 +1,104 @@ +
+
+

headline; ?> version; ?>

+
+ +
+

About

+
+

+ The Leaflet maps integration for Contao CMS is an Open Source Software license under the LGPL 3.0. + This extension is only exists because of great other Open Source Software which it heavenly depends on. +

+

+ This software ships with an visible attribution to netzmacht creative in the map attribution control. + If you want to remove this attribution, you have to purchase a commercial license. + For more details see the project website. +

+
+
+ > + +

+ netzmacht creative
+ David Molineus
+

+

+ DAB Bank München
+ IBAN: DE52701204008354237003
+ BIC: DABBDEMMXXX +

+
+ + + + +
+
+
+ +
+

Support Contao Leaflet

+ +
+
+

Fund a feature

+

Contao Leaflet is not feature complete. Have a look at the list of planned feature and support them.

+

Planned features

+
+
+

Individual development

+

If you have special requirements you can hire me for an individual development.

+

Contact

+
+
+

Commercial license

+

If you want to remove the attribution in the attribution control, you can purchase a commercial license.

+

Purchase license

+
+
+
+ +
+

Credits

+ + + + + + + + libraries): ?> + + + libraries as $library): ?> + + + + + + + + + + + + + + + + + dependencies): ?> + + + dependencies as $dep): ?> + + + + + + + +
NameVersionLicenseHomepage
Libraries
Graphics
Farm Fresh-Web Icons3.9.2CC BY 3.0 USfatcow.com/free-icons
Dependencies
+
+
diff --git a/src/Netzmacht/Contao/Leaflet/Backend/Credits.php b/src/Netzmacht/Contao/Leaflet/Backend/Credits.php new file mode 100644 index 0000000..351df6a --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Backend/Credits.php @@ -0,0 +1,93 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Backend; + + +class Credits +{ + public function generate() + { + $template = new \BackendTemplate('be_leaflet_credits'); + + $template->headline = 'Leaftlet maps integration for Contao CMS'; + $template->libraries = $this->getLibraries(); + + list($template->version, $template->dependencies) = $this->extractFromComposer(); + + return $template->parse(); + } + + private function getLibraries() + { + return array_map( + function ($library) { + $library = array_merge( + array( + 'homepage' => null, + 'version' => null, + ), + $library + ); + + if ($library['homepage']) { + $library['homepage'] = sprintf( + '%s', + $library['homepage'], + LINK_NEW_WINDOW, + preg_replace('#^(https?://(www)?)#i', '', $library['homepage']) + ); + } + + return $library; + }, + array_filter( + $GLOBALS['LEAFLET_LIBRARIES'], + function ($library) { + return isset($library['name']) && isset($library['license']); + } + ) + ); + } + + private function extractFromComposer() + { + $local = TL_ROOT . '/composer/vendor/netzmacht/contao-leaflet-maps/composer.json'; + $composer = TL_ROOT . '/composer/composer.lock'; + + if (!file_exists($local)) { + return array(); + } + + $local = json_decode(file_get_contents($local), true); + $installed = json_decode(file_get_contents($composer), true); + $deps = array(); + $version = null; + + foreach ($installed['packages'] as $package) { + if ($package['name'] === 'netzmacht/contao-leaflet-maps') { + $version = $package['version']; + } elseif (isset($local['require'][$package['name']])) { + $deps[] = array( + 'name' => $package['name'], + 'version' => $package['version'], + 'license' => !empty($package['license']) ? implode(', ', $package['license']) : '', + 'homepage' => sprintf( + 'Visit packagist', + $package['name'] + ) + ); + } + } + + return array($version, $deps); + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php index 5655bab..3d5bcd0 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php @@ -94,7 +94,7 @@ class BootSubscriber implements EventSubscriberInterface { $builder = $event->getBuilder(); - foreach ($GLOBALS['LEAFLET_ASSETS'] as $name => $assets) { + foreach ($GLOBALS['LEAFLET_LIBRARIES'] as $name => $assets) { if (!empty($assets['css'])) { list ($source, $type) = (array) $assets['css']; $builder->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE);