|
8 | 8 | use Drupal\Core\Session\AccountInterface;
|
9 | 9 | use Drupal\Core\Url;
|
10 | 10 | use Drupal\search_api\Entity\Index;
|
11 |
| -use Drupal\Core\Cache\CacheBackendInterface; |
12 | 11 | use Symfony\Component\HttpFoundation\Request;
|
13 | 12 | use Symfony\Component\HttpFoundation\Response;
|
14 |
| -use Drupal\Core\Cache\CacheFactoryInterface; |
15 |
| -use Drupal\Core\Render\RendererInterface; |
16 |
| -use Drupal\Core\Render\RenderContext; |
17 |
| -use Drupal\Core\Cache\CacheTagsInvalidatorInterface; |
18 |
| - |
| 13 | +use Drupal\Core\Cache\CacheBackendInterface; |
19 | 14 | use Drupal\Core\Cache\Cache;
|
20 | 15 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
21 | 16 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
@@ -111,47 +106,47 @@ class DynamicLandingPagesController extends ControllerBase {
|
111 | 106 | public const LICENCES = [
|
112 | 107 | 'CC0-1.0' => [
|
113 | 108 | 'url' => 'https://spdx.org/licenses/CC0-1.0',
|
114 |
| - 'img' => '/modules/metsis/metsis_search/icons/CC0.png', |
| 109 | + 'img' => '/modules/metsis/metsis_search/icons/CC0.webp', |
115 | 110 | ],
|
116 | 111 | 'CC-BY-3.0' => [
|
117 | 112 | 'url' => 'https://spdx.org/licenses/CC-BY-3.0',
|
118 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBY.png', |
| 113 | + 'img' => '/modules/metsis/metsis_search/icons/CCBY.webp', |
119 | 114 | ],
|
120 | 115 | 'CC-BY-4.0' => [
|
121 | 116 | 'url' => 'https://spdx.org/licenses/CC-BY-4.0',
|
122 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBY.png', |
| 117 | + 'img' => '/modules/metsis/metsis_search/icons/CCBY.webp', |
123 | 118 | ],
|
124 | 119 | 'CC-BY/NLOD' => [
|
125 | 120 | 'url' => 'https://spdx.org/licenses/CC-BY-4.0',
|
126 |
| - 'img' => '"/modules/metsis/metsis_search/icons/CCBY.png', |
| 121 | + 'img' => '"/modules/metsis/metsis_search/icons/CCBY.webp', |
127 | 122 | ],
|
128 | 123 | 'CC BY/NLOD' => [
|
129 | 124 | 'url' => 'https://spdx.org/licenses/CC-BY-4.0',
|
130 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBY.png', |
| 125 | + 'img' => '/modules/metsis/metsis_search/icons/CCBY.webp', |
131 | 126 | ],
|
132 | 127 | 'CC-BY-SA-4.0' => [
|
133 | 128 | 'url' => 'https://spdx.org/licenses/CC-BY-SA-4.0',
|
134 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYSA.png', |
| 129 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYSA.webp', |
135 | 130 | ],
|
136 | 131 | 'CC-BY-NC-4.0' => [
|
137 | 132 | 'url' => 'https://spdx.org/licenses/CC-BY-NC-4.0',
|
138 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYNC.png', |
| 133 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYNC.webp', |
139 | 134 | ],
|
140 | 135 | 'CC-BY-NC' => [
|
141 | 136 | 'url' => 'https://spdx.org/licenses/CC-BY-NC-4.0',
|
142 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYNC.png', |
| 137 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYNC.webp', |
143 | 138 | ],
|
144 | 139 | 'CC-BY-NC-SA-4.0' => [
|
145 | 140 | 'url' => 'https://spdx.org/licenses/CC-BY-NC-SA-4.0',
|
146 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYNCSA.png', |
| 141 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYNCSA.webp', |
147 | 142 | ],
|
148 | 143 | 'CC-BY-ND-4.0' => [
|
149 | 144 | 'url' => 'https://spdx.org/licenses/CC-BY-ND-4.0',
|
150 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYND.png', |
| 145 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYND.webp', |
151 | 146 | ],
|
152 | 147 | 'CC-BY-NC-ND-4.0' => [
|
153 | 148 | 'url' => 'https://spdx.org/licenses/CC-BY-NC-ND-4.0',
|
154 |
| - 'img' => '/modules/metsis/metsis_search/icons/CCBYNCND.png', |
| 149 | + 'img' => '/modules/metsis/metsis_search/icons/CCBYNCND.webp', |
155 | 150 | ],
|
156 | 151 | 'Not provided' => NULL,
|
157 | 152 | ];
|
@@ -212,7 +207,7 @@ public function getLandingPage(string $id, Request $request) {
|
212 | 207 |
|
213 | 208 | $this->getLogger('dynamic_landing_page')->notice("Cache MISS: " . $cid);
|
214 | 209 | // Cache the rendered HTML.
|
215 |
| - $this->cache->set($cid, $renderArray, [$cid]); |
| 210 | + $this->cache->set($cid, $renderArray, CacheBackendInterface::CACHE_PERMANENT, [$cid]); |
216 | 211 | }
|
217 | 212 | // Handle metadata export.
|
218 | 213 | if (NULL != $request->query->get('export_type')) {
|
@@ -242,14 +237,15 @@ public function getLandingPage(string $id, Request $request) {
|
242 | 237 | $current_last_modified = strtotime($current_data['timestamp']);
|
243 | 238 |
|
244 | 239 | if ($current_last_modified > $last_modified) {
|
| 240 | + $this->getLogger('dynamic_landing_page')->notice("Landingpage have been updated. Updating cache for: " . $cid); |
245 | 241 | // Update the cache if the data has changed.
|
246 | 242 | $current_result = $this->generateLandingPage($main_config, $host, $fullhost, $id, $id_prefix, $dataset_id, $export_list);
|
247 | 243 | // Check if the data has changed.
|
248 | 244 | $current_last_modified = $current_result['timestamp'];
|
249 | 245 | $renderArray = $current_result['renderArray'];
|
250 | 246 | $this->cacheInvalidator->invalidateTags([$cid]);
|
251 | 247 |
|
252 |
| - $this->cache->set($cid, $renderArray, [$cid]); |
| 248 | + $this->cache->set($cid, $renderArray, CacheBackendInterface::CACHE_PERMANENT, [$cid]); |
253 | 249 | }
|
254 | 250 |
|
255 | 251 | return $renderArray;
|
@@ -563,13 +559,12 @@ protected function generateLandingPage($main_config, $host, $fullhost, $id, $id_
|
563 | 559 | ];
|
564 | 560 | }
|
565 | 561 | if (isset($fields['use_constraint_identifier'])) {
|
| 562 | + |
566 | 563 | if (NULL != self::LICENCES[$fields['use_constraint_identifier']]) {
|
567 | 564 | $renderArray['constraints_and_info']['constraints']['licence_img'] = [
|
568 | 565 | '#type' => 'markup',
|
569 |
| - // '#prefix' => '<p>',. |
570 |
| - '#markup' => '<a rel="license" class="w3-text-blue" href="' . self::LICENCES[$fields['use_constraint_identifier']]['url'] . '"><img class="w3-image" loading="lazy" width="100" height="35" src="' . self::LICENCES[$fields['use_constraint_identifier']]['img'] . '"/></a>', |
571 |
| - // '#suffix' => '</p>',. |
572 |
| - '#allowed_tags' => ['img'], |
| 566 | + '#markup' => '<a rel="license" class="w3-text-blue" title="Link to license information" href="' . self::LICENCES[$fields['use_constraint_identifier']]['url'] . '"><img loading="lazy" width="100px" height="35px" alt="Use constraint icon for licence ' . $fields['use_constraint_identifier'] . '" ' . 'src = "' . self::LICENCES[$fields['use_constraint_identifier']]['img'] . '" /> </a> ', |
| 567 | + '#allowed_tags' => ['a', 'img'], |
573 | 568 | ];
|
574 | 569 | }
|
575 | 570 | else {
|
@@ -777,12 +772,14 @@ protected function generateLandingPage($main_config, $host, $fullhost, $id, $id_
|
777 | 772 | ];
|
778 | 773 | $renderArray['related_information']['collection_image'] = [
|
779 | 774 | '#theme' => 'image',
|
780 |
| - '#uri' => '/modules/metsis/metsis_search/images/collection.png', |
| 775 | + '#uri' => '/modules/metsis/metsis_search/images/collection.webp', |
781 | 776 | // '#style_name' => 'your_image_style',
|
782 | 777 | '#alt' => 'Collection icon',
|
783 | 778 | // '#title' => $image['ImageTitle'],
|
784 | 779 | '#attributes' => [
|
785 | 780 | 'class' => 'align-right',
|
| 781 | + 'width' => '96px', |
| 782 | + 'height' => '34px', |
786 | 783 | ],
|
787 | 784 | ];
|
788 | 785 | }
|
|
0 commit comments