diff --git a/drupal/modules/avoindata-appfeed/README.md b/drupal/modules/avoindata-appfeed/README.md deleted file mode 100644 index 649a17bfbd..0000000000 --- a/drupal/modules/avoindata-appfeed/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Avoindata app feed module # - -Avoindata app feed module. diff --git a/drupal/modules/avoindata-appfeed/avoindata_appfeed.info.yml b/drupal/modules/avoindata-appfeed/avoindata_appfeed.info.yml deleted file mode 100644 index 556d863060..0000000000 --- a/drupal/modules/avoindata-appfeed/avoindata_appfeed.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: Avoindata App Feed -type: module -description: Creates app feed component -package: Custom -core: 8.x -core_version_requirement: ^8 || ^9 diff --git a/drupal/modules/avoindata-appfeed/avoindata_appfeed.module b/drupal/modules/avoindata-appfeed/avoindata_appfeed.module deleted file mode 100644 index 7a60e06115..0000000000 --- a/drupal/modules/avoindata-appfeed/avoindata_appfeed.module +++ /dev/null @@ -1,132 +0,0 @@ - [ - 'variables' => [ - 'applications' => NULL, - 'language' => NULL, - ], - 'template' => 'avoindata_appfeed_block', - ], - ]; -} - -class AvoindataApplicationHandler implements TrustedCallbackInterface -{ - - - /** - * Return HTML of app list. - */ - function avoindata_recent_applications() - { - $client = \Drupal::httpClient(); - - try { - $recentApplicationsResponse = $client->request('POST', 'http://' . getenv('NGINX_HOST') . '/data/api/action/package_search', - ['json' => ['fq' => 'dataset_type:showcase', 'sort' => 'metadata_modified desc', 'rows' => 3]]); - $recentApplicationsResult = Json::decode($recentApplicationsResponse->getBody()); - $recentApplications = $recentApplicationsResult['result']['results']; - } catch (\Exception $e) { - $recentApplications = []; - } - - $resultHTML = ''; - $currentLang = \Drupal::languageManager()->getCurrentLanguage()->getId(); - - foreach ($recentApplications as $app) { - - if (strlen($app['featured_image']) != 0) { - $app_featured_image = $app['featured_image_display_url']; - } elseif (strlen($app['icon_display_url']) != 0) { - $app_featured_image = $app['icon_display_url']; - } else { - $app_featured_image = '/data/images/showcase_placeholder.png'; - } - - $app_date = \Drupal::service('date.formatter')->format(strtotime($app['metadata_created']), 'avoindata_long_date'); - $app_notes = $app['notes_translated'][$currentLang] ?? ""; - - if (is_array($app['category']) && array_key_exists($currentLang, $app['category'])) { - $app_categories = implode(",", $app['category'][$currentLang]); - } else { - $app_categories = ""; - } - - $converter = new CommonMarkConverter(); - $renderedNotes = $converter->convertToHtml($app_notes); - $renderedNotesText = Xss::filter($renderedNotes, array('p')); - - $resultHTML .= << - -
- - {$app['title']} - - -

- - - {$app_date} - - - - {$app_categories} - -

- -
- -EOT; - } - - return [ - '#markup' => $resultHTML, - '#cache' => ['max-age' => 0], - ]; - } - - /** - * {@inheritdoc} - */ - public static function trustedCallbacks() { - return ['avoindata_recent_applications']; - } -} diff --git a/drupal/modules/avoindata-appfeed/src/Plugin/Block/AppFeedBlock.php b/drupal/modules/avoindata-appfeed/src/Plugin/Block/AppFeedBlock.php deleted file mode 100644 index 0cca01e6bc..0000000000 --- a/drupal/modules/avoindata-appfeed/src/Plugin/Block/AppFeedBlock.php +++ /dev/null @@ -1,37 +0,0 @@ - [\AvoindataApplicationHandler::class . - ':avoindata_recent_applications', [], - ], - '#create_placeholder' => FALSE, - ]; - - return [ - '#applications' => $recentApplications, - '#language' => \Drupal::languageManager()->getCurrentLanguage()->getId(), - '#theme' => 'avoindata_appfeed', - ]; - } - -} diff --git a/drupal/modules/avoindata-appfeed/templates/avoindata_appfeed_block.html.twig b/drupal/modules/avoindata-appfeed/templates/avoindata_appfeed_block.html.twig deleted file mode 100644 index 079f9a72a9..0000000000 --- a/drupal/modules/avoindata-appfeed/templates/avoindata_appfeed_block.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{# -/** - * @file - * Avoindata App Feed Block - * - * @ingroup themeable - */ -#} -
-
-
-
-

- {% trans %} - Applications - {% endtrans %} -

-
-
- -
-
diff --git a/drupal/modules/avoindata-datasetlist/README.md b/drupal/modules/avoindata-datasetlist/README.md deleted file mode 100644 index d8895cf6ac..0000000000 --- a/drupal/modules/avoindata-datasetlist/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Avoindata dataset list module # - -Avoindata dataset list module. diff --git a/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.info.yml b/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.info.yml deleted file mode 100644 index 87777253e0..0000000000 --- a/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: Avoindata Dataset List -type: module -description: Creates dataset list component -package: Custom -core: 8.x -core_version_requirement: ^8 || ^9 diff --git a/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.module b/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.module deleted file mode 100644 index e269a8dc96..0000000000 --- a/drupal/modules/avoindata-datasetlist/avoindata_datasetlist.module +++ /dev/null @@ -1,166 +0,0 @@ - [ - 'variables' => [ - 'recentdatasets' => NULL, - 'newdatasets' => NULL, - 'populardatasets' => NULL, - 'language' => NULL, - ], - 'template' => 'avoindata_datasetlist_block', - ], - ]; -} - -/** - * Returns a number of HTML table rows based on the list of datasets given. - */ -function create_dataset_table_rows($dataset_list, $date_type) { - $currentLang = \Drupal::languageManager()->getCurrentLanguage()->getId(); - - $resultHTML = ''; - $field_for_date = ($date_type ? $date_type : 'metadata_modified'); - - if (count($dataset_list) > 0) { - foreach ($dataset_list as $dataset) { - $created_date = date('d.m.Y', strtotime($dataset[$field_for_date])); - $translated_title = ( - $dataset['title_translated'][$currentLang] - ? $dataset['title_translated'][$currentLang] - : $dataset['title_translated']['fi'] - ); - - $translated_description = ( - $dataset['notes_translated'][$currentLang] - ? $dataset['notes_translated'][$currentLang] - : $dataset['notes_translated']['fi'] - ); - - $converter = new CommonMarkConverter(); - $translated_description = $converter->convertToHtml($translated_description); - $translated_description = Xss::filter($translated_description, array('p')); - - $translated_label = strtoupper(t('Modified')); - - $resultHTML .= << -

{$translated_title}

-
{$translated_label} {$created_date}
-
{$translated_description}
-
- -EOT; - } - } - return $resultHTML; -} - -class AvoindataDatasetHandler implements TrustedCallbackInterface -{ - - - /** - * Gets recent datasets from Ckan and specifies that they won't be cached. - */ - function avoindata_recent_datasets() - { - $client = \Drupal::httpClient(); - try { - $recentDatasetsResponse = $client->request('POST', - 'http://' . getenv('NGINX_HOST') . '/data/api/action/package_search', - ['json' => ['sort' => 'metadata_modified desc', 'facet.limit' => 1, 'rows' =>3]] - ); - $recentDatasetsResult = Json::decode($recentDatasetsResponse->getBody()); - $recentDatasets = $recentDatasetsResult['result']['results']; - } catch (\Exception $e) { - $recentDatasets = NULL; - } - - return [ - '#markup' => create_dataset_table_rows($recentDatasets, 'metadata_modified'), - '#cache' => ['max-age' => 0], - ]; - } - - /** - * Gets new datasets from Ckan and specifies that they won't be cached. - */ - function avoindata_new_datasets() - { - $client = \Drupal::httpClient(); - try { - $newDatasetsResponse = $client->request('POST', - 'http://' . getenv('NGINX_HOST') . '/data/api/action/package_search', - ['json' => ['sort' => 'metadata_created desc', 'facet.limit' => 1, 'rows' =>3]] - ); - $newDatasetsResult = Json::decode($newDatasetsResponse->getBody()); - $newDatasets = $newDatasetsResult['result']['results']; - } catch (\Exception $e) { - $newDatasets = NULL; - } - - return [ - '#markup' => create_dataset_table_rows($newDatasets, NULL), - '#cache' => ['max-age' => 0], - ]; - } - - /** - * Gets popular datasets from Ckan and specifies that they won't be cached. - */ - function avoindata_popular_datasets() - { - $client = \Drupal::httpClient(); - try { - $popularDatasetsResponse = $client->request('POST', - 'http://' . getenv('NGINX_HOST') . '/data/api/action/package_search', - ['json' => ['sort' => 'views_recent desc', 'facet.limit' => 1, 'rows' =>3]] - ); - $popularDatasetsResult = Json::decode($popularDatasetsResponse->getBody()); - $popularDatasets = $popularDatasetsResult['result']['results']; - } catch (\Exception $e) { - $popularDatasets = NULL; - } - - return [ - '#markup' => create_dataset_table_rows($popularDatasets, NULL), - '#cache' => ['max-age' => 0], - ]; - } - - /** - * {@inheritdoc} - */ - public static function trustedCallbacks() { - return ['avoindata_recent_datasets', 'avoindata_new_datasets', 'avoindata_popular_datasets']; - } - -} diff --git a/drupal/modules/avoindata-datasetlist/src/Plugin/Block/DatasetlistBlock.php b/drupal/modules/avoindata-datasetlist/src/Plugin/Block/DatasetlistBlock.php deleted file mode 100644 index f81d845941..0000000000 --- a/drupal/modules/avoindata-datasetlist/src/Plugin/Block/DatasetlistBlock.php +++ /dev/null @@ -1,56 +0,0 @@ - [\AvoindataDatasetHandler::class . - ':avoindata_recent_datasets', [], - ], - '#create_placeholder' => FALSE, - ]; - - // New datasets. - $newDatasets = [ - '#lazy_builder' => [\AvoindataDatasetHandler::class . - ':avoindata_new_datasets', [], - ], - '#create_placeholder' => FALSE, - ]; - - // Popular datasets. - $popularDatasets = [ - '#lazy_builder' => [\AvoindataDatasetHandler::class . - ':avoindata_popular_datasets', [], - ], - '#create_placeholder' => FALSE, - ]; - - return [ - '#recentdatasets' => $recentDatasets, - '#newdatasets' => $newDatasets, - '#populardatasets' => $popularDatasets, - '#language' => \Drupal::languageManager()->getCurrentLanguage()->getId(), - '#theme' => 'avoindata_datasetlist', - ]; - } - -} diff --git a/drupal/modules/avoindata-datasetlist/templates/avoindata_datasetlist_block.html.twig b/drupal/modules/avoindata-datasetlist/templates/avoindata_datasetlist_block.html.twig deleted file mode 100644 index 0aac02f0d1..0000000000 --- a/drupal/modules/avoindata-datasetlist/templates/avoindata_datasetlist_block.html.twig +++ /dev/null @@ -1,113 +0,0 @@ -{# -/** - * @file - * Avoindata Dataset List Block - * - * @ingroup themeable - */ -#} -
-
-
-
-

- {% trans %} - Datasets - {% endtrans %} -

-
-
- -
-
- - - - - -
-
-
-
-

- {% trans with {'context': 'datasetlist offer data heading'} %} - Open your data - {% endtrans %} -

-

- {% trans with {'context': 'datasetlist offer data paragraph'} %} - Does your organization produce data that could benefit or interest others? We offer guidance and a distribution channel for your datasets. - {% endtrans %} -

-
- -
-
-